aboutsummaryrefslogtreecommitdiff
path: root/go/game/cardImplementations.go
diff options
context:
space:
mode:
Diffstat (limited to 'go/game/cardImplementations.go')
-rw-r--r--go/game/cardImplementations.go54
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{},