- Added Mana Clash

This commit is contained in:
moomarc
2013-03-10 14:57:18 +00:00
parent 40641f2b41
commit 4f114411e1
6 changed files with 132 additions and 51 deletions

1
.gitattributes vendored
View File

@@ -6326,6 +6326,7 @@ res/cardsfolder/m/man_o_war.txt svneol=native#text/plain
res/cardsfolder/m/mana_bloom.txt -text res/cardsfolder/m/mana_bloom.txt -text
res/cardsfolder/m/mana_breach.txt svneol=native#text/plain res/cardsfolder/m/mana_breach.txt svneol=native#text/plain
res/cardsfolder/m/mana_chains.txt -text res/cardsfolder/m/mana_chains.txt -text
res/cardsfolder/m/mana_clash.txt -text
res/cardsfolder/m/mana_crypt.txt svneol=native#text/plain res/cardsfolder/m/mana_crypt.txt svneol=native#text/plain
res/cardsfolder/m/mana_cylix.txt svneol=native#text/plain res/cardsfolder/m/mana_cylix.txt svneol=native#text/plain
res/cardsfolder/m/mana_drain.txt svneol=native#text/plain res/cardsfolder/m/mana_drain.txt svneol=native#text/plain

View File

@@ -0,0 +1,21 @@
Name:Mana Clash
ManaCost:R
Types:Sorcery
Text:no text
A:SP$ Repeat | Cost$ R | ValidTgts$ Opponent | RepeatCheckSVar$ RepeatCheck | RepeatSVarCompare$ GT0 | RepeatSubAbility$ ResetCheck | StackDescription$ SpellDescription | SpellDescription$ You and target opponent each flip a coin. CARDNAME deals 1 damage to each player whose coin comes up tails. Repeat this process until both players' coins come up heads on the same flip.
SVar:ResetCheck:DB$ StoreSVar | SVar$ RepeatCheck | Type$ Number | Expression$ 0 | SubAbility$ RepeatClash
SVar:RepeatClash:DB$ RepeatEach | RepeatPlayers$ TargetedAndYou | RepeatSubAbility$ FlipClash | SubAbility$ ClashDamage
SVar:FlipClash:DB$ FlipACoin | Flipper$ Remembered | NoCall$ True | TailsSubAbility$ ClashTails | RememberResult$ True
SVar:ClashTails:DB$ StoreSVar | SVar$ RepeatCheck | Type$ CountSVar | Expression$ RepeatCheck/Plus.1
SVar:ClashDamage:DB$ DamageAll | ValidPlayers$ FlippedTails | NumDmg$ 1 | SubAbility$ ResetFlips
SVar:ResetFlips:DB$ Cleanup | ClearCoinFlips$ True
SVar:RepeatCheck:Number$ 0
SVar:RemAIDeck:True
SVar:Picture:http://www.wizards.com/global/images/magic/general/mana_clash.jpg
Oracle:You and target opponent each flip a coin. Mana Clash deals 1 damage to each player whose coin comes up tails. Repeat this process until both players' coins come up heads on the same flip.
SetInfo:8ED Rare
SetInfo:7ED Rare
SetInfo:DRK Rare
SetInfo:9ED Rare
SetInfo:5ED Rare
SetInfo:4ED Rare

View File

