engine/actions.js
/*
      Spread this move action over the ticks for this round
     */
Spread this move action over the ticks for this round
Spread this move action over the ticks for this round
prepareRound(resolver) {
        if (this.speed > resolver.ticksPerRound) {
            throw new Error("Can't move faster than the ticks per round");
        }
        if (this.speed === 0) {
            return;
        }
        const numCellsCovered = this.speed + 1;
        const ticksPerCell = Math.floor(resolver.ticksPerRound / numCellsCovered);
        this._ticksPerCell = ticksPerCell;
        const remainingTicks = resolver.ticksPerRound % numCellsCovered;
        for (let i = 1; i <= this.speed; i++) {
            let tick = i * ticksPerCell;
            resolver.subscribe(
                tick,
                this._tick.bind(this),
                this._preTick.bind(this),
                this._postTick.bind(this)
            );
        }
    }
prepareRound ( resolver ) { if ( this . speed > resolver . ticksPerRound ) { throw new Error ( "Can't move faster than the ticks per round" ) ; } if ( this . speed === 0 ) { return ; } const numCellsCovered = this . speed + 1 ; const ticksPerCell = Math . floor ( resolver . ticksPerRound / numCellsCovered ) ; this . _ticksPerCell = ticksPerCell ; const remainingTicks = resolver . ticksPerRound % numCellsCovered ; for ( let i = 1 ; i <= this . speed ; i ++ ) { let tick = i * ticksPerCell ; resolver . subscribe ( tick , this . _tick . bind ( this ) , this . _preTick . bind ( this ) , this . _postTick . bind ( this ) ) ; } }
Spread this move action over the ticks for this round
Spread this move action over the ticks for this round
// we're not moving at all, kind of lame // split the move into moves of 1 cell // spread these out over the available ticks // subscribe to the round resolver