diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2025-10-18 12:59:08 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-10-18 12:59:08 +0200 |
| commit | 2c2a2d84a92cda814e0e56d9408e6cbfd68c4fbb (patch) | |
| tree | 91f5f79807d1aee3993e965d72b6707dbbef77f2 /go/game/cardImplementations.go | |
| parent | 6a0013c62f24654529fd589a7de486bf1888a63b (diff) | |
| download | muhqs-game-2c2a2d84a92cda814e0e56d9408e6cbfd68c4fbb.tar.gz muhqs-game-2c2a2d84a92cda814e0e56d9408e6cbfd68c4fbb.zip | |
support phase change triggers and implement relic
Diffstat (limited to 'go/game/cardImplementations.go')
| -rw-r--r-- | go/game/cardImplementations.go | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/go/game/cardImplementations.go b/go/game/cardImplementations.go index 886bf3bb..fa7259a6 100644 --- a/go/game/cardImplementations.go +++ b/go/game/cardImplementations.go @@ -247,6 +247,59 @@ func (*poisonDaggerImpl) onPile(p Permanent) { func (*poisonDaggerImpl) onUnpile(p Permanent) { } +type relicImpl struct{ cardImplementationBase } + +func (*relicImpl) onETB(s *LocalState, p Permanent) { + t := newUpkeepTrigger( + p, + func(*LocalState, Event) bool { return p.IsDestroyed() }, + func(*LocalState, Event) bool { + controlled := make(map[*Player]int) + for _, t := range AdjacentTiles(p) { + if t.Permanent == nil { + continue + } + if _, found := controlled[t.Permanent.Controller()]; found { + controlled[t.Permanent.Controller()] += 1 + } else { + controlled[t.Permanent.Controller()] = 1 + } + } + return len(controlled) > 0 + }, + func(*LocalState, Event) ActionResolveFunc { + return func(*LocalState) { + controlled := make(map[*Player]int) + for _, t := range AdjacentTiles(p) { + if t.Permanent == nil { + continue + } + if _, found := controlled[t.Permanent.Controller()]; found { + controlled[t.Permanent.Controller()] += 1 + } else { + controlled[t.Permanent.Controller()] = 1 + } + } + // Find maximum amount of units around relic + max := 0 + for _, c := range controlled { + if c > max { + max = c + } + } + // Each player controlling the most units gain 1 resource + for p, c := range controlled { + if c == max { + p.gainResource(1) + } + } + } + }, + "relic gain", + ) + s.addTrigger(t) +} + type spearImpl struct{ cardImplementationBase } func (*spearImpl) onPile(p Permanent) { @@ -914,6 +967,7 @@ func init() { "equipments/banner": &bannerImpl{aoe: bannerAoE}, "equipments/mace": &maceImpl{triggers: make(map[Permanent]Trigger)}, "equipments/poison_dagger": &poisonDaggerImpl{}, + "equipments/relic": &relicImpl{}, "equipments/spear": &spearImpl{}, "magic/appear!": &appearImpl{}, |
