diff --git a/game/actions/aoe_attack.go b/game/actions/aoe_attack.go index 8584d708..f3f48592 100644 --- a/game/actions/aoe_attack.go +++ b/game/actions/aoe_attack.go @@ -327,7 +327,7 @@ func (a *AoeAttack) getTargetsAt(g *game.Game, tx, ty int) []*game.Entity { targets = append(targets, ent) } } - algorithm.Choose(&targets, func(e *game.Entity) bool { + algorithm.Choose2(&targets, func(e *game.Entity) bool { return e.Stats != nil }) diff --git a/game/entity.go b/game/entity.go index 21d56b29..52318869 100644 --- a/game/entity.go +++ b/game/entity.go @@ -660,7 +660,7 @@ func (e *Entity) SetGear(gear_name string) bool { return false } if gear_name == "" { - algorithm.Choose(&e.Actions, func(a Action) bool { + algorithm.Choose2(&e.Actions, func(a Action) bool { return a.String() != e.ExplorerEnt.Gear.Action }) if e.ExplorerEnt.Gear.Condition != "" { diff --git a/game/los.go b/game/los.go index feb09d5a..0b1e9027 100644 --- a/game/los.go +++ b/game/los.go @@ -470,7 +470,7 @@ func (g *Game) OnRound(do_scripts bool) { g.viewer.RemoveDrawable(g.Ents[i]) } } - algorithm.Choose(&g.Ents, func(ent *Entity) bool { + algorithm.Choose2(&g.Ents, func(ent *Entity) bool { return ent.Stats == nil || ent.Stats.HpCur() > 0 }) diff --git a/game/script.go b/game/script.go index 511103a3..2f2010bc 100644 --- a/game/script.go +++ b/game/script.go @@ -1592,7 +1592,7 @@ func setWaypoint(gp *GamePanel) lua.GoFunction { } wp.Name = L.ToString(-4) // Remove any existing waypoint by the same name - algorithm.Choose(&gp.game.Waypoints, func(w waypoint) bool { + algorithm.Choose2(&gp.game.Waypoints, func(w waypoint) bool { return w.Name != wp.Name }) px, py := LuaToPoint(L, -2) diff --git a/game/status/status.go b/game/status/status.go index f99f439e..3f15889a 100644 --- a/game/status/status.go +++ b/game/status/status.go @@ -215,7 +215,7 @@ func (s *Inst) ApplyCondition(c Condition) { } func (s *Inst) RemoveCondition(name string) { - algorithm.Choose(&s.inst.Conditions, func(c Condition) bool { + algorithm.Choose2(&s.inst.Conditions, func(c Condition) bool { return c.Name() != name }) } diff --git a/game/ui_entity_placer.go b/game/ui_entity_placer.go index a35dc906..cb651121 100644 --- a/game/ui_entity_placer.go +++ b/game/ui_entity_placer.go @@ -78,7 +78,7 @@ func MakeEntityPlacer(game *Game, roster_names []string, roster_costs []int, min ent := ep.ents[len(ep.ents)-1] ep.points += ep.roster[ent.Name] ep.ents = ep.ents[0 : len(ep.ents)-1] - algorithm.Choose(&game.Ents, func(e *Entity) bool { return e != ent }) + algorithm.Choose2(&game.Ents, func(e *Entity) bool { return e != ent }) game.viewer.RemoveDrawable(ent) } diff --git a/game/ui_online.go b/game/ui_online.go index 420c3e29..9678842a 100644 --- a/game/ui_online.go +++ b/game/ui_online.go @@ -372,7 +372,7 @@ func (sm *OnlineMenu) Think(g *gui.Gui, t int64) { sm.layout.Error.err = resp.Err base.Error().Printf("Couldn't kill game: %v", resp.Err) } else { - algorithm.Choose(&glb.games, func(gf gameField) bool { + algorithm.Choose2(&glb.games, func(gf gameField) bool { return gf.key != req.Game_key }) } diff --git a/house/furniture_tab.go b/house/furniture_tab.go index 48526624..ce5e1b74 100644 --- a/house/furniture_tab.go +++ b/house/furniture_tab.go @@ -104,7 +104,7 @@ func (w *FurniturePanel) onEscape() { *w.furniture = *w.prev_object w.prev_object = nil } else { - algorithm.Choose(&w.Room.Furniture, func(f *Furniture) bool { + algorithm.Choose2(&w.Room.Furniture, func(f *Furniture) bool { return f != w.furniture }) } @@ -128,7 +128,7 @@ func (w *FurniturePanel) Respond(ui *gui.Gui, group gui.EventGroup) bool { // If we hit delete then we want to remove the furniture we're moving around // from the room. If we're not moving anything around then nothing happens. if found, event := group.FindEvent(gin.DeleteOrBackspace); found && event.Type == gin.Press { - algorithm.Choose(&w.Room.Furniture, func(f *Furniture) bool { + algorithm.Choose2(&w.Room.Furniture, func(f *Furniture) bool { return f != w.furniture }) w.furniture = nil diff --git a/house/house.go b/house/house.go index e872affd..0693aa3a 100644 --- a/house/house.go +++ b/house/house.go @@ -485,7 +485,7 @@ func (f *Floor) canAddDoor(target *Room, door *Door) bool { func (f *Floor) removeInvalidDoors() { for _, room := range f.Rooms { - algorithm.Choose(&room.Doors, func(a interface{}) bool { + algorithm.Choose2(&room.Doors, func(a interface{}) bool { _, other_door := f.FindMatchingDoor(room, a.(*Door)) return other_door != nil && !other_door.temporary }) @@ -796,7 +796,7 @@ func (hdt *houseDataTab) onEscape() { *hdt.temp_room = *hdt.prev_room hdt.prev_room = nil } else { - algorithm.Choose(&hdt.house.Floors[0].Rooms, func(r *Room) bool { + algorithm.Choose2(&hdt.house.Floors[0].Rooms, func(r *Room) bool { return r != hdt.temp_room }) } @@ -819,10 +819,10 @@ func (hdt *houseDataTab) Respond(ui *gui.Gui, group gui.EventGroup) bool { for i := range hdt.temp_spawns { spawns[hdt.temp_spawns[i]] = true } - algorithm.Choose(&hdt.house.Floors[0].Spawns, func(s *SpawnPoint) bool { + algorithm.Choose2(&hdt.house.Floors[0].Spawns, func(s *SpawnPoint) bool { return !spawns[s] }) - algorithm.Choose(&hdt.house.Floors[0].Rooms, func(r *Room) bool { + algorithm.Choose2(&hdt.house.Floors[0].Rooms, func(r *Room) bool { return r != hdt.temp_room }) hdt.temp_room = nil @@ -930,7 +930,7 @@ func (hdt *houseDoorTab) Think(ui *gui.Gui, t int64) { func (hdt *houseDoorTab) onEscape() { if hdt.temp_door != nil { if hdt.temp_room != nil { - algorithm.Choose(&hdt.temp_room.Doors, func(d *Door) bool { + algorithm.Choose2(&hdt.temp_room.Doors, func(d *Door) bool { return d != hdt.temp_door }) } @@ -955,7 +955,7 @@ func (hdt *houseDoorTab) Respond(ui *gui.Gui, group gui.EventGroup) bool { } if found, event := group.FindEvent(gin.DeleteOrBackspace); found && event.Type == gin.Press { - algorithm.Choose(&hdt.temp_room.Doors, func(d *Door) bool { + algorithm.Choose2(&hdt.temp_room.Doors, func(d *Door) bool { return d != hdt.temp_door }) hdt.temp_room = nil @@ -973,7 +973,7 @@ func (hdt *houseDoorTab) Respond(ui *gui.Gui, group gui.EventGroup) bool { if cursor != nil && hdt.temp_door != nil { room := hdt.viewer.FindClosestDoorPos(hdt.temp_door, bx, by) if room != hdt.temp_room { - algorithm.Choose(&hdt.temp_room.Doors, func(d *Door) bool { + algorithm.Choose2(&hdt.temp_room.Doors, func(d *Door) bool { return d != hdt.temp_door }) hdt.temp_room = room @@ -1007,7 +1007,7 @@ func (hdt *houseDoorTab) Respond(ui *gui.Gui, group gui.EventGroup) bool { hdt.temp_door.temporary = true room, door := hdt.house.Floors[0].FindMatchingDoor(hdt.temp_room, hdt.temp_door) if room != nil { - algorithm.Choose(&room.Doors, func(d *Door) bool { + algorithm.Choose2(&room.Doors, func(d *Door) bool { return d != door }) } @@ -1080,7 +1080,7 @@ func (hdt *houseRelicsTab) onEscape() { *hdt.temp_relic = *hdt.prev_relic hdt.prev_relic = nil } else { - algorithm.Choose(&hdt.house.Floors[0].Spawns, func(s *SpawnPoint) bool { + algorithm.Choose2(&hdt.house.Floors[0].Spawns, func(s *SpawnPoint) bool { return s != hdt.temp_relic }) } @@ -1167,7 +1167,7 @@ func (hdt *houseRelicsTab) Respond(ui *gui.Gui, group gui.EventGroup) bool { } if found, event := group.FindEvent(gin.DeleteOrBackspace); found && event.Type == gin.Press { - algorithm.Choose(&hdt.house.Floors[0].Spawns, func(s *SpawnPoint) bool { + algorithm.Choose2(&hdt.house.Floors[0].Spawns, func(s *SpawnPoint) bool { return s != hdt.temp_relic }) hdt.temp_relic = nil diff --git a/house/house_viewer.go b/house/house_viewer.go index aa0f8df9..5af8dc5c 100644 --- a/house/house_viewer.go +++ b/house/house_viewer.go @@ -121,7 +121,7 @@ func (hv *HouseViewer) AddDrawable(d Drawable) { hv.drawables = append(hv.drawables, d) } func (hv *HouseViewer) RemoveDrawable(d Drawable) { - algorithm.Choose(&hv.drawables, func(t Drawable) bool { + algorithm.Choose2(&hv.drawables, func(t Drawable) bool { return t != d }) } @@ -133,7 +133,7 @@ func (hv *HouseViewer) AddFloorDrawable(fd FloorDrawer) { hv.floor_drawers = append(hv.floor_drawers, fd) } func (hv *HouseViewer) RemoveFloorDrawable(fd FloorDrawer) { - algorithm.Choose(&hv.floor_drawers, func(t FloorDrawer) bool { + algorithm.Choose2(&hv.floor_drawers, func(t FloorDrawer) bool { return t != fd }) } diff --git a/house/wall_tab.go b/house/wall_tab.go index 6490769a..5dfc8e1b 100644 --- a/house/wall_tab.go +++ b/house/wall_tab.go @@ -70,7 +70,7 @@ func (w *WallPanel) onEscape() { if w.prev_wall_texture != nil { *w.wall_texture = *w.prev_wall_texture } else { - algorithm.Choose(&w.room.WallTextures, func(wt *WallTexture) bool { + algorithm.Choose2(&w.room.WallTextures, func(wt *WallTexture) bool { return wt != w.wall_texture }) } @@ -85,7 +85,7 @@ func (w *WallPanel) Respond(ui *gui.Gui, group gui.EventGroup) bool { } if found, event := group.FindEvent(gin.DeleteOrBackspace); found && event.Type == gin.Press { - algorithm.Choose(&w.room.WallTextures, func(wt *WallTexture) bool { + algorithm.Choose2(&w.room.WallTextures, func(wt *WallTexture) bool { return wt != w.wall_texture }) w.wall_texture = nil