Skip to content

Commit

Permalink
store/lines: Do not allow to place towers in top of each other
Browse files Browse the repository at this point in the history
  • Loading branch information
xescugc committed Jun 12, 2024
1 parent 88bc344 commit 8860224
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Binary file modified server/assets/wasm/maze-wars.wasm
Binary file not shown.
8 changes: 5 additions & 3 deletions store/lines.go
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,6 @@ func (ls *Lines) Reduce(state, a interface{}) interface{} {
if !p.CanPlaceTower(act.PlaceTower.Type) {
break
}
p.Gold -= tower.Towers[act.PlaceTower.Type].Gold

var w, h int = 16 * 2, 16 * 2
tid := uuid.Must(uuid.NewV4())
Expand All @@ -609,9 +608,12 @@ func (ls *Lines) Reduce(state, a interface{}) interface{} {
tw.ID = tid.String()

l := lstate.Lines[p.LineID]
// TODO: Check this errors
_ = l.Graph.AddTower(tw.ID, act.PlaceTower.X, act.PlaceTower.Y, tw.W, tw.H)
err := l.Graph.AddTower(tw.ID, act.PlaceTower.X, act.PlaceTower.Y, tw.W, tw.H)
if err != nil {
break
}

p.Gold -= tower.Towers[act.PlaceTower.Type].Gold
l.Towers[tw.ID] = tw

ls.recalculateLineUnitStepsAndMove(lstate, p.LineID, noTowerID)
Expand Down

0 comments on commit 8860224

Please sign in to comment.