package game type areaEffect interface { onEntering(Permanent) onLeaving(Permanent) } type dynamicAreaEffect struct { _onEntering func(Permanent) _onLeaving func(Permanent) } func newDynamicAreaEffect(enter func(Permanent), leave func(Permanent)) *dynamicAreaEffect { return &dynamicAreaEffect{enter, leave} } func (e *dynamicAreaEffect) onEntering(p Permanent) { if e._onEntering != nil { e._onEntering(p) } } func (e *dynamicAreaEffect) onLeaving(p Permanent) { if e._onLeaving != nil { e._onLeaving(p) } } func newGrantFullActionEffect(cardPath string, f ActionFuncPrototype, desc, tag string, ) *dynamicAreaEffect { onEntering := func(p Permanent) { if p.Card().Path() != cardPath { return } u := p.(*Unit) fa := newFullAction(u, f, desc) fa.tag = tag u.FullActions = append(u.FullActions, fa) } onLeaving := func(p Permanent) { if p.Card().Path() != cardPath { return } u := p.(*Unit) u.removeFullAction(tag) } return newDynamicAreaEffect(onEntering, onLeaving) }