Frame 1
var game = (new com.midasplayer.chesster.Game(_root));
if (com.midasplayer.chesster.Game.LOCAL_GAME) {
game.init();
}
Symbol 28 MovieClip [QuizSummary] Frame 1
#initclip 92
Object.registerClass("QuizSummary", com.midasplayer.chesster.QuizSummary);
#endinitclip
Symbol 42 MovieClip Frame 17
stop();
Symbol 51 MovieClip Frame 29
stop();
Symbol 58 MovieClip Frame 7
stop();
Symbol 71 MovieClip Frame 17
stop();
Symbol 78 MovieClip [Instructions] Frame 1
#initclip 66
Object.registerClass("Instructions", com.midasplayer.chesster.Instructions);
#endinitclip
Symbol 83 MovieClip Frame 13
stop();
Symbol 86 MovieClip Frame 13
stop();
Symbol 94 MovieClip Frame 21
stop();
Symbol 96 MovieClip Frame 20
stop();
Symbol 100 MovieClip [Summary] Frame 1
#initclip 67
Object.registerClass("Summary", com.midasplayer.chesster.Summary);
#endinitclip
Symbol 103 MovieClip [CheckAlert] Frame 1
#initclip 68
Object.registerClass("CheckAlert", com.midasplayer.chesster.Move);
#endinitclip
Symbol 106 MovieClip [PieceSelection] Frame 1
#initclip 69
Object.registerClass("PieceSelection", com.midasplayer.chesster.Move);
#endinitclip
Symbol 109 MovieClip [RockardMove] Frame 1
#initclip 70
Object.registerClass("RockardMove", com.midasplayer.chesster.RockardMove);
#endinitclip
Symbol 112 MovieClip [Move] Frame 1
#initclip 71
Object.registerClass("Move", com.midasplayer.chesster.Move);
#endinitclip
Symbol 113 MovieClip [KillStack] Frame 1
#initclip 72
Object.registerClass("KillStack", com.midasplayer.chesster.KillStack);
#endinitclip
Symbol 117 MovieClip [Knight] Frame 1
#initclip 73
Object.registerClass("Knight", com.midasplayer.chesster.Knight);
#endinitclip
Symbol 121 MovieClip [Bishop] Frame 1
#initclip 74
Object.registerClass("Bishop", com.midasplayer.chesster.Bishop);
#endinitclip
Symbol 125 MovieClip [Rook] Frame 1
#initclip 75
Object.registerClass("Rook", com.midasplayer.chesster.Rook);
#endinitclip
Symbol 129 MovieClip [Queen] Frame 1
#initclip 76
Object.registerClass("Queen", com.midasplayer.chesster.Queen);
#endinitclip
Symbol 133 MovieClip [King] Frame 1
#initclip 77
Object.registerClass("King", com.midasplayer.chesster.King);
#endinitclip
Symbol 137 MovieClip [Pawn] Frame 1
#initclip 78
Object.registerClass("Pawn", com.midasplayer.chesster.Pawn);
#endinitclip
Symbol 138 MovieClip [ChessBoard] Frame 1
#initclip 79
Object.registerClass("ChessBoard", com.midasplayer.chesster.ChessBoard);
#endinitclip
Symbol 148 MovieClip [GameTimer] Frame 1
#initclip 80
Object.registerClass("GameTimer", com.midasplayer.chesster.GameTimer);
#endinitclip
Symbol 150 MovieClip [TurnTimer] Frame 1
#initclip 81
Object.registerClass("TurnTimer", com.midasplayer.chesster.TurnTimer);
#endinitclip
Symbol 155 MovieClip [ChessterThumbs] Frame 1
#initclip 82
Object.registerClass("ChessterThumbs", com.midasplayer.chesster.SideIndicator);
#endinitclip
Symbol 160 MovieClip [Chesster] Frame 1
#initclip 83
Object.registerClass("Chesster", com.midasplayer.chesster.SideIndicator);
#endinitclip
Symbol 164 MovieClip [FadeText] Frame 1
#initclip 84
Object.registerClass("FadeText", com.midasplayer.fx.FadeText);
#endinitclip
Symbol 174 MovieClip [ChatBubble] Frame 1
#initclip 85
Object.registerClass("ChatBubble", com.midasplayer.fx.ChatBubble);
#endinitclip
Symbol 177 MovieClip [ChatField] Frame 1
#initclip 86
Object.registerClass("ChatField", com.midasplayer.chesster.ChatField);
#endinitclip
Symbol 179 MovieClip [ChatPopup] Frame 1
#initclip 87
Object.registerClass("ChatPopup", com.midasplayer.chesster.ChatPopup);
#endinitclip
Symbol 185 MovieClip [ClockLid] Frame 1
#initclip 88
Object.registerClass("ClockLid", com.midasplayer.chesster.SideIndicator);
#endinitclip
Symbol 196 MovieClip [StatusIndicator] Frame 1
#initclip 89
Object.registerClass("StatusIndicator", com.midasplayer.chesster.StatusIndicator);
#endinitclip
Symbol 202 MovieClip [MusicToggle] Frame 1
#initclip 90
Object.registerClass("MusicToggle", com.midasplayer.chesster.MusicToggle);
#endinitclip
Symbol 208 MovieClip [SoundToggle] Frame 1
#initclip 91
Object.registerClass("SoundToggle", com.midasplayer.chesster.SoundToggle);
#endinitclip
Symbol 216 MovieClip [__Packages.com.midasplayer.chesster.ChessBoard] Frame 0
class com.midasplayer.chesster.ChessBoard extends MovieClip
{
var m_inverted, _x, _y, m_gameStatus, m_game, _rotation, m_pieceArr, m_pieceLayer, m_kingPieces, m_activePiece, m_lastKilledPiece, createEmptyMovieClip, m_pieceShadowLayer, m_moveLayer, m_activeMoves, m_moveCalcLayer, getNextHighestDepth;
function ChessBoard () {
super();
m_inverted = false;
_x = BOARD_X;
_y = BOARD_Y;
m_gameStatus = GAMESTATUS_NORMAL;
}
function init(game) {
m_game = game;
}
function setRotation(rotation) {
_rotation = (BOARD_ROTATION = rotation);
}
function setInverted(inverted) {
m_inverted = inverted;
if (m_inverted) {
_rotation = 180 + BOARD_ROTATION;
} else {
_rotation = 0 + BOARD_ROTATION;
}
}
function getPieceArr(side) {
return(m_pieceArr[side]);
}
function getGameStatus() {
return(m_gameStatus);
}
function setGameStatus(gameStatus) {
m_gameStatus = gameStatus;
}
function getInverted() {
return(m_inverted);
}
function setupBoard() {
clearBoard();
setGameStatus(GAMESTATUS_NORMAL);
var _local2 = 0;
while (_local2 < 2) {
((_local2 == 0) ? undefined : undefined);
var _local3 = 0;
while (_local3 < WIDTH) {
m_pieceArr[_local2].push(m_pieceLayer.attachMovie(com.midasplayer.chesster.Pawn.SymbolName, (("pawn_" + _local2) + "_") + _local3, m_pieceLayer.getNextHighestDepth()));
m_pieceArr[_local2][_local3].setup(this, _local3 + 1, ((_local2 == WHITE) ? 2 : (HEIGHT - 1)), _local2);
_local3++;
}
m_pieceArr[_local2].push(m_pieceLayer.attachMovie(com.midasplayer.chesster.Rook.SymbolName, (("rook_" + _local2) + "_") + _local3, m_pieceLayer.getNextHighestDepth()));
m_pieceArr[_local2][_local3].setup(this, 1, ((_local2 == WHITE) ? 1 : (HEIGHT)), _local2);
_local3++;
m_pieceArr[_local2].push(m_pieceLayer.attachMovie(com.midasplayer.chesster.Queen.SymbolName, (("queen_" + _local2) + "_") + _local3, m_pieceLayer.getNextHighestDepth()));
m_pieceArr[_local2][_local3].setup(this, 2, ((_local2 == WHITE) ? 1 : (HEIGHT)), _local2);
_local3++;
m_pieceArr[_local2].push(m_pieceLayer.attachMovie(com.midasplayer.chesster.King.SymbolName, (("king_" + _local2) + "_") + _local3, m_pieceLayer.getNextHighestDepth()));
m_pieceArr[_local2][_local3].setup(this, 3, ((_local2 == WHITE) ? 1 : (HEIGHT)), _local2);
m_kingPieces.push(m_pieceArr[_local2][_local3]);
_local3++;
m_pieceArr[_local2].push(m_pieceLayer.attachMovie(com.midasplayer.chesster.Bishop.SymbolName, (("bishop_" + _local2) + "_") + _local3, m_pieceLayer.getNextHighestDepth()));
m_pieceArr[_local2][_local3].setup(this, WIDTH, ((_local2 == WHITE) ? 1 : (HEIGHT)), _local2);
_local3++;
m_pieceArr[_local2].push(m_pieceLayer.attachMovie(com.midasplayer.chesster.Knight.SymbolName, (("knight_" + _local2) + "_") + _local3, m_pieceLayer.getNextHighestDepth()));
m_pieceArr[_local2][_local3].setup(this, WIDTH - 1, ((_local2 == WHITE) ? 1 : (HEIGHT)), _local2);
_local3++;
_local2++;
}
}
function setupSideQuiz() {
clearBoard();
setGameStatus(GAMESTATUS_SIDE_QUIZ);
com.midasplayer.chesster.Game.debug("Randomizer seed: " + com.midasplayer.util.Randomizer.getSeed());
var _local2 = BLACK;
var _local3 = 0;
var _local19;
var _local18;
m_game.setActiveSide(BLACK);
_local2 = BLACK;
_local3 = 0;
var _local15 = com.midasplayer.util.Randomizer.randomRange(1, 3);
_local3 = 0;
while (_local3 < _local15) {
m_pieceArr[_local2].push(m_pieceLayer.attachMovie(com.midasplayer.chesster.Pawn.SymbolName, (("pawn_" + _local2) + "_") + _local3, m_pieceLayer.getNextHighestDepth()));
m_pieceArr[_local2][_local3].setup(this, 0, 0, _local2);
randomPlacePiece(m_pieceArr[_local2][_local3]);
_local3++;
}
m_pieceArr[_local2].push(m_pieceLayer.attachMovie(com.midasplayer.chesster.King.SymbolName, (("king_" + _local2) + "_") + _local3, m_pieceLayer.getNextHighestDepth()));
m_pieceArr[_local2][_local3].setup(this, 0, 0, _local2);
randomPlacePiece(m_pieceArr[_local2][_local3]);
_local18 = m_pieceArr[_local2][_local3];
_local3++;
_local2 = WHITE;
_local3 = 0;
_local15 = com.midasplayer.util.Randomizer.randomRange(1, 3);
_local3 = 0;
while (_local3 < _local15) {
m_pieceArr[_local2].push(m_pieceLayer.attachMovie(com.midasplayer.chesster.Pawn.SymbolName, (("pawn_" + _local2) + "_") + _local3, m_pieceLayer.getNextHighestDepth()));
m_pieceArr[_local2][_local3].setup(this, 0, 0, _local2);
randomPlacePiece(m_pieceArr[_local2][_local3]);
_local3++;
}
m_pieceArr[_local2].push(m_pieceLayer.attachMovie(com.midasplayer.chesster.King.SymbolName, (("king_" + _local2) + "_") + _local3, m_pieceLayer.getNextHighestDepth()));
m_pieceArr[_local2][_local3].setup(this, 0, 0, _local2);
m_pieceArr[_local2][_local3]._visible = false;
_local19 = m_pieceArr[_local2][_local3];
_local3++;
m_kingPieces.push(_local19);
m_kingPieces.push(_local18);
var _local17 = _local18.getBoardX();
var _local16 = _local18.getBoardY();
var _local10 = new Array(0, 1, 2, 3);
var _local12 = 0;
while (_local12 < 10) {
var _local13 = com.midasplayer.util.Randomizer.randomRange(0, 3);
var _local11 = com.midasplayer.util.Randomizer.randomRange(0, 3);
var _local14 = _local10[_local11];
_local10[_local11] = _local10[_local13];
_local10[_local13] = _local14;
_local12++;
}
_local15 = com.midasplayer.util.Randomizer.randomRange(2, 4);
var _local9 = 0;
while (_local9 < _local15) {
var _local8 = _local10[_local9];
if (_local8 == 0) {
m_pieceArr[_local2].push(m_pieceLayer.attachMovie(com.midasplayer.chesster.Rook.SymbolName, (("rook_" + _local2) + "_") + _local3, m_pieceLayer.getNextHighestDepth()));
} else if (_local8 == 1) {
m_pieceArr[_local2].push(m_pieceLayer.attachMovie(com.midasplayer.chesster.Queen.SymbolName, (("queen_" + _local2) + "_") + _local3, m_pieceLayer.getNextHighestDepth()));
} else if (_local8 == 2) {
m_pieceArr[_local2].push(m_pieceLayer.attachMovie(com.midasplayer.chesster.Bishop.SymbolName, (("bishop_" + _local2) + "_") + _local3, m_pieceLayer.getNextHighestDepth()));
} else if (_local8 == 3) {
m_pieceArr[_local2].push(m_pieceLayer.attachMovie(com.midasplayer.chesster.Knight.SymbolName, (("knight_" + _local2) + "_") + _local3, m_pieceLayer.getNextHighestDepth()));
}
m_pieceArr[_local2][_local3].setup(this, 0, 0, _local2);
if (_local9 == (_local15 - 1)) {
randomPlacePiece(m_pieceArr[_local2][_local3]);
} else {
var _local4 = m_pieceArr[_local2][_local3].getValidMoveData();
var _local5;
m_pieceArr[_local2][_local3].setBoardPos(_local17, _local16);
_local4 = m_pieceArr[_local2][_local3].getValidMoveData();
if (_local4.length > 0) {
_local5 = com.midasplayer.util.Randomizer.randomRange(0, _local4.length - 1);
m_pieceArr[_local2][_local3].setBoardPos(_local4[_local5].getToX(), _local4[_local5].getToY());
}
_local4 = m_pieceArr[_local2][_local3].getValidMoveData();
var _local6 = 0;
while (_local6 < 20) {
_local5 = com.midasplayer.util.Randomizer.randomRange(0, _local4.length - 1);
var _local7 = isSquareVacant(_local4[_local5].getToX(), _local4[_local5].getToY());
if (!_local7) {
} else {
m_pieceArr[_local2][_local3].setBoardPos(_local4[_local5].getToX(), _local4[_local5].getToY());
if (_local7 && (!testForCheck())) {
break;
}
if (_local6 == 19) {
break;
}
}
_local6++;
}
}
_local3++;
_local9++;
}
if (testForCheck() || (testForCheckMate())) {
setupSideQuiz();
}
m_game.setActiveSide(NONE);
}
function randomPlacePiece(piece) {
var _local8 = piece.getBoardX();
var _local7 = piece.getBoardY();
var _local12 = 1;
var _local11 = 2;
var _local10 = WIDTH;
var _local9 = HEIGHT - 1;
var _local4;
var _local3;
var _local2 = 0;
while (true) {
_local4 = com.midasplayer.util.Randomizer.randomRange(_local12, _local10);
_local3 = com.midasplayer.util.Randomizer.randomRange(_local11, _local9);
var _local5 = isSquareVacant(_local4, _local3);
piece.setBoardPos(_local4, _local3);
if (_local5 && (!testForCheck())) {
break;
}
if (_local2 > 35) {
piece.setBoardPos(_local8, _local7);
break;
}
_local2++;
}
}
function clearBoard() {
m_activePiece = null;
m_lastKilledPiece = null;
removeActiveMoves();
removePieces();
}
function removePieces() {
m_pieceLayer.removeMovieClip();
m_pieceLayer = createEmptyMovieClip("pieceLayer", PIECE_DEPTH);
m_pieceShadowLayer.removeMovieClip();
m_pieceShadowLayer = createEmptyMovieClip("pieceShadowLayer", PIECE_SHADOW_DEPTH);
m_pieceArr = new org.as2lib.data.holder.array.TypedArray(org.as2lib.data.holder.array.TypedArray);
m_pieceArr.push(new org.as2lib.data.holder.array.TypedArray(MovieClip));
m_pieceArr.push(new org.as2lib.data.holder.array.TypedArray(MovieClip));
m_kingPieces = new org.as2lib.data.holder.array.TypedArray(MovieClip);
}
function getShadowLayer() {
return(m_pieceShadowLayer);
}
function isSquareMoveable(x, y, side) {
if ((((x < 1) || (x > WIDTH)) || (y < 1)) || (y > HEIGHT)) {
return(false);
}
var _local2 = getPieceAtSquare(x, y);
if ((!_local2) || (_local2 && (_local2.getSide() != side))) {
return(true);
}
return(false);
}
function isSquareVacant(x, y) {
return(getPieceAtSquare(x, y) == null);
}
function getPieceAtSquare(x, y) {
var _local3 = 0;
while (_local3 < 2) {
var _local2 = 0;
while (_local2 < m_pieceArr[_local3].length) {
if (((m_pieceArr[_local3][_local2].getBoardX() == x) && (m_pieceArr[_local3][_local2].getBoardY() == y)) && (m_pieceArr[_local3][_local2].getAlive())) {
return(m_pieceArr[_local3][_local2]);
}
_local2++;
}
_local3++;
}
return(null);
}
function getActivePiece() {
return(m_activePiece);
}
function getActivePieceIndex() {
return(getPieceIndex(com.midasplayer.chesster.Piece(getActivePiece())));
}
function getPieceIndex(piece) {
if (piece == undefined) {
new Error("null pointer sent to getPieceIndex()");
}
var _local3 = 0;
while (_local3 < 2) {
var _local2 = 0;
while (_local2 < m_pieceArr[_local3].length) {
if (m_pieceArr[_local3][_local2] == piece) {
return(_local2);
}
_local2++;
}
_local3++;
}
return(-1);
}
function setActivePiece(piece, remote) {
removeActiveMoves();
if ((m_activePiece == piece) || (piece == null)) {
m_activePiece = null;
} else {
com.midasplayer.fx.SoundManager.play(com.midasplayer.chesster.Game.SOUND_PIECE_SELECTED);
m_activePiece = piece;
var _local3 = m_moveLayer.attachMovie("PieceSelection", "pieceSelection", m_moveLayer.getNextHighestDepth());
var _local5 = new com.midasplayer.chesster.MoveData(m_activePiece.getBoardX(), m_activePiece.getBoardY(), com.midasplayer.chesster.Piece(m_activePiece));
_local3.init(this, _local5);
_local3.setMoveable((m_game.getActiveSide() == com.midasplayer.chesster.Game.PLAYER_SIDE) || (com.midasplayer.chesster.Game.LOCAL_GAME));
}
var _local2 = m_kingPieces[m_game.getActiveSide()];
if ((_local2 != undefined) && (getGameStatus() == GAMESTATUS_CHECK)) {
var _local4 = m_moveLayer.attachMovie("CheckAlert", "checkAlert", m_moveLayer.getNextHighestDepth());
var _local5 = new com.midasplayer.chesster.MoveData(_local2.getBoardX(), _local2.getBoardY(), com.midasplayer.chesster.Piece(_local2));
_local4.init(this, _local5);
_local4.setMoveable(false);
}
if (((!remote) || (remote == undefined)) && (getGameStatus() != GAMESTATUS_SIDE_QUIZ)) {
com.midasplayer.chesster.Communicator.sendSelectPiece(m_activePiece.getBoardX(), m_activePiece.getBoardY());
}
}
function createMove(moveLayer, moveData) {
var _local3;
var _local2 = moveLayer.getNextHighestDepth();
switch (moveData.getMoveType()) {
case com.midasplayer.chesster.MoveData.NORMAL :
_local3 = moveLayer.attachMovie(com.midasplayer.chesster.Move.SymbolName, "move" + _local2, _local2);
break;
case com.midasplayer.chesster.MoveData.ROCKARD :
_local3 = moveLayer.attachMovie(com.midasplayer.chesster.RockardMove.SymbolName, "move" + _local2, _local2);
}
_local3.init(this, moveData);
_local3.setMoveable((m_game.getActiveSide() == com.midasplayer.chesster.Game.PLAYER_SIDE) || (com.midasplayer.chesster.Game.LOCAL_GAME));
return(_local3);
}
function removeActiveMoves(moveLayer) {
if ((moveLayer == m_moveLayer) || (moveLayer == undefined)) {
m_moveLayer.removeMovieClip();
m_moveLayer = createEmptyMovieClip("moveLayer", MOVE_DEPTH);
m_activeMoves = new org.as2lib.data.holder.array.TypedArray(MovieClip);
var _local3 = 0;
while (_local3 < 2) {
var _local2 = 0;
while (_local2 < m_pieceArr[_local3].length) {
m_pieceArr[_local3][_local2].setChildMove(undefined);
_local2++;
}
_local3++;
}
}
if ((moveLayer == m_moveCalcLayer) || (moveLayer == undefined)) {
m_moveCalcLayer.removeMovieClip();
m_moveCalcLayer = createEmptyMovieClip("moveCalcLayer", MOVE_CALC_DEPTH);
m_moveCalcLayer._visible = false;
}
}
function spawnActiveMoves(moveLayer, removeCheckMoves) {
if ((moveLayer == null) || (moveLayer == undefined)) {
moveLayer = m_moveLayer;
}
if ((removeCheckMoves == null) || (removeCheckMoves == undefined)) {
removeCheckMoves = moveLayer == m_moveLayer;
}
var _local9 = new org.as2lib.data.holder.array.TypedArray(MovieClip);
var _local7 = m_activePiece.getValidMoveData();
var _local2 = 0;
while (_local2 < _local7.length) {
var _local6 = _local7[_local2];
var _local3 = createMove(moveLayer, _local6);
var _local4 = false;
if (removeCheckMoves) {
makeMove(_local3, true);
if (testForCheck()) {
_local4 = true;
}
undoMove(_local3);
}
if (_local4) {
_local3.removeMovieClip();
} else {
_local9.push(_local3);
}
_local2++;
}
if (moveLayer == m_moveLayer) {
m_activeMoves = _local9;
_local2 = 0;
while (_local2 < m_activeMoves.length) {
var _local5 = getPieceAtSquare(m_activeMoves[_local2].getBoardX(), m_activeMoves[_local2].getBoardY());
if (_local5) {
_local5.setChildMove(m_activeMoves[_local2]);
}
_local2++;
}
}
return(_local9);
}
function testForCheck(side) {
var _local11 = ((side != undefined) ? (side) : (m_game.getActiveSide()));
var _local7 = false;
var _local12 = m_kingPieces[_local11];
var _local9 = _local12.getBoardX();
var _local8 = _local12.getBoardY();
var _local10 = m_pieceArr[((_local11 == WHITE) ? (BLACK) : (WHITE))];
var _local6 = 0;
while (_local6 < _local10.length) {
var _local5 = _local10[_local6];
if (!_local5.getAlive()) {
} else if (!_local5.movePossible(_local9, _local8)) {
} else {
var _local4 = _local5.getValidMoveData();
var _local2 = 0;
while (_local2 < _local4.length) {
var _local3 = _local4[_local2];
if ((_local3.getToX() == _local9) && (_local3.getToY() == _local8)) {
_local7 = true;
break;
}
_local2++;
}
if (_local7) {
break;
}
}
_local6++;
}
return(_local7);
}
function testForCheckMate(side) {
var _local9 = m_activePiece;
var _local8 = ((side != undefined) ? (side) : (m_game.getActiveSide()));
var _local5 = true;
var _local6 = m_pieceArr[_local8];
var _local2 = 0;
while (_local2 < _local6.length) {
var _local3 = _local6[_local2];
if (!_local3.getAlive()) {
} else {
m_activePiece = _local3;
var _local7 = createEmptyMovieClip("temp", getNextHighestDepth());
var _local4 = spawnActiveMoves(m_moveCalcLayer, true);
if (_local4.length) {
_local5 = false;
}
removeActiveMoves();
if (!_local5) {
break;
}
}
_local2++;
}
m_activePiece = _local9;
return(_local5);
}
function testForDraw() {
var _local4 = 0;
var _local3 = 0;
while (_local3 < 2) {
var _local2 = 0;
while (_local2 < m_pieceArr[_local3].length) {
if (m_pieceArr[_local3][_local2].getAlive()) {
_local4++;
}
_local2++;
}
_local3++;
}
if (_local4 <= 2) {
return(true);
}
if (m_game.isHistoryDraw()) {
return(true);
}
return(false);
}
function makeMoveRemote(pieceIndex, moveIndex) {
var _local2 = m_pieceArr[com.midasplayer.chesster.Game.OPPONENT_SIDE][pieceIndex];
if (getActivePiece() != _local2) {
var _local3 = _local2.getBoardX();
var _local4 = _local2.getBoardY();
m_game.setActivePieceRemote(_local3, _local4);
}
makeMove(m_activeMoves[moveIndex], false, false);
}
function makeMove(moveObj, dummy, local) {
makeMoveStart(moveObj, dummy);
if ((!dummy) && (getGameStatus() != GAMESTATUS_SIDE_QUIZ)) {
var _local3 = -1;
var _local4 = moveObj.getMoveData();
var _local6 = false;
var _local2 = 0;
while (_local2 < m_activeMoves.length) {
if (m_activeMoves[_local2] == moveObj) {
_local6 = true;
_local3 = _local2;
if (local) {
m_game.onMakeMoveLocal(_local3, _local4);
}
m_game.sendMovePlaydata(_local3, _local4);
break;
}
_local2++;
}
if ((!_local6) || (moveObj == undefined)) {
m_game.sendMovePlaydata(-1, _local4);
}
}
makeMoveComplete(moveObj, dummy);
}
function makeMoveStart(moveObj, dummy) {
if (!dummy) {
m_game.onMakeMove(moveObj);
}
var _local8 = getPieceAtSquare(moveObj.getToX(), moveObj.getToY());
m_lastKilledPiece = _local8;
if (_local8) {
_local8.setAlive(false);
if (!dummy) {
com.midasplayer.fx.SoundManager.play(com.midasplayer.chesster.Game.SOUND_PIECE_STRUCK);
if (getGameStatus() != GAMESTATUS_SIDE_QUIZ) {
m_game.onPieceStruck(_local8);
}
}
} else if (!dummy) {
com.midasplayer.fx.SoundManager.play(com.midasplayer.chesster.Game.SOUND_PIECE_MOVED);
}
var _local10 = moveObj.makeMove(dummy);
if (!_local10) {
if (m_lastKilledPiece) {
m_lastKilledPiece.setAlive(true);
}
throw new Error("Invalid move called: " + moveObj.toString());
return(undefined);
}
if (dummy) {
return(undefined);
}
if (m_activePiece instanceof com.midasplayer.chesster.Pawn) {
if (m_activePiece.getBoardY() == ((m_activePiece.getSide() == WHITE) ? (HEIGHT) : 1)) {
com.midasplayer.fx.SoundManager.play(com.midasplayer.chesster.Game.SOUND_PAWN_TO_QUEEN);
var _local3 = m_game.getActiveSide();
var _local2 = 0;
while (_local2 < m_pieceArr[_local3].length) {
if (m_pieceArr[_local3][_local2] == m_activePiece) {
var _local4 = m_activePiece.getBoardX();
var _local6 = m_activePiece.getBoardY();
var _local5 = m_activePiece._name;
m_activePiece.removeMovieClip();
m_pieceArr[_local3].splice(_local2, 1, m_pieceLayer.attachMovie(com.midasplayer.chesster.Queen.SymbolName, _local5, m_pieceLayer.getNextHighestDepth()));
m_pieceArr[_local3][_local2].setup(this, moveObj.getFromX(), moveObj.getFromY(), _local3);
m_pieceArr[_local3][_local2].setBoardPos(_local4, _local6, true);
}
_local2++;
}
}
}
}
function makeMoveComplete(moveObj, dummy) {
if (dummy) {
return(undefined);
}
if (getGameStatus() == GAMESTATUS_SIDE_QUIZ) {
var _local2 = testForCheck(BLACK) || (testForCheckMate(BLACK));
m_game.sideQuizComplete(_local2);
m_game.setActiveSide(NONE);
return(undefined);
}
m_game.logMove(moveObj);
m_game.resetTurnTimeOut();
m_game.changeSide();
}
function undoMove(moveObj) {
if (m_lastKilledPiece) {
m_lastKilledPiece.setAlive(true);
}
moveObj.undoMove();
}
function setActiveSide(activeSide) {
if ((activeSide != NONE) && (getGameStatus() != GAMESTATUS_SIDE_QUIZ)) {
m_gameStatus = GAMESTATUS_NORMAL;
if (testForCheck()) {
m_gameStatus = GAMESTATUS_CHECK;
}
if (testForCheckMate()) {
m_gameStatus = GAMESTATUS_CHECK_MATE;
} else if (testForDraw()) {
m_gameStatus = GAMESTATUS_DRAW;
}
}
if ((activeSide == com.midasplayer.chesster.Game.PLAYER_SIDE) || (com.midasplayer.chesster.Game.LOCAL_GAME)) {
setMoveableSide(activeSide);
} else {
setMoveableSide(NONE);
}
setActivePiece(null);
}
function setMoveableSide(activeSide) {
var _local3 = 0;
while (_local3 < 2) {
var _local2 = 0;
while (_local2 < m_pieceArr[_local3].length) {
if (m_pieceArr[_local3][_local2].getSide() == activeSide) {
m_pieceArr[_local3][_local2].setMoveable(true);
} else {
m_pieceArr[_local3][_local2].setMoveable(false);
}
_local2++;
}
_local3++;
}
}
static var BOARD_X = 474;
static var BOARD_Y = 251;
static var BOARD_ROTATION = 0;
static var SQUARE_SIZE = 64;
static var PIECE_DEPTH = 1000;
static var PIECE_SHADOW_DEPTH = PIECE_DEPTH - 1;
static var MOVE_DEPTH = 100;
static var MOVE_CALC_DEPTH = 5;
static var NONE = -1;
static var WHITE = 0;
static var BLACK = 1;
static var WIDTH = 5;
static var HEIGHT = 7;
static var GAMESTATUS_SIDE_QUIZ = -1;
static var GAMESTATUS_NORMAL = 0;
static var GAMESTATUS_CHECK = 1;
static var GAMESTATUS_CHECK_MATE = 2;
static var GAMESTATUS_DRAW = 3;
static var GAMESTATUS_CHECK_TIMEOUT = 4;
static var GAMESTATUS_TURN_TIMEOUT = 5;
static var GAMESTATUS_GAME_TIMEOUT = 6;
static var GAMESTATUS_PLAYER_DISCONNECT = 7;
static var SymbolName = "ChessBoard";
static var ImageSymbolName = "ChessBoardImage";
}
Symbol 217 MovieClip [__Packages.org.as2lib.core.BasicInterface] Frame 0
interface org.as2lib.core.BasicInterface
{
}
Symbol 218 MovieClip [__Packages.org.as2lib.data.holder.array.TypedArray] Frame 0
class org.as2lib.data.holder.array.TypedArray extends Array implements org.as2lib.core.BasicInterface
{
var type, length;
function TypedArray (type) {
super();
this.type = type;
_global.ASSetPropFlags(this, ["type"], 1, true);
if (arguments.length > 1) {
arguments.shift();
push.apply(this, arguments);
}
}
function getType(Void) {
return(type);
}
function concat() {
var _local6 = new org.as2lib.data.holder.array.TypedArray(type);
var _local8 = length;
while (_local8-- , _local8 - -1) {
_local6[_local8] = this[_local8];
}
var _local9 = arguments.length;
var _local5 = 0;
while (_local5 < _local9) {
var _local4 = arguments[_local5];
if (_local4 instanceof Array) {
var _local7 = _local4.length;
var _local3 = 0;
while (_local3 < _local7) {
_local6.push(_local4[_local3]);
_local3 = _local3 - -1;
}
} else {
_local6.push(_local4);
}
_local5 = _local5 - -1;
}
return(_local6);
}
function push(value) {
if (arguments.length > 1) {
var _local5 = arguments.length;
var _local4 = 0;
while (_local4 < _local5) {
validate(arguments[_local4]);
_local4++;
}
} else {
validate(value);
}
return(Number(super.push.apply(this, arguments)));
}
function unshift(value) {
if (arguments.length > 1) {
var _local5 = arguments.length;
var _local4 = 0;
while (_local4 < _local5) {
validate(arguments[_local4]);
_local4++;
}
} else {
validate(value);
}
return(Number(super.unshift.apply(this, arguments)));
}
function toString() {
return(super.toString());
}
function validate(object) {
if (!org.as2lib.util.ObjectUtil.typesMatch(object, type)) {
throw new org.as2lib.env.except.IllegalArgumentException(((("Type mismatch between object [" + object) + "] and type [") + org.as2lib.env.reflect.ReflectUtil.getTypeNameForType(type)) + "].", this, arguments);
}
}
}
Symbol 219 MovieClip [__Packages.org.as2lib.core.BasicClass] Frame 0
class org.as2lib.core.BasicClass implements org.as2lib.core.BasicInterface
{
function BasicClass () {
}
function toString() {
return(org.as2lib.Config.getObjectStringifier().execute(this));
}
}
Symbol 220 MovieClip [__Packages.org.as2lib.Config] Frame 0
class org.as2lib.Config extends org.as2lib.core.BasicClass
{
static var objectStringifier;
function Config (Void) {
super();
}
static function setObjectStringifier(newStringifier) {
objectStringifier = newStringifier;
}
static function getObjectStringifier(Void) {
if (!objectStringifier) {
objectStringifier = new org.as2lib.core.ObjectStringifier();
}
return(objectStringifier);
}
}
Symbol 221 MovieClip [__Packages.org.as2lib.util.Stringifier] Frame 0
interface org.as2lib.util.Stringifier extends org.as2lib.core.BasicInterface
{
}
Symbol 222 MovieClip [__Packages.org.as2lib.core.ObjectStringifier] Frame 0
class org.as2lib.core.ObjectStringifier extends org.as2lib.core.BasicClass implements org.as2lib.util.Stringifier
{
function ObjectStringifier () {
super();
}
function execute(target) {
return(("[type " + org.as2lib.env.reflect.ReflectUtil.getTypeName(target)) + "]");
}
}
Symbol 223 MovieClip [__Packages.org.as2lib.env.reflect.ReflectUtil] Frame 0
class org.as2lib.env.reflect.ReflectUtil extends org.as2lib.core.BasicClass
{
function ReflectUtil (Void) {
super();
}
static function getUnusedMemberName(object) {
var _local1 = 10000;
var _local3 = MEMBER_PREFIX + "_";
var _local2 = MEMBER_PREFIX + "-";
while (_local1-- , _local1 - -1) {
if (object[_local3 + _local1] === undefined) {
return(_local3 + _local1);
}
if (object[_local2 + _local1] === undefined) {
return(_local2 + _local1);
}
}
return(null);
}
static function getTypeAndMethodInfo(object, method) {
if ((object === null) || (object === undefined)) {
return(null);
}
if (typeof(object) == "function") {
return(getTypeAndMethodInfoByType(object, method));
}
return(getTypeAndMethodInfoByInstance(object, method));
}
static function getTypeAndMethodInfoByType(type, method) {
if ((type === null) || (type === undefined)) {
return(null);
}
if (method.valueOf() == type.valueOf()) {
return([false, getTypeNameForType(type), CONSTRUCTOR]);
}
var _local2 = getMethodNameByObject(method, type);
if ((!(_local2 === null)) && (!(_local2 === undefined))) {
return([true, getTypeNameForType(type), _local2]);
}
return(getTypeAndMethodInfoByPrototype(type.prototype, method));
}
static function getTypeAndMethodInfoByInstance(instance, method) {
if ((instance === null) || (instance === undefined)) {
return(null);
}
if (instance.__constructor__) {
if (instance.__constructor__.prototype == instance.__proto__) {
return(getTypeAndMethodInfoByType(instance.__constructor__, method));
}
}
if (instance.constructor) {
if (instance.constructor.prototype == instance.__proto__) {
return(getTypeAndMethodInfoByType(instance.constructor, method));
}
}
return(getTypeAndMethodInfoByPrototype(instance.__proto__, method));
}
static function getTypeAndMethodInfoByPrototype(p, m) {
if ((p === null) || (p === undefined)) {
return(null);
}
var _local6 = p;
_global.ASSetPropFlags(_global, null, 0, true);
var _local4;
while (p) {
if (p.constructor.valueOf() == m.valueOf()) {
_local4 = CONSTRUCTOR;
} else {
_local4 = getMethodNameByObject(m, p);
}
if (_local4 != null) {
var _local3 = new Array();
_local3[0] = false;
_local3[1] = getTypeNameByPrototype(p, _global, "", [_global]);
_local3[2] = _local4;
return(_local3);
}
p = p.__proto__;
}
return([null, getTypeNameByPrototype(_local6, _global, "", [_global]), null]);
}
static function getTypeName(object) {
if ((object === null) || (object === undefined)) {
return(null);
}
if (typeof(object) == "function") {
return(getTypeNameForType(object));
}
return(getTypeNameForInstance(object));
}
static function getTypeNameForInstance(instance) {
if ((instance === null) || (instance === undefined)) {
return(null);
}
_global.ASSetPropFlags(_global, null, 0, true);
return(getTypeNameByPrototype(instance.__proto__, _global, "", [_global]));
}
static function getTypeNameForType(type) {
if ((type === null) || (type === undefined)) {
return(null);
}
_global.ASSetPropFlags(_global, null, 0, true);
return(getTypeNameByPrototype(type.prototype, _global, "", [_global]));
}
static function getTypeNameByPrototype(c, p, n, a) {
var y = c.__as2lib__typeName;
if ((y != null) && (y != c.__proto__.__as2lib__typeName)) {
return(y);
}
if (n == null) {
n = "";
}
var s = _global.ASSetPropFlags;
for (var r in p) {
try {
if (((!eval ("_global." + r.split("_").join("."))) || (r.indexOf("_") < 0)) && (p[r].prototype === c)) {
var x = (n + r);
c.__as2lib__typeName = x;
s(c, "__as2lib__typeName", 1, true);
return(x);
}
if (p[r].__constructor__.valueOf() == Object) {
var f = false;
var i = 0;
while (i < a.length) {
if (a[i].valueOf() == p[r].valueOf()) {
f = true;
}
i++;
}
if (!f) {
a.push(p[r]);
r = getTypeNameByPrototype(c, p[r], (n + r) + ".", a);
if (r) {
return(r);
}
}
} else if (typeof(p[r]) == "function") {
p[r].prototype.__as2lib__typeName = n + r;
s(p[r].prototype, "__as2lib__typeName", 1, true);
}
} catch(e) {
}
}
return(null);
}
static function getMethodName(method, object) {
if (((!method) || (object === null)) || (object === undefined)) {
return(null);
}
if (typeof(object) == "function") {
return(getMethodNameByType(method, object));
}
return(getMethodNameByInstance(method, object));
}
static function getMethodNameByInstance(method, instance) {
if (((!method) || (instance === null)) || (instance === undefined)) {
return(null);
}
if (instance.__constructor__) {
if (instance.__constructor__.prototype == instance.__proto__) {
return(getMethodNameByType(method, instance.__constructor__));
}
}
if (instance.constructor) {
if (instance.constructor.prototype == instance.__proto__) {
return(getMethodNameByType(method, instance.constructor));
}
}
return(getMethodNameByPrototype(method, instance.__proto__));
}
static function getMethodNameByType(method, type) {
if ((!method) || (!type)) {
return(null);
}
var _local1 = getMethodNameByPrototype(method, type.prototype);
if (_local1 != null) {
return(_local1);
}
return(getMethodNameByObject(method, type));
}
static function getMethodNameByPrototype(m, p) {
if ((((m === null) || (m === undefined)) || (p === null)) || (p === undefined)) {
return(null);
}
while (p) {
var _local2 = getMethodNameByObject(m, p);
if (_local2 != null) {
return(_local2);
}
p = p.__proto__;
}
return(null);
}
static function getMethodNameByObject(m, o) {
var _local6 = m.__as2lib__methodName;
if (_local6 != null) {
return(_local6);
}
var _local5 = _global.ASSetPropFlags;
_local5(o, null, 0, true);
_local5(o, ["__proto__", "prototype", "__constructor__", "constructor"], 7, true);
for (var _local4 in o) {
try {
if (o[_local4].valueOf() == m.valueOf()) {
m.__as2lib__methodName = _local4;
return(_local4);
}
if (typeof(o[_local4]) == "function") {
o[_local4].__as2lib__methodName = _local4;
}
} catch(e) {
}
}
_local5(o, null, 1, true);
return(null);
}
static function isMethodStatic(methodName, object) {
if (((!methodName) || (object === null)) || (object === undefined)) {
return(false);
}
if (typeof(object) == "function") {
return(isMethodStaticByType(methodName, object));
}
return(isMethodStaticByInstance(methodName, object));
}
static function isMethodStaticByInstance(methodName, instance) {
if (((!methodName) || (instance === null)) || (instance === undefined)) {
return(false);
}
return(isMethodStaticByType(methodName, (instance.__constructor__ ? (instance.__constructor) : (instance.constructor))));
}
static function isMethodStaticByType(methodName, type) {
if ((!methodName) || (!type)) {
return(false);
}
try {
if (type[methodName]) {
return(true);
}
} catch(e) {
}
return(false);
}
static function isConstructor(constructor, object) {
if ((((constructor === null) || (constructor === undefined)) || (object === null)) || (object === undefined)) {
return(false);
}
if (typeof(object) == "function") {
return(isConstructorByType(constructor, object));
}
return(isConstructorByInstance(constructor, object));
}
static function isConstructorByInstance(method, instance) {
if (((!method) || (instance === null)) || (instance === undefined)) {
return(false);
}
return(isConstructorByType(method, (instance.__constructor__ ? (instance.__constructor__) : (instance.constructor))));
}
static function isConstructorByType(method, type) {
if ((((method === null) || (method === undefined)) || (type === null)) || (type === undefined)) {
return(false);
}
return(method.valueOf() == type.valueOf());
}
static function getVariableNames(instance) {
var _local3 = new Array();
var _local5 = _global.ASSetPropFlags;
_local5(instance, null, 0, true);
_local5(instance, ["__proto__", "prototype", "__constructor__", "constructor"], 7, true);
for (var _local4 in instance) {
try {
if (typeof(instance[_local4]) != "function") {
_local3.push(_local4);
}
} catch(e) {
}
}
_local5(instance, null, 1, true);
return(_local3);
}
static function getTypeByName(path) {
var result = eval ("_global." + path);
if (!result) {
result = eval ("_global." + path.split(".").join("_"));
}
return(result);
}
static var CONSTRUCTOR = "new";
static var UNKNOWN = "[unknown]";
static var MEMBER_PREFIX = "__as2lib__member";
}
Symbol 224 MovieClip [__Packages.org.as2lib.util.ObjectUtil] Frame 0
class org.as2lib.util.ObjectUtil extends org.as2lib.core.BasicClass
{
function ObjectUtil (Void) {
super();
}
static function stringify(object) {
return(org.as2lib.Config.getObjectStringifier().execute(object));
}
static function typesMatch(object, type) {
if (type === Object) {
return(true);
}
if (isPrimitiveType(object)) {
var _local2 = typeof(object);
if (((type === String) || (org.as2lib.util.ClassUtil.isSubClassOf(type, String))) && (_local2 == TYPE_STRING)) {
return(true);
}
if (((type === Boolean) || (org.as2lib.util.ClassUtil.isSubClassOf(type, Boolean))) && (_local2 == TYPE_BOOLEAN)) {
return(true);
}
if (((type === Number) || (org.as2lib.util.ClassUtil.isSubClassOf(type, Number))) && (_local2 == TYPE_NUMBER)) {
return(true);
}
return(false);
}
return(isInstanceOf(object, type));
}
static function compareTypeOf(firstObject, secondObject) {
return(typeof(firstObject) == typeof(secondObject));
}
static function isPrimitiveType(object) {
var _local1 = typeof(object);
return(((_local1 == TYPE_STRING) || (_local1 == TYPE_NUMBER)) || (_local1 == TYPE_BOOLEAN));
}
static function isTypeOf(object, type) {
return(typeof(object) == type);
}
static function isInstanceOf(object, type) {
if (type === Object) {
return(true);
}
return(object instanceof type);
}
static function isExplicitInstanceOf(object, clazz) {
if (isPrimitiveType(object)) {
if (clazz == String) {
return(typeof(object) == TYPE_STRING);
}
if (clazz == Number) {
return(typeof(object) == TYPE_NUMBER);
}
if (clazz == Boolean) {
return(typeof(object) == TYPE_BOOLEAN);
}
}
return((object instanceof clazz) && (!(object.__proto__ instanceof clazz)));
}
static function compare(obj1, obj2) {
return(compareRecursive(obj1, obj2, [], []));
}
static function compareRecursive(obj1, obj2, stack1, stack2) {
if ((typeof(obj1) == "object") && (!(((obj1 instanceof String) || (obj1 instanceof Number)) || (obj1 instanceof Boolean)))) {
if (obj1 === obj2) {
return(true);
}
if (obj1 instanceof org.as2lib.util.Comparable) {
var _local7 = obj1;
return(_local7.compare(obj2));
}
if (obj1.__proto__ == obj2.__proto__) {
var _local6 = org.as2lib.util.ArrayUtil.lastIndexOf(stack1, obj1);
if (_local6 > -1) {
if (obj2 == stack2[_local6]) {
return(true);
}
}
stack1.push(obj1);
stack2.push(obj2);
var _local2;
for (_local2 in obj1) {
if (!compareRecursive(obj1[_local2], obj2[_local2], stack1, stack2)) {
return(false);
}
}
stack1.pop();
stack2.pop();
return(true);
}
return(false);
}
return(obj1 == obj2);
}
static var TYPE_STRING = "string";
static var TYPE_NUMBER = "number";
static var TYPE_OBJECT = "object";
static var TYPE_BOOLEAN = "boolean";
static var TYPE_MOVIECLIP = "movieclip";
static var TYPE_FUNCTION = "function";
static var TYPE_UNDEFINED = "undefined";
static var TYPE_NULL = "null";
}
Symbol 225 MovieClip [__Packages.org.as2lib.util.ClassUtil] Frame 0
class org.as2lib.util.ClassUtil extends org.as2lib.core.BasicClass
{
function ClassUtil () {
super();
}
static function isSubClassOf(subClass, superClass) {
var _local1 = subClass.prototype;
while (!(_local1 === undefined)) {
_local1 = _local1.__proto__;
if (_local1 === superClass.prototype) {
return(true);
}
}
return(false);
}
static function isImplementationOf(clazz, interfaze) {
if (isSubClassOf(clazz, interfaze)) {
return(false);
}
return(createCleanInstance(clazz) instanceof interfaze);
}
static function createCleanInstance(clazz) {
var _local1 = new Object();
_local1.__proto__ = clazz.prototype;
_local1.__constructor__ = clazz;
return(_local1);
}
static function createInstance(clazz, args) {
if (!clazz) {
return(null);
}
var _local1 = new Object();
_local1.__proto__ = clazz.prototype;
_local1.__constructor__ = clazz;
clazz.apply(_local1, args);
return(_local1);
}
}
Symbol 226 MovieClip [__Packages.org.as2lib.util.Comparable] Frame 0
interface org.as2lib.util.Comparable extends org.as2lib.core.BasicInterface
{
}
Symbol 227 MovieClip [__Packages.org.as2lib.util.ArrayUtil] Frame 0
class org.as2lib.util.ArrayUtil extends org.as2lib.core.BasicClass
{
function ArrayUtil (Void) {
super();
}
static function clone(array) {
return(array.concat());
}
static function removeElement(array, element) {
return(removeAllOccurances(array, element));
}
static function removeAllOccurances(array, element) {
var _local1 = array.length;
var _local3 = new Array();
while (_local1-- , _local1 - -1) {
if (array[_local1] === element) {
_local3.unshift(_local1);
array.splice(_local1, 1);
}
}
return(_local3);
}
static function removeLastOccurance(array, element) {
var _local1 = array.length;
while (_local1-- , _local1 - -1) {
if (array[_local1] === element) {
array.splice(_local1, 1);
return(_local1);
}
}
return(-1);
}
static function removeFirstOccurance(array, element) {
var _local3 = array.length;
var _local1 = 0;
while (_local1 < _local3) {
if (array[_local1] === element) {
array.splice(_local1, 1);
return(_local1);
}
_local1 = _local1 - -1;
}
return(-1);
}
static function contains(array, object) {
for (var _local3 in array) {
if (array[_local3] === object) {
return(true);
}
}
return(false);
}
static function indexOf(array, object) {
var _local1 = 0;
while (_local1 < array.length) {
if (array[_local1] === object) {
return(_local1);
}
_local1++;
}
return(-1);
}
static function lastIndexOf(array, object) {
var _local1 = array.length;
while (_local1-- , _local1 - -1) {
if (array[_local1] === object) {
return(_local1);
}
}
return(-1);
}
static function shuffle(array) {
var _local4 = array.length;
var _local3;
var _local5;
var _local1 = _local4 - 1;
while (_local1 >= 0) {
_local3 = Math.floor(Math.random() * _local4);
_local5 = array[_local1];
array[_local1] = array[_local3];
array[_local3] = _local5;
_local1--;
}
}
static function swap(array, i, j) {
if (!array) {
throw new org.as2lib.env.except.IllegalArgumentException("Array to swap content has to be available", this, arguments);
}
if ((i > (array.length - 1)) || (i < 0)) {
throw new org.as2lib.data.holder.NoSuchElementException(("The first index " + i) + " is not available within the array", this, arguments);
}
if ((j > (array.length - 1)) || (j < 0)) {
throw new org.as2lib.data.holder.NoSuchElementException(("The second index " + j) + " is not available within the array", this, arguments);
}
var tmp = array[i];
array[i] = array[j];
array[j] = tmp;
return(array);
}
static function isSame(array1, array2) {
var _local1 = array1.length;
if (_local1 != array2.length) {
return(false);
}
while (_local1-- , _local1 - -1) {
if (!(array1[_local1] === array2[_local1])) {
return(false);
}
}
return(true);
}
}
Symbol 228 MovieClip [__Packages.org.as2lib.env.except.AbstractThrowable] Frame 0
class org.as2lib.env.except.AbstractThrowable extends Error
{
static var stringifier, logger;
var message, stackTrace, cause, errorCode;
function AbstractThrowable (message, thrower, args) {
super();
this.message = message;
stackTrace = new Array();
addStackTraceElement(thrower, args.callee, args);
}
static function getStringifier(Void) {
if (!stringifier) {
stringifier = new org.as2lib.env.except.ThrowableStringifier();
}
return(stringifier);
}
static function setStringifier(throwableStringifier) {
stringifier = throwableStringifier;
}
static function getLogger(Void) {
if (!logger) {
logger = org.as2lib.env.log.LogManager.getLogger("org.as2lib.env.except.Throwable");
}
return(logger);
}
function addStackTraceElement(thrower, method, args) {
stackTrace.push(new org.as2lib.env.except.StackTraceElement(thrower, method, args));
}
function getStackTrace(Void) {
return(stackTrace);
}
function getCause(Void) {
return(cause);
}
function initCause(newCause) {
if (!newCause) {
throw new org.as2lib.env.except.IllegalArgumentException("Cause must not be null or undefined.", this, arguments);
}
if (cause) {
throw new org.as2lib.env.except.IllegalStateException(("The cause [" + cause) + "] has already been initialized.", this, arguments);
}
cause = newCause;
return(org.as2lib.env.except.Throwable(this));
}
function getMessage(Void) {
return(message);
}
function initErrorCode(errorCode) {
this.errorCode = errorCode;
return(org.as2lib.env.except.Throwable(this));
}
function getErrorCode(Void) {
return(errorCode);
}
function doToString(Void) {
return(getStringifier().execute(this));
}
}
Symbol 229 MovieClip [__Packages.org.as2lib.env.log.Logger] Frame 0
interface org.as2lib.env.log.Logger extends org.as2lib.core.BasicInterface
{
}
Symbol 230 MovieClip [__Packages.org.as2lib.env.except.ThrowableStringifier] Frame 0
class org.as2lib.env.except.ThrowableStringifier extends org.as2lib.core.BasicClass implements org.as2lib.util.Stringifier
{
var showStackTrace, showCause;
function ThrowableStringifier (showStackTrace, showCause) {
super();
this.showStackTrace = ((showStackTrace == null) ? true : (showStackTrace));
this.showCause = ((showCause == null) ? true : (showCause));
}
function execute(target) {
var _local2 = target;
var _local3 = "";
var _local4 = org.as2lib.env.reflect.ReflectUtil.getTypeNameForInstance(_local2);
var _local5 = _local4.length + 2;
_local3 = _local3 + ((_local4 + ": ") + org.as2lib.util.StringUtil.addSpaceIndent(_local2.getMessage(), _local5).substr(_local5));
var _local7 = _local2.getStackTrace();
if (_local7 && (_local7.length > 0)) {
_local3 = _local3 + (newline + stringifyStackTrace(_local2.getStackTrace()));
}
var _local6 = _local2.getCause();
if (_local6) {
_local3 = _local3 + ("\nCaused by: " + _local6);
}
return(_local3);
}
function stringifyStackTrace(stackTrace) {
var _local4 = "";
var _local1 = 0;
while (_local1 < stackTrace.length) {
var _local2 = stackTrace[_local1];
_local4 = _local4 + (" at " + _local2.toString());
if (_local1 < (stackTrace.length - 1)) {
_local4 = _local4 + newline;
}
_local1++;
}
return(_local4);
}
}
Symbol 231 MovieClip [__Packages.org.as2lib.env.except.Throwable] Frame 0
interface org.as2lib.env.except.Throwable extends org.as2lib.core.BasicInterface
{
}
Symbol 232 MovieClip [__Packages.org.as2lib.util.StringUtil] Frame 0
class org.as2lib.util.StringUtil extends org.as2lib.core.BasicClass
{
function StringUtil (Void) {
super();
}
static function replace(string, what, to) {
return(string.split(what).join(to));
}
static function trim(string) {
return(leftTrim(rightTrim(string)));
}
static function leftTrim(string) {
return(leftTrimForChars(string, "\n\t\n "));
}
static function rightTrim(string) {
return(rightTrimForChars(string, "\n\t\n "));
}
static function leftTrimForChars(string, chars) {
var _local1 = 0;
var _local3 = string.length;
while ((_local1 < _local3) && (chars.indexOf(string.charAt(_local1)) >= 0)) {
_local1++;
}
return(((_local1 > 0) ? (string.substr(_local1, _local3)) : (string)));
}
static function rightTrimForChars(string, chars) {
var _local3 = 0;
var _local1 = string.length - 1;
while ((_local3 < _local1) && (chars.indexOf(string.charAt(_local1)) >= 0)) {
_local1--;
}
return(((_local1 >= 0) ? (string.substr(_local3, _local1 + 1)) : (string)));
}
static function leftTrimForChar(string, char) {
if (char.length != 1) {
throw new org.as2lib.env.except.IllegalArgumentException(("The Second Attribute char [" + char) + "] must exactly one character.", this, arguments);
}
return(leftTrimForChars(string, char));
}
static function rightTrimForChar(string, char) {
if (char.length != 1) {
throw new org.as2lib.env.except.IllegalArgumentException(("The Second Attribute char [" + char) + "] must exactly one character.", this, arguments);
}
return(rightTrimForChars(string, char));
}
static function checkEmail(email) {
if (email.length < 6) {
return(false);
}
if ((email.split("@").length > 2) || (email.indexOf("@") < 0)) {
return(false);
}
if (email.lastIndexOf("@") > email.lastIndexOf(".")) {
return(false);
}
if (email.lastIndexOf(".") > (email.length - 3)) {
return(false);
}
if (email.lastIndexOf(".") <= (email.lastIndexOf("@") + 1)) {
return(false);
}
return(true);
}
static function assureLength(string, length) {
if ((length < 0) || ((!length) && (!(length === 0)))) {
throw new org.as2lib.env.except.IllegalArgumentException(("The given length [" + length) + "] has to be bigger or equals 0.", this, arguments);
}
return(string.length >= length);
}
static function contains(string, chars) {
if ((chars == null) || (string == null)) {
return(false);
}
var _local1 = chars.length - 1;
while (_local1 >= 0) {
if (string.indexOf(chars.charAt(_local1)) >= 0) {
return(true);
}
_local1--;
}
return(false);
}
static function startsWith(string, searchString) {
if (string.indexOf(searchString) == 0) {
return(true);
}
return(false);
}
static function endsWith(string, searchString) {
if (string.lastIndexOf(searchString) == (string.length - searchString.length)) {
return(true);
}
return(false);
}
static function addSpaceIndent(string, size) {
if (string == null) {
string = "";
}
if (size < 0) {
throw new org.as2lib.env.except.IllegalArgumentException("The given size has to be bigger or equals null.", this, arguments);
}
var indentString = multiply(" ", size);
return(indentString + replace(string, newline, newline + indentString));
}
static function multiply(string, factor) {
var _local2 = "";
var _local1 = factor;
while (_local1 > 0) {
_local2 = _local2 + string;
_local1--;
}
return(_local2);
}
static function ucFirst(string) {
return(string.charAt(0).toUpperCase() + string.substr(1));
}
static function ucWords(string) {
var _local2 = string.split(" ");
var _local3 = _local2.length;
var _local1 = 0;
while (_local1 < _local3) {
_local2[_local1] = ucFirst(_local2[_local1]);
_local1++;
}
return(_local2.join(" "));
}
static function firstChar(string) {
return(string.charAt(0));
}
static function lastChar(string) {
return(string.charAt(string.length - 1));
}
static function getCharValue(char) {
var _local1 = char.toUpperCase().charCodeAt(0);
if ((_local1 > 47) && (_local1 < 58)) {
return(_local1 - 48);
}
if ((_local1 > 64) && (_local1 < 91)) {
return(_local1 - 55);
}
return(0);
}
static function escape(string, keyMap, ignoreUnicode) {
if (!keyMap) {
keyMap = DEFAULT_ESCAPE_MAP;
}
var _local1 = 0;
var _local3 = keyMap.length;
while (_local1 < _local3) {
string = string.split(keyMap[_local1]).join(keyMap[_local1 + 1]);
_local1 = _local1 + 2;
}
if (!ignoreUnicode) {
_local1 = 0;
_local3 = string.length;
while (_local1 < _local3) {
if (string.substring(_local1, _local1 + 2) == "\\u") {
string = (string.substring(0, _local1) + String.fromCharCode(parseInt(string.substring(_local1 + 2, _local1 + 6), 16))) + string.substring(_local1 + 6);
}
_local1++;
}
}
return(string);
}
static var DEFAULT_ESCAPE_MAP = ["\\t", "\t", "\\n", newline, "\\r", "\r", "\\\"", "\"", "\\\\", "\\", "\\'", "'", "\\f", "\f", "\\b", "\b", "\\", ""];
}
Symbol 233 MovieClip [__Packages.org.as2lib.env.except.StackTraceElement] Frame 0
class org.as2lib.env.except.StackTraceElement extends org.as2lib.core.BasicClass
{
static var stringifier;
var thrower, method, args;
function StackTraceElement (thrower, method, args) {
super();
this.thrower = (thrower ? (thrower) : null);
this.method = (method ? (method) : null);
this.args = (args ? (args.concat()) : null);
}
static function getStringifier(Void) {
if (!stringifier) {
stringifier = new org.as2lib.env.except.StackTraceElementStringifier();
}
return(stringifier);
}
static function setStringifier(stackTraceElementStringifier) {
stringifier = stackTraceElementStringifier;
}
function getThrower(Void) {
return(thrower);
}
function getMethod(Void) {
return(method);
}
function getArguments(Void) {
return(args.concat());
}
function toString() {
return(getStringifier().execute(this));
}
}
Symbol 234 MovieClip [__Packages.org.as2lib.env.except.StackTraceElementStringifier] Frame 0
class org.as2lib.env.except.StackTraceElementStringifier extends org.as2lib.core.BasicClass implements org.as2lib.util.Stringifier
{
var showArgumentsValues;
function StackTraceElementStringifier (showArgumentsValues) {
super();
this.showArgumentsValues = showArgumentsValues;
}
function execute(target) {
var _local7 = target;
var _local4;
try {
var _local6 = org.as2lib.env.reflect.ReflectUtil.getTypeAndMethodInfo(_local7.getThrower(), _local7.getMethod());
_local4 = ((_local6[0] == null) ? (UNKNOWN + " ") : ((_local6[0] ? "static " : "")));
_local4 = _local4 + ((_local6[1] == null) ? (UNKNOWN) : (_local6[1]));
_local4 = _local4 + ("." + ((_local6[2] == null) ? (UNKNOWN) : (_local6[2])));
_local4 = _local4 + "(";
if (showArgumentsValues) {
_local4 = _local4 + (_local7.getArguments().toString() ? (_local7.getArguments().toString()) : (UNKNOWN));
} else {
var _local5 = _local7.getArguments();
var _local2 = 0;
while (_local2 < _local5.length) {
var _local3 = org.as2lib.env.reflect.ReflectUtil.getTypeName(_local5[_local2]);
if (_local3 == null) {
_local3 = UNKNOWN;
}
_local4 = _local4 + _local3;
if (_local2 < (_local5.length - 1)) {
_local4 = _local4 + ", ";
}
_local2++;
}
}
_local4 = _local4 + ")";
} catch(e) {
_local4 = "Exception was thrown during generation of string representation of stack trace element: \n" + org.as2lib.util.StringUtil.addSpaceIndent(e.toString(), 2);
}
return(_local4);
}
static var UNKNOWN = "[unknown]";
}
Symbol 235 MovieClip [__Packages.org.as2lib.env.log.LogManager] Frame 0
class org.as2lib.env.log.LogManager extends org.as2lib.core.BasicClass
{
static var repository, loggerProxies;
function LogManager (Void) {
super();
}
static function getLogger() {
if (arguments[0].__proto__ != String.prototype) {
return(getLoggerByObject(arguments[0]));
}
return(getLoggerByName(arguments[0]));
}
static function getLoggerByObject(object) {
return(getLoggerByName(org.as2lib.env.reflect.ReflectUtil.getTypeName(object)));
}
static function getLoggerByName(loggerName) {
if (!repository) {
if (loggerProxies[loggerName]) {
return(loggerProxies[loggerName]);
}
if (!loggerProxies) {
loggerProxies = new Array();
}
var _local2 = getBlankLogger();
_local2.__resolve = function () {
return(false);
};
_local2.name = loggerName;
loggerProxies.push(_local2);
loggerProxies[loggerName] = _local2;
return(_local2);
}
var _local2 = repository.getLogger(loggerName);
if (_local2) {
return(_local2);
}
return(null);
}
static function getBlankLogger(Void) {
var _local1 = new Object();
_local1.__proto__ = org.as2lib.env.log.Logger.prototype;
_local1.__constructor__ = org.as2lib.env.log.Logger;
return(_local1);
}
static function setLogger(logger) {
repository = getBlankLoggerRepository();
repository.getLogger = function (loggerName) {
return(logger);
};
}
static function getBlankLoggerRepository(Void) {
var _local1 = new Object();
_local1.__proto__ = org.as2lib.env.log.LoggerRepository.prototype;
_local1.__constructor__ = org.as2lib.env.log.LoggerRepository;
return(_local1);
}
static function getLoggerRepository(Void) {
return(repository);
}
static function setLoggerRepository(loggerRepository) {
repository = loggerRepository;
if (loggerProxies) {
var _local2 = loggerProxies.length - 1;
while (_local2 >= 0) {
var _local1 = loggerProxies[_local2];
var _local3 = _local1.name;
delete _local1.__constructor__;
delete _local1.__resolve;
delete _local1.name;
loggerProxies.pop();
delete loggerProxies[_local3];
var _local4 = loggerRepository.getLogger(_local3);
_local1.__proto__ = _local4;
_local2--;
}
}
}
static function hasLoggerRepository(Void) {
return(repository != null);
}
}
Symbol 236 MovieClip [__Packages.org.as2lib.env.log.LoggerRepository] Frame 0
interface org.as2lib.env.log.LoggerRepository extends org.as2lib.core.BasicInterface
{
}
Symbol 237 MovieClip [__Packages.org.as2lib.env.except.IllegalStateException] Frame 0
class org.as2lib.env.except.IllegalStateException extends org.as2lib.env.except.FatalException
{
var __proto__, message, stackTrace, addStackTraceElement;
function IllegalStateException (message, thrower, args) {
super();
__proto__.__proto__ = org.as2lib.env.except.FatalException.prototype;
this.message = message;
stackTrace = new Array();
addStackTraceElement(thrower, args.callee, args);
}
}
Symbol 238 MovieClip [__Packages.org.as2lib.env.except.FatalException] Frame 0
class org.as2lib.env.except.FatalException extends org.as2lib.env.except.AbstractThrowable implements org.as2lib.env.except.Throwable
{
var doToString;
function FatalException (message, thrower, args) {
super(message, thrower, args);
}
function toString() {
if (!arguments.caller) {
if (org.as2lib.env.except.AbstractThrowable.getLogger().isFatalEnabled()) {
org.as2lib.env.except.AbstractThrowable.getLogger().fatal(this);
}
}
return(doToString());
}
}
Symbol 239 MovieClip [__Packages.org.as2lib.env.except.IllegalArgumentException] Frame 0
class org.as2lib.env.except.IllegalArgumentException extends org.as2lib.env.except.FatalException
{
function IllegalArgumentException (message, thrower, args) {
super(message, thrower, args);
}
}
Symbol 240 MovieClip [__Packages.org.as2lib.env.except.Exception] Frame 0
class org.as2lib.env.except.Exception extends org.as2lib.env.except.AbstractThrowable implements org.as2lib.env.except.Throwable
{
var doToString;
function Exception (message, thrower, args) {
super(message, thrower, args);
}
function toString() {
if (!arguments.caller) {
if (org.as2lib.env.except.AbstractThrowable.getLogger().isErrorEnabled()) {
org.as2lib.env.except.AbstractThrowable.getLogger().error(this);
}
}
return(doToString());
}
}
Symbol 241 MovieClip [__Packages.org.as2lib.data.holder.DataHolderException] Frame 0
class org.as2lib.data.holder.DataHolderException extends org.as2lib.env.except.Exception
{
function DataHolderException (message, thrower, args) {
super(message, thrower, args);
}
}
Symbol 242 MovieClip [__Packages.org.as2lib.data.holder.NoSuchElementException] Frame 0
class org.as2lib.data.holder.NoSuchElementException extends org.as2lib.data.holder.DataHolderException
{
function NoSuchElementException (message, thrower, args) {
super(message, thrower, args);
}
}
Symbol 243 MovieClip [__Packages.com.midasplayer.chesster.BoardObject] Frame 0
class com.midasplayer.chesster.BoardObject extends MovieClip
{
var m_boardX, m_boardY, m_interpolationStart, m_interpolationFromBoardX, m_interpolationFromBoardY, _x, _y, m_parentBoard, _rotation;
function BoardObject () {
super();
m_boardX = 1;
m_boardY = 1;
setScreenPos();
}
function setBoardPos(boardX, boardY, interpolation) {
if ((interpolation == true) && ((boardX != m_boardX) || (boardY != m_boardY))) {
startInterpolation();
}
m_boardX = boardX;
m_boardY = boardY;
setScreenPos();
}
function getBoardX() {
return(m_boardX);
}
function getBoardY() {
return(m_boardY);
}
function startInterpolation() {
m_interpolationStart = getTimer();
m_interpolationFromBoardX = m_boardX;
m_interpolationFromBoardY = m_boardY;
}
function isInterpolating() {
return(m_interpolating);
}
function setScreenPos() {
var _local2 = 1;
m_interpolating = false;
if ((m_interpolationStart != 0) && (m_interpolationTime > 0)) {
_local2 = Math.min(1, (getTimer() - m_interpolationStart) / m_interpolationTime);
}
m_interpolating = _local2 != 1;
if (m_interpolating) {
var _local6 = getScreenX(m_boardX);
var _local5 = getScreenY(m_boardY);
var _local4 = getScreenX(m_interpolationFromBoardX);
var _local3 = getScreenY(m_interpolationFromBoardY);
_local2 = Math.sin((_local2 * Math.PI) / 2);
_x = _local4 + ((_local6 - _local4) * _local2);
_y = _local3 + ((_local5 - _local3) * _local2);
} else {
_x = getScreenX(m_boardX);
_y = getScreenY(m_boardY);
m_interpolationStart = 0;
}
if (m_parentBoard.getInverted()) {
_rotation = 180;
}
}
static function getScreenX(boardX) {
var _local1 = (((-com.midasplayer.chesster.ChessBoard.SQUARE_SIZE) * com.midasplayer.chesster.ChessBoard.WIDTH) / 2) + ((boardX - 1) * com.midasplayer.chesster.ChessBoard.SQUARE_SIZE);
_local1 = _local1 + (com.midasplayer.chesster.ChessBoard.SQUARE_SIZE / 2);
return(_local1);
}
static function getScreenY(boardY) {
var _local1 = (((-com.midasplayer.chesster.ChessBoard.SQUARE_SIZE) * com.midasplayer.chesster.ChessBoard.HEIGHT) / 2) + ((com.midasplayer.chesster.ChessBoard.HEIGHT - boardY) * com.midasplayer.chesster.ChessBoard.SQUARE_SIZE);
_local1 = _local1 + (com.midasplayer.chesster.ChessBoard.SQUARE_SIZE / 2);
return(_local1);
}
var m_interpolationTime = 0;
var m_interpolating = false;
}
Symbol 244 MovieClip [__Packages.com.midasplayer.chesster.Piece] Frame 0
class com.midasplayer.chesster.Piece extends com.midasplayer.chesster.BoardObject
{
var m_boardX, m_boardY, m_hasMoved, m_alive, m_interpolationTime, m_parentBoard, m_side, gotoAndStop, m_dir, m_moveable, setScreenPos, createEmptyMovieClip, getNextHighestDepth, hitArea, m_deathEffectFactor, m_deathEffectStart, m_childMove, useHandCursor, _alpha, isInterpolating, m_shadow, _name, _x, _y, _rotation, _xscale, _yscale;
function Piece () {
super();
m_boardX = 1;
m_boardY = 1;
m_hasMoved = false;
m_alive = ALIVE;
m_interpolationTime = 500;
}
function setHasMoved(moved) {
m_hasMoved = moved;
}
function hasMoved() {
return(m_hasMoved);
}
function setup(parentBoard, x, y, side) {
m_parentBoard = parentBoard;
m_boardX = x;
m_boardY = y;
m_side = side;
gotoAndStop(m_side + 1);
m_dir = ((side == com.midasplayer.chesster.ChessBoard.WHITE) ? 1 : -1);
m_moveable = true;
makeHitBox();
setScreenPos();
}
function makeHitBox() {
var _local2 = createEmptyMovieClip("hitBox", getNextHighestDepth());
var _local4 = com.midasplayer.chesster.ChessBoard.SQUARE_SIZE;
var _local3 = com.midasplayer.chesster.ChessBoard.SQUARE_SIZE;
_local2.beginFill(16711680, 0);
_local2.moveTo((-_local4) / 2, (-_local3) / 2);
_local2.lineTo((-_local4) / 2, _local3 / 2);
_local2.lineTo(_local4 / 2, _local3 / 2);
_local2.lineTo(_local4 / 2, (-_local3) / 2);
_local2.lineTo((-_local4) / 2, (-_local3) / 2);
_local2.endFill();
hitArea = _local2;
}
function getDeathEffectFactor() {
return(m_deathEffectFactor);
}
function setAlive(alive) {
if (alive) {
m_alive = ALIVE;
} else if (!alive) {
m_alive = PENDING_DEATH;
m_deathEffectStart = getTimer();
}
m_childMove = undefined;
setScreenPos();
}
function getAlive() {
return(m_alive == ALIVE);
}
function isPendingDeath() {
return(m_alive == PENDING_DEATH);
}
function isDead() {
return(m_alive == DEAD);
}
function kill() {
m_alive = DEAD;
removeShadow();
}
function setMoveable(moveable) {
m_moveable = moveable && (getAlive());
updateHandCursor();
}
function setChildMove(moveObj) {
m_childMove = moveObj;
updateHandCursor();
}
function updateHandCursor() {
useHandCursor = getAlive() && (m_moveable || (m_childMove != undefined));
}
function calcInterpolationTime(moveObj) {
var _local3 = 200;
if (moveObj.getType() == com.midasplayer.chesster.MoveData.ROCKARD) {
m_interpolationTime = _local3 * 3;
} else {
var _local4 = Math.abs(moveObj.getToX() - moveObj.getFromX()) + Math.abs(moveObj.getToY() - moveObj.getFromY());
m_interpolationTime = _local4 * _local3;
}
m_interpolationTime = Math.max(m_interpolationTime, MIN_MOVE_TIME);
}
function onPress() {
if (!getAlive()) {
return(undefined);
}
if (m_childMove) {
m_childMove.onPress();
} else if (m_moveable) {
m_parentBoard.setActivePiece(this);
m_parentBoard.spawnActiveMoves();
}
}
function onEnterFrame() {
if (isPendingDeath() || (!getAlive())) {
if (m_deathEffectFactor <= 2) {
m_deathEffectFactor = (getTimer() - m_deathEffectStart) / DEATH_EFFECT_DURATION;
}
if (m_deathEffectFactor <= 2) {
_alpha = (Math.cos(m_deathEffectFactor * Math.PI) * 50) + 50;
} else {
_alpha = 100;
}
return(undefined);
}
super.setScreenPos();
if ((m_parentBoard.getActivePiece() == this) || (isInterpolating())) {
var _local4 = m_parentBoard.getShadowLayer();
if (m_shadow == undefined) {
m_shadow = _local4.attachMovie(m_shadowSymbol, _name + "_shadow", _local4.getNextHighestDepth());
var _local5 = new Color(m_shadow);
var _local3 = _local5.getTransform();
_local3.ra = -100;
_local3.ga = -100;
_local3.ba = -100;
_local3.aa = 40;
_local5.setTransform(_local3);
}
m_shadow._x = _x + (10 * (m_parentBoard.getInverted() ? -1 : 1));
m_shadow._y = _y + (8 * (m_parentBoard.getInverted() ? -1 : 1));
m_shadow._rotation = _rotation;
_xscale = 115;
_yscale = 115;
} else {
if (m_shadow != undefined) {
removeShadow();
}
_xscale = 100;
_yscale = 100;
}
}
function removeShadow() {
m_shadow.removeMovieClip();
m_shadow = undefined;
}
function removeMovieClip() {
removeShadow();
super.removeMovieClip();
}
function getValidMoveData() {
var _local2 = new org.as2lib.data.holder.array.TypedArray(com.midasplayer.chesster.MoveData);
_local2.push(new com.midasplayer.chesster.MoveData(m_boardX, m_boardY + (1 * m_dir), this));
_local2.push(new com.midasplayer.chesster.MoveData(m_boardX, m_boardY + (2 * m_dir), this));
return(_local2);
}
function movePossible(x, y) {
return(true);
}
function getSide() {
return(m_side);
}
function getType() {
return(SymbolName);
}
function getRockardKingX() {
return((com.midasplayer.chesster.ChessBoard.WIDTH + 1) / 2);
}
function getRockardKingY() {
return(((m_side == com.midasplayer.chesster.ChessBoard.WHITE) ? 1 : (com.midasplayer.chesster.ChessBoard.HEIGHT)));
}
function getRockardRookX() {
return(1);
}
function getRockardRookY() {
return(getRockardKingY());
}
function getRockardKing() {
var _local2 = m_parentBoard.getPieceAtSquare(getRockardKingX(), getRockardKingY());
return(_local2);
}
function getRockardRook() {
var _local2 = m_parentBoard.getPieceAtSquare(getRockardRookX(), getRockardRookY());
return(_local2);
}
function isRockardValid() {
var _local3 = getRockardRookX();
var _local6 = getRockardRookY();
var _local4 = getRockardKingX();
var _local7 = getRockardKingY();
if (((getRockardKing() instanceof com.midasplayer.chesster.King) && (getRockardRook() instanceof com.midasplayer.chesster.Rook)) && (m_parentBoard.getGameStatus() != com.midasplayer.chesster.ChessBoard.GAMESTATUS_CHECK)) {
if (getRockardKing().hasMoved() || (getRockardRook().hasMoved())) {
return(false);
}
var _local5 = true;
var _local2 = Math.min(_local3, _local4) + 1;
while (_local2 < Math.max(_local3, _local4)) {
if (!m_parentBoard.isSquareVacant(_local2, _local6)) {
_local5 = false;
}
_local2++;
}
if (_local5) {
return(true);
}
}
return(false);
}
static var SymbolName = "undefined";
static var ALIVE = 0;
static var DEAD = 1;
static var PENDING_DEATH = 2;
static var DEATH_EFFECT_DURATION = 400;
static var MIN_MOVE_TIME = 400;
var m_shadowSymbol = "undefined";
}
Symbol 245 MovieClip [__Packages.com.midasplayer.chesster.Move] Frame 0
class com.midasplayer.chesster.Move extends com.midasplayer.chesster.BoardObject
{
var m_parentBoard, m_moveable, m_useEffect, m_effectCounter, m_moveData, setBoardPos, setScreenPos, gotoAndStop, _alpha, _rotation, useHandCursor, getBoardY, getBoardX;
function Move () {
super();
m_parentBoard = null;
m_moveable = true;
m_useEffect = false;
m_effectCounter = 0;
}
function init(board, moveData) {
if ((board == undefined) || (moveData == undefined)) {
throw new Error("Move::init() called with bad parameters");
}
m_parentBoard = board;
m_moveData = moveData;
setBoardPos(getToX(), getToY());
setScreenPos();
var _local2 = (getToX() + getToY()) % 2;
if (_local2 == 1) {
gotoAndStop(1);
} else if (_local2 == 0) {
gotoAndStop(2);
}
}
function getMoveData() {
return(m_moveData);
}
function getToX() {
return(m_moveData.getToX());
}
function getToY() {
return(m_moveData.getToY());
}
function setToX(x) {
m_moveData.setToX(x);
}
function setToY(y) {
m_moveData.setToY(y);
}
function getFromX() {
return(m_moveData.getFromX());
}
function getFromY() {
return(m_moveData.getFromY());
}
function getType() {
return(m_moveData.getMoveType());
}
function makeMove(dummy) {
var _local2 = m_parentBoard.getActivePiece();
if (!_local2) {
return(false);
}
if (!dummy) {
_local2.calcInterpolationTime(this);
_local2.setHasMoved(true);
}
_local2.setBoardPos(getToX(), getToY(), !dummy);
return(true);
}
function undoMove() {
var _local2 = m_parentBoard.getActivePiece();
if (!_local2) {
return(false);
}
_local2.setBoardPos(getFromX(), getFromY(), false);
return(true);
}
function onEnterFrame() {
setScreenPos();
if (m_useEffect) {
m_effectCounter = m_effectCounter + 0.025;
m_effectCounter = m_effectCounter - Math.floor(m_effectCounter);
_alpha = 40 + (Math.sin((m_effectCounter * Math.PI) * 2) * 15);
_rotation = m_effectCounter * 360;
}
}
function setMoveable(moveable) {
m_moveable = (useHandCursor = moveable);
}
function onPress() {
if ((m_parentBoard != undefined) && (m_moveable)) {
onActivate();
}
}
function onActivate() {
m_parentBoard.makeMove(this, false, true);
}
function toString() {
return(((((xToString(getFromX()) + getFromY()) + " - ") + xToString(getBoardX())) + getBoardY()) + newline);
}
function xToString(x) {
switch (x) {
case 1 :
return("A");
case 2 :
return("B");
case 3 :
return("C");
case 4 :
return("D");
case 5 :
return("E");
case 6 :
return("F");
case 7 :
return("G");
}
return(undefined);
}
static var SymbolName = "Move";
}
Symbol 246 MovieClip [__Packages.com.midasplayer.chesster.MoveData] Frame 0
class com.midasplayer.chesster.MoveData
{
var m_moveType, m_piece, m_toX, m_toY, m_fromX, m_fromY, m_data;
function MoveData (toX, toY, piece, moveType, moveData) {
if (((toX == undefined) || (toY == undefined)) || (piece == undefined)) {
throw new Error("MoveData::MoveData() called with bad parameters");
}
m_moveType = ((moveType == undefined) ? (NORMAL) : (moveType));
m_piece = piece;
m_toX = toX;
m_toY = toY;
m_fromX = piece.getBoardX();
m_fromY = piece.getBoardY();
m_data = moveData;
}
function isEqual(moveData) {
if (moveData.m_piece != m_piece) {
return(false);
}
if (moveData.m_fromX != m_fromX) {
return(false);
}
if (moveData.m_fromY != m_fromY) {
return(false);
}
if (moveData.m_toX != m_toX) {
return(false);
}
if (moveData.m_toY != m_toY) {
return(false);
}
if (moveData.m_moveType != m_moveType) {
return(false);
}
return(true);
}
function toString() {
var _local2 = "";
_local2 = _local2 + String(m_fromX);
_local2 = _local2 + " ";
_local2 = _local2 + String(m_fromY);
_local2 = _local2 + " ";
_local2 = _local2 + String(m_toX);
_local2 = _local2 + " ";
_local2 = _local2 + String(m_toY);
_local2 = _local2 + " ";
_local2 = _local2 + String(m_moveType);
return(_local2);
}
function getToX() {
return(m_toX);
}
function getToY() {
return(m_toY);
}
function setToX(x) {
m_toX = x;
}
function setToY(y) {
m_toY = y;
}
function getFromX() {
return(m_fromX);
}
function getFromY() {
return(m_fromY);
}
function getMoveType() {
return(m_moveType);
}
static var NORMAL = 1;
static var ROCKARD = 2;
}
Symbol 247 MovieClip [__Packages.com.midasplayer.chesster.King] Frame 0
class com.midasplayer.chesster.King extends com.midasplayer.chesster.Piece
{
var m_shadowSymbol, m_boardX, m_dir, m_boardY, m_parentBoard, m_side, isRockardValid, getRockardRook;
function King () {
super();
m_shadowSymbol = "KingShadow";
}
function movePossible(x, y) {
var _local3 = x - m_boardX;
var _local2 = (y - m_boardY) * m_dir;
if ((Math.abs(_local3) <= 1) && (Math.abs(_local2) <= 1)) {
return(true);
}
}
function getValidMoveData() {
var _local4 = new org.as2lib.data.holder.array.TypedArray(com.midasplayer.chesster.MoveData);
var _local3;
var _local2;
var _local8;
_local3 = m_boardX - 1;
_local2 = m_boardY + 1;
if (m_parentBoard.isSquareMoveable(_local3, _local2, m_side)) {
_local4.push(new com.midasplayer.chesster.MoveData(_local3, _local2, this));
}
_local3 = m_boardX + 0;
_local2 = m_boardY + 1;
if (m_parentBoard.isSquareMoveable(_local3, _local2, m_side)) {
_local4.push(new com.midasplayer.chesster.MoveData(_local3, _local2, this));
}
_local3 = m_boardX + 1;
_local2 = m_boardY + 1;
if (m_parentBoard.isSquareMoveable(_local3, _local2, m_side)) {
_local4.push(new com.midasplayer.chesster.MoveData(_local3, _local2, this));
}
_local3 = m_boardX + 1;
_local2 = m_boardY + 0;
if (m_parentBoard.isSquareMoveable(_local3, _local2, m_side)) {
_local4.push(new com.midasplayer.chesster.MoveData(_local3, _local2, this));
}
_local3 = m_boardX + 1;
_local2 = m_boardY - 1;
if (m_parentBoard.isSquareMoveable(_local3, _local2, m_side)) {
_local4.push(new com.midasplayer.chesster.MoveData(_local3, _local2, this));
}
_local3 = m_boardX + 0;
_local2 = m_boardY - 1;
if (m_parentBoard.isSquareMoveable(_local3, _local2, m_side)) {
_local4.push(new com.midasplayer.chesster.MoveData(_local3, _local2, this));
}
_local3 = m_boardX - 1;
_local2 = m_boardY - 1;
if (m_parentBoard.isSquareMoveable(_local3, _local2, m_side)) {
_local4.push(new com.midasplayer.chesster.MoveData(_local3, _local2, this));
}
_local3 = m_boardX - 1;
_local2 = m_boardY + 0;
if (m_parentBoard.isSquareMoveable(_local3, _local2, m_side)) {
_local4.push(new com.midasplayer.chesster.MoveData(_local3, _local2, this));
}
if (isRockardValid()) {
var _local5 = getRockardRook();
var _local7 = _local5.getBoardX();
var _local6 = _local5.getBoardY();
_local4.push(new com.midasplayer.chesster.MoveData(_local7, _local6, this, com.midasplayer.chesster.MoveData.ROCKARD));
}
return(_local4);
}
static var SymbolName = "King";
}
Symbol 248 MovieClip [__Packages.com.midasplayer.chesster.Rook] Frame 0
class com.midasplayer.chesster.Rook extends com.midasplayer.chesster.Piece
{
var m_shadowSymbol, m_boardX, m_dir, m_boardY, m_parentBoard, m_side, isRockardValid, getRockardKing;
function Rook () {
super();
m_shadowSymbol = "RookShadow";
}
function movePossible(x, y) {
var _local3 = x - m_boardX;
var _local2 = (y - m_boardY) * m_dir;
if ((_local3 == 0) || (_local2 == 0)) {
return(true);
}
}
function getValidMoveData() {
var _local4 = new org.as2lib.data.holder.array.TypedArray(com.midasplayer.chesster.MoveData);
var _local3;
var _local2;
var _local8;
_local3 = m_boardX + 0;
_local2 = m_boardY + 1;
while (m_parentBoard.isSquareMoveable(_local3, _local2, m_side)) {
_local4.push(new com.midasplayer.chesster.MoveData(_local3, _local2, this));
if (!m_parentBoard.isSquareVacant(_local3, _local2)) {
break;
}
_local2++;
}
_local3 = m_boardX + 0;
_local2 = m_boardY - 1;
while (m_parentBoard.isSquareMoveable(_local3, _local2, m_side)) {
_local4.push(new com.midasplayer.chesster.MoveData(_local3, _local2, this));
if (!m_parentBoard.isSquareVacant(_local3, _local2)) {
break;
}
_local2--;
}
_local3 = m_boardX + 1;
_local2 = m_boardY + 0;
while (m_parentBoard.isSquareMoveable(_local3, _local2, m_side)) {
_local4.push(new com.midasplayer.chesster.MoveData(_local3, _local2, this));
if (!m_parentBoard.isSquareVacant(_local3, _local2)) {
break;
}
_local3++;
}
_local3 = m_boardX - 1;
_local2 = m_boardY + 0;
while (m_parentBoard.isSquareMoveable(_local3, _local2, m_side)) {
_local4.push(new com.midasplayer.chesster.MoveData(_local3, _local2, this));
if (!m_parentBoard.isSquareVacant(_local3, _local2)) {
break;
}
_local3--;
}
if (isRockardValid()) {
var _local5 = getRockardKing();
var _local7 = _local5.getBoardX();
var _local6 = _local5.getBoardY();
_local4.push(new com.midasplayer.chesster.MoveData(_local7, _local6, this, com.midasplayer.chesster.MoveData.ROCKARD));
}
return(_local4);
}
static var SymbolName = "Rook";
}
Symbol 249 MovieClip [__Packages.com.midasplayer.chesster.Pawn] Frame 0
class com.midasplayer.chesster.Pawn extends com.midasplayer.chesster.Piece
{
var m_shadowSymbol, m_boardX, m_dir, m_boardY, m_parentBoard, m_side;
function Pawn () {
super();
m_shadowSymbol = "PawnShadow";
}
function movePossible(x, y) {
var _local3 = x - m_boardX;
var _local2 = (y - m_boardY) * m_dir;
if ((Math.abs(_local3) <= 1) && (_local2 == 1)) {
return(true);
}
if ((Math.abs(_local3) == 0) && (_local2 == 2)) {
return(true);
}
}
function getValidMoveData() {
var _local4 = new org.as2lib.data.holder.array.TypedArray(com.midasplayer.chesster.MoveData);
var _local3;
var _local2;
var _local5;
_local3 = m_boardX - 1;
_local2 = m_boardY + (1 * m_dir);
_local5 = m_parentBoard.getPieceAtSquare(_local3, _local2);
if (_local5 && (_local5.getSide() != m_side)) {
_local4.push(new com.midasplayer.chesster.MoveData(_local3, _local2, this));
}
_local3 = m_boardX + 1;
_local2 = m_boardY + (1 * m_dir);
_local5 = m_parentBoard.getPieceAtSquare(_local3, _local2);
if (_local5 && (_local5.getSide() != m_side)) {
_local4.push(new com.midasplayer.chesster.MoveData(_local3, _local2, this));
}
_local3 = m_boardX;
_local2 = m_boardY + (1 * m_dir);
if (m_parentBoard.isSquareVacant(_local3, _local2)) {
_local4.push(new com.midasplayer.chesster.MoveData(_local3, _local2, this));
_local3 = m_boardX;
_local2 = m_boardY + (2 * m_dir);
if (m_parentBoard.isSquareVacant(_local3, _local2) && (m_boardY == ((m_side == com.midasplayer.chesster.ChessBoard.WHITE) ? 2 : (com.midasplayer.chesster.ChessBoard.HEIGHT - 1)))) {
_local4.push(new com.midasplayer.chesster.MoveData(_local3, _local2, this));
}
}
return(_local4);
}
static var SymbolName = "Pawn";
}
Symbol 250 MovieClip [__Packages.com.midasplayer.chesster.Queen] Frame 0
class com.midasplayer.chesster.Queen extends com.midasplayer.chesster.Piece
{
var m_shadowSymbol, m_boardX, m_dir, m_boardY, m_parentBoard, m_side;
function Queen () {
super();
m_shadowSymbol = "QueenShadow";
}
function movePossible(x, y) {
var _local3 = x - m_boardX;
var _local2 = (y - m_boardY) * m_dir;
if ((_local3 == 0) || (_local2 == 0)) {
return(true);
}
if (Math.abs(_local3) == Math.abs(_local2)) {
return(true);
}
}
function getValidMoveData() {
var _local4 = new org.as2lib.data.holder.array.TypedArray(com.midasplayer.chesster.MoveData);
var _local3;
var _local2;
var _local5;
_local3 = m_boardX + 1;
_local2 = m_boardY + 1;
while (m_parentBoard.isSquareMoveable(_local3, _local2, m_side)) {
_local4.push(new com.midasplayer.chesster.MoveData(_local3, _local2, this));
if (!m_parentBoard.isSquareVacant(_local3, _local2)) {
break;
}
_local3++;
_local2++;
}
_local3 = m_boardX - 1;
_local2 = m_boardY - 1;
while (m_parentBoard.isSquareMoveable(_local3, _local2, m_side)) {
_local4.push(new com.midasplayer.chesster.MoveData(_local3, _local2, this));
if (!m_parentBoard.isSquareVacant(_local3, _local2)) {
break;
}
_local3--;
_local2--;
}
_local3 = m_boardX + 1;
_local2 = m_boardY - 1;
while (m_parentBoard.isSquareMoveable(_local3, _local2, m_side)) {
_local4.push(new com.midasplayer.chesster.MoveData(_local3, _local2, this));
if (!m_parentBoard.isSquareVacant(_local3, _local2)) {
break;
}
_local3++;
_local2--;
}
_local3 = m_boardX - 1;
_local2 = m_boardY + 1;
while (m_parentBoard.isSquareMoveable(_local3, _local2, m_side)) {
_local4.push(new com.midasplayer.chesster.MoveData(_local3, _local2, this));
if (!m_parentBoard.isSquareVacant(_local3, _local2)) {
break;
}
_local3--;
_local2++;
}
_local3 = m_boardX + 0;
_local2 = m_boardY + 1;
while (m_parentBoard.isSquareMoveable(_local3, _local2, m_side)) {
_local4.push(new com.midasplayer.chesster.MoveData(_local3, _local2, this));
if (!m_parentBoard.isSquareVacant(_local3, _local2)) {
break;
}
_local2++;
}
_local3 = m_boardX + 0;
_local2 = m_boardY - 1;
while (m_parentBoard.isSquareMoveable(_local3, _local2, m_side)) {
_local4.push(new com.midasplayer.chesster.MoveData(_local3, _local2, this));
if (!m_parentBoard.isSquareVacant(_local3, _local2)) {
break;
}
_local2--;
}
_local3 = m_boardX + 1;
_local2 = m_boardY + 0;
while (m_parentBoard.isSquareMoveable(_local3, _local2, m_side)) {
_local4.push(new com.midasplayer.chesster.MoveData(_local3, _local2, this));
if (!m_parentBoard.isSquareVacant(_local3, _local2)) {
break;
}
_local3++;
}
_local3 = m_boardX - 1;
_local2 = m_boardY + 0;
while (m_parentBoard.isSquareMoveable(_local3, _local2, m_side)) {
_local4.push(new com.midasplayer.chesster.MoveData(_local3, _local2, this));
if (!m_parentBoard.isSquareVacant(_local3, _local2)) {
break;
}
_local3--;
}
return(_local4);
}
static var SymbolName = "Queen";
}
Symbol 251 MovieClip [__Packages.com.midasplayer.chesster.Bishop] Frame 0
class com.midasplayer.chesster.Bishop extends com.midasplayer.chesster.Piece
{
var m_shadowSymbol, m_boardX, m_dir, m_boardY, m_parentBoard, m_side;
function Bishop () {
super();
m_shadowSymbol = "BishopShadow";
}
function movePossible(x, y) {
var _local3 = x - m_boardX;
var _local2 = (y - m_boardY) * m_dir;
if (Math.abs(_local3) == Math.abs(_local2)) {
return(true);
}
}
function getValidMoveData() {
var _local4 = new org.as2lib.data.holder.array.TypedArray(com.midasplayer.chesster.MoveData);
var _local3;
var _local2;
var _local5;
_local3 = m_boardX + 1;
_local2 = m_boardY + 1;
while (m_parentBoard.isSquareMoveable(_local3, _local2, m_side)) {
_local4.push(new com.midasplayer.chesster.MoveData(_local3, _local2, this));
if (!m_parentBoard.isSquareVacant(_local3, _local2)) {
break;
}
_local3++;
_local2++;
}
_local3 = m_boardX - 1;
_local2 = m_boardY - 1;
while (m_parentBoard.isSquareMoveable(_local3, _local2, m_side)) {
_local4.push(new com.midasplayer.chesster.MoveData(_local3, _local2, this));
if (!m_parentBoard.isSquareVacant(_local3, _local2)) {
break;
}
_local3--;
_local2--;
}
_local3 = m_boardX + 1;
_local2 = m_boardY - 1;
while (m_parentBoard.isSquareMoveable(_local3, _local2, m_side)) {
_local4.push(new com.midasplayer.chesster.MoveData(_local3, _local2, this));
if (!m_parentBoard.isSquareVacant(_local3, _local2)) {
break;
}
_local3++;
_local2--;
}
_local3 = m_boardX - 1;
_local2 = m_boardY + 1;
while (m_parentBoard.isSquareMoveable(_local3, _local2, m_side)) {
_local4.push(new com.midasplayer.chesster.MoveData(_local3, _local2, this));
if (!m_parentBoard.isSquareVacant(_local3, _local2)) {
break;
}
_local3--;
_local2++;
}
return(_local4);
}
static var SymbolName = "Bishop";
}
Symbol 252 MovieClip [__Packages.com.midasplayer.chesster.Knight] Frame 0
class com.midasplayer.chesster.Knight extends com.midasplayer.chesster.Piece
{
var m_shadowSymbol, m_boardX, m_dir, m_boardY, m_parentBoard, m_side;
function Knight () {
super();
m_shadowSymbol = "KnightShadow";
}
function movePossible(x, y) {
var _local3 = x - m_boardX;
var _local2 = (y - m_boardY) * m_dir;
if ((Math.abs(_local3) == 2) && (Math.abs(_local2) == 1)) {
return(true);
}
if ((Math.abs(_local3) == 1) && (Math.abs(_local2) == 2)) {
return(true);
}
}
function getValidMoveData() {
var _local4 = new org.as2lib.data.holder.array.TypedArray(com.midasplayer.chesster.MoveData);
var _local3;
var _local2;
var _local5;
_local3 = m_boardX - 2;
_local2 = m_boardY + 1;
if (m_parentBoard.isSquareMoveable(_local3, _local2, m_side)) {
_local4.push(new com.midasplayer.chesster.MoveData(_local3, _local2, this));
}
_local3 = m_boardX + 2;
_local2 = m_boardY + 1;
if (m_parentBoard.isSquareMoveable(_local3, _local2, m_side)) {
_local4.push(new com.midasplayer.chesster.MoveData(_local3, _local2, this));
}
_local3 = m_boardX - 2;
_local2 = m_boardY - 1;
if (m_parentBoard.isSquareMoveable(_local3, _local2, m_side)) {
_local4.push(new com.midasplayer.chesster.MoveData(_local3, _local2, this));
}
_local3 = m_boardX + 2;
_local2 = m_boardY - 1;
if (m_parentBoard.isSquareMoveable(_local3, _local2, m_side)) {
_local4.push(new com.midasplayer.chesster.MoveData(_local3, _local2, this));
}
_local3 = m_boardX - 1;
_local2 = m_boardY + 2;
if (m_parentBoard.isSquareMoveable(_local3, _local2, m_side)) {
_local4.push(new com.midasplayer.chesster.MoveData(_local3, _local2, this));
}
_local3 = m_boardX + 1;
_local2 = m_boardY + 2;
if (m_parentBoard.isSquareMoveable(_local3, _local2, m_side)) {
_local4.push(new com.midasplayer.chesster.MoveData(_local3, _local2, this));
}
_local3 = m_boardX - 1;
_local2 = m_boardY - 2;
if (m_parentBoard.isSquareMoveable(_local3, _local2, m_side)) {
_local4.push(new com.midasplayer.chesster.MoveData(_local3, _local2, this));
}
_local3 = m_boardX + 1;
_local2 = m_boardY - 2;
if (m_parentBoard.isSquareMoveable(_local3, _local2, m_side)) {
_local4.push(new com.midasplayer.chesster.MoveData(_local3, _local2, this));
}
return(_local4);
}
static var SymbolName = "Knight";
}
Symbol 253 MovieClip [__Packages.com.midasplayer.util.Randomizer] Frame 0
class com.midasplayer.util.Randomizer
{
static var m_seedParam;
function Randomizer () {
}
static function getSeed() {
if (!SEEDED) {
seed(DEFAULT_SEED);
}
return(m_seedParam);
}
static function seed(ijkl) {
m_seedParam = ijkl;
CURRENT_SEED = Math.round(Math.abs(ijkl % BIG_PRIME));
ranmarin(CURRENT_SEED);
}
static function ranmarin(ijkl) {
var _local10;
var _local11;
var _local7;
var _local9;
var _local3;
var _local5;
var _local2;
var _local1;
var _local4;
var _local8;
var _local6;
_local10 = ijkl / 30082;
_local11 = ijkl - (30082 * _local10);
_local7 = ((_local10 / 177) % 177) + 2;
_local3 = (_local10 % 177) + 2;
_local2 = ((_local11 / 169) % 178) + 1;
_local1 = _local11 % 169;
_local9 = 0;
while (_local9 < 97) {
_local8 = 0;
_local6 = 0.5;
_local5 = 0;
while (_local5 < 24) {
_local4 = (((_local7 * _local3) % 179) * _local2) % 179;
_local7 = _local3;
_local3 = _local2;
_local2 = _local4;
_local1 = ((53 * _local1) + 1) % 169;
if (((_local1 * _local4) % 64) >= 32) {
_local8 = _local8 + _local6;
}
_local6 = _local6 * 0.5;
_local5++;
}
m_u[_local9] = _local8;
_local9++;
}
m_c = 0.0216028690338135;
m_cd = 0.456233084201813;
m_cm = 0.999999821186066;
m_i97 = 96;
m_j97 = 32;
SEEDED = true;
}
static function random() {
if (!SEEDED) {
seed(DEFAULT_SEED);
}
var _local1;
_local1 = m_u[m_i97] - m_u[m_j97];
if (_local1 < 0) {
_local1 = _local1 + 1;
}
m_u[m_i97] = _local1;
if ((--m_i97) < 0) {
m_i97 = 96;
}
if ((--m_j97) < 0) {
m_j97 = 96;
}
m_c = m_c - m_cd;
if (m_c < 0) {
m_c = m_c + m_cm;
}
_local1 = _local1 - m_c;
if (_local1 < 0) {
_local1 = _local1 + 1;
}
return(_local1);
}
static function randomRange(minValue, maxValue) {
return(Math.floor(random() * ((maxValue - minValue) + 1)) + minValue);
}
static function signedRandom() {
return((random() * 2) - 1);
}
static var m_u = new Array(97);
static var m_uvec = new Array(97);
static var m_c = 0;
static var m_cd = 0;
static var m_cm = 0;
static var m_i97 = 0;
static var m_j97 = 0;
static var DEFAULT_SEED = new Date().getTime();
static var CURRENT_SEED = 54217137;
static var SEEDED = false;
static var BIG_PRIME = 899999963;
}
Symbol 254 MovieClip [__Packages.com.midasplayer.util.Map] Frame 0
class com.midasplayer.util.Map
{
var map, lastSize;
function Map (init) {
map = new Object();
for (var _local3 in init) {
map["@" + _local3] = init[_local3];
}
lastSize = -1;
}
function put(key, value) {
map["@" + key] = value;
lastSize = -1;
}
function get(key) {
return(map["@" + key]);
}
function remove(key) {
var _local2 = map["@" + key];
delete map["@" + key];
lastSize = -1;
return(_local2);
}
function count() {
if (lastSize < 0) {
lastSize = 0;
for (var _local2 in map) {
lastSize++;
}
}
return(lastSize);
}
function size() {
return(count());
}
function clear() {
map = {};
lastSize = 0;
}
function dump() {
var _local2 = "";
for (var _local3 in map) {
_local2 = _local2 + (((_local3 + "=>") + map[_local3]) + newline);
}
}
function toArray() {
var _local2 = [];
for (var _local3 in map) {
_local2[_local2.length] = map[_local3];
}
return(_local2);
}
function keySet() {
var _local2 = [];
for (var _local3 in map) {
_local2[_local2.length] = _local3.substring(1);
}
return(_local2);
}
function foreach(fn) {
do {
if ((in map) == null) {
break;
}
var _local3 = in map;
} while (fn(_local3.substring(1), map[_local3]) != false);
do {
} while ("foreach" != null);
lastSize = -1;
}
}
Symbol 255 MovieClip [__Packages.com.midasplayer.fx.SoundManager] Frame 0
class com.midasplayer.fx.SoundManager
{
function SoundManager () {
}
static function parseGroup(group) {
return(((group == undefined) ? (DEFAULT_GROUP) : (group)));
}
static function addSoundGroup(group) {
var _local1 = soundEnabledMap.get(group);
if (_local1 == undefined) {
soundEnabledMap.put(group, {groupEnabled:isSoundEnabled(DEFAULT_GROUP)});
}
}
static function isSoundEnabled(group) {
group = parseGroup(group);
var _local1 = soundEnabledMap.get(group).groupEnabled;
if (_local1 == undefined) {
_local1 = true;
}
return(_local1);
}
static function enableSounds(enabled, group) {
group = parseGroup(group);
addSoundGroup(group);
var _local2 = (soundEnabledMap.get(group).groupEnabled = enabled);
if (!enabled) {
muteAll(group);
} else {
restoreMuteAll(group);
}
}
static function stopAll(group) {
sounds.foreach(function (name, soundEntry) {
soundEntry.sound.stop();
soundEntry.playStatus = false;
});
}
static function muteAll(group) {
group = parseGroup(group);
sounds.foreach(function (name, soundEntry) {
if (soundEntry.group == group) {
soundEntry.sound.setVolume(0);
}
});
}
static function restoreMuteAll(group) {
group = parseGroup(group);
sounds.foreach(function (name, soundEntry) {
if (soundEntry.group == group) {
soundEntry.sound.setVolume(soundEntry.realVol);
}
});
}
static function stop(resource) {
var _local1 = sounds.get(resource);
if (_local1 != undefined) {
_local1.sound.stop();
_local1.playStatus = false;
}
}
static function getCalibratedVolume(flashVolume) {
flashVolume = Math.min(100, flashVolume);
flashVolume = Math.max(0, flashVolume);
return(Math.ceil(Math.pow(flashVolume / 100, 1.46) * 100));
}
static function setVolume(resource, percent) {
var _local1 = sounds.get(resource);
if ((_local1 != undefined) && (_local1.playStatus == true)) {
var _local2 = getCalibratedVolume(percent);
_local1.sound.setVolume(_local2);
_local1.sound.volume = _local2;
}
}
static function isPlaying(resource) {
var _local1 = sounds.get(resource);
return((_local1 != undefined) && (_local1.playStatus == true));
}
static function play(resource, volume, isLoop, group) {
if (volume == undefined) {
volume = 100;
}
if (isLoop == undefined) {
isLoop = false;
}
volume = getCalibratedVolume(volume);
var _local1 = sounds.get(resource);
if (_local1 == undefined) {
_local1 = loadResource(resource, group);
}
if (_local1 != undefined) {
_local1.sound.setVolume((isSoundEnabled(_local1.group) ? (volume) : 0));
_local1.realVol = volume;
_local1.playStatus = true;
_local1.sound.start(0, (isLoop ? 32767 : 1));
}
}
static function loadResource(resource, group) {
group = parseGroup(group);
addSoundGroup(group);
var _local3 = _root.getNextHighestDepth();
var _local2 = new Sound(_root.createEmptyMovieClip("sm_sndhold_" + _local3, _local3));
_local2.attachSound(resource);
_local2.onSoundComplete = function () {
var _local1 = com.midasplayer.fx.SoundManager.sounds.get(resource);
_local1.playStatus = false;
};
sounds.put(resource, {realVol:100, sound:_local2, playStatus:true, group:group});
return(sounds.get(resource));
}
static var DEFAULT_GROUP = "default";
static var sounds = new com.midasplayer.util.Map();
static var soundEnabledMap = new com.midasplayer.util.Map();
}
Symbol 256 MovieClip [__Packages.com.midasplayer.chesster.Communicator] Frame 0
class com.midasplayer.chesster.Communicator
{
static var hostname_, port_, slotid_, magic_, m_game;
function Communicator () {
}
static function init(hostname, port, slotid, magic) {
hostname_ = hostname;
port_ = port;
slotid_ = slotid;
magic_ = magic;
socket_.onConnect = handleConnect;
socket_.onClose = handleClose;
socket_.onData = handleData;
}
static function setGame(game) {
m_game = game;
}
static function doConnect() {
socket_.connect(hostname_, port_);
}
static function handleConnect(success) {
if (!success) {
com.midasplayer.chesster.Game.debug((("Connection failed! Host: " + hostname_) + " Port: ") + port_);
onPlayerDisconnect();
} else {
sendClientConnect();
}
}
static function handleClose() {
onPlayerDisconnect();
com.midasplayer.chesster.Game.debug("close");
}
static function handleData(msg) {
var _local2 = new com.midasplayer.util.StringTokenizer(msg);
var _local5 = _local2.nextToken();
if (_local5 == "SCA") {
var _local6 = Number(_local2.nextToken());
var _local4 = _local2.nextToken();
_local4 = _local4.substring(1, _local4.length);
if (_local4.charAt(_local4.length - 1) != "\"") {
_local4 = _local4 + _local2.nextToken();
}
_local4 = _local4.substring(0, _local4.length - 1);
var _local7 = _local2.nextToken();
onClientAccepted(_local6, _local4, _local7);
} else if (_local5 == "SAC") {
var _local6 = Number(_local2.nextToken());
var _local4 = _local2.nextToken();
_local4 = _local4.substring(1, _local4.length);
if (_local4.charAt(_local4.length - 1) != "\"") {
_local4 = _local4 + _local2.nextToken();
}
_local4 = _local4.substring(0, _local4.length - 1);
var _local7 = _local2.nextToken();
onAnotherClientAccepted(_local6, _local4, _local7);
} else if (_local5 == "SCD") {
onOpponentDisconnect();
} else if (_local5 == "MCC") {
var _local3 = "";
var _local1 = _local2.nextToken();
while (_local1 != "") {
_local3 = _local3 + (_local1 + " ");
_local1 = _local2.nextToken();
if (_local1 != "") {
_local3 = _local3 + "";
}
}
m_game.recievedChatMsg(_local3);
} else if (_local5 == "GTO") {
m_game.gameTimeOut();
} else if (_local5 == "TTO") {
var _local9 = Number(_local2.nextToken());
m_game.turnTimeOut(_local9);
} else if (_local5 == "PMP") {
var _local12 = Number(_local2.nextToken());
var _local8 = Number(_local2.nextToken());
var _local9 = Number(_local2.nextToken());
m_game.makeMoveRemote(_local12, _local8, _local9);
} else if (_local5 == "PSP") {
var _local13 = Number(_local2.nextToken());
var _local14 = Number(_local2.nextToken());
} else if (_local5 == "PQT") {
var _local11 = Number(_local2.nextToken());
m_game.setOpponentQuizTime(_local11);
} else if (_local5 == "PAS") {
var _local10 = Number(_local2.nextToken());
m_game.opponentAssignSide(_local10);
}
}
static function onLeave() {
}
static function onEnter() {
}
static function sendGameOver() {
var _local1 = "PGO";
com.midasplayer.chesster.Game.debug("sending: " + _local1);
socket_.send(_local1);
_local1 = "CGO";
com.midasplayer.chesster.Game.debug("sending: " + _local1);
socket_.send(_local1);
}
static function sendClientConnect() {
var _local1 = ((("CCC " + slotid_) + " ") + magic_) + "";
com.midasplayer.chesster.Game.debug("sending: " + _local1);
socket_.send(_local1);
}
static function sendClientIsReady() {
var _local1 = "CIR";
com.midasplayer.chesster.Game.debug("sending: " + _local1);
socket_.send(_local1);
}
static function sendExitGame() {
var _local1 = "PXG";
com.midasplayer.chesster.Game.debug("sending: " + _local1);
socket_.send(_local1);
}
static function sendPing() {
var _local1 = "CTM";
socket_.send(_local1);
}
static function sendPlayerDisconnect() {
var _local1 = "SCD";
com.midasplayer.chesster.Game.debug("sending: " + _local1);
socket_.send(_local1);
}
static function sendSelectPiece(boardX, boardY) {
var _local1 = ((("PSP " + boardX) + " ") + boardY) + "";
socket_.send(_local1);
}
static function sendMovePiece(pieceIndex, moveIndex, gameTimeLeft) {
var _local1 = ((((("PMP " + pieceIndex) + " ") + moveIndex) + " ") + gameTimeLeft) + "";
socket_.send(_local1);
}
static function sendChatMsg(msg) {
msg = ("MCC " + msg) + "";
socket_.send(msg);
}
static function sendGameTimeout() {
var _local1 = "GTO";
socket_.send(_local1);
}
static function sendTurnTimeout(gameTimeLeft) {
var _local1 = ("TTO " + gameTimeLeft) + "";
socket_.send(_local1);
}
static function sendQuizTime(quizTime) {
var _local1 = ("PQT " + quizTime) + "";
socket_.send(_local1);
}
static function sendAssignSide(side) {
var _local1 = ("PAS " + side) + "";
socket_.send(_local1);
}
static function onClientAccepted(playerNum) {
com.midasplayer.chesster.Game.debug("onClientAccepted");
}
static function onAnotherClientAccepted() {
com.midasplayer.chesster.Game.debug("onAnotherClientAccepted");
}
static function onPlayerDisconnect() {
com.midasplayer.chesster.Game.debug("onPlayerDisconnect");
}
static function onOpponentDisconnect() {
com.midasplayer.chesster.Game.debug("onOpponentDisconnect");
}
static function onStartGame() {
com.midasplayer.chesster.Game.debug("onStartGame");
}
static var socket_ = new XMLSocket();
}
Symbol 257 MovieClip [__Packages.com.midasplayer.util.StringTokenizer] Frame 0
class com.midasplayer.util.StringTokenizer
{
var str_, index_, delim;
function StringTokenizer (str) {
str_ = str;
index_ = 0;
delim = " ";
}
function hasMoreTokens() {
var _local2 = str_.indexOf(delim, index_);
return(_local2 != -1);
}
function nextToken() {
var _local2 = str_.indexOf(delim, index_);
if (_local2 == -1) {
_local2 = str_.length;
}
var _local3 = str_.substring(index_, _local2);
index_ = _local2 + 1;
return(_local3);
}
}
Symbol 258 MovieClip [__Packages.com.midasplayer.chesster.RockardMove] Frame 0
class com.midasplayer.chesster.RockardMove extends com.midasplayer.chesster.Move
{
var setToX, setToY, m_parentBoard, m_boardY;
function RockardMove () {
super();
}
function init(board, moveData) {
super.init(board, moveData);
setToX(-1);
setToY(-1);
}
function makeMove(dummy) {
var _local3 = m_parentBoard.getPieceAtSquare(1, m_boardY);
var _local2 = m_parentBoard.getPieceAtSquare(3, m_boardY);
if (!dummy) {
_local3.calcInterpolationTime(this);
_local2.calcInterpolationTime(this);
}
_local3.setBoardPos(3, m_boardY, !dummy);
_local2.setBoardPos(2, m_boardY, !dummy);
return(true);
}
function undoMove() {
var _local3 = m_parentBoard.getPieceAtSquare(3, m_boardY);
var _local2 = m_parentBoard.getPieceAtSquare(2, m_boardY);
_local3.setBoardPos(1, m_boardY, false);
_local2.setBoardPos(3, m_boardY, false);
return(true);
}
static var SymbolName = "RockardMove";
}
Symbol 259 MovieClip [__Packages.com.midasplayer.chesster.Game] Frame 0
class com.midasplayer.chesster.Game
{
var m_scopeRef, m_gameOver, m_gda, m_localPlayer, m_opponentPlayer, m_shadowLayer, m_boardLayer, m_weedLayer, m_sideIndicatorBottomLayer, m_avatarLayer, m_sideIndicatorTopLayer, m_statusLayer, m_dynamicLayer, m_avatarBGLayer, m_avatarFGLayer, m_board, m_chatbox, m_kacktemp, m_createAvatarsID, m_playerAvatar, m_opponentAvatar, m_playerAvatarMask, m_opponentAvatarMask, m_playerAvatarFrame, m_opponentAvatarFrame, m_moveLog, m_killStack, m_clock, m_turnTimer, m_gameTimer, m_statusIndicator, m_sideIndicator, m_sideIndicatorTop, m_chatPopup, m_chatField, m_playerAvatarShadow, m_opponentAvatarShadow, m_playerAvatarBG, m_opponentAvatarBG, m_instructions, m_timeOuts, m_pingIntervalId, m_activeSide, m_gameOverArgument;
function Game (scope) {
m_scopeRef = scope;
m_gameOver = false;
m_gda = new com.midasplayer.util.GameDataAcquirer();
m_gda.beginWait(mx.utils.Delegate.create(this, init));
m_localPlayer = new com.midasplayer.chesster.Player();
m_opponentPlayer = new com.midasplayer.chesster.Player();
initSounds();
m_shadowLayer = m_scopeRef.createEmptyMovieClip("shadowLayer", m_scopeRef.getNextHighestDepth());
m_boardLayer = m_scopeRef.createEmptyMovieClip("boardAndPiecesLayer", m_scopeRef.getNextHighestDepth());
m_weedLayer = m_scopeRef.createEmptyMovieClip("weedLayer", m_scopeRef.getNextHighestDepth());
m_sideIndicatorBottomLayer = m_scopeRef.createEmptyMovieClip("sideIndicatorBottomLayer", m_scopeRef.getNextHighestDepth());
m_avatarLayer = m_scopeRef.createEmptyMovieClip("avatarLayer", m_scopeRef.getNextHighestDepth());
m_sideIndicatorTopLayer = m_scopeRef.createEmptyMovieClip("sideIndicatorTopLayer", m_scopeRef.getNextHighestDepth());
m_statusLayer = m_scopeRef.createEmptyMovieClip("statusLayer", m_scopeRef.getNextHighestDepth());
m_dynamicLayer = m_scopeRef.createEmptyMovieClip("statusLayer", m_scopeRef.getNextHighestDepth());
m_avatarBGLayer = m_avatarLayer.createEmptyMovieClip("avatarBGLayer", m_avatarLayer.getNextHighestDepth());
m_avatarFGLayer = m_avatarLayer.createEmptyMovieClip("avatarBGLayer", m_avatarLayer.getNextHighestDepth());
}
function getBoard() {
return(com.midasplayer.chesster.ChessBoard(m_board));
}
function getPlayer() {
return(m_localPlayer);
}
function getOpponent() {
return(m_opponentPlayer);
}
function getPlayerQuizTime() {
return(m_playerQuizTime);
}
function getOpponentQuizTime() {
return(m_opponentQuizTime);
}
function initSounds() {
com.midasplayer.fx.SoundManager.loadResource(SOUND_SHOW_INSTRUCTIONS, MUSIC_GROUP_NAME);
com.midasplayer.fx.SoundManager.loadResource(SOUND_BACKGROUND_LOOP, MUSIC_GROUP_NAME);
com.midasplayer.fx.SoundManager.loadResource(SOUND_GAME_LOSE, MUSIC_GROUP_NAME);
com.midasplayer.fx.SoundManager.loadResource(SOUND_GAME_WON, MUSIC_GROUP_NAME);
com.midasplayer.fx.SoundManager.loadResource(SOUND_PIECE_SELECTED);
com.midasplayer.fx.SoundManager.loadResource(SOUND_PIECE_MOVED);
com.midasplayer.fx.SoundManager.loadResource(SOUND_PIECE_STRUCK);
com.midasplayer.fx.SoundManager.loadResource(SOUND_PAWN_TO_QUEEN);
com.midasplayer.fx.SoundManager.loadResource(SOUND_TURN_TIMER_ALERT);
com.midasplayer.fx.SoundManager.loadResource(SOUND_GAME_TIMER_ALERT);
com.midasplayer.fx.SoundManager.loadResource(SOUND_CHANGE_TURN);
com.midasplayer.fx.SoundManager.loadResource(SOUND_GAME_CHECK);
if (LOCAL_GAME || (DEV)) {
com.midasplayer.fx.SoundManager.enableSounds(false, MUSIC_GROUP_NAME);
}
if (DEV) {
com.midasplayer.fx.SoundManager.enableSounds(false);
}
}
function loadChatControl() {
System.security.allowDomain(_root.gameDomain);
var _local3 = (LOCAL_GAME ? "" : "/") + "ctl/ChatControl.swf";
m_chatbox = m_avatarLayer.createEmptyMovieClip("chatbox", m_avatarLayer.getNextHighestDepth());
m_avatarLayer.CHATCONTROL_ALLOW_DOMAIN = _root.gameDomain;
m_chatbox.CHATCONTROL_ALLOW_DOMAIN = _root.gameDomain;
m_chatbox.allowDomain = _root.gameDomain;
m_avatarLayer.GAME_REFERENCE = this;
m_avatarLayer.onChatControlLoaded = function () {
this.GAME_REFERENCE.onChatControlLoaded();
};
m_chatbox.loadMovie((LOCAL_GAME ? "" : "/") + "ctl/ChatControl.swf");
m_kacktemp = setInterval(this, "onChatControlLoaded", 5000);
}
function onChatControlLoaded() {
if (m_kacktemp != undefined) {
clearInterval(m_kacktemp);
}
if (m_createAvatarsID == undefined) {
m_createAvatarsID = setInterval(this, "createAvatars", 1000);
}
}
function createAvatars() {
m_avatarLayer.CHATCONTROL_ALLOW_DOMAIN = _root.gameDomain;
m_chatbox.CHATCONTROL_ALLOW_DOMAIN = _root.gameDomain;
if (!arePlayersConnected()) {
return(undefined);
}
clearInterval(m_createAvatarsID);
m_chatbox.init(null, (LOCAL_GAME ? "" : "/"));
var _local4 = m_localPlayer.getAvatarString();
if (((_local4 == "") || (_local4 == undefined)) || (USE_DEFAULT_AVATARS)) {
m_localPlayer.setPlayerNum(1);
if (PLAYER_SIDE == com.midasplayer.chesster.ChessBoard.WHITE) {
_local4 = DEFAULT_WHITE_AVATAR;
} else {
_local4 = DEFAULT_BLACK_AVATAR;
}
}
var _local3 = m_opponentPlayer.getAvatarString();
if (((_local3 == "") || (_local3 == undefined)) || (USE_DEFAULT_AVATARS)) {
m_opponentPlayer.setPlayerNum(2);
if (OPPONENT_SIDE == com.midasplayer.chesster.ChessBoard.WHITE) {
_local3 = DEFAULT_WHITE_AVATAR;
} else {
_local3 = DEFAULT_BLACK_AVATAR;
}
}
m_playerAvatar = m_chatbox.getAvatar(m_localPlayer.getPlayerNum(), _local4, PLAYER_AVATAR_X, PLAYER_AVATAR_Y - 5, true, null, true);
m_opponentAvatar = m_chatbox.getAvatar(m_opponentPlayer.getPlayerNum(), _local3, OPPONENT_AVATAR_X, OPPONENT_AVATAR_Y - 5, false, null, true);
m_playerAvatar.getClip()._rotation = PLAYER_AVATAR_ROTATION;
m_opponentAvatar.getClip()._rotation = OPPONENT_AVATAR_ROTATION;
m_opponentAvatar.getClip()._xscale = m_opponentAvatar.getClip()._xscale * -1;
m_playerAvatar.getClip().setMask(m_playerAvatarMask);
m_opponentAvatar.getClip().setMask(m_opponentAvatarMask);
m_playerAvatar.show();
m_opponentAvatar.show();
var _local5 = m_scopeRef.player_name_txt;
_local5._x = PLAYER_AVATAR_X - (_local5._width / 2);
_local5._y = PLAYER_AVATAR_Y + 65;
_local5.text = m_localPlayer.getUsername();
_local5 = m_scopeRef.opponent_name_txt;
_local5._x = OPPONENT_AVATAR_X - (_local5._width / 2);
_local5._y = OPPONENT_AVATAR_Y + 65;
_local5.text = m_opponentPlayer.getUsername();
m_playerAvatarFrame.gotoAndStop(((PLAYER_SIDE == com.midasplayer.chesster.ChessBoard.WHITE) ? 1 : 2));
m_opponentAvatarFrame.gotoAndStop(((OPPONENT_SIDE == com.midasplayer.chesster.ChessBoard.WHITE) ? 1 : 2));
}
function init() {
loadChatControl();
if (!LOCAL_GAME) {
GAME_TIME = new Number(m_gda.getGameData("gametime"));
TURN_TIME = new Number(m_gda.getGameData("turntime"));
CHESS_TURN_TIME = new Number(m_gda.getGameData("chess_turntime"));
NUM_TIMEOUTS = new Number(m_gda.getGameData("num_timeouts"));
PIECE_TIME_BONUS = new Number(m_gda.getGameData("piece_time_bonus"));
PIECE_KILLED_BONUS_LIMIT = new Number(m_gda.getGameData("piece_killed_bonus_limit"));
PIECE_KILLED_BONUS_MAX = new Number(m_gda.getGameData("piece_killed_bonus_max"));
com.midasplayer.util.Randomizer.seed(new Number(m_gda.getGameData("randomseed")));
}
var _local5 = m_gda.getMultiplayerData("hostname");
var _local2 = m_gda.getMultiplayerData("port");
var _local3 = m_gda.getMultiplayerData("slotid");
var _local4 = m_gda.getMultiplayerData("magic");
com.midasplayer.chesster.Communicator.init(_local5, _local2, _local3, _local4);
com.midasplayer.chesster.Communicator.setGame(this);
initCommunication();
m_moveLog = new org.as2lib.data.holder.array.TypedArray(org.as2lib.data.holder.array.TypedArray);
m_moveLog.push(new org.as2lib.data.holder.array.TypedArray(com.midasplayer.chesster.MoveData));
m_moveLog.push(new org.as2lib.data.holder.array.TypedArray(com.midasplayer.chesster.MoveData));
createGUI();
setActiveSide(com.midasplayer.chesster.ChessBoard.NONE);
showInstructions();
}
function createGUI() {
m_killStack = m_statusLayer.attachMovie(com.midasplayer.chesster.KillStack.SymbolName, "killstack", m_statusLayer.getNextHighestDepth());
m_killStack.init(this);
m_board = m_boardLayer.attachMovie(com.midasplayer.chesster.ChessBoard.SymbolName, "chessBoard", m_boardLayer.getNextHighestDepth());
m_board.init(this);
m_board.setRotation(-2.759);
m_clock = new org.as2lib.data.holder.array.TypedArray(MovieClip);
m_turnTimer = new org.as2lib.data.holder.array.TypedArray(MovieClip);
m_gameTimer = new org.as2lib.data.holder.array.TypedArray(MovieClip);
m_clock.push(m_statusLayer.attachMovie("Clock", "player_clock", m_statusLayer.getNextHighestDepth()));
m_clock[0]._x = PLAYER_CLOCK_X;
m_clock[0]._y = PLAYER_CLOCK_Y;
m_clock[0]._rotation = PLAYER_CLOCK_ROTATION;
m_gameTimer.push(m_clock[0].attachMovie(com.midasplayer.chesster.GameTimer.SymbolName, "gameTimer", m_clock[0].getNextHighestDepth()));
m_gameTimer[0].init(this);
m_turnTimer.push(m_clock[0].attachMovie(com.midasplayer.chesster.TurnTimer.SymbolName, "turnTimer", m_clock[0].getNextHighestDepth()));
m_turnTimer[0].init(this);
m_turnTimer[0]._x = 22.5;
var _local4 = m_clock[0].attachMovie("ClockLid", "sideInidicator_0", m_clock[0].getNextHighestDepth());
_local4.init(this, 2, 2);
_local4.setDefaultFrame(2);
m_clock.push(m_statusLayer.attachMovie("Clock", "opponent_clock", m_statusLayer.getNextHighestDepth()));
m_clock[1]._x = OPPONENT_CLOCK_X;
m_clock[1]._y = OPPONENT_CLOCK_Y;
m_clock[1]._rotation = OPPONENT_CLOCK_ROTATION;
m_gameTimer.push(m_clock[1].attachMovie(com.midasplayer.chesster.GameTimer.SymbolName, "gameTimer", m_clock[1].getNextHighestDepth()));
m_gameTimer[1].init(this);
m_turnTimer.push(m_clock[1].attachMovie(com.midasplayer.chesster.TurnTimer.SymbolName, "turnTimer", m_clock[1].getNextHighestDepth()));
m_turnTimer[1].init(this);
m_turnTimer[1]._x = 22.5;
_local4 = m_clock[1].attachMovie("ClockLid", "sideInidicator_0", m_clock[1].getNextHighestDepth());
_local4.init(this, 1, 2, 3, 8);
_local4.setDefaultFrame(2);
m_clock[0]._xscale = (m_clock[0]._yscale = (m_clock[1]._xscale = (m_clock[1]._yscale = CLOCK_SCALE)));
m_statusIndicator = m_statusLayer.attachMovie(com.midasplayer.chesster.StatusIndicator.SymbolName, "statusInidicator", m_statusLayer.getNextHighestDepth());
m_statusIndicator.init(this);
m_statusIndicator._x = 260;
m_statusIndicator._y = 290;
m_sideIndicator = m_sideIndicatorBottomLayer.attachMovie(com.midasplayer.chesster.SideIndicator.SymbolName, "sideInidicator", m_sideIndicatorBottomLayer.getNextHighestDepth());
m_sideIndicator.init(this, 1, 2);
m_sideIndicator._x = SIDE_INDICATOR_X;
m_sideIndicator._y = SIDE_INDICATOR_Y;
m_sideIndicator.indicateWinner(true);
m_sideIndicatorTop = m_sideIndicatorTopLayer.attachMovie("ChessterThumbs", "sideInidicator_thumbs", m_sideIndicatorBottomLayer.getNextHighestDepth());
m_sideIndicatorTop.init(this, 1, 2);
m_sideIndicatorTop._x = SIDE_INDICATOR_X;
m_sideIndicatorTop._y = SIDE_INDICATOR_Y;
m_sideIndicatorTop.indicateWinner(true);
m_chatPopup = m_statusLayer.attachMovie(com.midasplayer.chesster.ChatPopup.SymbolName, "chatPopup", m_statusLayer.getNextHighestDepth());
m_chatPopup._x = 150;
m_chatPopup._y = 350;
m_chatField = m_statusLayer.attachMovie(com.midasplayer.chesster.ChatField.SymbolName, "chatField", m_statusLayer.getNextHighestDepth());
m_chatField.init(this);
m_chatField._x = 40;
m_chatField._y = 320;
m_chatPopup.init(this, m_chatField);
m_chatPopup.hideChatField();
m_playerAvatarShadow = m_shadowLayer.attachMovie("AvatarShadow", "avatarShadow_white", m_shadowLayer.getNextHighestDepth());
m_playerAvatarShadow._x = PLAYER_AVATAR_X;
m_playerAvatarShadow._y = PLAYER_AVATAR_Y;
m_playerAvatarShadow._rotation = PLAYER_AVATAR_ROTATION;
m_opponentAvatarShadow = m_shadowLayer.attachMovie("AvatarShadow", "avatarShadow_black", m_shadowLayer.getNextHighestDepth());
m_opponentAvatarShadow._x = OPPONENT_AVATAR_X;
m_opponentAvatarShadow._y = OPPONENT_AVATAR_Y;
m_opponentAvatarShadow._rotation = OPPONENT_AVATAR_ROTATION;
m_playerAvatarBG = m_avatarBGLayer.attachMovie("AvatarBG", "playerAvatarBG", m_avatarBGLayer.getNextHighestDepth());
m_playerAvatarBG._x = PLAYER_AVATAR_X;
m_playerAvatarBG._y = PLAYER_AVATAR_Y;
m_playerAvatarBG._rotation = PLAYER_AVATAR_ROTATION;
m_playerAvatarMask = m_playerAvatarBG.duplicateMovieClip("playerAvatarMask", m_avatarBGLayer.getNextHighestDepth());
m_opponentAvatarBG = m_avatarBGLayer.attachMovie("AvatarBG", "opponentAvatarBG", m_avatarBGLayer.getNextHighestDepth());
m_opponentAvatarBG._x = OPPONENT_AVATAR_X;
m_opponentAvatarBG._y = OPPONENT_AVATAR_Y;
m_opponentAvatarBG._rotation = OPPONENT_AVATAR_ROTATION;
m_opponentAvatarMask = m_opponentAvatarBG.duplicateMovieClip("opponentAvatarMask", m_avatarBGLayer.getNextHighestDepth());
m_playerAvatarFrame = m_avatarFGLayer.attachMovie("AvatarFrame", "playerAvatarFrame", m_avatarFGLayer.getNextHighestDepth());
m_playerAvatarFrame._x = PLAYER_AVATAR_X;
m_playerAvatarFrame._y = PLAYER_AVATAR_Y;
m_playerAvatarFrame._rotation = PLAYER_AVATAR_ROTATION;
m_playerAvatarFrame.gotoAndStop(2);
m_opponentAvatarFrame = m_avatarFGLayer.attachMovie("AvatarFrame", "opponentAvatarFrame", m_avatarFGLayer.getNextHighestDepth());
m_opponentAvatarFrame._x = OPPONENT_AVATAR_X;
m_opponentAvatarFrame._y = OPPONENT_AVATAR_Y;
m_opponentAvatarFrame._rotation = OPPONENT_AVATAR_ROTATION;
m_opponentAvatarFrame.gotoAndStop(2);
_root.end_game_button.end_game_txt.text = com.midasplayer.util.I18n.getString("end_game");
_root.end_game_button.onRelease = mx.utils.Delegate.create(this, surrender);
_root.end_game_button.onRollOver = (_root.end_game_button.onDragOver = function () {
var _local3 = new Color(this);
var _local2 = _local3.getTransform();
_local2.rb = 10;
_local2.gb = 10;
_local2.bb = 10;
_local3.setTransform(_local2);
});
_root.end_game_button.onRollOut = (_root.end_game_button.onDragOut = function () {
var _local3 = new Color(this);
var _local2 = _local3.getTransform();
_local2.rb = -10;
_local2.gb = -10;
_local2.bb = -10;
_local3.setTransform(_local2);
});
}
function showInstructions() {
com.midasplayer.fx.SoundManager.play(SOUND_SHOW_INSTRUCTIONS, MUSIC_VOLUME, false, MUSIC_GROUP_NAME);
m_instructions = m_weedLayer.attachMovie(com.midasplayer.chesster.Instructions.SymbolName, "instructions", m_weedLayer.getNextHighestDepth());
m_instructions._x = com.midasplayer.chesster.ChessBoard.BOARD_X;
m_instructions._y = com.midasplayer.chesster.ChessBoard.BOARD_Y;
m_instructions._rotation = com.midasplayer.chesster.ChessBoard.BOARD_ROTATION;
m_instructions.init(this);
m_instructions.setActive(true);
}
function arePlayersConnected() {
return((m_localPlayer.isConnected() && (m_opponentPlayer.isConnected())) || (LOCAL_GAME));
}
function arePlayersReady() {
return(m_localPlayer.isReady() && (m_opponentPlayer.isReady() || (LOCAL_GAME)));
}
function isPlayerReady() {
return(m_localPlayer.isReady());
}
function playerReady() {
m_localPlayer.setReady(true);
com.midasplayer.chesster.Communicator.sendClientIsReady();
}
function opponentReady() {
m_opponentPlayer.setReady(true);
}
function playerAssignSide(side) {
com.midasplayer.chesster.Communicator.sendAssignSide(side);
assignSide(side);
}
function opponentAssignSide(side) {
side = ((side == com.midasplayer.chesster.ChessBoard.WHITE) ? (com.midasplayer.chesster.ChessBoard.BLACK) : (com.midasplayer.chesster.ChessBoard.WHITE));
assignSide(side);
}
function assignSide(side) {
PLAYER_SIDE = side;
OPPONENT_SIDE = ((PLAYER_SIDE == com.midasplayer.chesster.ChessBoard.WHITE) ? (com.midasplayer.chesster.ChessBoard.BLACK) : (com.midasplayer.chesster.ChessBoard.WHITE));
m_playerAvatarFrame.gotoAndStop(PLAYER_SIDE + 1);
m_opponentAvatarFrame.gotoAndStop(OPPONENT_SIDE + 1);
playerReady();
opponentReady();
var _local2 = PLAYER_SIDE != com.midasplayer.chesster.ChessBoard.WHITE;
debug("--- assignSide() - playerSide: " + PLAYER_SIDE);
m_board.setInverted(_local2);
m_board.setupBoard();
m_board.setActiveSide(com.midasplayer.chesster.ChessBoard.NONE);
m_instructions.setActive(false);
startGame();
}
function setupSideQuiz() {
if (m_gameOver) {
return(undefined);
}
m_board.setupSideQuiz();
}
function startSideQuiz() {
m_quizStartTime = getTimer();
m_turnTimer[LOCAL_INDEX].setTime(SIDE_QUIZ_TIME);
m_turnTimer[LOCAL_INDEX].startTimer();
setActiveSide(com.midasplayer.chesster.ChessBoard.WHITE);
}
function sideQuizComplete(succeded) {
setActiveSide(com.midasplayer.chesster.ChessBoard.NONE);
if (succeded) {
m_playerQuizTime = getTimer() - m_quizStartTime;
} else {
m_playerQuizTime = SIDE_QUIZ_TIME;
}
com.midasplayer.chesster.Communicator.sendQuizTime(m_playerQuizTime);
m_turnTimer[LOCAL_INDEX].pauseTimer();
m_instructions = m_weedLayer.attachMovie(com.midasplayer.chesster.QuizSummary.SymbolName, "summary", m_weedLayer.getNextHighestDepth());
m_instructions._x = com.midasplayer.chesster.ChessBoard.BOARD_X;
m_instructions._y = com.midasplayer.chesster.ChessBoard.BOARD_Y;
m_instructions._rotation = com.midasplayer.chesster.ChessBoard.BOARD_ROTATION;
m_instructions.init(this);
if (((m_playerQuizTime != -1) && (m_opponentQuizTime != -1)) && (!m_instructions.isActive())) {
m_instructions.setActive(true);
}
}
function setOpponentQuizTime(quizTime) {
m_opponentQuizTime = quizTime;
if (((m_playerQuizTime != -1) && (m_opponentQuizTime != -1)) && (!m_instructions.isActive())) {
m_instructions.setActive(true);
}
}
function startGame() {
if (m_gameOver) {
return(undefined);
}
clearInterval(m_startGameID);
fscommand ("gameStart");
if (!PRACTICE_GAME) {
var _local2 = ("1," + PLAYER_SIDE) + " ,=0";
fscommand ("playData", _local2);
}
if (com.midasplayer.fx.SoundManager.isPlaying(SOUND_SHOW_INSTRUCTIONS)) {
com.midasplayer.fx.SoundManager.stop(SOUND_SHOW_INSTRUCTIONS);
}
com.midasplayer.fx.SoundManager.play(SOUND_BACKGROUND_LOOP, MUSIC_VOLUME, true, MUSIC_GROUP_NAME);
m_gameTimer[0].setTime(GAME_TIME);
m_gameTimer[0].startTimer();
m_gameTimer[0].pauseTimer();
m_gameTimer[1].setTime(GAME_TIME);
m_gameTimer[1].startTimer();
m_gameTimer[1].pauseTimer();
m_turnTimer[0].setTime(TURN_TIME);
m_turnTimer[0].pauseTimer();
m_turnTimer[1].setTime(TURN_TIME);
m_turnTimer[1].pauseTimer();
m_timeOuts = new org.as2lib.data.holder.array.TypedArray(Number);
m_timeOuts.push(0);
m_timeOuts.push(0);
setActiveSide(com.midasplayer.chesster.ChessBoard.WHITE);
}
function initCommunication() {
m_pingIntervalId = setInterval(this, "ping", 5000);
com.midasplayer.chesster.Communicator.onClientAccepted = mx.utils.Delegate.create(this, clientAccepted);
com.midasplayer.chesster.Communicator.onAnotherClientAccepted = mx.utils.Delegate.create(this, anotherClientAccepted);
com.midasplayer.chesster.Communicator.onPlayerDisconnect = mx.utils.Delegate.create(this, playerDisconnect);
com.midasplayer.chesster.Communicator.onOpponentDisconnect = mx.utils.Delegate.create(this, opponentDisconnect);
com.midasplayer.chesster.Communicator.doConnect();
}
function clientAccepted(playerNum, username, avatar) {
m_localPlayer.setPlayerNum(playerNum);
m_localPlayer.setUsername(username);
m_localPlayer.setAvatarString(avatar);
m_localPlayer.setConnected(true);
}
function anotherClientAccepted(playerNum, username, avatar) {
m_opponentPlayer.setPlayerNum(playerNum);
m_opponentPlayer.setUsername(username);
m_opponentPlayer.setAvatarString(avatar);
m_opponentPlayer.setConnected(true);
}
function playerDisconnect() {
if (LOCAL_GAME || (m_gameOver)) {
return(undefined);
}
com.midasplayer.chesster.Communicator.sendPlayerDisconnect();
if (!PRACTICE_GAME) {
var _local2 = ("999," + PLAYER_SIDE) + " ,=0";
fscommand ("playData", _local2);
}
playerLose();
endGame();
}
function opponentDisconnect() {
if (LOCAL_GAME || (m_gameOver)) {
return(undefined);
}
m_board.setGameStatus(com.midasplayer.chesster.ChessBoard.GAMESTATUS_PLAYER_DISCONNECT);
playerWon();
if (!PRACTICE_GAME) {
var _local2 = ("999," + OPPONENT_SIDE) + " ,=0";
fscommand ("playData", _local2);
}
}
function ping() {
com.midasplayer.chesster.Communicator.sendPing();
}
function setActivePieceRemote(boardX, boardY) {
if ((((boardX == undefined) || (boardX == 0)) || (boardY == undefined)) || (boardY == 0)) {
m_board.setActivePiece(null, true);
} else {
var _local3 = m_board.getPieceAtSquare(boardX, boardY);
m_board.setActivePiece(_local3, true);
m_board.spawnActiveMoves();
}
}
function makeMoveRemote(pieceIndex, moveIndex, gameTimeLeft) {
m_board.makeMoveRemote(pieceIndex, moveIndex);
m_gameTimer[OPPONENT_INDEX].setPartElapsed(gameTimeLeft);
}
function onMakeMove(moveObj) {
m_playerAvatar.setMood("neutral");
m_opponentAvatar.setMood("neutral");
}
function onMakeMoveLocal(moveIndex, moveData) {
var _local2 = m_gameTimer[LOCAL_INDEX].getPartElapsed();
com.midasplayer.chesster.Communicator.sendMovePiece(m_board.getActivePieceIndex(), moveIndex, _local2);
}
function sendMovePlaydata(moveIndex, moveData) {
var _local3 = m_gameTimer[LOCAL_INDEX].getPartElapsed();
if (!PRACTICE_GAME) {
var _local2 = ((((((((("357," + getActiveSide()) + " ") + m_board.getActivePieceIndex()) + " ") + getTimer()) + " ") + _local3) + " ") + moveData.toString()) + " ,=0";
fscommand ("playData", _local2);
}
}
function addToKillStack(piece) {
m_killStack.addPiece(piece);
}
function onPieceStruck(piece) {
addToKillStack(piece);
var _local8 = ((getActiveSide() == com.midasplayer.chesster.ChessBoard.WHITE) ? (com.midasplayer.chesster.ChessBoard.BLACK) : (com.midasplayer.chesster.ChessBoard.WHITE));
var _local11 = m_killStack.getKillCount(_local8);
var _local2 = PIECE_TIME_BONUS;
var _local4 = _local11 - PIECE_KILLED_BONUS_LIMIT;
if (_local4 > 0) {
var _local7 = (10 - PIECE_KILLED_BONUS_LIMIT) - 1;
var _local9 = PIECE_KILLED_BONUS_MAX / Math.pow(_local7, 2);
var _local5 = _local9 * Math.pow(_local4, 2);
_local2 = Math.round((_local2 + _local5) / 1000) * 1000;
}
m_gameTimer[((m_activeSide == PLAYER_SIDE) ? (LOCAL_INDEX) : (OPPONENT_INDEX))].addTime(_local2);
var _local6 = m_dynamicLayer.attachMovie(com.midasplayer.fx.FadeText.SymbolName, "fadeText", m_dynamicLayer.getNextHighestDepth());
var _local3 = {x:com.midasplayer.chesster.BoardObject.getScreenX(piece.getBoardX()), y:com.midasplayer.chesster.BoardObject.getScreenY(piece.getBoardY())};
m_board.localToGlobal(_local3);
_local6.init("+" + (_local2 / 1000), _local3.x, _local3.y - 20, 1.2);
if (getActiveSide() == PLAYER_SIDE) {
m_playerAvatar.setMood("happy");
m_opponentAvatar.setMood("angry");
} else if (getActiveSide() != PLAYER_SIDE) {
m_playerAvatar.setMood("angry");
m_opponentAvatar.setMood("happy");
}
}
function onTurnTimeOut() {
if ((getActiveSide() == PLAYER_SIDE) || (LOCAL_GAME)) {
var _local2 = m_gameTimer[LOCAL_INDEX].getPartElapsed();
com.midasplayer.chesster.Communicator.sendTurnTimeout(_local2);
turnTimeOut(_local2);
} else {
m_turnTimer[OPPONENT_INDEX].pauseTimer();
m_gameTimer[OPPONENT_INDEX].pauseTimer();
}
}
function turnTimeOut(gameTimeLeft) {
if (!PRACTICE_GAME) {
var _local2 = "97," + getActiveSide();
fscommand ("playData", _local2);
debug("playData: " + _local2);
}
if ((getActiveSide() != PLAYER_SIDE) && (!LOCAL_GAME)) {
m_gameTimer[OPPONENT_INDEX].setPartElapsed(gameTimeLeft);
}
com.midasplayer.fx.SoundManager.play(SOUND_CHANGE_TURN);
if (getActiveSide() == PLAYER_SIDE) {
m_playerAvatar.setMood("angry");
m_opponentAvatar.setMood("happy");
} else if (getActiveSide() != PLAYER_SIDE) {
m_playerAvatar.setMood("happy");
m_opponentAvatar.setMood("angry");
}
m_timeOuts[m_activeSide]++;
if (m_timeOuts[m_activeSide] >= NUM_TIMEOUTS) {
m_board.setGameStatus(com.midasplayer.chesster.ChessBoard.GAMESTATUS_TURN_TIMEOUT);
activeSideLose();
} else if (m_board.getGameStatus() == com.midasplayer.chesster.ChessBoard.GAMESTATUS_CHECK) {
m_board.setGameStatus(com.midasplayer.chesster.ChessBoard.GAMESTATUS_CHECK_TIMEOUT);
activeSideLose();
} else {
changeSide();
}
}
function resetTurnTimeOut() {
m_timeOuts[m_activeSide] = 0;
}
function onGameTimeOut() {
if ((getActiveSide() == PLAYER_SIDE) || (LOCAL_GAME)) {
com.midasplayer.chesster.Communicator.sendGameTimeout();
gameTimeOut();
} else {
m_turnTimer[OPPONENT_INDEX].pauseTimer();
m_gameTimer[OPPONENT_INDEX].pauseTimer();
}
}
function gameTimeOut() {
if (!PRACTICE_GAME) {
var _local2 = "666," + getActiveSide();
fscommand ("playData", _local2);
debug("playData: " + _local2);
}
m_board.setGameStatus(com.midasplayer.chesster.ChessBoard.GAMESTATUS_GAME_TIMEOUT);
gameWon(((getActiveSide() == com.midasplayer.chesster.ChessBoard.WHITE) ? (com.midasplayer.chesster.ChessBoard.BLACK) : (com.midasplayer.chesster.ChessBoard.WHITE)));
}
function changeSide() {
setActiveSide(((m_activeSide == com.midasplayer.chesster.ChessBoard.WHITE) ? (com.midasplayer.chesster.ChessBoard.BLACK) : (com.midasplayer.chesster.ChessBoard.WHITE)));
if (m_board.getGameStatus() == com.midasplayer.chesster.ChessBoard.GAMESTATUS_CHECK_MATE) {
gameWon(((getActiveSide() == com.midasplayer.chesster.ChessBoard.WHITE) ? (com.midasplayer.chesster.ChessBoard.BLACK) : (com.midasplayer.chesster.ChessBoard.WHITE)));
} else if (m_board.getGameStatus() == com.midasplayer.chesster.ChessBoard.GAMESTATUS_CHECK) {
com.midasplayer.fx.SoundManager.play(SOUND_GAME_CHECK);
m_turnTimer[((m_activeSide == PLAYER_SIDE) ? 0 : 1)].setTime(CHESS_TURN_TIME);
} else if (m_board.getGameStatus() == com.midasplayer.chesster.ChessBoard.GAMESTATUS_DRAW) {
_level0.statusText.text = "";
draw();
} else {
_level0.statusText.text = "";
m_turnTimer[((m_activeSide == PLAYER_SIDE) ? 0 : 1)].setTime(TURN_TIME);
}
}
function setActiveSide(side) {
m_activeSide = side;
m_board.setActiveSide(m_activeSide);
if (m_activeSide != com.midasplayer.chesster.ChessBoard.NONE) {
if (m_board.getGameStatus() == com.midasplayer.chesster.ChessBoard.GAMESTATUS_CHECK_MATE) {
if (!PRACTICE_GAME) {
var _local2 = "321," + getActiveSide();
fscommand ("playData", _local2);
}
}
if (m_board.getGameStatus() == com.midasplayer.chesster.ChessBoard.GAMESTATUS_CHECK) {
if (!PRACTICE_GAME) {
var _local2 = "123," + getActiveSide();
fscommand ("playData", _local2);
}
}
if (m_board.getGameStatus() == com.midasplayer.chesster.ChessBoard.GAMESTATUS_DRAW) {
if (!PRACTICE_GAME) {
var _local2 = "222," + getActiveSide();
fscommand ("playData", _local2);
}
}
}
setAvatarScale(true, PLAYER_AVATAR_X, PLAYER_AVATAR_Y);
setAvatarScale(false, OPPONENT_AVATAR_X, OPPONENT_AVATAR_Y, true);
if ((m_activeSide != com.midasplayer.chesster.ChessBoard.NONE) && (m_board.getGameStatus() != com.midasplayer.chesster.ChessBoard.GAMESTATUS_SIDE_QUIZ)) {
startTimer();
}
}
function setAvatarScale(local, avatarX, avatarY, invertedX) {
var _local3;
if (getWinningSide() == (local ? (PLAYER_SIDE) : (OPPONENT_SIDE))) {
_local3 = ACTIVE_PLAYER_SCALE;
} else if (getWinningSide() == (local ? (OPPONENT_SIDE) : (PLAYER_SIDE))) {
_local3 = INACTIVE_PLAYER_SCALE;
} else {
_local3 = ((getActiveSide() == (local ? (OPPONENT_SIDE) : (PLAYER_SIDE))) ? (INACTIVE_PLAYER_SCALE) : (ACTIVE_PLAYER_SCALE));
}
var _local5 = (local ? (m_playerAvatar.getClip()) : (m_opponentAvatar.getClip()));
var _local4 = (local ? (m_playerAvatarShadow) : (m_opponentAvatarShadow));
var _local7 = (local ? (m_playerAvatarBG) : (m_opponentAvatarBG));
var _local6 = (local ? (m_playerAvatarFrame) : (m_opponentAvatarFrame));
var _local8 = (local ? (m_playerAvatarMask) : (m_opponentAvatarMask));
_local5._xscale = (_local5._yscale = (_local4._xscale = (_local4._yscale = (_local7._xscale = (_local7._yscale = (_local6._xscale = (_local6._yscale = (_local8._xscale = (_local8._yscale = _local3)))))))));
if (invertedX) {
_local5._xscale = _local5._xscale * -1;
}
_local4._x = avatarX + ((_local3 == ACTIVE_PLAYER_SCALE) ? 20 : 5);
_local4._y = avatarY + ((_local3 == ACTIVE_PLAYER_SCALE) ? 20 : 5);
}
function getActiveSide() {
return(m_activeSide);
}
function startTimer() {
m_gameTimer[((m_activeSide == PLAYER_SIDE) ? (LOCAL_INDEX) : (OPPONENT_INDEX))].unpauseTimer();
m_gameTimer[((m_activeSide == PLAYER_SIDE) ? (OPPONENT_INDEX) : (LOCAL_INDEX))].pauseTimer();
m_turnTimer[((m_activeSide == PLAYER_SIDE) ? (LOCAL_INDEX) : (OPPONENT_INDEX))].startTimer();
m_turnTimer[((m_activeSide == PLAYER_SIDE) ? (OPPONENT_INDEX) : (LOCAL_INDEX))].stopTimer();
}
function stopTimer() {
m_turnTimer[0].pauseTimer();
m_turnTimer[1].pauseTimer();
m_gameTimer[0].pauseTimer();
m_gameTimer[1].pauseTimer();
}
function draw() {
if (m_gameTimer[LOCAL_INDEX].getPartElapsed() > m_gameTimer[OPPONENT_INDEX].getPartElapsed()) {
playerLose();
} else if (m_gameTimer[LOCAL_INDEX].getPartElapsed() < m_gameTimer[OPPONENT_INDEX].getPartElapsed()) {
playerWon();
}
}
function surrender() {
if (LOCAL_GAME) {
endGame();
}
if (!m_gameOver) {
playerDisconnect();
} else if (m_gameOver) {
endGame();
}
}
function gameWon(side) {
if (m_gameOver) {
return(undefined);
}
m_winningSide = side;
m_gameOver = true;
setActiveSide(com.midasplayer.chesster.ChessBoard.NONE);
stopTimer();
debug("---------===============---------");
debug(" GAME OVER ");
debug(" The winner is: " + ((side == com.midasplayer.chesster.ChessBoard.WHITE) ? "WHITE" : "BLACK"));
debug("---------===============---------");
m_instructions.removeMovieClip();
m_instructions = m_weedLayer.attachMovie(com.midasplayer.chesster.Summary.SymbolName, "summary", m_weedLayer.getNextHighestDepth());
m_instructions._x = com.midasplayer.chesster.ChessBoard.BOARD_X;
m_instructions._y = com.midasplayer.chesster.ChessBoard.BOARD_Y;
m_instructions._rotation = com.midasplayer.chesster.ChessBoard.BOARD_ROTATION;
m_instructions.init(this);
m_playerAvatar.setMood(((side == PLAYER_SIDE) ? "happy" : "angry"));
m_opponentAvatar.setMood(((side == PLAYER_SIDE) ? "angry" : "happy"));
com.midasplayer.fx.SoundManager.stopAll();
if (side == PLAYER_SIDE) {
com.midasplayer.fx.SoundManager.play(SOUND_GAME_WON, MUSIC_VOLUME, false, MUSIC_GROUP_NAME);
} else {
com.midasplayer.fx.SoundManager.play(SOUND_GAME_LOSE, MUSIC_VOLUME, false, MUSIC_GROUP_NAME);
}
m_gameOverArgument = ((side == PLAYER_SIDE) ? 1000 : 0);
m_endGameID = setInterval(this, "endGame", GAME_OVER_DELAY);
}
function endGame() {
debug("gameOver, " + m_gameOverArgument);
fscommand ("gameOver", m_gameOverArgument);
com.midasplayer.chesster.Communicator.sendGameOver();
clearInterval(m_endGameID);
}
function getWinningSide() {
return(m_winningSide);
}
function activeSideLose() {
gameWon(((getActiveSide() == com.midasplayer.chesster.ChessBoard.WHITE) ? (com.midasplayer.chesster.ChessBoard.BLACK) : (com.midasplayer.chesster.ChessBoard.WHITE)));
}
function activeSideWon() {
gameWon(getActiveSide());
}
function playerLose() {
gameWon(((PLAYER_SIDE == com.midasplayer.chesster.ChessBoard.WHITE) ? (com.midasplayer.chesster.ChessBoard.BLACK) : (com.midasplayer.chesster.ChessBoard.WHITE)));
}
function playerWon() {
gameWon(PLAYER_SIDE);
}
function getGameStatusText() {
var _local2 = m_board.getGameStatus();
if (_local2 == com.midasplayer.chesster.ChessBoard.GAMESTATUS_NORMAL) {
return(undefined);
}
if (_local2 == com.midasplayer.chesster.ChessBoard.GAMESTATUS_CHECK) {
return(com.midasplayer.util.I18n.getString("check"));
}
if (_local2 == com.midasplayer.chesster.ChessBoard.GAMESTATUS_CHECK_MATE) {
return(com.midasplayer.util.I18n.getString("check_mate"));
}
if (_local2 == com.midasplayer.chesster.ChessBoard.GAMESTATUS_DRAW) {
return(com.midasplayer.util.I18n.getString("draw"));
}
if (_local2 == com.midasplayer.chesster.ChessBoard.GAMESTATUS_CHECK_TIMEOUT) {
return(com.midasplayer.util.I18n.getString("check_timeout"));
}
if (_local2 == com.midasplayer.chesster.ChessBoard.GAMESTATUS_TURN_TIMEOUT) {
return(com.midasplayer.util.I18n.getString("turn_timeout"));
}
if (_local2 == com.midasplayer.chesster.ChessBoard.GAMESTATUS_GAME_TIMEOUT) {
return(com.midasplayer.util.I18n.getString("game_timeout"));
}
if (_local2 == com.midasplayer.chesster.ChessBoard.GAMESTATUS_PLAYER_DISCONNECT) {
return(com.midasplayer.util.I18n.getString("player_disconnect"));
}
return(undefined);
}
static function debug(msg) {
_level0.debugText.text = (msg + "\n--------------\n") + _level0.debugText.text;
}
function logMove(moveObj) {
m_moveLog[getActiveSide()].push(moveObj.getMoveData());
}
function isHistoryDraw() {
var _local4 = false;
var _local2 = 0;
while (_local2 < 2) {
var _local3 = m_moveLog[_local2].length - 1;
if ((m_moveLog[_local2][_local3].isEqual(m_moveLog[_local2][_local3 - 2]) && (m_moveLog[_local2][_local3].isEqual(m_moveLog[_local2][_local3 - 4]))) && (m_moveLog[_local2][_local3 - 1].isEqual(m_moveLog[_local2][_local3 - 3]))) {
} else {
return(false);
}
_local2++;
}
debug("Repeating moves - Forcing draw!");
return(true);
}
function sendChatMsg(msg) {
if (msg == "") {
return(undefined);
}
addChatMsg(msg, true);
com.midasplayer.chesster.Communicator.sendChatMsg(msg);
m_chatField._visible = false;
}
function recievedChatMsg(msg) {
m_chatbox.hm(msg);
addChatMsg(msg, false);
}
function addChatMsg(msg, local) {
var _local4 = (local ? (PLAYER_AVATAR_X) : (OPPONENT_AVATAR_X));
var _local3 = (local ? (PLAYER_AVATAR_Y) : (OPPONENT_AVATAR_Y)) - 60;
var _local2 = m_dynamicLayer.attachMovie(com.midasplayer.fx.ChatBubble.SymbolName, "chatMsg", m_dynamicLayer.getNextHighestDepth(), 0, 0);
_local2.init(msg, _local4, _local3);
}
static var LOCAL_GAME = false;
static var PRACTICE_GAME = false;
static var DEV = false;
static var USE_DEFAULT_AVATARS = false;
static var PLAYER_SIDE = com.midasplayer.chesster.ChessBoard.WHITE;
static var OPPONENT_SIDE = com.midasplayer.chesster.ChessBoard.BLACK;
static var GAME_TIME = 120000;
static var TURN_TIME = 20000;
static var CHESS_TURN_TIME = 2 * TURN_TIME;
static var NUM_TIMEOUTS = 2;
static var PIECE_TIME_BONUS = 10000;
static var PIECE_KILLED_BONUS_LIMIT = 0;
static var PIECE_KILLED_BONUS_MAX = 20000;
static var SIDE_QUIZ_TIME = 10000;
static var GAME_OVER_DELAY = 15000;
static var DEFAULT_WHITE_AVATAR = "hair24C,f6f8af:head1,ffdec7:blush1,ffdec7:mouth1,ffdec7:lips1,f6f8af:sweat1,ffdec7:makeup10:eyes1:eyebrows1:nose4,ffdec7:addon2B:ear1,ffdec7:hair24A,f6f8af";
static var DEFAULT_BLACK_AVATAR = "hair30C,651212:head4,c48072:blush1,c48072:mouth1,c48072:beard1,651212:sweat1,c48072:makeup4:eyes2:eyebrows1:nose4,c48072:hair30B,651212:ear1,c48072:hair30A,651212";
static var LOCAL_INDEX = 0;
static var OPPONENT_INDEX = 1;
static var PLAYER_AVATAR_X = 170;
static var PLAYER_AVATAR_Y = 240;
static var PLAYER_AVATAR_ROTATION = -8;
static var OPPONENT_AVATAR_X = 60;
static var OPPONENT_AVATAR_Y = 240;
static var OPPONENT_AVATAR_ROTATION = 10;
static var ACTIVE_PLAYER_SCALE = 100;
static var INACTIVE_PLAYER_SCALE = 80;
static var CHAT_X = 0;
static var CHAT_Y = 0;
static var PLAYER_CLOCK_X = 240;
static var PLAYER_CLOCK_Y = 435;
static var PLAYER_CLOCK_ROTATION = 0;
static var OPPONENT_CLOCK_X = 85;
static var OPPONENT_CLOCK_Y = 430;
static var OPPONENT_CLOCK_ROTATION = 0;
static var CLOCK_SCALE = 100;
static var SIDE_INDICATOR_X = 130;
static var SIDE_INDICATOR_Y = 145;
static var SOUND_SHOW_INSTRUCTIONS = "intro";
static var SOUND_BACKGROUND_LOOP = "background_loop";
static var SOUND_GAME_LOSE = "game_lose";
static var SOUND_GAME_WON = "game_won";
static var SOUND_PIECE_SELECTED = "piece_selected";
static var SOUND_PIECE_MOVED = "piece_moved";
static var SOUND_PIECE_STRUCK = "piece_struck";
static var SOUND_PAWN_TO_QUEEN = "pawn_to_queen";
static var SOUND_TURN_TIMER_ALERT = "turn_timer_alert";
static var SOUND_GAME_TIMER_ALERT = "game_timer_alert";
static var SOUND_CHANGE_TURN = "change_turn";
static var SOUND_GAME_CHECK = "check_warning";
static var MUSIC_VOLUME = 50;
static var MUSIC_GROUP_NAME = "music";
var m_quizStartTime = -1;
var m_playerQuizTime = -1;
var m_opponentQuizTime = -1;
var m_winningSide = com.midasplayer.chesster.ChessBoard.NONE;
var m_endGameID = -1;
var m_startGameID = -1;
}
Symbol 260 MovieClip [__Packages.com.midasplayer.chesster.Player] Frame 0
class com.midasplayer.chesster.Player
{
var scoreTotal_, scoreRound_, playerNum_, username_, avatarString_, roundEnded_, moreMoves_, exitGame_;
function Player () {
scoreTotal_ = 0;
scoreRound_ = 0;
}
function getPlayerNum() {
return(playerNum_);
}
function setPlayerNum(playerNum) {
playerNum_ = playerNum;
}
function getUsername() {
return(username_);
}
function setUsername(username) {
username_ = username;
}
function getAvatarString() {
return(avatarString_);
}
function setAvatarString(avatarString) {
avatarString_ = avatarString;
}
function isReady() {
return(isReady_);
}
function setReady(ready) {
isReady_ = ready;
}
function getScoreTotal() {
return(scoreTotal_);
}
function getScoreRound() {
return(scoreRound_);
}
function newRound() {
scoreRound_ = 0;
roundEnded_ = false;
moreMoves_ = true;
}
function addScore(score) {
scoreTotal_ = scoreTotal_ + score;
scoreRound_ = scoreRound_ + score;
if (scoreTotal_ < 0) {
scoreTotal_ = 0;
scoreRound_ = 0;
}
}
function setNoMoreMoves() {
moreMoves_ = false;
roundEnded_ = true;
}
function setRoundEnded() {
roundEnded_ = true;
}
function isRoundEnded() {
return(roundEnded_);
}
function hasMoreMoves() {
return(moreMoves_);
}
function setExitGame() {
exitGame_ = true;
}
function getExitGame() {
return(exitGame_);
}
function hasExitGame() {
return(exitGame_);
}
function setConnected(c) {
connected_ = c;
}
function isConnected() {
return(connected_);
}
function setAvatar(avatar) {
avatar_ = avatar;
}
function getAvatar() {
return(avatar_);
}
function setMood(mood) {
if (_level0.chatbox.getBytesLoaded() == _level0.chatbox.getBytesTotal()) {
_level0.chatbox.setMood(avatar_, mood);
}
}
var avatar_ = null;
var connected_ = false;
var isReady_ = false;
}
Symbol 261 MovieClip [__Packages.com.midasplayer.util.GameDataAcquirer] Frame 0
class com.midasplayer.util.GameDataAcquirer
{
var attrib, multiplayerAttrib, trees, targetVar, dataEvent, timerFn, timer, error;
function GameDataAcquirer (variable) {
attrib = new com.midasplayer.util.Map();
multiplayerAttrib = new com.midasplayer.util.Map();
trees = new com.midasplayer.util.Map();
if (variable != undefined) {
targetVar = variable;
} else {
targetVar = "gameData";
}
}
function beginWait(fn) {
dataEvent = fn;
timerFn = function (caller) {
var _local1 = _level0[caller.targetVar];
if (((_local1 != undefined) && (_local1 != null)) && (_local1.length > 0)) {
caller.parse(_local1);
if (caller.dataEvent != undefined) {
caller.dataEvent();
}
caller.dataEvent = undefined;
clearInterval(caller.timer);
}
};
timer = setInterval(timerFn, 100, this);
}
function poll() {
if (!parsed) {
var _local2 = _level0[targetVar];
if (((_local2 != undefined) && (_local2 != null)) && (_local2.length > 0)) {
parse(_local2);
parsed = true;
return(true);
}
}
return(false);
}
function getAttributes() {
return(attrib);
}
function getSubTrees(name) {
return(trees.get(name));
}
function getGameData(name) {
return(attrib.get(name));
}
function getMultiplayerData(name) {
return(multiplayerAttrib.get(name));
}
function parse(data) {
attrib.clear();
var _local7 = new com.midasplayer.util.Map();
var _local9 = new XML();
_local9.ignoreWhite = true;
_local9.parseXML(data);
var _local4 = _local9.firstChild;
if (_local4.nodeName != "gamedata") {
error = "Bad XML (expected <gamedata>)";
return(undefined);
}
for (var _local8 in _local4.attributes) {
var _local5;
var _local3 = _local4.attributes[_local8];
if ((_local3.indexOf("[") == 0) && ((_local5 = _local3.indexOf("]")) != -1)) {
_local3 = _local3.substring(1, _local5).split(",");
}
attrib.put(_local8, _local3);
}
for (var _local8 in _local4.childNodes) {
var _local2 = _local4.childNodes[_local8];
switch (_local2.nodeName) {
case "text" :
_local7.put(_local2.attributes.id, _local2.firstChild.nodeValue);
break;
case "multiplayer" :
for (var _local8 in _local2.attributes) {
multiplayerAttrib.put(_local8, _local2.attributes[_local8]);
}
break;
default :
var _local6;
_local6 = trees.get(_local2.nodeName);
if (_local6 == undefined) {
trees.put(_local2.nodeName, [_local2]);
} else {
_local6.push(_local2);
}
}
}
com.midasplayer.util.I18n.init(_local7);
}
var parsed = false;
}
Symbol 262 MovieClip [__Packages.com.midasplayer.util.I18n] Frame 0
class com.midasplayer.util.I18n
{
static var lang;
function I18n () {
}
static function init(newLang) {
lang = newLang;
}
static function getString(name) {
var _local1 = lang.get(name);
if (_local1 == undefined) {
return(("{" + name) + "}");
}
return(_local1.toString());
}
}
Symbol 263 MovieClip [__Packages.mx.utils.Delegate] Frame 0
class mx.utils.Delegate extends Object
{
var func;
function Delegate (f) {
super();
func = f;
}
static function create(obj, func) {
var _local2 = function () {
var _local2 = arguments.callee.target;
var _local3 = arguments.callee.func;
return(_local3.apply(_local2, arguments));
};
_local2.target = obj;
_local2.func = func;
return(_local2);
}
function createDelegate(obj) {
return(create(obj, func));
}
}
Symbol 264 MovieClip [__Packages.com.midasplayer.chesster.KillStack] Frame 0
class com.midasplayer.chesster.KillStack extends MovieClip
{
var m_game, m_index, _x, _y, m_killCount, m_pieceArray;
function KillStack () {
super();
m_game = null;
m_index = 0;
_x = 650;
_y = 10;
m_killCount = new org.as2lib.data.holder.array.TypedArray(Number);
m_killCount.push(0);
m_killCount.push(0);
m_pieceArray = new org.as2lib.data.holder.array.TypedArray(com.midasplayer.chesster.Piece);
}
function init(game) {
m_game = game;
}
function addPiece(piece) {
if (m_index > posArray.length) {
com.midasplayer.chesster.Game.debug("Killstack does not support this many pieces. Add more data to the class!");
return(undefined);
}
m_pieceArray.push(piece);
m_killCount[piece.getSide()]++;
m_index++;
}
function onEnterFrame() {
var _local3 = 0;
while (_local3 < m_pieceArray.length) {
var _local2 = m_pieceArray[_local3];
if (_local2.isPendingDeath() && (_local2.getDeathEffectFactor() >= 1)) {
_local2.kill();
var _local4 = {x:posArray[_local3].x + _x, y:posArray[_local3].y + _y};
var _local5 = m_game.getBoard();
_local5.globalToLocal(_local4);
_local2._rotation = posArray[_local3].rotation - _local5._rotation;
_local2._x = _local4.x;
_local2._y = _local4.y;
_local2.swapDepths(KILL_DEPTH + _local3);
}
_local3++;
}
}
function getKillCount(side) {
return(m_killCount[side]);
}
static var SymbolName = "KillStack";
static var KILL_DEPTH = 1000;
static var posArray = [{x:44, y:468, rotation:9.5}, {x:69, y:435, rotation:39.5}, {x:44.5, y:404, rotation:-20.5}, {x:44, y:362, rotation:69.5}, {x:65, y:349, rotation:-9}, {x:43, y:315, rotation:6}, {x:66, y:293, rotation:-61}, {x:41, y:264, rotation:13}, {x:68, y:238, rotation:-2}, {x:65, y:200, rotation:17}, {x:36, y:178, rotation:28}, {x:56, y:151, rotation:28}, {x:36, y:130, rotation:13}, {x:68, y:100, rotation:13.5}, {x:36, y:90, rotation:-37}, {x:64, y:56, rotation:-2}, {x:32, y:35.5, rotation:5}, {x:59, y:32.5, rotation:-160}];
}
Symbol 265 MovieClip [__Packages.com.midasplayer.chesster.Timer] Frame 0
class com.midasplayer.chesster.Timer extends MovieClip
{
var m_game, m_time, m_effectCounter, m_width, _width, m_running, m_useEffect, m_hidePaused, m_progression, m_partElapsed, m_startTime, m_pauseTime, _visible, stop, _yscale, _alpha, m_alertMovieClip, _rotation;
function Timer () {
super();
m_game = null;
m_time = 20;
m_effectCounter = 0;
m_width = _width;
m_running = false;
m_useEffect = true;
m_hidePaused = false;
m_progression = PROGRESSION_ROTATION;
m_partElapsed = 0;
}
function init(game) {
m_game = game;
}
function setAlertTime(timeParam) {
m_alertTime = timeParam;
}
function setTime(timeParam) {
m_time = timeParam;
}
function getTime() {
return(m_time);
}
function addTime(timeParam) {
m_startTime = Math.min(getTimer(), m_startTime + timeParam);
updatePartElapsed();
}
function startTimer() {
m_startTime = getTimer();
m_running = true;
m_alertPlayed = false;
}
function stopTimer() {
m_running = false;
m_startTime = undefined;
m_alertPlayed = false;
}
function pauseTimer() {
m_running = false;
m_pauseTime = getTimer();
if (com.midasplayer.fx.SoundManager.isPlaying(m_alertSound)) {
com.midasplayer.fx.SoundManager.stop(m_alertSound);
}
m_alertPlayed = false;
}
function unpauseTimer() {
m_running = true;
m_startTime = m_startTime + (getTimer() - m_pauseTime);
}
function hideTimer() {
_visible = false;
}
function showTimer() {
_visible = true;
}
function setPartElapsed(partElapsed) {
m_startTime = getTimer() - (partElapsed * m_time);
updatePartElapsed();
}
function updatePartElapsed() {
m_partElapsed = (getTimer() - m_startTime) / m_time;
}
function getPartElapsed() {
return(m_partElapsed);
}
function onEnterFrame() {
stop();
if (m_running) {
updatePartElapsed();
if (getPartElapsed() > 1) {
stopTimer();
onTimerElapsed();
}
}
if (m_hidePaused) {
_visible = m_running;
}
var _local4 = 1 - (m_alertTime / getTime());
if (m_useEffect && (m_running)) {
if (getPartElapsed() >= _local4) {
m_effectCounter = m_effectCounter + 0.125;
if ((!com.midasplayer.fx.SoundManager.isPlaying(m_alertSound)) && (!m_alertPlayed)) {
com.midasplayer.fx.SoundManager.play(m_alertSound, 100, m_alertLooped);
m_alertPlayed = true;
}
} else {
m_effectCounter = 0;
}
m_effectCounter = m_effectCounter - Math.floor(m_effectCounter);
_yscale = 100 + (m_effectCounter * 30);
_alpha = 100 - (Math.sin((m_effectCounter * Math.PI) * 2) * 40);
} else {
_yscale = 100;
_alpha = 100;
}
if (m_alertMovieClip) {
var _local3 = Math.max(0, Math.min(1, (getPartElapsed() - _local4) / (1 - _local4)));
if (((!m_running) && (!m_alertWhenPaused)) || (m_startTime == undefined)) {
_local3 = 0;
}
var _local5 = new Color(m_alertMovieClip);
var _local2 = _local5.getTransform();
_local2.ra = 100;
_local2.ga = 100 * (1 - _local3);
_local2.ba = 100 * (1 - _local3);
_local2.aa = 100;
_local5.setTransform(_local2);
}
if (m_progression == PROGRESSION_WIDTH) {
_width = m_width * (1 - getPartElapsed());
} else if (m_progression == PROGRESSION_ROTATION) {
_rotation = getPartElapsed() * 360;
}
}
function onTimerElapsed() {
}
static var SymbolName = "Timer";
static var PROGRESSION_WIDTH = 0;
static var PROGRESSION_ROTATION = 1;
var m_alertSound = "";
var m_alertTime = 0;
var m_alertLooped = false;
var m_alertPlayed = false;
var m_alertWhenPaused = false;
}
Symbol 266 MovieClip [__Packages.com.midasplayer.chesster.GameTimer] Frame 0
class com.midasplayer.chesster.GameTimer extends com.midasplayer.chesster.Timer
{
var m_alertSound, m_alertTime, m_alertLooped, m_alertMovieClip, _parent, m_alertWhenPaused, m_game;
function GameTimer () {
super();
m_alertSound = com.midasplayer.chesster.Game.SOUND_GAME_TIMER_ALERT;
m_alertTime = 20000;
m_alertLooped = true;
m_alertMovieClip = _parent.gameTimeIndicator;
m_alertWhenPaused = true;
}
function onTimerElapsed() {
m_game.onGameTimeOut();
}
static var SymbolName = "GameTimer";
}
Symbol 267 MovieClip [__Packages.com.midasplayer.chesster.TurnTimer] Frame 0
class com.midasplayer.chesster.TurnTimer extends com.midasplayer.chesster.Timer
{
var m_alertSound, m_hidePaused, m_alertTime, m_alertLooped, m_alertMovieClip, _parent, m_game;
function TurnTimer () {
super();
m_alertSound = com.midasplayer.chesster.Game.SOUND_TURN_TIMER_ALERT;
m_hidePaused = false;
m_alertTime = 3000;
m_alertLooped = false;
m_alertMovieClip = _parent.turnTimeIndicator;
}
function onTimerElapsed() {
if (m_game.getBoard().getGameStatus() == com.midasplayer.chesster.ChessBoard.GAMESTATUS_SIDE_QUIZ) {
m_game.sideQuizComplete(false);
} else {
m_game.onTurnTimeOut();
}
}
static var SymbolName = "TurnTimer";
}
Symbol 268 MovieClip [__Packages.com.midasplayer.chesster.StatusIndicator] Frame 0
class com.midasplayer.chesster.StatusIndicator extends MovieClip
{
var m_game, m_statusTextfield, status_textfield, _totalframes, _currentframe, gotoAndStop;
function StatusIndicator () {
super();
m_game = null;
}
function init(game, startFrame, endFrame, transitionStartFrame, transitionEndFrame) {
m_game = game;
}
function onEnterFrame() {
var _local2 = m_game.getGameStatusText();
m_statusTextfield = status_textfield;
m_statusTextfield.text = _local2;
if ((_currentframe != _totalframes) && (_local2 != undefined)) {
m_playbackDirection = 1;
} else if ((_currentframe != 1) && (_local2 == undefined)) {
m_playbackDirection = -1;
} else {
m_playbackDirection = 0;
}
gotoAndStop(_currentframe + m_playbackDirection);
}
static var SymbolName = "StatusIndicator";
var m_playbackDirection = 0;
}
Symbol 269 MovieClip [__Packages.com.midasplayer.chesster.SideIndicator] Frame 0
class com.midasplayer.chesster.SideIndicator extends MovieClip
{
var m_game, m_startFrame, m_endFrame, m_transitionStartFrame, m_transitionEndFrame, m_defaultFrame, gotoAndStop, _currentframe;
function SideIndicator () {
super();
m_game = null;
m_startFrame = 1;
m_endFrame = 2;
m_transitionStartFrame = -1;
m_transitionEndFrame = -1;
m_defaultFrame = m_startFrame;
}
function init(game, startFrame, endFrame, transitionStartFrame, transitionEndFrame) {
m_game = game;
if (startFrame != undefined) {
m_startFrame = startFrame;
}
if (endFrame != undefined) {
m_endFrame = endFrame;
}
if (transitionStartFrame != undefined) {
m_transitionStartFrame = transitionStartFrame;
}
if (transitionEndFrame != undefined) {
m_transitionEndFrame = transitionEndFrame;
}
}
function setDefaultFrame(frame) {
m_defaultFrame = frame;
}
function indicateWinner(indicateWinner) {
m_indicateWinner = indicateWinner;
}
function onEnterFrame() {
var _local2 = -1;
if ((m_game.getWinningSide() == com.midasplayer.chesster.Game.PLAYER_SIDE) && (m_indicateWinner)) {
_local2 = m_startFrame;
} else if ((m_game.getWinningSide() == com.midasplayer.chesster.Game.OPPONENT_SIDE) && (m_indicateWinner)) {
_local2 = m_endFrame;
} else if (m_game.getActiveSide() == com.midasplayer.chesster.Game.PLAYER_SIDE) {
_local2 = m_startFrame;
} else if (m_game.getActiveSide() == com.midasplayer.chesster.Game.OPPONENT_SIDE) {
_local2 = m_endFrame;
} else {
_local2 = m_defaultFrame;
}
if ((m_transitionStartFrame == -1) || (m_transitionEndFrame == -1)) {
gotoAndStop(_local2);
} else if ((_currentframe != _local2) && (m_playbackDirection == 0)) {
if (_local2 == m_startFrame) {
gotoAndStop(m_transitionEndFrame);
m_playbackDirection = -1;
} else if (_local2 == m_endFrame) {
gotoAndStop(m_transitionStartFrame);
m_playbackDirection = 1;
}
}
if ((_currentframe == m_transitionEndFrame) && (m_playbackDirection == 1)) {
gotoAndStop(m_endFrame);
m_playbackDirection = 0;
} else if ((_currentframe == m_transitionStartFrame) && (m_playbackDirection == -1)) {
gotoAndStop(m_startFrame);
m_playbackDirection = 0;
}
gotoAndStop(_currentframe + m_playbackDirection);
}
static var SymbolName = "Chesster";
var m_indicateWinner = false;
var m_playbackDirection = 0;
}
Symbol 270 MovieClip [__Packages.com.midasplayer.chesster.ChatPopup] Frame 0
class com.midasplayer.chesster.ChatPopup extends MovieClip
{
var m_game, m_chatField;
function ChatPopup () {
super();
}
function init(game, chatField) {
m_game = game;
m_chatField = chatField;
Key.addListener(this);
}
function showChatField() {
if (!m_chatField._visible) {
m_chatField._visible = true;
}
var _local2 = (m_chatField.getInputField()._parent + ".") + m_chatField.getInputField()._name;
if ((Selection.getFocus() != _local2) && (m_chatField.getInputField().text == "")) {
Selection.setFocus(m_chatField.getInputField());
Selection.setFocus(m_chatField.getInputField());
}
}
function hideChatField() {
m_chatField._visible = false;
}
function deactivate() {
}
function onPress() {
if (m_chatField._visible) {
hideChatField();
} else {
showChatField();
}
}
function onKeyDown() {
showChatField();
}
static var SymbolName = "ChatPopup";
}
Symbol 271 MovieClip [__Packages.com.midasplayer.chesster.ChatField] Frame 0
class com.midasplayer.chesster.ChatField extends MovieClip
{
var m_game, attachMovie, getNextHighestDepth, m_textField, chatTextField, _visible;
function ChatField () {
super();
}
function init(game) {
m_game = game;
var _local2 = attachMovie("ChatButton", "chatButton", getNextHighestDepth());
_local2._alpha = 0;
_local2.onPress = mx.utils.Delegate.create(this, sendChatMsg);
m_textField = chatTextField;
}
function getInputField() {
return(m_textField);
}
function sendChatMsg() {
if (m_textField.text == "") {
return(undefined);
}
m_game.sendChatMsg(m_textField.text);
m_textField.text = "";
}
function onEnterFrame() {
super.onEnterFrame();
if (Key.isDown(13) && (_visible == true)) {
sendChatMsg();
}
}
static var SymbolName = "ChatField";
}
Symbol 272 MovieClip [__Packages.com.midasplayer.chesster.SquareEffectBase] Frame 0
class com.midasplayer.chesster.SquareEffectBase extends MovieClip
{
var m_squareLayer, _parent, _x, _y, _rotation, m_squareArray, getDepth, swapDepths;
function SquareEffectBase () {
super();
}
function createSquares() {
m_squareLayer = _parent.createEmptyMovieClip("squareLayer", _parent.getNextHighestDepth());
m_squareLayer._x = _x;
m_squareLayer._y = _y;
m_squareLayer._rotation = _rotation;
m_squareArray = new Array();
var _local4 = 0;
while (_local4 < com.midasplayer.chesster.ChessBoard.HEIGHT) {
var _local2 = 0;
while (_local2 < com.midasplayer.chesster.ChessBoard.WIDTH) {
m_squareArray.push(m_squareLayer.attachMovie("SquareWhite", (("square_" + _local2) + "_") + _local4, m_squareLayer.getNextHighestDepth()));
var _local3 = m_squareArray.length;
m_squareArray[_local3 - 1]._x = (_local2 - Math.floor(com.midasplayer.chesster.ChessBoard.WIDTH / 2)) * com.midasplayer.chesster.ChessBoard.SQUARE_SIZE;
m_squareArray[_local3 - 1]._y = (_local4 - Math.floor(com.midasplayer.chesster.ChessBoard.HEIGHT / 2)) * com.midasplayer.chesster.ChessBoard.SQUARE_SIZE;
_local2++;
}
_local4++;
}
var _local5 = getDepth();
var _local6 = m_squareLayer.getDepth();
swapDepths(m_squareLayer.getDepth());
m_squareLayer.swapDepths(_local5);
}
function removeMovieClip() {
m_squareLayer.removeMovieClip();
super.removeMovieClip();
}
function removeSquares() {
var _local3 = new Array();
_local3.push(m_squareArray.pop());
m_squareArray.reverse();
_local3.push(m_squareArray.pop());
var _local2 = 0;
while (_local2 < _local3.length) {
_local3[_local2].removeMovieClip();
_local2++;
}
}
}
Symbol 273 MovieClip [__Packages.com.midasplayer.chesster.Instructions] Frame 0
class com.midasplayer.chesster.Instructions extends com.midasplayer.chesster.SquareEffectBase
{
var m_game, m_active, m_weed, attachMovie, getNextHighestDepth, m_instructionsTextfield, instructions_text, m_timeTextfield, instructions_time_text, m_skipButton, skip_button, createSquares, m_squareLayer, m_startTime;
function Instructions () {
super();
m_game = null;
m_active = false;
}
function init(game) {
m_game = game;
m_weed = attachMovie("weedDisappear", "weed", getNextHighestDepth());
m_instructionsTextfield = instructions_text;
m_timeTextfield = instructions_time_text;
m_instructionsTextfield.text = com.midasplayer.util.I18n.getString("instruction_text");
m_skipButton = skip_button;
m_skipButton.onPress = mx.utils.Delegate.create(this, endIntro);
m_skipButton.skip_text.text = com.midasplayer.util.I18n.getString("skip");
createSquares();
m_game.setupSideQuiz();
}
function removeMovieClip() {
m_squareLayer.removeMovieClip();
super.removeMovieClip();
}
function setActive(active) {
m_active = active;
if (active && (m_startTime == undefined)) {
m_startTime = getTimer();
} else if (!active) {
m_startTime = undefined;
}
}
function onEnterFrame() {
if (!m_active) {
return(undefined);
}
var _local3 = getTimer() - m_startTime;
var _local2 = Math.max(0, (TIME_OUT_LENGTH - _local3) / 1000);
m_timeTextfield.text = (Math.round(_local2) + " ") + com.midasplayer.util.I18n.getString("sec");
if (_local2 <= 0) {
if (!m_isStarted) {
m_game.startSideQuiz();
m_isStarted = true;
removeMovieClip();
}
}
if ((!m_game.isPlayerReady()) && (_local3 > TIME_OUT_LENGTH)) {
endIntro();
}
}
function endIntro() {
m_startTime = m_startTime - TIME_OUT_LENGTH;
}
static var SymbolName = "Instructions";
static var TIME_OUT_LENGTH = 10000;
static var ANIMATION_LENGTH = 1.5;
var m_isStarted = false;
}
Symbol 274 MovieClip [__Packages.com.midasplayer.chesster.QuizSummary] Frame 0
class com.midasplayer.chesster.QuizSummary extends com.midasplayer.chesster.SquareEffectBase
{
var m_game, m_active, m_weed, attachMovie, getNextHighestDepth, m_playerTextfield, player_text, m_playerTimeTextfield, player_time, m_opponentTextfield, opponent_text, m_opponentTimeTextfield, opponent_time, m_chooseTextfield, choose_text, m_whiteButton, whiteButton, m_blackButton, blackButton, m_timeTextfield, time_text, createSquares, m_startTime, removeSquares, removeMovieClip;
function QuizSummary () {
super();
m_game = null;
m_active = false;
}
function init(game) {
m_game = game;
m_weed = attachMovie("WeedAppear", "weed", getNextHighestDepth());
m_playerTextfield = player_text;
m_playerTimeTextfield = player_time;
m_opponentTextfield = opponent_text;
m_opponentTimeTextfield = opponent_time;
m_playerTextfield.text = com.midasplayer.util.I18n.getString("your_time") + ":";
m_opponentTextfield.text = com.midasplayer.util.I18n.getString("opponent_time") + ":";
m_playerTimeTextfield.text = ((m_game.getPlayerQuizTime() / 1000) + " ") + com.midasplayer.util.I18n.getString("sec");
m_opponentTimeTextfield.text = com.midasplayer.util.I18n.getString("waiting") + "...";
m_chooseTextfield = choose_text;
m_chooseTextfield._visible = false;
m_whiteButton = whiteButton;
m_blackButton = blackButton;
m_whiteButton._visible = false;
m_blackButton._visible = false;
m_whiteButton.onPress = mx.utils.Delegate.create(this, whitePressed);
m_blackButton.onPress = mx.utils.Delegate.create(this, blackPressed);
m_timeTextfield = time_text;
m_timeTextfield._visible = false;
createSquares();
if (com.midasplayer.chesster.Game.LOCAL_GAME) {
m_game.setOpponentQuizTime(10000);
}
}
function isActive() {
return(m_active);
}
function setActive(active) {
m_active = active;
if (active && (m_startTime == undefined)) {
m_startTime = getTimer();
} else if (!active) {
m_startTime = undefined;
}
if (m_active) {
m_opponentTimeTextfield.text = ((m_game.getOpponentQuizTime() / 1000) + " ") + com.midasplayer.util.I18n.getString("sec");
var _local3 = m_game.getPlayerQuizTime();
var _local2 = m_game.getOpponentQuizTime();
if (_local3 < _local2) {
m_playerChoosing = true;
m_whiteButton._visible = true;
m_blackButton._visible = true;
m_timeTextfield._visible = true;
m_chooseTextfield.text = com.midasplayer.util.I18n.getString("player_choose");
m_chooseTextfield._visible = true;
} else if (_local2 < _local3) {
m_chooseTextfield.text = com.midasplayer.util.I18n.getString("opponent_choose");
m_chooseTextfield._visible = true;
} else if ((m_game.getPlayer().getPlayerNum() == 1) || (com.midasplayer.chesster.Game.LOCAL_GAME)) {
m_game.playerAssignSide(((com.midasplayer.util.Randomizer.randomRange(0, 1) == 0) ? (com.midasplayer.chesster.ChessBoard.WHITE) : (com.midasplayer.chesster.ChessBoard.BLACK)));
}
} else if (!m_active) {
m_startTime = getTimer();
m_playerTextfield._visible = false;
m_playerTimeTextfield._visible = false;
m_opponentTextfield._visible = false;
m_opponentTimeTextfield._visible = false;
m_chooseTextfield._visible = false;
m_whiteButton._visible = false;
m_blackButton._visible = false;
m_timeTextfield._visible = false;
m_weed.removeMovieClip();
m_weed = attachMovie("weedDisappear", "weed", getNextHighestDepth());
}
}
function onEnterFrame() {
var _local2 = getTimer() - m_startTime;
var _local3 = Math.max(0, (TIME_OUT_LENGTH - _local2) / 1000);
if (!m_active) {
if (m_game.arePlayersReady()) {
removeSquares();
if (_local2 >= START_GAME_DELAY) {
removeMovieClip();
}
}
return(undefined);
}
m_timeTextfield.text = (Math.round(_local3) + " ") + com.midasplayer.util.I18n.getString("sec");
if ((m_playerChoosing && (_local2 > TIME_OUT_LENGTH)) && (!m_game.isPlayerReady())) {
whitePressed();
}
}
function whitePressed() {
if (m_playerChoosing && (!m_game.isPlayerReady())) {
m_game.playerAssignSide(com.midasplayer.chesster.ChessBoard.WHITE);
}
}
function blackPressed() {
if (m_playerChoosing & (!m_game.isPlayerReady())) {
m_game.playerAssignSide(com.midasplayer.chesster.ChessBoard.BLACK);
}
}
static var SymbolName = "QuizSummary";
static var TIME_OUT_LENGTH = 5000;
static var START_GAME_DELAY = 1000;
var m_playerChoosing = false;
}
Symbol 275 MovieClip [__Packages.com.midasplayer.fx.TextObject] Frame 0
class com.midasplayer.fx.TextObject extends MovieClip
{
var m_textField, _x, _y, m_x, m_y, m_startTime, m_textString, m_life, m_part, removeMovieClip;
function TextObject () {
super();
m_textField = this[TEXT_FIELD_NAME];
}
function init(txt, x, y, life) {
if (x != undefined) {
_x = x;
}
if (y != undefined) {
_y = y;
}
m_x = _x;
m_y = _y;
m_startTime = getTimer();
m_textString = txt;
m_textField.text = m_textString;
if (life == undefined) {
life = DEFAULT_LIFE;
}
m_life = life * 1000;
}
function onEnterFrame() {
m_part = Math.min(1, (getTimer() - m_startTime) / m_life);
update();
if (m_part >= 1) {
removeMovieClip();
}
}
function update() {
}
static var SymbolName = "TextObject";
static var DEFAULT_LIFE = 10;
static var TEXT_FIELD_NAME = "textField";
}
Symbol 276 MovieClip [__Packages.com.midasplayer.fx.FadeText] Frame 0
class com.midasplayer.fx.FadeText extends com.midasplayer.fx.TextObject
{
var _y, m_part, m_y, _x, m_life, m_x, m_textField;
function FadeText () {
super();
}
function update() {
_y = m_y - (50 * m_part);
_x = m_x + ((Math.sin((((m_life / 1000) * m_part) * Math.PI) * 2) * 8) * m_part);
}
function init(txt, x, y, life) {
super.init(txt, x, y, life);
m_textField.selectable = false;
}
static var SymbolName = "FadeText";
}
Symbol 277 MovieClip [__Packages.com.midasplayer.chesster.Summary] Frame 0
class com.midasplayer.chesster.Summary extends MovieClip
{
var m_game, m_active, m_weed, attachMovie, getNextHighestDepth, m_instructionsTextfield, instructions_text;
function Summary () {
super();
m_game = null;
m_active = false;
}
function init(game) {
m_game = game;
m_weed = attachMovie("weedAppear", "weed", getNextHighestDepth());
m_instructionsTextfield = instructions_text;
}
static var SymbolName = "Summary";
static var TimeOutLength = 7000;
}
Symbol 278 MovieClip [__Packages.com.midasplayer.fx.ChatBubble] Frame 0
class com.midasplayer.fx.ChatBubble extends com.midasplayer.fx.TextObject
{
var m_textField, gotoAndStop;
function ChatBubble () {
super();
}
function update() {
}
function init(txt, x, y, life) {
txt = txt.substr(0, 100);
var _local6 = m_textField.getTextFormat();
var _local4 = _local6.getTextExtent(txt, m_textField._width);
var _local5 = Math.min(Math.ceil(_local4.textFieldHeight / HEIGHT_PER_FRAME), 4);
gotoAndStop(_local5);
m_textField = this[com.midasplayer.fx.TextObject.TEXT_FIELD_NAME];
super.init(txt, x, y, life);
}
static var SymbolName = "ChatBubble";
static var HEIGHT_PER_FRAME = 23;
static var NUM_FRAMES = 4;
}
Symbol 279 MovieClip [__Packages.com.midasplayer.chesster.MusicToggle] Frame 0
class com.midasplayer.chesster.MusicToggle extends MovieClip
{
var gotoAndStop, stop;
function MusicToggle () {
super();
}
function SoundToggle() {
}
function onEnterFrame() {
if (com.midasplayer.fx.SoundManager.isSoundEnabled("music")) {
gotoAndStop(SOUND_ENABLED_FRAME);
} else {
gotoAndStop(SOUND_DISABLED_FRAME);
}
stop();
}
function onRelease() {
if (com.midasplayer.fx.SoundManager.isSoundEnabled(com.midasplayer.chesster.Game.MUSIC_GROUP_NAME)) {
com.midasplayer.fx.SoundManager.enableSounds(false, com.midasplayer.chesster.Game.MUSIC_GROUP_NAME);
} else {
com.midasplayer.fx.SoundManager.enableSounds(true, com.midasplayer.chesster.Game.MUSIC_GROUP_NAME);
}
}
static var SymbolName = "MusicToggle";
static var SOUND_ENABLED_FRAME = 2;
static var SOUND_DISABLED_FRAME = 1;
}
Symbol 280 MovieClip [__Packages.com.midasplayer.chesster.SoundToggle] Frame 0
class com.midasplayer.chesster.SoundToggle extends MovieClip
{
var gotoAndStop, stop;
function SoundToggle () {
super();
}
function onEnterFrame() {
if (com.midasplayer.fx.SoundManager.isSoundEnabled()) {
gotoAndStop(SOUND_ENABLED_FRAME);
} else {
gotoAndStop(SOUND_DISABLED_FRAME);
}
stop();
}
function onRelease() {
if (com.midasplayer.fx.SoundManager.isSoundEnabled()) {
com.midasplayer.fx.SoundManager.enableSounds(false);
} else {
com.midasplayer.fx.SoundManager.enableSounds(true);
}
}
static var SymbolName = "SoundToggle";
static var SOUND_ENABLED_FRAME = 2;
static var SOUND_DISABLED_FRAME = 1;
}