@@ -125,6 +125,7 @@ public class Card extends GameEntity implements Comparable<Card> {
private final ArrayList<Card> encodedCards = new ArrayList<Card>(); private final ArrayList<Card> encodedCards = new ArrayList<Card>();
private Card championedCard = null; private Card championedCard = null;
private final List<Card> devouredCards = new ArrayList<Card>(); private final List<Card> devouredCards = new ArrayList<Card>();
private Map<Player, String> flipResult = new TreeMap<Player, String>();
private Map<Card, Integer> receivedDamageFromThisTurn = new TreeMap<Card, Integer>(); private Map<Card, Integer> receivedDamageFromThisTurn = new TreeMap<Card, Integer>();
private Map<Card, Integer> dealtDamageToThisTurn = new TreeMap<Card, Integer>(); private Map<Card, Integer> dealtDamageToThisTurn = new TreeMap<Card, Integer>();
@@ -759,6 +760,39 @@ public class Card extends GameEntity implements Comparable<Card> {
this.encodedCards.clear(); this.encodedCards.clear();
} }
/**
* <p>
* addFlipResult.
* </p>
*
* @param flipper The Player who flipped the coin.
* @param result The result of the coin flip as a String.
*/
public final void addFlipResult(final Player flipper, final String result) {
this.flipResult.put(flipper, result);
}
/**
* <p>
* getFlipResult.
* </p>
*
* @param flipper The Player who flipped the coin.
* @return a String result - Heads or Tails.
*/
public final String getFlipResult(final Player flipper) {
return this.flipResult.get(flipper);
}
/**
* <p>
* clearFlipResult.
* </p>
*/
public final void clearFlipResult() {
this.flipResult.clear();
}
/** /**
* <p> * <p>
* Setter for the field <code>championedCard</code>. * Setter for the field <code>championedCard</code>.

View File

@@ -705,6 +705,12 @@ public class AbilityUtils {
players.add(p); players.add(p);
} }
} }
} else if (defined.equals("TargetedAndYou")) {
final SpellAbility saTargeting = sa.getSATargetingPlayer();
if (saTargeting != null) {
players.addAll(saTargeting.getTarget().getTargetPlayers());
players.add(sa.getActivatingPlayer());
}
} else if (defined.equals("Remembered")) { } else if (defined.equals("Remembered")) {
for (final Object rem : card.getRemembered()) { for (final Object rem : card.getRemembered()) {
if (rem instanceof Player) { if (rem instanceof Player) {
@@ -861,6 +867,14 @@ public class AbilityUtils {
if (!players.contains(p)) { if (!players.contains(p)) {
players.add(p); players.add(p);
} }
} else if (defined.startsWith("Flipped")) {
for (Player p : Singletons.getModel().getGame().getPlayers()) {
if (null != sa.getSourceCard().getFlipResult(p)) {
if (sa.getSourceCard().getFlipResult(p).equals(defined.substring(7))) {
players.add(p);
}
}
}
} else if (defined.equals("You")) { } else if (defined.equals("You")) {
players.add(sa.getActivatingPlayer()); players.add(sa.getActivatingPlayer());
} else if (defined.equals("Each")) { } else if (defined.equals("Each")) {

View File

@@ -37,6 +37,9 @@ public class CleanUpEffect extends SpellAbilityEffect {
if (sa.hasParam("ClearTriggered")) { if (sa.hasParam("ClearTriggered")) {
Singletons.getModel().getGame().getTriggerHandler().clearDelayedTrigger(source); Singletons.getModel().getGame().getTriggerHandler().clearDelayedTrigger(source);
} }
if (sa.hasParam("ClearCoinFlips")) {
source.clearFlipResult();
}
} }
} }

View File

@@ -37,7 +37,12 @@ public class FlipCoinEffect extends SpellAbilityEffect {
final Card host = sa.getSourceCard(); final Card host = sa.getSourceCard();
final Player player = host.getController(); final Player player = host.getController();
final List<Player> caller = AbilityUtils.getDefinedPlayers(sa.getSourceCard(), sa.getParam("Caller"), sa); final List<Player> playersToFlip = AbilityUtils.getDefinedPlayers(host, sa.getParam("Flipper"), sa);
if (playersToFlip.isEmpty()) {
playersToFlip.add(sa.getActivatingPlayer());
}
final List<Player> caller = AbilityUtils.getDefinedPlayers(host, sa.getParam("Caller"), sa);
if (caller.isEmpty()) { if (caller.isEmpty()) {
caller.add(player); caller.add(player);
} }
@@ -45,20 +50,21 @@ public class FlipCoinEffect extends SpellAbilityEffect {
final boolean noCall = sa.hasParam("NoCall"); final boolean noCall = sa.hasParam("NoCall");
boolean victory = false; boolean victory = false;
if (!noCall) { if (!noCall) {
victory = GuiDialog.flipCoin(caller.get(0), sa.getSourceCard()); victory = GuiDialog.flipCoin(caller.get(0), host);
} }
// Run triggers // Run triggers
// HashMap<String,Object> runParams = new HashMap<String,Object>(); // HashMap<String,Object> runParams = new HashMap<String,Object>();
// runParams.put("Player", player); // runParams.put("Player", player);
if (sa.getParam("RememberAll") != null) { final boolean rememberResult = sa.hasParam("RememberResult");
host.addRemembered(host);
for (final Player flipper : playersToFlip) {
if (noCall) {
final boolean resultIsHeads = FlipCoinEffect.flipCoinNoCall(sa.getSourceCard(), flipper);
if (rememberResult) {
host.addFlipResult(flipper, resultIsHeads ? "Heads" : "Tails");
} }
if (noCall) {
final boolean resultIsHeads = FlipCoinEffect.flipCoin(sa.getSourceCard());
System.out.println("Flipped coin result:" + (resultIsHeads ? " Heads" : " Tails"));
if (resultIsHeads) { if (resultIsHeads) {
if (sa.hasParam("HeadsSubAbility")) { if (sa.hasParam("HeadsSubAbility")) {
final SpellAbility heads = AbilityFactory.getAbility(host.getSVar(sa.getParam("HeadsSubAbility")), host); final SpellAbility heads = AbilityFactory.getAbility(host.getSVar(sa.getParam("HeadsSubAbility")), host);
@@ -103,20 +109,21 @@ public class FlipCoinEffect extends SpellAbilityEffect {
// runParams.put("Won","False"); // runParams.put("Won","False");
} }
} }
}
// AllZone.getTriggerHandler().runTrigger("FlipsACoin",runParams); // AllZone.getTriggerHandler().runTrigger("FlipsACoin",runParams);
} }
/** /**
* <p> * <p>
* flipACoin without call. * flipCoinNoCall Flip a coin without any call.
* </p> * </p>
* *
* @param source * @param source the source card.
* a {@link forge.Card} object. * @param flipper the player flipping the coin.
* @return a boolean. * @return a boolean.
*/ */
private static boolean flipCoin(final Card source) { public static boolean flipCoinNoCall(final Card source, final Player flipper) {
final boolean resultIsHeads = MyRandom.getRandom().nextBoolean(); final boolean resultIsHeads = MyRandom.getRandom().nextBoolean();
Singletons.getModel().getGame().getEvents().post(new FlipCoinEvent()); Singletons.getModel().getGame().getEvents().post(new FlipCoinEvent());
@@ -124,7 +131,8 @@ public class FlipCoinEffect extends SpellAbilityEffect {
msgTitle.append(source); msgTitle.append(source);
msgTitle.append(" Flip result:"); msgTitle.append(" Flip result:");
final StringBuilder result = new StringBuilder(); final StringBuilder result = new StringBuilder();
result.append("Flip comes up"); result.append(flipper.getName());
result.append("'s flip comes up");
result.append(resultIsHeads ? " heads." : " tails."); result.append(resultIsHeads ? " heads." : " tails.");
JOptionPane.showMessageDialog(null, result, msgTitle.toString(), JOptionPane.PLAIN_MESSAGE); JOptionPane.showMessageDialog(null, result, msgTitle.toString(), JOptionPane.PLAIN_MESSAGE);