diff --git a/www/js/game.js b/www/js/game.js index a2ad7b4..3c53310 100644 --- a/www/js/game.js +++ b/www/js/game.js @@ -133,7 +133,7 @@ GAME.Play = class { }; GAME.GamePiece = class { - constructor(name, moves, promote_moves) { + constructor(name, moves, promote_moves=null) { this.name = name; this.moves = moves; this.pmoves = promote_moves; @@ -176,9 +176,10 @@ GAME.Piece = class { } moves() { + let def = GAME.Const.Piece[this.piece]; let moves = null; - if(this.promoted) { moves = GAME.Const.Piece[this.piece].pmoves; } - else { moves = GAME.Const.Piece[this.piece].moves; } + if(this.promoted && def.pmoves !== null) { moves = def.pmoves; } + else { moves = def.moves; } if(this.player == GAME.Const.Player.Dusk) { moves = moves.rotate(); } return moves; } @@ -627,6 +628,16 @@ GAME.Const = { new GAME.GamePiece( "Knight", new GAME.PieceMovement() + .add(17) + .add(12) + .add(17) + .add(18) + .add(23) + .add(25) + .add(26) + .add(28) + .add(29), + /*new GAME.PieceMovement() .add(12) .add(13) .add(14) @@ -638,23 +649,7 @@ GAME.Const = { .add(20) .add(21) .add(22) - .add(23), - new GAME.PieceMovement() - .add(1) - .add(3) - .add(5) - .add(12) - .add(13) - .add(14) - .add(15) - .add(16) - .add(17) - .add(18) - .add(19) - .add(20) - .add(21) - .add(22) - .add(23), + .add(23),*/ ), new GAME.GamePiece( "Tower", diff --git a/www/js/interface.js b/www/js/interface.js index f0ae86f..708ca65 100644 --- a/www/js/interface.js +++ b/www/js/interface.js @@ -589,14 +589,15 @@ const INTERFACE = { hints(piece) { let descriptor = GAME.Const.Piece[piece.piece]; - let moves = descriptor.moves; - if(piece.promoted) { moves = descriptor.pmoves; } - if(((piece.player ^ INTERFACE_DATA.player ^ INTERFACE_DATA.rotate) & 1) != 0) { moves = moves.rotate(); } + let moves = piece.moves(); + //if(((piece.player ^ INTERFACE_DATA.player ^ INTERFACE_DATA.rotate) & 1) != 0) { moves = moves.rotate(); } moves = moves.direction; for(let mask = BITWISE.lsb(moves); moves > 0; mask = BITWISE.lsb(moves)) { let move = BITWISE.ffs(mask); - if(move >= 12) { + if(move >= 24) { + move -= 24; + } else if(move >= 12) { move = Math.floor((move - 12) / 2) + 6; } @@ -763,6 +764,7 @@ const INTERFACE = { GAME.init(); INTERFACE_DATA.player = 0; INTERFACE_DATA.rotate = 0; + INTERFACE.draw(); }, message(code, data) {