Frame 1
version._visible = false;
output._visible = false;
debug2._visible = false;
checkButton._visible = false;
_global.soundEnabled = true;
_global.isPractice = false;
_global.debug = false;
_root.gameOverPlate._visible = false;
if (_global.debug) {
gameData = "<gamedata timelimit=\"300\" seed=\"1787292605\"><multiplayer hostname=\"dn.dev.midasplayer.com\" port=\"9001\" slotid=\"21228\" magic=\"3264459566530675712\" chatcontrol=\"/ctl/ChatControl.swf\"></multiplayer><text id=\"test\">test</text></gamedata>";
}
var firstTick = true;
var commTester;
_global.gameObject = null;
board.createEmptyMovieClip("chatbox", 1);
board.chatbox.loadMovie("/ctl/ChatControl.swf");
var chatbox = board.chatbox;
_global.qqchatbox = chatbox;
onEnterFrame = function () {
if (firstTick) {
if (chatbox.init != undefined) {
if (gameData != undefined) {
_root.output.text = _root.output.text + gameData;
firstTick = false;
chatbox.enable();
_global.gameObject = new qq.Game();
_global.gameObject.setup(board);
}
}
} else {
_global.gameObject.tick();
}
};
Instance of Symbol 223 MovieClip "checkButton" in Frame 1
on (press) {
_root.output._visible = !_root.output._visible;
_root.version._visible = !_root.version._visible;
_root.debug2._visible = !_root.debug2._visible;
}
Instance of Symbol 289 MovieClip in Frame 1
on (rollOver) {
gotoAndStop (2);
}
on (rollOut) {
gotoAndStop((_global.soundEnabled ? 1 : 3));
}
on (release) {
gotoAndStop((_global.soundEnabled ? 1 : 3));
}
on (releaseOutside) {
gotoAndStop((_global.soundEnabled ? 1 : 3));
}
on (press) {
_global.soundEnabled = !_global.soundEnabled;
gotoAndStop (4);
if (!_global.soundEnabled) {
_global.fiftyfiftySound.stop();
_global.submitSound.stop();
_global.correctSound.stop();
_global.wrongSound.stop();
_global.hurrySound.stop();
_global.roundstartSound.stop();
_global.introSound.stop();
_global.gameMusicSound.stop();
_global.showScoresSound.stop();
_global.lastQuestionSound.stop();
_global.goodEventSound.stop();
_global.badEventSound.stop();
}
}
Symbol 41 MovieClip [timer_main] Frame 1
stop();
Symbol 53 MovieClip [question_no] Frame 1
stop();
Symbol 93 MovieClip [lamp_small] Frame 1
stop();
Symbol 110 MovieClip Frame 1
stop();
Symbol 127 MovieClip Frame 1
stop();
Symbol 128 MovieClip [PlayerInfo] Frame 1
#initclip 17
Object.registerClass("PlayerInfo", qq.PlayerInfo);
#endinitclip
Symbol 130 MovieClip [question_no] Frame 1
stop();
Symbol 135 MovieClip [HelpButton] Frame 1
#initclip 14
Object.registerClass("HelpButton", qq.HelpButton);
#endinitclip
Symbol 135 MovieClip [HelpButton] Frame 2
stop();
Symbol 146 MovieClip Frame 2
stop();
stop();
Symbol 149 MovieClip [AnswerButton] Frame 1
#initclip 15
Object.registerClass("AnswerButton", qq.AnswerButton);
#endinitclip
Symbol 182 MovieClip Frame 1
stop();
Symbol 186 MovieClip Frame 1
stop();
Symbol 205 MovieClip [Board] Frame 1
#initclip 16
Object.registerClass("Board", qq.Board);
#endinitclip
Symbol 211 Button
on (press) {
_global.gameObject.endGame();
}
Instance of Symbol 215 MovieClip in Symbol 218 MovieClip Frame 1
on (press) {
}
Symbol 235 MovieClip Frame 40
gotoAndPlay (10);
Symbol 249 MovieClip Frame 9
stop();
Symbol 257 MovieClip Frame 21
gotoAndPlay (16);
Symbol 262 MovieClip Frame 21
stop();
Symbol 265 MovieClip Frame 48
stop();
Symbol 276 MovieClip Frame 34
gotoAndPlay (10);
Symbol 284 MovieClip Frame 1
stop();
Symbol 289 MovieClip Frame 1
stop();
Symbol 290 MovieClip [__Packages.qq.Game] Frame 0
class qq.Game
{
var hasSentGameEnd, hasPressedQuit, isFastest, gameLanguage, firstTick, questionNum, hasPlayedHurry, doGameEndAt, connectedTime, shouldShowAnswers, gameEnded, gameStarted, quitAt, playerScore, toAnswer, active, correctAnswer, showNextQuestionAt, lockedTimers, shouldRequestNextQuestion, hasRequestedNextQuestion, hasSent5050, hasUsed5050, questionReceivedTime, hasSubmitted, firstQuestion, board, comm, serverIp, serverPort, slotId, magic, guessedAnswer, currentQuestion;
function Game () {
}
function setup(board) {
hasSentGameEnd = false;
hasPressedQuit = false;
isFastest = true;
gameLanguage = "??";
firstTick = true;
questionNum = 0;
hasPlayedHurry = false;
doGameEndAt = -1;
connectedTime = -1;
shouldShowAnswers = false;
gameEnded = false;
gameStarted = false;
quitAt = -1;
playerScore = -1;
toAnswer = new Array();
active = new Array();
var _local4 = 0;
while (_local4 < 5) {
toAnswer[_local4] = new Object();
active[_local4] = false;
_local4++;
}
correctAnswer = -1;
showNextQuestionAt = -1;
_global.fiftyfiftySound = new Sound();
_global.fiftyfiftySound.attachSound("fiftyfiftySound");
_global.submitSound = new Sound();
_global.submitSound.attachSound("submitSound");
_global.correctSound = new Sound();
_global.correctSound.attachSound("correctSound");
_global.wrongSound = new Sound();
_global.wrongSound.attachSound("wrongSound");
_global.hurrySound = new Sound();
_global.hurrySound.attachSound("hurrySound");
_global.roundstartSound = new Sound();
_global.roundstartSound.attachSound("roundstartSound");
_global.introSound = new Sound();
_global.introSound.attachSound("introSound");
_global.gameMusicSound = new Sound();
_global.gameMusicSound.attachSound("gameMusicSound");
_global.showScoresSound = new Sound();
_global.showScoresSound.attachSound("showScoresSound");
_global.lastQuestionSound = new Sound();
_global.lastQuestionSound.attachSound("lastQuestionSound");
_global.goodEventSound = new Sound();
_global.goodEventSound.attachSound("goodEventSound");
_global.badEventSound = new Sound();
_global.badEventSound.attachSound("badEventSound");
lockedTimers = new Array();
_local4 = 0;
while (_local4 < 5) {
lockedTimers[_local4] = true;
_local4++;
}
shouldRequestNextQuestion = false;
hasRequestedNextQuestion = true;
hasSent5050 = true;
hasUsed5050 = false;
questionReceivedTime = getTimer() + 10000000;
hasSubmitted = true;
firstQuestion = true;
this.board = board;
parseGameData(_root.gameData);
comm = new qq.Comm(this, serverIp, serverPort, slotId, magic);
board.init(this);
}
function parseGameData(gameData) {
var _local5 = new XML(gameData);
_global.textMappings = new Object();
var _local4 = _local5.firstchild.childNodes;
gameLanguage = _local5.firstchild.attributes.language.toString();
var _local3 = 0;
while (_local3 < _local4.length) {
if (_local4[_local3].nodeName == "text") {
_global.textMappings[new String(_local4[_local3].attributes.id)] = new String(_local4[_local3].firstChild.nodeValue);
}
if (_local4[_local3].nodeName == "multiplayer") {
serverIp = new String(_local4[_local3].attributes.hostname);
serverPort = new Number(_local4[_local3].attributes.port);
slotId = new String(_local4[_local3].attributes.slotid);
magic = new String(_local4[_local3].attributes.magic);
}
_local3++;
}
}
function tick() {
if (firstTick) {
_root.redcross.textLabel.text = _global.textMappings.redcross_info;
if (gameLanguage == "en") {
_root.redcross._alpha = 100;
} else {
_root.redcross._alpha = 0;
}
_root.quitLabel.text = _global.textMappings.end_game;
if (_global.soundEnabled) {
_global.introSound.start();
}
firstTick = false;
}
board.tick();
comm.tick();
if ((doGameEndAt >= 0) && (getTimer() > doGameEndAt)) {
if (hasPressedQuit) {
playerScore = 1;
}
hasSentGameEnd = true;
fscommand ("gameEnd", playerScore);
doGameEndAt = -1;
}
if (quitAt >= 0) {
var _local7 = Math.floor((quitAt - getTimer()) / 1000);
if (_local7 < 0) {
_local7 = 0;
}
board.updateQuitTime(_local7);
if (getTimer() > quitAt) {
if (hasPressedQuit) {
playerScore = -1;
}
if (!hasSentGameEnd) {
hasSentGameEnd = true;
fscommand ("gameEnd", playerScore);
}
comm.shutdownForReal();
fscommand ("gameQuit");
quitAt = -1;
}
}
if (((!gameStarted) && (connectedTime >= 0)) && ((getTimer() - connectedTime) > 30000)) {
board.endGame(_global.textMappings.you_won, _global.textMappings.opponent_noconnect);
}
if (gameEnded || (!gameStarted)) {
return(undefined);
}
if (showNextQuestionAt >= 0) {
questionReceivedTime = getTimer() - 20000;
if (getTimer() > showNextQuestionAt) {
_global.gameMusicSound.stop();
if (correctAnswer == guessedAnswer) {
if (_global.soundEnabled) {
_global.correctSound.start();
}
board.nancy.gotoAndStop(3);
} else {
if (_global.soundEnabled) {
_global.wrongSound.start();
}
board.nancy.gotoAndStop(4);
}
shouldRequestNextQuestion = true;
var _local4 = 0;
while (_local4 < 4) {
if (_local4 == correctAnswer) {
board["answer" + _local4].bg.gotoAndStop(5);
}
board["answer" + _local4].active = false;
_local4++;
}
_local4 = 0;
while (_local4 < 5) {
if (active[_local4]) {
board.clientAnsweredFinal(_local4, toAnswer[_local4].wasRight, toAnswer[_local4].answerNum, toAnswer[_local4].scoreGained);
}
_local4++;
}
board.allClientsAnswered();
showNextQuestionAt = -1;
}
}
var _local5 = Math.round((getTimer() - questionReceivedTime) / 500) + 1;
if (_local5 < 1) {
_local5 = 1;
}
if (_local5 > 40) {
_local5 = 40;
}
if ((_local5 > 36) && (!hasPlayedHurry)) {
hasPlayedHurry = true;
if (_global.soundEnabled) {
_global.hurrySound.start();
}
}
_local5 = Math.round(((getTimer() - questionReceivedTime) * 26) / 20000) + 1;
if (_local5 < 1) {
_local5 = 1;
}
if (_local5 > 26) {
_local5 = 26;
}
board.timeCounter.gotoAndStop(_local5);
var _local6 = Math.round((getTimer() - questionReceivedTime) / 1000);
if (((_local6 >= 25) && (!hasRequestedNextQuestion)) && (shouldRequestNextQuestion)) {
hasRequestedNextQuestion = true;
shouldRequestNextQuestion = false;
comm.requestNextQuestion();
}
if ((_local6 > -1) && (shouldShowAnswers)) {
shouldShowAnswers = false;
if (_global.soundEnabled) {
_global.gameMusicSound.start(0, 10000);
}
var _local4 = 0;
while (_local4 < 4) {
board["answer" + _local4].answerText._visible = true;
board["answer" + _local4].bg.gotoAndStop(1);
board["answer" + _local4].active = true;
_local4++;
}
hasSubmitted = false;
}
if (_local6 > 20) {
_local6 = 0;
if (!hasSubmitted) {
if (_global.soundEnabled) {
_global.submitSound.start();
}
comm.sendAnswer(-1);
board.nancy.gotoAndStop(1);
hasSubmitted = true;
}
} else {
var _local4 = 0;
while (_local4 < 5) {
if (active[_local4] && (!lockedTimers[_local4])) {
board["playerInfo" + _local4].timer.gotoAndStop(Math.floor(_local6 / 2) + 1);
}
_local4++;
}
}
}
function connectedAs(client) {
board.connected(client.id, client.name, client.avatar, true);
active[client.id] = true;
connectedTime = getTimer();
}
function clientConnected(client) {
board.connected(client.id, client.name, client.avatar, false);
active[client.id] = true;
}
function clientDisconnected(id) {
active[id] = false;
board.disconnected(id);
}
function setCorrectAnswer(correctAnswer) {
isFastest = true;
this.correctAnswer = correctAnswer;
hasPlayedHurry = true;
showNextQuestionAt = getTimer() + 2000;
questionReceivedTime = getTimer() - 21000;
}
function questionReceived(question) {
hasSent5050 = false;
hasPlayedHurry = false;
hasRequestedNextQuestion = false;
var _local3 = 0;
while (_local3 < 5) {
lockedTimers[_local3] = false;
board["playerInfo" + _local3].timer.gotoAndStop(1);
_local3++;
}
questionReceivedTime = getTimer() + 2000;
shouldShowAnswers = true;
if (firstQuestion) {
firstQuestion = false;
}
if (!hasUsed5050) {
board.fiftyfiftybutton.active = true;
board.fiftyfiftybutton.gotoAndStop(1);
} else {
board.fiftyfiftybutton.active = false;
board.fiftyfiftybutton.gotoAndStop(2);
}
board.nancy.gotoAndStop(2);
board.initQuestion();
currentQuestion = question;
util.TextScaler.setText(board.question.questionTextOld, board.question.questionText.text);
util.TextScaler.setText(board.question.questionText, question.questionText);
board.question.gotoAndPlay(2);
_local3 = 0;
while (_local3 < 4) {
util.TextScaler.setText(board["answer" + _local3].answerText, question.answers[_local3]);
board["answer" + _local3].answerText._visible = false;
board["answer" + _local3].bg.gotoAndStop(2);
board["answer" + _local3].active = false;
_local3++;
}
questionNum++;
if (questionNum == 10) {
if (_global.soundEnabled) {
_global.lastQuestionSound.start();
}
} else if (_global.soundEnabled) {
_global.roundstartSound.start();
}
}
function answerPressed(id) {
if (!hasSubmitted) {
if (id == -1) {
if (!hasSent5050) {
if (_global.soundEnabled) {
_global.fiftyfiftySound.start();
}
hasSent5050 = true;
hasUsed5050 = true;
comm.send5050();
board.fiftyfiftybutton.gotoAndStop(3);
board.fiftyfiftybutton.active = false;
}
} else {
board.fiftyfiftybutton.active = false;
board.fiftyfiftybutton.gotoAndStop(2);
if (_global.soundEnabled) {
_global.submitSound.start();
}
var _local3 = 0;
while (_local3 < 4) {
board["answer" + _local3].bg.gotoAndStop(2);
board["answer" + _local3].active = false;
_local3++;
}
board["answer" + id].bg.gotoAndStop(3);
guessedAnswer = id;
board.nancy.gotoAndStop(1);
comm.sendAnswer(id);
hasSubmitted = true;
}
}
}
function fiftyFiftyAnswer(wrongAnswer0, wrongAnswer1) {
board["answer" + wrongAnswer0].bg.gotoAndStop(2);
board["answer" + wrongAnswer0].active = false;
board["answer" + wrongAnswer1].bg.gotoAndStop(2);
board["answer" + wrongAnswer1].active = false;
}
function clientAnswered(playerNum, client_timeused) {
board.clientAnswered(playerNum, client_timeused);
lockedTimers[playerNum] = true;
var _local2 = Math.round(client_timeused / 1000);
if (_local2 < 0) {
_local2 = 0;
}
if (_local2 > 20) {
_local2 = 20;
}
board["playerInfo" + playerNum].timer.gotoAndStop(Math.floor(_local2 / 2) + 1);
}
function clientAnsweredFinal(playerNum, wasRight, answerNum, scoreGained) {
toAnswer[playerNum].wasRight = wasRight;
toAnswer[playerNum].scoreGained = scoreGained;
toAnswer[playerNum].answerNum = answerNum;
}
function setFastestPlayer(playerNum) {
var _local2 = 0;
while (_local2 < 5) {
board.setFastest(_local2, false);
_local2++;
}
board.setFastest(playerNum, true);
}
function endGame() {
fscommand ("playData", "700=0");
playerScore = -1;
hasPressedQuit = true;
board.endGame(_global.textMappings.end_game, _global.textMappings.local_disconnect);
}
}
Symbol 291 MovieClip [__Packages.util.CommCallback] Frame 0
interface util.CommCallback{}
Symbol 292 MovieClip [__Packages.util.Client] Frame 0
class util.Client
{
var id, name, avatar, isPlayer, isConnected;
function Client (id, name, avatar) {
this.id = id;
this.name = name;
this.avatar = avatar;
isPlayer = false;
isConnected = true;
}
}
Symbol 293 MovieClip [__Packages.qq.Comm] Frame 0
class qq.Comm
{
var allConnected, started, playerData, startAt, playerScore, currentQuestion, questionNum, game, clients, comm, client, questionReceiveTime, question;
function Comm (game, ip, port, slot, magic) {
allConnected = false;
started = false;
playerData = new Array();
startAt = getTimer() + 10000;
var _local4 = 0;
while (_local4 < 5) {
playerData[_local4] = new Object();
playerData[_local4].name = "-- nobody --";
playerData[_local4].score = -1;
playerData[_local4].state = "Not connected";
_local4++;
}
playerScore = 0;
currentQuestion = 0;
questionNum = 0;
this.game = game;
clients = new Array();
util.GameDataParser.parseGameData();
comm = new util.Communicator(this);
comm.connect(ip, port, slot, magic);
System.security.allowDomain(_root.gameDomain);
_global.qqchatbox.setAllowDomain(_root.gameDomain);
_global.qqchatbox.init(this);
}
function tick() {
comm.tick();
if (((!started) && (allConnected)) && (getTimer() > startAt)) {
game.board.updateInitTime(_global.textMappings.waiting_for_opponent);
started = true;
fscommand ("playData", "992=0");
comm.sendData("JGQ");
game.board.startGame();
} else {
var _local3 = Math.floor((startAt - getTimer()) / 1000);
if (_local3 < 0) {
_local3 = 0;
}
game.board.updateInitTime(_global.textMappings.game_starts_in.split("{0}").join("" + _local3));
}
}
function connecting() {
_root.output.text = _root.output.text + "\rConnecting..";
}
function unableToConnect() {
_root.output.text = _root.output.text + "\rUnable to connect";
game.board.endGame(_global.textMappings.game_over, _global.textMappings.unable_to_connect);
}
function localDisconnect() {
game.board.endGame(_global.textMappings.game_over, _global.textMappings.local_disconnect);
_root.output.text = _root.output.text + "\rLocal disconnect";
fscommand ("playData", "118=0");
}
function clientAccepted(client) {
_root.output.text = _root.output.text + ("\rConnected as " + client.name);
this.client = client;
client.isPlayer = true;
clients[client.id] = client;
comm.sendData("CIR");
game.connectedAs(client);
fscommand ("playData", ("188," + client.id) + "=0");
playerData[client.id].name = client.name.substr(1, client.name.length - 2);
playerData[client.id].score = 0;
playerData[client.id].state = "";
}
function clientConnected(client) {
fscommand ("playData", ("841," + client.id) + "=0");
_root.output.text = _root.output.text + (("\r" + client.name) + " joined the game");
clients[client.id] = client;
game.clientConnected(client);
playerData[client.id].name = client.name.substr(1, client.name.length - 2);
playerData[client.id].score = 0;
playerData[client.id].state = "";
}
function clientDisconnected(id, remainingPlayers) {
var _local4 = clients[id];
fscommand ("playData", ("448," + _local4.id) + "=0");
_root.output.text = _root.output.text + (("\r" + _local4.name) + " left the game");
if (currentQuestion < 10) {
playerData[_local4.id].state = "Disconnected";
game.clientDisconnected(id);
}
if ((remainingPlayers == 1) && (currentQuestion < 10)) {
playerScore = 100000 /* 0x0186A0 */;
game.playerScore = 100000 /* 0x0186A0 */;
game.board.endGame(_global.textMappings.you_won, _global.textMappings.opponent_disconnect);
}
clients[id].isConnected = false;
}
function startGame() {
game.gameStarted = true;
_root.output.text = _root.output.text + "\rGame started! w00";
allConnected = true;
}
function gameCommand(cmdStr) {
var _local16 = cmdStr.substr(0, 3);
if (_local16 == "JSQ") {
currentQuestion++;
comm.sendData("JTS");
questionReceiveTime = getTimer();
question = new qq.Question(cmdStr.substr(4));
fscommand ("playData", ("14," + question.questionId) + "=0");
_root.output.text = _root.output.text + ((("\rGot question id: " + question.questionId) + "/") + typeof(question.questionId));
game.questionReceived(question);
} else if (_local16 == "JCA") {
var _local17 = cmdStr.split(" ");
var _local22 = new Number(_local17[1]);
var _local12 = new Number(_local17[2]);
var _local9 = new Number(_local17[3]);
game.clientAnswered(_local22, _local12);
} else if (_local16 == "JSR") {
var _local21 = new XML(cmdStr.substr(4));
var _local5 = "340,";
var _local10 = new Number(_local21.firstchild.attributes.answer);
_local5 = _local5 + _local10;
var _local14 = 0;
var _local4 = _local21.firstchild.childNodes;
var _local11 = 1E17;
var _local15 = -1;
var _local3 = 0;
while (_local3 < _local4.length) {
if (_local4[_local3].nodeName == "player") {
_local5 = _local5 + (" " + _local4[_local3].attributes.id);
_local5 = _local5 + (" " + _local4[_local3].attributes.answer);
_local5 = _local5 + (" " + _local4[_local3].attributes.client_timeused);
_local5 = _local5 + (" " + _local4[_local3].attributes.server_timeused);
_local5 = _local5 + (" " + _local4[_local3].attributes.score);
_local5 = _local5 + (" " + _local4[_local3].attributes.c);
var _local6 = new Number(_local4[_local3].attributes.id);
var _local7 = new Number(_local4[_local3].attributes.answer);
var _local12 = new Number(_local4[_local3].attributes.client_timeused);
var _local9 = new Number(_local4[_local3].attributes.server_timeused);
var _local8 = new Number(_local4[_local3].attributes.score);
var _local13 = new String(_local4[_local3].attributes.c);
playerData[_local6].score = playerData[_local6].score + _local8;
if (_local6.valueOf() == client.id.valueOf()) {
_local14 = _local8;
}
game.clientAnsweredFinal(_local6, _local7.valueOf() == _local10.valueOf(), _local7, _local8);
if ((_local7.valueOf() == _local10.valueOf()) && (_local9 < _local11)) {
_local11 = _local9;
_local15 = _local6;
}
}
_local3++;
}
game.setFastestPlayer(_local15);
playerScore = playerScore + _local14;
_local5 = _local5 + ("=" + _local14);
fscommand ("playData", _local5);
game.setCorrectAnswer(_local10.valueOf());
game.playerScore = playerScore;
} else if (_local16 == "JSL") {
var _local17 = cmdStr.split(" ");
var _local22 = new Number(_local17[1]);
if (_local22.valueOf() == client.id.valueOf()) {
var _local19 = new Number(_local17[2]);
var _local20 = new Number(_local17[3]);
game.fiftyFiftyAnswer(_local19.valueOf(), _local20.valueOf());
fscommand ("playData", ((("225," + _local19) + " ") + _local20) + "=0");
}
} else if (_local16 == "MCC") {
}
}
function requestNextQuestion() {
questionNum++;
if (questionNum < 10) {
comm.sendData("JGQ");
} else {
var _local3 = new Array();
var _local7 = new Array();
var _local6 = 0;
while (_local6 < 5) {
_local3[_local6] = playerData[_local6];
_local6++;
}
_local6 = 0;
while (_local6 < 5) {
var _local4 = -999;
var _local5 = -1;
var _local2 = 0;
while (_local2 < 5) {
if (_local3[_local2] != null) {
if (_local3[_local2].score > _local4) {
_local4 = _local3[_local2].score;
_local5 = _local2;
}
}
_local2++;
}
_local7[_local6] = _local3[_local5];
_local3[_local5] = null;
_local6++;
}
game.board.endGameShowWinner(_local7);
}
}
function doGameOver() {
comm.sendData("CGO");
game.playerScore = playerScore;
game.doGameEndAt = getTimer() + 1000;
}
function shutdownForReal() {
comm.disconnect();
}
function ccom(v) {
comm.sendData(v.toString());
}
function send5050() {
comm.sendData("JUL");
fscommand ("playData", "512=0");
}
function sendAnswer(id) {
var _local2 = getTimer() - questionReceiveTime;
fscommand ("playData", ((("330," + id) + " ") + _local2) + "=0");
comm.sendData((("JSA " + id) + " ") + _local2);
}
}
Symbol 294 MovieClip [__Packages.util.Communicator] Frame 0
class util.Communicator
{
var callback, slotId, magic, socket;
function Communicator (callback) {
this.callback = callback;
}
function connect(serverIp, serverPort, slotId, magic) {
this.slotId = slotId;
this.magic = magic;
socket = new XMLSocket();
callback.connecting();
var thisComm = this;
socket.onConnect = function (success) {
if (success) {
thisComm.connected();
} else {
thisComm.unableToConnect();
}
};
socket.onData = function (str) {
thisComm.cmdReceived(str);
};
socket.onClose = function () {
thisComm.localDisconnect();
};
if (!socket.connect(serverIp, serverPort)) {
thisComm.unableToConnect();
}
}
function cmdReceived(str) {
var _local2 = str.split(" ");
if (_local2[0] == "SCA") {
var _local5 = new Number(_local2[1]);
var _local3 = _local2[2];
var _local4 = 3;
while (_local3.charAt(_local3.length - 1) != "\"") {
_local3 = _local3 + (" " + _local2[_local4++]);
}
var _local6 = _local2[_local4];
callback.clientAccepted(new util.Client(_local5, _local3, _local6));
isConnected = true;
} else if (_local2[0] == "SAC") {
var _local5 = new Number(_local2[1]);
var _local3 = _local2[2];
var _local4 = 3;
while (_local3.charAt(_local3.length - 1) != "\"") {
_local3 = _local3 + (" " + _local2[_local4++]);
}
var _local6 = _local2[_local4];
callback.clientConnected(new util.Client(_local5, _local3, _local6));
} else if (_local2[0] == "SCD") {
var _local5 = new Number(_local2[1]);
var _local7 = new Number(_local2[2]);
callback.clientDisconnected(_local5, _local7);
} else if (_local2[0] == "SSG") {
fscommand ("gameStart");
callback.startGame();
} else if (_local2[0] == "STM") {
var _local8 = new Number(_local2[1]);
} else {
callback.gameCommand(str);
}
}
function unableToConnect() {
disconnected();
callback.unableToConnect();
}
function localDisconnect() {
disconnected();
callback.localDisconnect();
}
function disconnected() {
isConnected = false;
}
function connected() {
sendData((("CCC " + slotId) + " ") + magic);
}
function sendData(cmd) {
socket.send(cmd);
}
function disconnect() {
socket.close();
isConnected = false;
}
function tick() {
if (isConnected) {
var _local2 = getTimer();
if ((_local2 - lastPingTime) > 10000) {
lastPingTime = _local2;
sendData("CTM");
}
}
}
var pingTime = 4;
var lastPingTime = -1;
var isConnected = false;
}
Symbol 295 MovieClip [__Packages.qq.Question] Frame 0
class qq.Question
{
var answers, timeLimit, questionId, theme, difficulty, questionText;
function Question (str) {
answers = new Array();
var _local5 = new XML(str);
timeLimit = new Number(_local5.firstchild.attributes.timelimit);
questionId = new String(_local5.firstchild.attributes.id);
theme = new String(_local5.firstchild.attributes.theme);
difficulty = new Number(_local5.firstchild.attributes.difficulty);
var _local3 = _local5.firstchild.childNodes;
var _local2 = 0;
while (_local2 < _local3.length) {
if (_local3[_local2].nodeName == "questiontext") {
questionText = new String(_local3[_local2].firstChild.nodeValue);
}
if (_local3[_local2].nodeName == "alternative") {
var _local4 = new Number(_local3[_local2].attributes.id);
answers[_local4] = new String(_local3[_local2].firstChild.nodeValue);
}
_local2++;
}
}
}
Symbol 296 MovieClip [__Packages.util.GameDataParser] Frame 0
class util.GameDataParser
{
function GameDataParser () {
}
static function parseGameData() {
var _local5 = new XML(_root.gameData);
_global.textMappings = new Object();
var _local4 = _local5.firstchild.childNodes;
var _local3 = 0;
while (_local3 < _local4.length) {
if (_local4[_local3].nodeName == "id") {
}
if (_local4[_local3].nodeName == "text") {
_global.textMappings[_local4[_local3].attributes.id] = new String(_local4[_local3].firstChild.nodeValue);
}
_local3++;
}
}
}
Symbol 297 MovieClip [__Packages.qq.Board] Frame 0
class qq.Board extends MovieClip
{
var winplate, gameOver, previousLeader, happyMoods, unhappyMoods, gameStarted, game, avatars, showTimes, animations, avatarStrings, isConnected, data, nancy, roundCounter, currentQuestion, playerScores, targetMoods, changeTimes, answer0, answer1, answer2, answer3, fiftyfiftybutton;
function Board () {
super();
}
function init(game) {
winplate._visible = false;
gameOver = false;
previousLeader = -1;
happyMoods = "happy superior teasing".split(" ");
unhappyMoods = "angry ashamed mad".split(" ");
gameStarted = false;
this.game = game;
avatars = new Array();
showTimes = new Array();
animations = new Array();
avatarStrings = new Array();
isConnected = new Array();
data = new Array();
nancy.gotoAndStop(1);
roundCounter.gotoAndStop(1);
currentQuestion = -1;
playerScores = new Array();
initGame("instructions", _global.textMappings.instructions1);
targetMoods = new Array();
changeTimes = new Array();
var _local4 = 0;
while (_local4 < 5) {
isConnected[_local4] = false;
changeTimes[_local4] = -1;
targetMoods[_local4] = "neutral";
playerScores[_local4] = 0;
animations[_local4] = 1;
data[_local4] = new Object();
data[_local4].wins = 0;
data[_local4].losses = 0;
data[_local4].isFastest = false;
this["playerInfo" + _local4].nameField.text = "-- Nobody --";
this["playerInfo" + _local4].scoreField.text = "0";
this["playerInfo" + _local4].statusLight.gotoAndStop(1);
this["playerInfo" + _local4].choiceLetter.text = "";
var _local3 = 0;
while (_local3 < 10) {
this["playerInfo" + _local4]["roundLight" + _local3].gotoAndStop(1);
_local3++;
}
avatars[_local4] = undefined;
this["playerInfo" + _local4].avatarHolder.fakeFace._alpha = 0;
_local4++;
}
_local4 = 0;
while (_local4 < 10) {
this["roundCounter" + _local4].gotoAndStop(1);
_local4++;
}
answer0.setGame(0, game);
answer1.setGame(1, game);
answer2.setGame(2, game);
answer3.setGame(3, game);
fiftyfiftybutton.setGame(-1, game);
}
function connected(id, name, avatar, isPlayer) {
_root.dbg.text = _root.dbg.text + (((((("Id: " + id) + ", ") + typeof(id)) + ", name: ") + name) + "\r");
if (avatar.length < 4) {
if ((id == 0) || (id == 5)) {
avatar = "hats13B:hair11C,f1282a:head3:blush1:mouth1:mustasch2,f1282a:sweat1:eyes2:eyebrows1:nose1:addon2B:ear1:hair11A,f1282a:hats13A:";
}
if (id == 1) {
avatar = "hair7C:head2:blush1:mouth1:sweat1:eyes1:eyebrows1:nose1:hair7B:glasses3:ear1:addon1A:hats9A:";
}
if (id == 2) {
avatar = "hair16C,32ff00:head4:blush1:mouth1:beard3,32ff00:sweat1:eyes2:wrinkles1:eyebrows1:nose3:hair16B,32ff00:glasses1:ear1:addon5A:hair16A,32ff00:hats19A:";
}
if (id == 3) {
avatar = "hair4C,e9e0b2:head1:blush1:mouth1:sweat1:eyes1:eyebrows1:nose4:addon2B:hair4B,e9e0b2:ear1:hair4A:hats1A:";
}
if (id == 4) {
avatar = "head3:blush1:mouth1:sweat1:eyes1:wrinkles2:eyebrows1:nose3:hair14B,f38d29:ear1:addon3A:hair14A,f38d29::hats7A:";
}
}
this["playerInfo" + id].nameField.text = name.substr(1, name.length - 2);
this["playerInfo" + id].scoreField.text = "0";
this["playerInfo" + id].statusLight.gotoAndStop(1);
this["playerInfo" + id].avatarHolder.fakeFace._alpha = 100;
var _local6 = this["playerInfo" + id].avatarHolder;
var _local7 = {x:_local6._width / 2, y:_local6._height / 2};
_local6.localToGlobal(_local7);
avatarStrings[id] = avatar;
var _local9 = _global.qqchatbox.getAvatar(id.valueOf(), avatar, (_local7.x - 50) - 4, (_local7.y - 50) - 4, isPlayer);
avatars[id] = _local9;
showTimes[id] = getTimer() + 100;
isConnected[id] = true;
}
function startGame() {
gameStarted = true;
_root.gameStartPlate._visible = false;
_root.redcross._alpha = 0;
}
function disconnected(id) {
isConnected[id] = false;
avatars[id].hide();
avatars[id]._visible = false;
avatars[id] = undefined;
_root["avatarEffect" + id].gotoAndStop(1);
this["playerInfo" + id].avatarHolder.fakeFace._alpha = 0;
}
function tick() {
var _local4 = 0;
while (_local4 < 5) {
if (isConnected[_local4]) {
if (((avatars[_local4] != undefined) && (showTimes[_local4] >= 0)) && (getTimer() > showTimes[_local4])) {
avatars[_local4].show();
showTimes[_local4] = -1;
}
if (((avatars[_local4] != undefined) && (changeTimes[_local4] >= 0)) && (getTimer() > changeTimes[_local4])) {
if (avatars[_local4].clipRef._visible) {
_global.qqchatbox.setMood(avatars[_local4], targetMoods[_local4]);
_root["avatarEffect" + _local4].gotoAndStop(animations[_local4]);
if (animations[_local4] >= 8) {
if (_global.soundEnabled) {
_global.goodEventSound.start();
}
} else if (animations[_local4] > 1) {
if (_global.soundEnabled) {
_global.badEventSound.start();
}
}
}
changeTimes[_local4] = -1;
}
}
_local4++;
}
}
function setAllMoods(mood) {
var _local2 = 0;
while (_local2 < 5) {
setMood(_local2, mood);
_local2++;
}
}
function setMoodHappy(id) {
setMoodAt(id, happyMoods[Math.floor(Math.random() * 3)], getTimer() + Math.floor(Math.random() * 4000));
}
function setMoodUnhappy(id, mood) {
setMoodAt(id, unhappyMoods[Math.floor(Math.random() * 3)], getTimer() + Math.floor(Math.random() * 4000));
}
function setMood(id, mood) {
setMoodAt(id, mood, getTimer() + Math.floor(Math.random() * 500));
}
function setMoodAt(id, mood, time) {
targetMoods[id] = mood;
changeTimes[id] = time;
}
function initQuestion() {
setAllMoods("neutral");
var _local2 = 0;
while (_local2 < 5) {
animations[_local2] = 1;
_local2++;
}
currentQuestion++;
roundCounter.gotoAndStop(currentQuestion + 1);
_local2 = 0;
while (_local2 < 5) {
this["playerInfo" + _local2].statusLight.gotoAndStop(1);
this["playerInfo" + _local2].choiceLetter.text = "";
_local2++;
}
}
function clientAnswered(id, client_timeused) {
this["playerInfo" + id].statusLight.gotoAndStop(2);
}
function setFastest(id, isFastest) {
data[id].isFastest = isFastest;
_root.output.text = _root.output.text + ((("\rdata[" + id) + "].isFastest: ") + data[id].isFastest);
}
function clientAnsweredFinal(id, wasRight, answerNum, scoreGained) {
playerScores[id] = playerScores[id] + scoreGained.valueOf();
this["playerInfo" + id].scoreField.text = playerScores[id.valueOf()];
if (answerNum == 0) {
this["playerInfo" + id].choiceLetter.text = "A";
} else if (answerNum == 1) {
this["playerInfo" + id].choiceLetter.text = "B";
} else if (answerNum == 2) {
this["playerInfo" + id].choiceLetter.text = "C";
} else if (answerNum == 3) {
this["playerInfo" + id].choiceLetter.text = "D";
}
if (wasRight) {
if (data[id].isFastest) {
data[id].wins = data[id].wins + 1;
animations[id] = 11 + Math.floor(Math.random() * 3);
} else {
data[id].wins = 0;
}
data[id].losses = 0;
_root.output.text = _root.output.text + ((("\rdata[" + id) + "].wins: ") + data[id].wins);
if (data[id].wins >= 3) {
animations[id] = 9;
}
setMoodHappy(id);
this["playerInfo" + id].statusLight.gotoAndStop(3);
this["playerInfo" + id]["roundLight" + currentQuestion].gotoAndStop(2);
} else {
data[id].wins = 0;
data[id].losses = data[id].losses + 1;
if (data[id].losses >= 4) {
animations[id] = 2 + Math.floor(Math.random() * 2);
} else if (data[id].losses >= 3) {
animations[id] = 5 + (Math.floor(Math.random() * 2) * 2);
} else if (data[id].losses >= 2) {
animations[id] = 4 + (Math.floor(Math.random() * 2) * 2);
}
setMoodUnhappy(id);
this["playerInfo" + id].statusLight.gotoAndStop(4);
this["playerInfo" + id]["roundLight" + currentQuestion].gotoAndStop(3);
}
}
function allClientsAnswered() {
var _local2 = findLeader();
if (_local2 != previousLeader) {
if (previousLeader >= 0) {
animations[_local2] = 8 + (Math.floor(Math.random() * 2) * 2);
}
previousLeader = _local2;
}
}
function initGame(header, message) {
_root.gameStartPlate.headerText.text = header;
_root.gameStartPlate.textText.text = message;
_root.gameStartPlate._visible = true;
_root.gameStartPlate.timeText.text = "";
}
function updateInitTime(timeText) {
_root.gameStartPlate.timeText.text = timeText;
}
function endGame(header, message) {
if (!gameOver) {
gameOver = true;
_global.gameMusicSound.stop();
if (_global.soundEnabled) {
_global.showScoresSound.start();
}
_root.gameStartPlate._visible = false;
game.comm.doGameOver();
game.gameEnded = true;
_root.gameOverPlate.headerText.text = header;
_root.gameOverPlate.textText.text = message;
_root.gameOverPlate.timeText.text = "";
_root.gameOverPlate._visible = true;
game.quitAt = getTimer() + 6000;
}
}
function findLeader() {
var _local3 = -99999;
var _local4 = 0;
var _local2 = 0;
while (_local2 < 5) {
if (playerScores[_local2] > _local3) {
_local3 = playerScores[_local2];
_local4 = _local2;
}
_local2++;
}
return(_local4);
}
function endGameShowWinner(playerData) {
if (!gameOver) {
var _local8 = findLeader();
gameOver = true;
_global.gameMusicSound.stop();
if (_global.soundEnabled) {
_global.showScoresSound.start();
}
var _local6 = {x:winplate.avatarHolder._width / 2, y:winplate.avatarHolder._height / 2};
winplate.avatarHolder.localToGlobal(_local6);
var _local7 = _global.qqchatbox.getAvatar(11, avatarStrings[_local8], (_local6.x - 50) - 4, (_local6.y - 50) - 4, false);
_local7.show();
winplate.gameoverTitle.text = _global.textMappings.results_header;
winplate.resultHeader.text = "";
var _local4 = 0;
while (_local4 < 5) {
winplate["nameLabel" + _local4].text = "";
winplate["scoreLabel" + _local4].text = "";
_local4++;
}
_local4 = 0;
var _local3 = 0;
while (_local3 < 5) {
if (playerData[_local3].score >= 0) {
winplate["nameLabel" + _local4].text = (("" + (_local4 + 1)) + ". ") + playerData[_local3].name;
winplate["scoreLabel" + _local4].text = "" + playerData[_local3].score;
_local4++;
}
_local3++;
}
winplate.backInfoLabel.text = _global.textMappings.seconds_to_menu.split("{0}").join("6");
winplate._visible = true;
game.comm.doGameOver();
game.gameEnded = true;
game.quitAt = getTimer() + 6000;
}
}
function updateQuitTime(remainingTime) {
winplate.backInfoLabel.text = _global.textMappings.seconds_to_menu.split("{0}").join("" + remainingTime);
}
}
Symbol 298 MovieClip [__Packages.util.TextScaler] Frame 0
class util.TextScaler
{
function TextScaler () {
}
static function setText(textField, str) {
var _local6 = str;
var _local4 = textField._width;
var _local5 = textField._height;
var _local2 = 150;
var _local7 = 2;
textField.text = str;
}
static function fitText(textString, myTextFormat, boxWidth, boxHeight) {
textString = textString.split("\n\r").join("\r");
textString = textString.split("\r\n").join("\r");
textString = textString.split(newline).join("\r");
textString = textString.split("\r").join("\r ");
var _local3 = textString.split(" ");
var _local2 = "";
var _local4 = "";
var _local6 = 0;
var _local1 = 0;
while (_local1 < _local3.length) {
var _local10 = myTextFormat.getTextExtent((_local2 + _local3[_local1]) + " ");
if (_local10.textFieldWidth < boxWidth) {
_local2 = _local2 + (_local3[_local1] + " ");
} else {
_local10 = myTextFormat.getTextExtent(_local3[_local1]);
_local6 = _local6 + _local10.textFieldHeight;
_local4 = _local4 + (_local2.substr(0, _local2.length - 1) + "\r");
_local2 = _local3[_local1] + " ";
}
_local1++;
}
if (_local2.substr(-2) != "\r") {
var _local10 = myTextFormat.getTextExtent("Kallestropp");
_local6 = _local6 + _local10.textFieldHeight;
_local4 = _local4 + _local2;
}
_local4 = _local4.split(" ").join(" ");
_local4 = _local4.split(" ").join(" ");
_local4 = _local4.split("\r ").join("\r");
var _local10 = myTextFormat.getTextExtent(_local4);
var _local9 = _local10.textFieldHeight;
if (boxHeight > (_local9 + 2)) {
return(_local4);
}
return(false);
}
}
Symbol 299 MovieClip [__Packages.util.CommTester] Frame 0
class util.CommTester
{
var clients, comm;
function CommTester () {
clients = new Array();
util.GameDataParser.parseGameData();
comm = new util.Communicator(this);
comm.connect("127.0.0.1", 8391);
}
function tick() {
comm.tick();
}
function connecting() {
_root.output.text = _root.output.text + "\rConnecting..";
}
function unableToConnect() {
_root.output.text = _root.output.text + "\rUnable to connect";
}
function localDisconnect() {
_root.output.text = _root.output.text + "\rLocal disconnect";
}
function clientAccepted(client) {
_root.output.text = _root.output.text + ("\rConnected as " + client.name);
client.isPlayer = true;
clients[client.id] = client;
}
function clientConnected(client) {
_root.output.text = _root.output.text + (("\r" + client.name) + " joined the game");
clients[client.id] = client;
}
function clientDisconnected(id, remainingPlayers) {
var _local3 = clients[id];
_root.output.text = _root.output.text + (("\r" + _local3.name) + " left the game");
clients[id].isConnected = false;
}
function startGame() {
_root.output.text = _root.output.text + "\rGame started! w00";
}
function gameCommand(cmd) {
_root.output.text = _root.output.text + (("\rGame command received: \"" + cmd) + "\"");
}
}
Symbol 300 MovieClip [__Packages.qq.HelpButton] Frame 0
class qq.HelpButton extends MovieClip
{
var active, id, game, gotoAndStop;
function HelpButton () {
super();
}
function setGame(id, game) {
active = false;
this.id = id;
this.game = game;
gotoAndStop(1);
}
function onPress() {
if ((game != undefined) && (active)) {
game.answerPressed(id);
}
}
function onRollOver() {
if ((game != undefined) && (active)) {
gotoAndStop(4);
}
}
function onRollOut() {
if ((game != undefined) && (active)) {
gotoAndStop(1);
}
}
}
Symbol 301 MovieClip [__Packages.qq.AnswerButton] Frame 0
class qq.AnswerButton extends MovieClip
{
var active, id, game, bg;
function AnswerButton () {
super();
}
function setGame(id, game) {
active = false;
this.id = id;
this.game = game;
bg.gotoAndStop(1);
}
function onLoad() {
bg._height = 83;
}
function onPress() {
if ((game != undefined) && (active)) {
game.answerPressed(id);
}
}
function onRollOver() {
if ((game != undefined) && (active)) {
bg.gotoAndStop(4);
}
}
function onRollOut() {
if ((game != undefined) && (active)) {
bg.gotoAndStop(1);
}
}
}
Symbol 302 MovieClip [__Packages.qq.PlayerInfo] Frame 0
class qq.PlayerInfo extends MovieClip
{
function PlayerInfo () {
super();
}
}