add readme and change some scripts
This commit is contained in:
parent
239c879649
commit
6474c2fd8c
15 changed files with 265 additions and 231 deletions
34
scripts/fix_tiles.ts
Normal file
34
scripts/fix_tiles.ts
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import GameCommon from '../src/common/GameCommon'
|
||||
import { logger } from '../src/common/Util'
|
||||
import GameStorage from '../src/server/GameStorage'
|
||||
|
||||
const log = logger('fix_tiles.js')
|
||||
|
||||
function fix_tiles(gameId) {
|
||||
GameStorage.loadGame(gameId)
|
||||
let changed = false
|
||||
const tiles = GameCommon.getTilesSortedByZIndex(gameId)
|
||||
for (let tile of tiles) {
|
||||
if (tile.owner === -1) {
|
||||
const p = GameCommon.getFinalTilePos(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)
|
||||
changed = true
|
||||
}
|
||||
} else if (tile.owner !== 0) {
|
||||
tile.owner = 0
|
||||
log.log('unowning tile', tile.idx)
|
||||
GameCommon.setTile(gameId, tile.idx, tile)
|
||||
changed = true
|
||||
}
|
||||
}
|
||||
if (changed) {
|
||||
GameStorage.persistGame(gameId)
|
||||
}
|
||||
}
|
||||
|
||||
fix_tiles(process.argv[2])
|
||||
Loading…
Add table
Add a link
Reference in a new issue