type hints galore!

This commit is contained in:
Zutatensuppe 2021-05-29 15:36:03 +02:00
parent 7b1f270587
commit 46f3fc7480
17 changed files with 700 additions and 667 deletions

View file

@ -7,22 +7,22 @@ const log = logger('fix_tiles.js')
function fix_tiles(gameId) {
GameStorage.loadGame(gameId)
let changed = false
const tiles = GameCommon.getTilesSortedByZIndex(gameId)
const tiles = GameCommon.getPiecesSortedByZIndex(gameId)
for (let tile of tiles) {
if (tile.owner === -1) {
const p = GameCommon.getFinalTilePos(gameId, tile.idx)
const p = GameCommon.getFinalPiecePos(gameId, tile.idx)
if (p.x === tile.pos.x && p.y === tile.pos.y) {
// log.log('all good', tile.pos)
} else {
log.log('bad tile pos', tile.pos, 'should be: ', p)
tile.pos = p
GameCommon.setTile(gameId, tile.idx, tile)
GameCommon.setPiece(gameId, tile.idx, tile)
changed = true
}
} else if (tile.owner !== 0) {
tile.owner = 0
log.log('unowning tile', tile.idx)
GameCommon.setTile(gameId, tile.idx, tile)
GameCommon.setPiece(gameId, tile.idx, tile)
changed = true
}
}