1
+ package mage .cards .c ;
2
+
3
+ import java .util .Set ;
4
+ import java .util .UUID ;
5
+
6
+ import mage .abilities .Ability ;
7
+ import mage .abilities .common .EntersBattlefieldTriggeredAbility ;
8
+ import mage .abilities .common .SimpleActivatedAbility ;
9
+ import mage .abilities .costs .common .ExileFromGraveCost ;
10
+ import mage .abilities .costs .common .SacrificeSourceCost ;
11
+ import mage .abilities .costs .mana .ManaCostsImpl ;
12
+ import mage .abilities .effects .OneShotEffect ;
13
+ import mage .abilities .effects .common .BecomesMonarchSourceEffect ;
14
+ import mage .abilities .effects .keyword .SurveilEffect ;
15
+ import mage .abilities .hint .common .MonarchHint ;
16
+ import mage .cards .*;
17
+ import mage .constants .CardType ;
18
+ import mage .constants .Outcome ;
19
+ import mage .constants .Zone ;
20
+ import mage .filter .StaticFilters ;
21
+ import mage .game .Game ;
22
+ import mage .players .Player ;
23
+ import mage .target .TargetCard ;
24
+ import mage .target .common .TargetCardInYourGraveyard ;
25
+ import mage .target .common .TargetOpponent ;
26
+
27
+ /**
28
+ * @author balazskristof
29
+ */
30
+ public final class CoinOfFate extends CardImpl {
31
+
32
+ public CoinOfFate (UUID ownerId , CardSetInfo setInfo ) {
33
+ super (ownerId , setInfo , new CardType []{CardType .ARTIFACT }, "{1}{W}" );
34
+
35
+ // When this artifact enters, surveil 1.
36
+ this .addAbility (new EntersBattlefieldTriggeredAbility (new SurveilEffect (1 )));
37
+
38
+ // {3}{W},{T}, Exile two creature cards from your graveyard, Sacrifice this artifact: An opponent chooses one of the exiled cards. You put that card on the bottom of your library and return the other to the battlefield tapped. You become the monarch.
39
+ Ability ability = new SimpleActivatedAbility (new CoinOfFateEffect (), new ManaCostsImpl <>("{3}{W}" )).addHint (MonarchHint .instance );
40
+ ability .addEffect (new BecomesMonarchSourceEffect ());
41
+ ability .addCost (new ExileFromGraveCost (new TargetCardInYourGraveyard (2 , StaticFilters .FILTER_CARD_CREATURES ), true ));
42
+ ability .addCost (new SacrificeSourceCost ());
43
+ this .addAbility (ability );
44
+ }
45
+
46
+ private CoinOfFate (final CoinOfFate card ) {
47
+ super (card );
48
+ }
49
+
50
+ @ Override
51
+ public CoinOfFate copy () {
52
+ return new CoinOfFate (this );
53
+ }
54
+ }
55
+
56
+ class CoinOfFateEffect extends OneShotEffect {
57
+
58
+ public CoinOfFateEffect () {
59
+ super (Outcome .Benefit );
60
+ staticText = "An opponent chooses one of the exiled cards. "
61
+ + "You put that card on the bottom of your library and return the other to the battlefield tapped" ;
62
+ }
63
+
64
+ private CoinOfFateEffect (final CoinOfFateEffect effect ) {
65
+ super (effect );
66
+ }
67
+
68
+ @ Override
69
+ public CoinOfFateEffect copy () {
70
+ return new CoinOfFateEffect (this );
71
+ }
72
+
73
+ @ Override
74
+ public boolean apply (Game game , Ability source ) {
75
+ Player controller = game .getPlayer (source .getControllerId ());
76
+ if (controller == null ) {
77
+ return false ;
78
+ }
79
+ Cards cards = new CardsImpl (getTargetPointer ().getTargets (game , source ));
80
+ if (cards .isEmpty ()) {
81
+ return false ;
82
+ }
83
+ Player opponent ;
84
+ Set <UUID > opponents = game .getOpponents (controller .getId ());
85
+ if (opponents .size () == 1 ) {
86
+ opponent = game .getPlayer (opponents .iterator ().next ());
87
+ } else {
88
+ TargetOpponent targetOpponent = new TargetOpponent (true );
89
+ controller .chooseTarget (Outcome .Detriment , targetOpponent , source , game );
90
+ opponent = game .getPlayer (targetOpponent .getFirstTarget ());
91
+ }
92
+ if (opponent == null ) {
93
+ return false ;
94
+ }
95
+ TargetCard targetCard = new TargetCard (Zone .EXILED , StaticFilters .FILTER_CARD_CREATURE );
96
+ targetCard .withChooseHint ("card to put on the bottom of opponent's library, the other is put onto the battlefield tapped" );
97
+ opponent .chooseTarget (Outcome .Benefit , cards , targetCard , source , game );
98
+ Card cardToLibrary = game .getCard (targetCard .getFirstTarget ());
99
+ if (cardToLibrary != null ) {
100
+ controller .moveCardToLibraryWithInfo (cardToLibrary , source , game , Zone .EXILED , false , true );
101
+ cards .remove (cardToLibrary );
102
+ }
103
+ if (!cards .isEmpty ()) {
104
+ controller .moveCards (game .getCard (cards .iterator ().next ()), Zone .BATTLEFIELD , source , game , true , false , true , null );
105
+ }
106
+ return true ;
107
+ }
108
+ }
0 commit comments