adds player change support
parent
c3d0a69148
commit
3ead03ef72
@ -1,8 +1,23 @@
|
||||
import {type as T} from './def'
|
||||
export default class PlayerChanges {
|
||||
constructor () {
|
||||
this.changes = {}
|
||||
}
|
||||
|
||||
getKey (level, column) {
|
||||
return `${column}.${level}`
|
||||
}
|
||||
|
||||
apply (level, column, newBlock) {
|
||||
const key = this.getKey(level, column)
|
||||
this.changes[key] = newBlock
|
||||
console.log('applied', level, column, newBlock, this.changes)
|
||||
}
|
||||
|
||||
export default class Player {
|
||||
constructor (grid) {
|
||||
this._player_changes = []
|
||||
this._grid = grid
|
||||
level (level, column, row) {
|
||||
for (let i = 0; i < row.length; i++) {
|
||||
const key = this.getKey(level - 1, column + i)
|
||||
const change = this.changes[key]
|
||||
if (change) row[i] = change
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue