Skip to content

Commit

Permalink
Allow bombing empty squares (fix #61)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcreedcmu committed Nov 21, 2023
1 parent 500c40d commit 6b842e7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 27 deletions.
7 changes: 1 addition & 6 deletions src/core/reduce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,7 @@ function getIntentOfMouseDown(tool: Tool, wp: WidgetPoint, button: number, mods:
return { t: 'vacuous' };
}
case 'bomb':
if (hoverTile || hoverBlock) {
return bombIntent;
}
else {
return { t: 'vacuous' };
}
return bombIntent;
}
}

Expand Down
37 changes: 16 additions & 21 deletions src/core/state-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,30 +93,25 @@ function killTileOfState(state: GameState, wp: DragWidgetPoint, radius: number,
return getOverlayLayer(state.coreState.bonusOverlay, getBonusLayer(), p) == 'block';
}

if (tileAt(p_in_world_int) || blockAt(p_in_world_int)) {
const tilesToDestroy: Point[] = splashDamage(p_in_world_int, radius);
// remove all tiles in radius
const tilesToDestroy: Point[] = splashDamage(p_in_world_int, radius);
// remove all tiles in radius
tilesToDestroy.forEach(p => {
const tileAtP = tileAt(p);
if (tileAtP !== undefined)
state = removeTile(state, tileAtP.id);
});
// remove all blocks in radius
state = produce(state, s => {
tilesToDestroy.forEach(p => {
const tileAtP = tileAt(p);
if (tileAtP !== undefined)
state = removeTile(state, tileAtP.id);
});
// remove all bonuses in radius
state = produce(state, s => {
tilesToDestroy.forEach(p => {
if (blockAt(p))
setOverlay(s.coreState.bonusOverlay, p, 'empty');
});
if (blockAt(p))
setOverlay(s.coreState.bonusOverlay, p, 'empty');
});
});

return checkValid(produce(state, s => {
s.coreState.score -= cost;
s.coreState.animations.push(anim);
}));
}
else {
return state;
}
return checkValid(produce(state, s => {
s.coreState.score -= cost;
s.coreState.animations.push(anim);
}));
}
case 'hand': {
const p_in_hand_int = vint(wp.p_in_local);
Expand Down

0 comments on commit 6b842e7

Please sign in to comment.