diff options
| -rw-r--r-- | go/game/cardImplementations.go | 15 | ||||
| -rw-r--r-- | go/game/cardImplementations_test.go | 29 |
2 files changed, 44 insertions, 0 deletions
diff --git a/go/game/cardImplementations.go b/go/game/cardImplementations.go index 478e1681..926a3cad 100644 --- a/go/game/cardImplementations.go +++ b/go/game/cardImplementations.go @@ -794,6 +794,20 @@ func (*patricianImpl) freeActions(p Permanent) []*FreeAction { return []*FreeAction{m, a, ar, d, r} } +type recycleImpl struct{ cardImplementationBase } + +func (*recycleImpl) playTargets() TargetDesc { + return TargetDesc{"cards from your discard pile", "0-2"} +} + +func (*recycleImpl) onPlay(a *PlayAction) { + p := a.Controller() + cards := a.Target().Selection() + for _, card := range cards { + p.DiscardPile.MoveCard(card.(*Card), p.Hand) + } +} + func init() { cardImplementations = map[string]cardImplementation{ "base/advisor": &advisorImpl{}, @@ -845,5 +859,6 @@ func init() { "exp1/illusion": &illusionImpl{}, "exp1/illusionist": &illusionistImpl{}, "exp1/patrician": &patricianImpl{}, + "exp1/recycle!": &recycleImpl{}, } } diff --git a/go/game/cardImplementations_test.go b/go/game/cardImplementations_test.go index 7f0c2878..f75e4d80 100644 --- a/go/game/cardImplementations_test.go +++ b/go/game/cardImplementations_test.go @@ -296,3 +296,32 @@ func TestPatrician(t *testing.T) { t.Fatal("patrician has no armor") } } + +func TestRecycle(t *testing.T) { + s, _, player, _ := newMockState() + player.Resource = 10 + rts := NewPileOfCards() + rts.FromString("[magic/ritual!, magic/ritual!]") + player.DiscardPile.AddPoc(rts) + + r := NewCard("exp1/recycle!") + player.Hand.AddCard(r) + a := NewPlayAction(player, r) + a.Target().AddSelection(rts.Cards()[0]) + a.Target().AddSelection(rts.Cards()[1]) + + s.declareAction(a) + s.stack.pop() + if player.Hand.Size() != 2 { + t.Fatal("Hand does not contain two cards") + } + + player.Hand.MoveInto(player.DiscardPile) + player.DiscardPile.MoveCard(r, player.DiscardPile) + a.Target().AddSelection(rts.Cards()[0]) + s.declareAction(a) + s.stack.pop() + if player.Hand.Size() != 1 { + t.Fatal("Hand does not contain one cards") + } +} |
