Frame 1
fscommand ("showmenu", false);
_root.best = 0;
_root.sunet = 1;
stop();
logo.onEnterFrame = function () {
if (_root.getBytesLoaded() == _root.getBytesTotal()) {
this.play();
} else {
tgFrame = Math.round((_root.getBytesLoaded() / _root.getBytesTotal()) * 100);
this.progress.gotoAndStop(tgFrame);
}
};
Frame 2
stop();
son1 = new Sound();
son1.attachSound("shot1");
son1.setVolume(80);
Frame 3
activePiece = new Array();
locVect = new Array();
crowned = new Array();
crowned2 = new Array();
_root.flin = 0;
_root.fcol = 0;
activePiece[1] = null;
activePiece[2] = null;
_root.computerScore = 12;
_root.playerScore = 12;
i = 1;
while (i <= 12) {
crowned[i] = 0;
i++;
}
i = 1;
while (i <= 12) {
crowned2[i] = 0;
i++;
}
kxxxx = 0;
this.verifOverComp = function () {
okx = 1;
i = 1;
while (i <= 12) {
linie = Math.round(((_root["c" + i]._y - 50) / 40) + 1);
coloana = Math.round(((_root["c" + i]._x - 50) / 40) + 1);
valo = computerMoveValue(linie, coloana);
if (valo > 0) {
okx = 0;
}
i++;
}
return(okx);
};
this.verifOverPlayer = function () {
okx = 1;
i = 1;
while (i <= 12) {
linie = Math.round(((_root["p" + i]._y - 50) / 40) + 1);
coloana = Math.round(((_root["p" + i]._x - 50) / 40) + 1);
valo = playerMoveValue(linie, coloana);
if (valo > 0) {
okx = 0;
}
i++;
}
return(okx);
};
this.computerMove = function () {
valMax = 0;
linStart = 0;
colStart = 0;
linDest = 0;
colDest = 0;
kx = 1;
if (_root.sunet == 1) {
_root.son1.start();
}
i = 1;
while (i <= 12) {
locVect[i] = -1;
i++;
}
while (kx < 13) {
ran = random(12) + 1;
okie = true;
i = 1;
while (i <= 12) {
if (ran == locVect[i]) {
okie = false;
}
i++;
}
if (okie) {
locVect[kx] = ran;
kx++;
}
}
i = 1;
while (i <= 12) {
kxx = locVect[i];
linie = Math.round(((_root["c" + kxx]._y - 50) / 40) + 1);
coloana = Math.round(((_root["c" + kxx]._x - 50) / 40) + 1);
valoare = computerMoveValue(linie, coloana);
if (valoare > valMax) {
valMax = valoare;
linStart = linie;
colStart = coloana;
linDest = _root.flin;
colDest = _root.fcol;
}
i++;
}
piece2 = matPosC[linStart][colStart];
moveY = (linDest - linStart) * 40;
moveX = (colDest - colStart) * 40;
_root[(("sq" + linStart) + "") + colStart].play();
_root[(("sq" + linDest) + "") + colDest].play();
_root["c" + piece2]._x = _root["c" + piece2]._x + moveX;
_root["c" + piece2]._y = _root["c" + piece2]._y + moveY;
if (linDest == 1) {
_root["c" + piece2].gotoAndStop(2);
_root.crowned2[piece2] = 1;
}
matPosC[linDest][colDest] = matPosC[linStart][colStart];
matPosC[linStart][colStart] = 0;
if (valMax == 4) {
piece3 = matPosP[(linDest + linStart) / 2][(colDest + colStart) / 2];
_root["p" + piece3]._x = -1000;
matPosP[(linDest + linStart) / 2][(colDest + colStart) / 2] = 0;
_root.playerScore--;
if (_root.playerScore == 0) {
_root.gOver.play();
_root.gOver.msg.text = "You lose!";
}
plScore1.text = _root.playerScore;
plScore2.text = _root.playerScore;
valoare2 = computerMoveValue(lindest, coldest);
if (valoare2 == 4) {
linie = Math.round(((_root["c" + piece2]._y - 50) / 40) + 1);
coloana = Math.round(((_root["c" + piece2]._x - 50) / 40) + 1);
linStart = linie;
colStart = coloana;
linDest = _root.flin;
colDest = _root.fcol;
moveY = (linDest - linStart) * 40;
moveX = (colDest - colStart) * 40;
_root[(("sq" + linStart) + "") + colStart].play();
_root[(("sq" + linDest) + "") + colDest].play();
_root["c" + piece2]._x = _root["c" + piece2]._x + moveX;
_root["c" + piece2]._y = _root["c" + piece2]._y + moveY;
if (linDest == 1) {
_root["c" + piece2].gotoAndStop(2);
_root.crowned2[piece2] = 1;
}
matPosC[linDest][colDest] = matPosC[linStart][colStart];
matPosC[linStart][colStart] = 0;
piece3 = matPosP[(linDest + linStart) / 2][(colDest + colStart) / 2];
_root["p" + piece3]._x = -1000;
matPosP[(linDest + linStart) / 2][(colDest + colStart) / 2] = 0;
_root.playerScore--;
if (_root.playerScore == 0) {
_root.gOver.play();
_root.gOver.msg.text = "You lose!";
}
plScore1.text = _root.playerScore;
plScore2.text = _root.playerScore;
}
valoare2 = computerMoveValue(lindest, coldest);
if (valoare2 == 4) {
linie = Math.round(((_root["c" + piece2]._y - 50) / 40) + 1);
coloana = Math.round(((_root["c" + piece2]._x - 50) / 40) + 1);
linStart = linie;
colStart = coloana;
linDest = _root.flin;
colDest = _root.fcol;
moveY = (linDest - linStart) * 40;
moveX = (colDest - colStart) * 40;
_root[(("sq" + linStart) + "") + colStart].play();
_root[(("sq" + linDest) + "") + colDest].play();
_root["c" + piece2]._x = _root["c" + piece2]._x + moveX;
_root["c" + piece2]._y = _root["c" + piece2]._y + moveY;
if (linDest == 1) {
_root["c" + piece2].gotoAndStop(2);
_root.crowned2[piece2] = 1;
}
matPosC[linDest][colDest] = matPosC[linStart][colStart];
matPosC[linStart][colStart] = 0;
piece3 = matPosP[(linDest + linStart) / 2][(colDest + colStart) / 2];
_root["p" + piece3]._x = -1000;
matPosP[(linDest + linStart) / 2][(colDest + colStart) / 2] = 0;
_root.playerScore--;
if (_root.playerScore == 0) {
_root.gOver.play();
_root.gOver.msg.text = "You lose!";
}
plScore1.text = _root.playerScore;
plScore2.text = _root.playerScore;
}
}
if (verifOverComp() == 1) {
_root.gOver.play();
_root.gOver.msg.text = "You win!";
}
if (verifOverPlayer() == 1) {
_root.gOver.play();
_root.gOver.msg.text = "You lose!";
}
};
this.computerMoveValue = function (ilin, icol) {
val = 0;
_root.flin = 0;
_root.fcol = 0;
piece4 = matPosC[ilin][icol];
if (_root.crowned2[piece4] == 1) {
if ((matPosP[ilin + 1][icol + 1] == 0) && (matPosC[ilin + 1][icol + 1] == 0)) {
val = 1;
_root.flin = ilin + 1;
_root.fcol = icol + 1;
}
if ((matPosP[ilin + 1][icol - 1] == 0) && (matPosC[ilin + 1][icol - 1] == 0)) {
val = 1;
_root.flin = ilin + 1;
_root.fcol = icol - 1;
}
}
if ((matPosP[ilin - 1][icol + 1] == 0) && (matPosC[ilin - 1][icol + 1] == 0)) {
val = 1;
_root.flin = ilin - 1;
_root.fcol = icol + 1;
}
if ((matPosP[ilin - 1][icol - 1] == 0) && (matPosC[ilin - 1][icol - 1] == 0)) {
val = 1;
_root.flin = ilin - 1;
_root.fcol = icol - 1;
}
if (_root.crowned2[piece4] == 1) {
if ((matPosP[ilin + 2][icol + 2] == 0) && (matPosP[ilin + 2][icol] == 0)) {
if ((matPosP[ilin + 1][icol + 1] == 0) && (matPosC[ilin + 1][icol + 1] == 0)) {
val = 2;
_root.flin = ilin + 1;
_root.fcol = icol + 1;
}
}
if ((matPosP[ilin + 2][icol - 2] == 0) && (matPosP[ilin + 2][icol] == 0)) {
if ((matPosP[ilin + 1][icol - 1] == 0) && (matPosC[ilin + 1][icol - 1] == 0)) {
val = 2;
_root.flin = ilin + 1;
_root.fcol = icol - 1;
}
}
}
if ((matPosP[ilin - 2][icol + 2] == 0) && (matPosP[ilin - 2][icol] == 0)) {
if ((matPosP[ilin - 1][icol + 1] == 0) && (matPosC[ilin - 1][icol + 1] == 0)) {
val = 2;
_root.flin = ilin - 1;
_root.fcol = icol + 1;
}
}
if ((matPosP[ilin - 2][icol - 2] == 0) && (matPosP[ilin - 2][icol] == 0)) {
if ((matPosP[ilin - 1][icol - 1] == 0) && (matPosC[ilin - 1][icol - 1] == 0)) {
val = 2;
_root.flin = ilin - 1;
_root.fcol = icol - 1;
}
}
if (_root.crowned2[piece4] == 1) {
if ((matPosC[ilin + 2][icol + 2] != 0) && (matPosP[ilin + 3][icol + 3] != 0)) {
if ((matPosC[ilin + 1][icol + 1] == 0) && (matPosP[ilin + 1][icol + 1] == 0)) {
val = 3;
_root.flin = ilin + 1;
_root.fcol = icol + 1;
}
}
if ((matPosC[ilin + 2][icol - 2] != 0) && (matPosP[ilin + 3][icol - 3] != 0)) {
if ((matPosC[ilin + 1][icol - 1] == 0) && (matPosP[ilin + 1][icol - 1] == 0)) {
val = 3;
_root.flin = ilin + 1;
_root.fcol = icol - 1;
}
}
}
if ((matPosC[ilin - 2][icol + 2] != 0) && (matPosP[ilin - 3][icol + 3] != 0)) {
if ((matPosC[ilin - 1][icol + 1] == 0) && (matPosP[ilin - 1][icol + 1] == 0)) {
val = 3;
_root.flin = ilin - 1;
_root.fcol = icol + 1;
}
}
if ((matPosC[ilin - 2][icol - 2] != 0) && (matPosP[ilin - 3][icol - 3] != 0)) {
if ((matPosC[ilin - 1][icol - 1] == 0) && (matPosP[ilin - 1][icol - 1] == 0)) {
val = 3;
_root.flin = ilin - 1;
_root.fcol = icol - 1;
}
}
if (_root.crowned2[piece4] == 1) {
if (matPosP[ilin + 1][icol + 1] != 0) {
if ((matPosP[ilin + 2][icol + 2] == 0) && (matPosC[ilin + 2][icol + 2] == 0)) {
val = 4;
_root.flin = ilin + 2;
_root.fcol = icol + 2;
}
}
if (matPosP[ilin + 1][icol - 1] != 0) {
if ((matPosP[ilin + 2][icol - 2] == 0) && (matPosC[ilin + 2][icol - 2] == 0)) {
val = 4;
_root.flin = ilin + 2;
_root.fcol = icol - 2;
}
}
}
if (matPosP[ilin - 1][icol + 1] != 0) {
if ((matPosP[ilin - 2][icol + 2] == 0) && (matPosC[ilin - 2][icol + 2] == 0)) {
val = 4;
_root.flin = ilin - 2;
_root.fcol = icol + 2;
}
}
if (matPosP[ilin - 1][icol - 1] != 0) {
if ((matPosP[ilin - 2][icol - 2] == 0) && (matPosC[ilin - 2][icol - 2] == 0)) {
val = 4;
_root.flin = ilin - 2;
_root.fcol = icol - 2;
}
}
return(val);
};
this.playerMoveValue = function (ilin, icol) {
val2 = 0;
piece6 = matPosP[ilin][icol];
if ((matPosP[ilin + 1][icol + 1] == 0) && (matPosP[ilin + 1][icol + 1] == 0)) {
val2 = 1;
}
if ((matPosC[ilin + 1][icol - 1] == 0) && (matPosP[ilin + 1][icol - 1] == 0)) {
val2 = 1;
}
if (_root.crowned[piece6] == 1) {
if ((matPosC[ilin - 1][icol + 1] == 0) && (matPosP[ilin - 1][icol + 1] == 0)) {
val2 = 1;
}
if ((matPosC[ilin - 1][icol - 1] == 0) && (matPosP[ilin - 1][icol - 1] == 0)) {
val2 = 1;
}
}
if ((matPosC[ilin + 2][icol + 2] == 0) && (matPosC[ilin + 2][icol] == 0)) {
if ((matPosC[ilin + 1][icol + 1] == 0) && (matPosP[ilin + 1][icol + 1] == 0)) {
val2 = 2;
}
}
if ((matPosC[ilin + 2][icol - 2] == 0) && (matPosC[ilin + 2][icol] == 0)) {
if ((matPosC[ilin + 1][icol - 1] == 0) && (matPosP[ilin + 1][icol - 1] == 0)) {
val2 = 2;
}
}
if (_root.crowned[piece6] == 1) {
if ((matPosC[ilin - 2][icol + 2] == 0) && (matPosC[ilin - 2][icol] == 0)) {
if ((matPosC[ilin - 1][icol + 1] == 0) && (matPosP[ilin - 1][icol + 1] == 0)) {
val = 2;
}
}
if ((matPosC[ilin - 2][icol - 2] == 0) && (matPosC[ilin - 2][icol] == 0)) {
if ((matPosC[ilin - 1][icol - 1] == 0) && (matPosP[ilin - 1][icol - 1] == 0)) {
val2 = 2;
}
}
}
if ((matPosP[ilin + 2][icol + 2] != 0) && (matPosC[ilin + 3][icol + 3] != 0)) {
if ((matPosP[ilin + 1][icol + 1] == 0) && (matPosC[ilin + 1][icol + 1] == 0)) {
val2 = 3;
}
}
if ((matPosP[ilin + 2][icol - 2] != 0) && (matPosC[ilin + 3][icol - 3] != 0)) {
if ((matPosP[ilin + 1][icol - 1] == 0) && (matPosC[ilin + 1][icol - 1] == 0)) {
val2 = 3;
}
}
if (_root.crowned[piece6] == 1) {
if ((matPosP[ilin - 2][icol + 2] != 0) && (matPosC[ilin - 3][icol + 3] != 0)) {
if ((matPosP[ilin - 1][icol + 1] == 0) && (matPosC[ilin - 1][icol + 1] == 0)) {
val2 = 3;
}
}
if ((matPosP[ilin - 2][icol - 2] != 0) && (matPosC[ilin - 3][icol - 3] != 0)) {
if ((matPosP[ilin - 1][icol - 1] == 0) && (matPosC[ilin - 1][icol - 1] == 0)) {
val2 = 3;
}
}
}
if ((matPosC[ilin + 1][icol + 1] != 0) && (matPosC[ilin + 1][icol + 1] != null)) {
if ((matPosC[ilin + 2][icol + 2] == 0) && (matPosP[ilin + 2][icol + 2] == 0)) {
val2 = 4;
}
}
if ((matPosC[ilin + 1][icol - 1] != 0) && (matPosC[ilin + 1][icol - 1] != null)) {
if ((matPosC[ilin + 2][icol - 2] == 0) && (matPosP[ilin + 2][icol - 2] == 0)) {
val2 = 4;
}
}
if (_root.crowned[piece6] == 1) {
if ((matPosC[ilin - 1][icol + 1] != 0) && (matPosC[ilin - 1][icol + 1] != null)) {
if ((matPosC[ilin - 2][icol + 2] == 0) && (matPosP[ilin - 2][icol + 2] == 0)) {
val2 = 4;
}
}
if ((matPosC[ilin - 1][icol - 1] != 0) && (matPosC[ilin - 1][icol - 1] != null)) {
if ((matPosC[ilin - 2][icol - 2] == 0) && (matPosP[ilin - 2][icol - 2] == 0)) {
val2 = 4;
}
}
}
return(val2);
};
this.movePiece = function (xini, yini, xfin, yfin) {
aux1 = matPosP[xini][yini];
_root["p" + aux1]._x = xfin;
_root["p" + aux1]._y = yfin;
_root["p" + aux1]._alpha = 100;
aux3 = _root.activePiece[1];
aux4 = _root.activePiece[2];
SqXPos = Math.round(((yfin - 50) / 40) + 1);
SqYPos = Math.round(((xfin - 50) / 40) + 1);
if (SqXPos == 8) {
_root["p" + aux1].gotoAndStop(2);
_root.crowned[aux1] = 1;
}
if (Math.abs(SqXPos - aux3) == 2) {
auxlin = (SqXPos + aux3) / 2;
auxcol = (SqYPos + aux4) / 2;
auxPiece = matPosC[auxlin][auxcol];
_root["c" + auxPiece]._x = -1000;
matPosC[auxlin][auxcol] = 0;
_root.computerScore--;
if (_root.computerScore == 0) {
_root.gOver.play();
_root.gOver.msg.text = "You win!";
}
computerScore1.text = _root.computerScore;
computerScore2.text = _root.computerScore;
}
_root.matPosP[SqXPos][SqYPos] = _root.matPosP[aux3][aux4];
_root.matPosP[aux3][aux4] = 0;
activePiece[1] = null;
activePiece[2] = null;
};
this.validMove = function (xini, yini, xfin, yfin) {
ok = true;
piece1 = matPosP[xini][yini];
if (kxxxx == 1) {
if (Math.abs(xini - xfin) != 2) {
ok = false;
}
}
if (((Math.abs(xini - xfin) + Math.abs(yini - yfin)) != 2) && ((Math.abs(xini - xfin) + Math.abs(yini - yfin)) != 4)) {
ok = false;
}
if (Math.abs(xini - xfin) == 0) {
ok = false;
}
if (Math.abs(yini - yfin) == 0) {
ok = false;
}
if ((Math.abs(xini - xfin) + Math.abs(yini - yfin)) == 4) {
if (matPosC[(xini + xfin) / 2][(yini + yfin) / 2] == 0) {
ok = false;
}
}
if ((crowned[piece1] == 0) && ((xini - xfin) > 0)) {
ok = false;
}
if (matPosC[xfin][yfin] != 0) {
ok = false;
}
if (matPosP[xfin][yfin] != 0) {
ok = false;
}
if (ok == false) {
aux2 = matPosP[xini][yini];
if (_root.kxxxx == 0) {
_root["p" + aux2]._alpha = 100;
activePiece[1] = null;
activePiece[2] = null;
}
}
return(ok);
};
this.initMatPosP = function () {
matPosP = new Array();
i = 1;
while (i <= 8) {
matPosP[i] = new Array();
i++;
}
i = 1;
while (i <= 8) {
j = 1;
while (j <= 8) {
matPosP[i][j] = 0;
j++;
}
i++;
}
matPosP[1][1] = 1;
matPosP[1][3] = 2;
matPosP[1][5] = 3;
matPosP[1][7] = 4;
matPosP[2][2] = 5;
matPosP[2][4] = 6;
matPosP[2][6] = 7;
matPosP[2][8] = 8;
matPosP[3][1] = 9;
matPosP[3][3] = 10;
matPosP[3][5] = 11;
matPosP[3][7] = 12;
};
this.initMatPosC = function () {
matPosC = new Array();
i = 0;
while (i <= 9) {
matPosC[i] = new Array();
i++;
}
i = 0;
while (i <= 9) {
j = 0;
while (j <= 9) {
matPosC[i][j] = 0;
j++;
}
i++;
}
matPosC[8][2] = 1;
matPosC[8][4] = 2;
matPosC[8][6] = 3;
matPosC[8][8] = 4;
matPosC[7][1] = 5;
matPosC[7][3] = 6;
matPosC[7][5] = 7;
matPosC[7][7] = 8;
matPosC[6][2] = 9;
matPosC[6][4] = 10;
matPosC[6][6] = 11;
matPosC[6][8] = 12;
};
stop();
initMatPosP();
initMatPosC();
computerMove();
Symbol 10 MovieClip Frame 1
stop();
Symbol 14 MovieClip Frame 63
stop();
Symbol 14 MovieClip Frame 272
_root.gotoAndStop(2);
Symbol 19 Button
on (release) {
_root.gotoAndStop(3);
}
Symbol 23 Button
on (release) {
if (_root.sunet == 0) {
_root.sunet = 1;
_root.son.start(0, 100);
} else {
_root.sunet = 0;
_root.son.stop();
}
}
Symbol 59 MovieClip Frame 1
stop();
this.onRelease = function () {
SqXPos = Math.round(((this._y - 50) / 40) + 1);
SqYPos = Math.round(((this._x - 50) / 40) + 1);
piecex = _root.matPosP[_root.activePiece[1]][_root.activePiece[2]];
xStart = _root.activePiece[1];
yStart = _root.activePiece[2];
if (_root.activePiece[1] != null) {
if (_root.validMove(_root.activePiece[1], _root.activePiece[2], SqXPos, SqYPos)) {
valxxx = _root.playerMoveValue(xStart, yStart);
_root.movePiece(_root.activePiece[1], _root.activePiece[2], this._x, this._y);
if ((_root.playerMoveValue(SqXPos, SqYPos) == 4) && (valxxx == 4)) {
_root["p" + piecex]._alpha = 70;
_root.activePiece[1] = SqXPos;
_root.activePiece[2] = SqYPos;
_root.kxxxx = 1;
} else {
if (verifOverComp() == 1) {
_root.gOver.play();
_root.gOver.msg.text = "You win!";
}
if (verifOverPlayer() == 1) {
_root.gOver.play();
_root.gOver.msg.text = "You lose!";
}
_root.kxxxx = 0;
_root.computerMove();
}
}
}
};
Symbol 62 MovieClip Frame 1
stop();
this.onRelease = function () {
if (_root.kxxxx == 0) {
if (_root.activePiece[1] == null) {
this._alpha = 30;
PXPos = Math.round(((this._y - 50) / 40) + 1);
PYPos = Math.round(((this._x - 50) / 40) + 1);
_root.activePiece[1] = PXPos;
_root.activePiece[2] = PYPos;
}
}
};
Symbol 62 MovieClip Frame 2
stop();
Symbol 65 MovieClip Frame 1
stop();
Symbol 65 MovieClip Frame 2
stop();
Symbol 79 Button
on (release) {
_root.gotoAndStop(2);
}
Symbol 80 MovieClip Frame 1
stop();
Symbol 80 MovieClip Frame 2
stop();
Symbol 82 Button
on (release) {
_root.gotoAndStop(2);
}
Symbol 86 MovieClip Frame 1
stop();
this.movX1 = null;
this.movX1 = null;
this.piece3 = null;
Symbol 86 MovieClip Frame 2
_root["c" + piece3]._x = _root["c" + piece3]._x + moveX1;
_root["c" + piece3]._y = _root["c" + piece3]._y + moveY1;
Symbol 86 MovieClip Frame 7
_root["c" + piece3]._x = _root["c" + piece3]._x + moveX1;
_root["c" + piece3]._y = _root["c" + piece3]._y + moveY1;
Symbol 86 MovieClip Frame 12
_root["c" + piece3]._x = _root["c" + piece3]._x + moveX1;
_root["c" + piece3]._y = _root["c" + piece3]._y + moveY1;
Symbol 86 MovieClip Frame 17
_root["c" + piece3]._x = _root["c" + piece3]._x + moveX1;
_root["c" + piece3]._y = _root["c" + piece3]._y + moveY1;