diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2023-02-20 21:13:47 +0100 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-01-27 16:43:51 +0100 |
| commit | 74ae4f091755544906bb2bb38bd360cc4d7b6237 (patch) | |
| tree | 01dc6ae303daaa671edbc2223091a5ffb64e6f1e /go/game/unit.go | |
| parent | 14f7b0274a20ffc8189d18de5031defcc15e9890 (diff) | |
| download | muhqs-game-74ae4f091755544906bb2bb38bd360cc4d7b6237.tar.gz muhqs-game-74ae4f091755544906bb2bb38bd360cc4d7b6237.zip | |
implement equip action
Diffstat (limited to 'go/game/unit.go')
| -rw-r--r-- | go/game/unit.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/go/game/unit.go b/go/game/unit.go index 5b071d7b..99c7c28d 100644 --- a/go/game/unit.go +++ b/go/game/unit.go @@ -200,6 +200,24 @@ func (u *Unit) AvailSlowActions() (actions []Action) { } } + if u.AvailAttackActions > 0 || u.AvailMoveActions > 0 { + for _, tile := range TilesInRange(m, u, 1) { + if tile.Permanent == nil { + continue + } + + if equipment, ok := tile.Permanent.(*Equipment); ok { + actions = append(actions, NewEquipAction(u, equipment)) + } + + for _, perm := range tile.Permanent.Pile() { + if equipment, ok := perm.(*Equipment); ok { + actions = append(actions, NewEquipAction(u, equipment)) + } + } + } + } + return actions } @@ -278,3 +296,12 @@ func (u *Unit) addDamage(damage int) { u.permanentBase.addDamage(damage) } + +func (u *Unit) equip(e *Equipment) { + if e.containingPerm != nil { + removePermanentFromPile(e.containingPerm, e) + } else { + leaveTile(e) + } + addPermanentToPile(u, e) +} |
