Fixed a bug where the human was able to choose new targets for copied spells and added the LQ pic for Sun Titan. Expanded the Whenever Keyword with BeginningOfUpkeep so that it can trigger at the beginning of an upkeep and added a Controller_Upkeep condition so that it checks whether or not it is the source card controller's upkeep. Re-arranged the code in the WheneverKeyword to make it much more flexible and it is now able to take groups of effects and individual targets for groups of effects. Added Agent of Masks

This commit is contained in:
jendave
2011-08-06 05:17:37 +00:00
parent d4e70e72c1
commit 666fc41273
5 changed files with 167 additions and 153 deletions

View File

@@ -38,6 +38,8 @@ snow_covered_mountain.jpg http://www.wizards.com/global/images/magic/gene
snow_covered_mountain1.jpg http://www.wizards.com/global/images/magic/general/snow_covered_mountain.jpg snow_covered_mountain1.jpg http://www.wizards.com/global/images/magic/general/snow_covered_mountain.jpg
snow_covered_mountain2.jpg http://www.magickartenmarkt.de/img/cards/Ice_Age/snow_covered_mountain.jpg snow_covered_mountain2.jpg http://www.magickartenmarkt.de/img/cards/Ice_Age/snow_covered_mountain.jpg
snow_covered_mountain3.jpg http://www.magickartenmarkt.de/img/cards/Ice_Age/snow_covered_mountain.jpg snow_covered_mountain3.jpg http://www.magickartenmarkt.de/img/cards/Ice_Age/snow_covered_mountain.jpg
agent_of_masks.jpg http://www.wizards.com/global/images/magic/general/agent_of_masks.jpg
sun_titan.jpg http://www.wizards.com/global/images/magic/general/sun_titan.jpg
roc_egg.jpg http://www.wizards.com/global/images/magic/general/roc_egg.jpg roc_egg.jpg http://www.wizards.com/global/images/magic/general/roc_egg.jpg
sleepers_robe.jpg http://www.wizards.com/global/images/magic/general/sleepers_robe.jpg sleepers_robe.jpg http://www.wizards.com/global/images/magic/general/sleepers_robe.jpg
ophidian_eye.jpg http://www.wizards.com/global/images/magic/general/ophidian_eye.jpg ophidian_eye.jpg http://www.wizards.com/global/images/magic/general/ophidian_eye.jpg

View File

@@ -1,3 +1,10 @@
Agent of Masks
3 W B
Creature Human Advisor
no text
2/3
WheneverKeyword:BeginningOfUpkeep:No_Initiator:Play:ModifyLife/1!ModifyLife/-1:ControllingPlayer_Self!ControllingPlayer_Opponent:ASAP:No_Condition:ControllerUpkeep:At the beginning of your upkeep, each opponent loses 1 life. You gain life equal to the life lost this way.
Sun Titan Sun Titan
4 W W 4 W W
Creature Giant Creature Giant

View File

@@ -207,7 +207,12 @@ public class CardFactory implements NewConstants {
|| (in.getSpellAbility()[i].getTargetPlayer().equals(Constant.Player.Computer))) || (in.getSpellAbility()[i].getTargetPlayer().equals(Constant.Player.Computer)))
sa[i].setTargetPlayer(in.getSpellAbility()[i].getTargetPlayer()); sa[i].setTargetPlayer(in.getSpellAbility()[i].getTargetPlayer());
} }
AllZone.GameAction.playSpellAbility(sa[i]); if(Source.getController().equals(Constant.Player.Human)) AllZone.GameAction.playSpellAbility(sa[i]);
else {
if(sa[i].canPlayAI()) {
ComputerUtil.playStackFree(sa[i]);
}
}
} }
} }
} }

View File

@@ -703,7 +703,6 @@ public class GameAction {
static boolean MultiTarget_Cancelled = false; static boolean MultiTarget_Cancelled = false;
public void RunWheneverKeyword(Card c, String Event, Object[] Custom_Parameters) { public void RunWheneverKeyword(Card c, String Event, Object[] Custom_Parameters) {
/** /**
* TODO DiscardCards/X
* Custom_Parameters Info: * Custom_Parameters Info:
* For GainLife : Custom_Parameters[0] = Amount of Life Gained * For GainLife : Custom_Parameters[0] = Amount of Life Gained
* For DealsDamage : Custom_Parameters[0] = Player Target * For DealsDamage : Custom_Parameters[0] = Player Target
@@ -734,6 +733,7 @@ public class GameAction {
String parse = card.getKeyword().get(WheneverKeyword_Number[CKeywords]).toString(); String parse = card.getKeyword().get(WheneverKeyword_Number[CKeywords]).toString();
String k[] = parse.split(":"); String k[] = parse.split(":");
final String F_k[] = k; final String F_k[] = k;
// Conditions
if((k[1].contains(Event))) if((k[1].contains(Event)))
{ {
if(k[1].contains("DealsDamage")) { if(k[1].contains("DealsDamage")) {
@@ -750,7 +750,6 @@ public class GameAction {
String SpellControllerParse = k[1]; String SpellControllerParse = k[1];
String SpellController[] = SpellControllerParse.split("/"); String SpellController[] = SpellControllerParse.split("/");
for(int z = 0; z < SpellController.length - 1; z++) { for(int z = 0; z < SpellController.length - 1; z++) {
// JOptionPane.showMessageDialog(null, SpellController[z + 1] + c.getController() + card.getController(), "", JOptionPane.INFORMATION_MESSAGE);
if(SpellController[z + 1].equals("Controller") && (c.getController()).equals(card.getController())) Nullified = false; if(SpellController[z + 1].equals("Controller") && (c.getController()).equals(card.getController())) Nullified = false;
} }
if(Nullified == true) k[4] = "Null"; if(Nullified == true) k[4] = "Null";
@@ -801,6 +800,9 @@ public class GameAction {
for(int z = 0; z < Keyword.length - 1; z++) if((c.getKeyword()).contains(Keyword[z + 1])) Nullified = false; for(int z = 0; z < Keyword.length - 1; z++) if((c.getKeyword()).contains(Keyword[z + 1])) Nullified = false;
if(Nullified == true) k[4] = "Null"; if(Nullified == true) k[4] = "Null";
} }
if(k[8].contains("ControllerUpkeep")) {
if(getLastPlayerToDraw().equals(card.getController())) k[4] = "Null";
}
if(k[8].contains("ControllerEndStep")) { if(k[8].contains("ControllerEndStep")) {
if(!getLastPlayerToDraw().equals(card.getController())) k[4] = "Null"; if(!getLastPlayerToDraw().equals(card.getController())) k[4] = "Null";
} }
@@ -812,187 +814,193 @@ public class GameAction {
ManaCost = PayAmountParse.split("/")[1]; ManaCost = PayAmountParse.split("/")[1];
} }
// Targets // Targets
String TargetPlayer = "";
if(k[5].equals("ControllingPlayer_Self")) TargetPlayer = card.getController(); int Target_Conditions = 1;
if(k[5].equals("ControllingPlayer_Opponent")) TargetPlayer = getOpponent(card.getController()); String TargetParse = k[5];
if(k[5].equals("ControllingPlayer_Initiator")) TargetPlayer = F_TriggeringCard.getController(); String Targets[] = TargetParse.split("!");
final String F_TargetPlayer = TargetPlayer; Target_Conditions = Targets.length;
Card TargetCard = null; String TargetPlayer[] = new String[Target_Conditions];
if(k[5].equals("Self")) TargetCard = F_card; Card TargetCard[] = new Card[Target_Conditions];
if(k[5].equals("Initiating_Card")) TargetCard = c; for(int y = 0; y < Target_Conditions; y++) {
final Card F_TargetCard = TargetCard; if(Targets[y].equals("ControllingPlayer_Self")) TargetPlayer[y] = card.getController();
if(Targets[y].equals("ControllingPlayer_Opponent")) TargetPlayer[y] = getOpponent(card.getController());
if(Targets[y].equals("ControllingPlayer_Initiator")) TargetPlayer[y] = F_TriggeringCard.getController();
if(Targets[y].equals("Self")) TargetCard[y] = F_card;
if(Targets[y].equals("Initiating_Card")) TargetCard[y] = c;
}
final String[] F_TargetPlayer = TargetPlayer;
final Card[] F_TargetCard = TargetCard;
// JOptionPane.showMessageDialog(null, Targets, "", JOptionPane.INFORMATION_MESSAGE);
// Effects // Effects
// +1 +1 Counters
if(k[4].contains("+1+1 Counters")) { int Effects = 1;
String AmountParse = k[4]; String EffectParse = k[4];
String S_Amount = AmountParse.split("/")[1]; String Effect[] = EffectParse.split("!");
int I_Amount = 0; Effects = Effect.length;
if(S_Amount.equals("Power")) I_Amount = F_TriggeringCard.getNetAttack(); final Command[] Command_Effects = new Command[Effects];
else if(S_Amount.equals("Life_Gained")) I_Amount = ((Integer)Custom_Parameters[0]); final Command[] CommandExecute = new Command[1];
else if(I_Amount == 0) I_Amount = Integer.valueOf(S_Amount); String StackDescription = F_card + " - ";
final int F_Amount = I_Amount; final int[] Effects_Count = new int[1];
final Ability ability = new Ability(card, ManaCost) {
final Ability ability = new Ability(card, ManaCost) {
@Override @Override
public void resolve() { public void resolve() {
Whenever_ManaPaid(F_card, F_k, Proper_resolve, this); for(int Commands = 0; Commands < Command_Effects.length; Commands++) Whenever_ManaPaid(F_card, F_k, Command_Effects[Commands], this);
} }
public Command Proper_resolve = new Command() { };
for(int y = 0; y < Effects; y++) {
// Variables
String AmountParse = Effect[y];
int I_Amount = 0;
String S_Amount = "";
if((AmountParse.split("/")).length > 1) {
S_Amount = AmountParse.split("/")[1];
if(S_Amount.equals("Toughness")) I_Amount = F_TriggeringCard.getNetDefense();
else if(S_Amount.equals("Power")) I_Amount = F_TriggeringCard.getNetAttack();
else if(S_Amount.equals("Life_Gained")) I_Amount = ((Integer)Custom_Parameters[0]);
else I_Amount = Integer.valueOf(S_Amount);
}
int Multiple_Targets = 1;
if(k[8].contains("MultipleTargets")) {
Multiple_Targets = I_Amount;
I_Amount = 1;
}
final int F_Multiple_Targets = Multiple_Targets;
final Object[] Targets_Multi = new Object[Multiple_Targets];
final int[] index = new int[1];
final int F_Amount = I_Amount;
final int F_Target = Effects_Count[0];
final Command MultiTargetsCommand = new Command() {
private static final long serialVersionUID = -83034517601871955L;
public void execute() {
MultiTarget_Cancelled = false;
for(int i = 0; i < F_Multiple_Targets; i++) {
AllZone.InputControl.setInput(CardFactoryUtil.input_MultitargetCreatureOrPlayer(ability , i , F_Amount*F_Multiple_Targets,new Command() {
private static final long serialVersionUID = -328305150127775L;
public void execute() {
Targets_Multi[index[0]] = ability.getTargetPlayer();
if(Targets_Multi[index[0]] == null) Targets_Multi[index[0]] = ability.getTargetCard();
index[0]++;
}
}));
}
AllZone.Stack.add(ability);
}
};
if(k[8].contains("MultipleTargets")) CommandExecute[0] = MultiTargetsCommand;
else CommandExecute[0] = Command.Blank;
// Null
if(Effect[y].equals("Null")) {
Command_Effects[F_Target] = Command.Blank;
}
// +1 +1 Counters
if(Effect[y].contains("+1+1 Counters")) {
Command Proper_resolve = new Command() {
private static final long serialVersionUID = 151367344511590317L; private static final long serialVersionUID = 151367344511590317L;
public void execute() { public void execute() {
if(Whenever_Go(F_card,F_k) == true) if(AllZone.GameAction.isCardInPlay(F_TargetCard)) F_TargetCard.addCounter(Counters.P1P1, F_Amount); if(Whenever_Go(F_card,F_k) == true) if(AllZone.GameAction.isCardInPlay(F_TargetCard[F_Target])) F_TargetCard[F_Target].addCounter(Counters.P1P1, F_Amount);
}
}; };
}; };
ability.setStackDescription(F_TargetCard.getName() + " - gets " + F_Amount + " +1/+1 counters."); Command_Effects[F_Target] = Proper_resolve;
Whenever_Input(F_card,F_k,Command.Blank,ability); StackDescription = StackDescription + F_TargetCard[y] + " gets " + F_Amount + " +1/+1 counters";
} }
// Gain Life // Gain Life
if(k[4].contains("ModifyLife")) { if(Effect[y].contains("ModifyLife")) {
String AmountParse = k[4]; Command Proper_resolve = new Command() {
String S_Amount = AmountParse.split("/")[1]; private static final long serialVersionUID = 151367344511590317L;
int I_Amount = 0;
if(S_Amount.equals("Toughness")) I_Amount = F_TriggeringCard.getNetDefense();
else I_Amount = Integer.valueOf(S_Amount);
final int F_Amount = I_Amount;
final Ability ability = new Ability(card, ManaCost) {
@Override
public void resolve() {
Whenever_ManaPaid(F_card, F_k, Proper_resolve, this);
}
public Command Proper_resolve = new Command() {
private static final long serialVersionUID = 151367344511590317L;
public void execute() {
if(Whenever_Go(F_card,F_k) == true) if(AllZone.GameAction.isCardInPlay(F_card)) {
PlayerLife life = AllZone.GameAction.getPlayerLife(F_TargetPlayer);
if(F_Amount > -1) life.addLife(F_Amount);
else life.subtractLife(F_Amount * -1,F_card);
}
public void execute() {
if(Whenever_Go(F_card,F_k) == true) if(AllZone.GameAction.isCardInPlay(F_card)) {
PlayerLife life = AllZone.GameAction.getPlayerLife(F_TargetPlayer[F_Target]);
if(F_Amount > -1) life.addLife(F_Amount);
else life.subtractLife(F_Amount * -1,F_card);
} }
};
}; }
ability.setStackDescription(F_card + " - " + F_TargetPlayer + ((F_Amount > -1)? " gains " + F_Amount:"") + ((F_Amount <= -1)? " loses " + F_Amount * -1:"") + " life."); };
Whenever_Input(F_card,F_k,Command.Blank,ability); Command_Effects[F_Target] = Proper_resolve;
StackDescription = StackDescription + F_TargetPlayer[F_Target] + ((F_Amount > -1)? " gains " + F_Amount:"") + ((F_Amount <= -1)? " loses " + F_Amount * -1:"") + " life";
} }
// Draw Cards // Draw Cards
if(k[4].contains("DrawCards")) { if(Effect[y].contains("DrawCards")) {
String AmountParse = k[4]; Command Proper_resolve = new Command() {
String S_Amount = AmountParse.split("/")[1];
int I_Amount = 0;
if(S_Amount.equals("Toughness")) I_Amount = F_TriggeringCard.getNetDefense(); // LOL wut
else I_Amount = Integer.valueOf(S_Amount);
final int F_Amount = I_Amount;
final Ability ability = new Ability(card, ManaCost) {
@Override
public void resolve() {
Whenever_ManaPaid(F_card, F_k, Proper_resolve, this);
}
public Command Proper_resolve = new Command() {
private static final long serialVersionUID = 151367344511590317L; private static final long serialVersionUID = 151367344511590317L;
public void execute() { public void execute() {
if(Whenever_Go(F_card,F_k) == true) if(AllZone.GameAction.isCardInPlay(F_card)) { if(Whenever_Go(F_card,F_k) == true) if(AllZone.GameAction.isCardInPlay(F_card)) {
AllZone.GameAction.drawCard(F_TargetPlayer); AllZone.GameAction.drawCard(F_TargetPlayer[F_Target]);
} }
} }
};
}; };
ability.setStackDescription(F_card + " - " + F_TargetPlayer + " draws " + F_Amount + " card(s)."); Command_Effects[F_Target] = Proper_resolve;
Whenever_Input(F_card,F_k,Command.Blank,ability); StackDescription = StackDescription + F_TargetPlayer[F_Target] + " draws " + F_Amount + " card(s)";
} }
// Discard Cards // Discard Cards
if(k[4].contains("DiscardCards")) { if(Effect[y].contains("DiscardCards")) {
String AmountParse = k[4]; Command Proper_resolve = new Command() {
String S_Amount = AmountParse.split("/")[1];
int I_Amount = 0;
if(S_Amount.equals("Toughness")) I_Amount = F_TriggeringCard.getNetDefense(); // LOL wut
else I_Amount = Integer.valueOf(S_Amount);
final int F_Amount = I_Amount;
final Ability ability = new Ability(card, ManaCost) {
@Override
public void resolve() {
Whenever_ManaPaid(F_card, F_k, Proper_resolve, this);
}
public Command Proper_resolve = new Command() {
private static final long serialVersionUID = 151367344511590317L; private static final long serialVersionUID = 151367344511590317L;
public void execute() { public void execute() {
if(Whenever_Go(F_card,F_k) == true) if(AllZone.GameAction.isCardInPlay(F_card)) { if(Whenever_Go(F_card,F_k) == true) if(AllZone.GameAction.isCardInPlay(F_card)) {
AllZone.GameAction.discard(F_TargetPlayer,F_Amount); AllZone.GameAction.discard(F_TargetPlayer[F_Target],F_Amount);
} }
} }
}; };
}; Command_Effects[F_Target] = Proper_resolve;
ability.setStackDescription(F_card + " - " + F_TargetPlayer + " discards " + F_Amount + " card(s)."); StackDescription = StackDescription + F_TargetPlayer[F_Target] + " discards " + F_Amount + " card(s)";
Whenever_Input(F_card,F_k,Command.Blank,ability);
} }
// Copy Spell // Copy Spell
if(k[4].contains("CopySpell")) { if(Effect[y].contains("CopySpell")) {
final Ability ability = new Ability(card, ManaCost) { Command Proper_resolve = new Command() {
@Override
public void resolve() {
Whenever_ManaPaid(F_card, F_k, Proper_resolve, this);
}
public Command Proper_resolve = new Command() {
private static final long serialVersionUID = 151367344511590317L; private static final long serialVersionUID = 151367344511590317L;
public void execute() { public void execute() {
if(Whenever_Go(F_card,F_k) == true) if(AllZone.GameAction.isCardInPlay(F_card)) { if(Whenever_Go(F_card,F_k) == true) if(AllZone.GameAction.isCardInPlay(F_card)) {
AllZone.CardFactory.copySpellontoStack(F_card,F_TargetCard, true); AllZone.CardFactory.copySpellontoStack(F_card,F_TargetCard[F_Target], true);
}; };
} }
}; };
}; Command_Effects[F_Target] = Proper_resolve;
ability.setStackDescription(F_card + " - " + F_TargetPlayer + " copies " + TargetCard); StackDescription = StackDescription + F_card.getController() + " copies " + F_TargetCard[y];
Whenever_Input(F_card,F_k,Command.Blank,ability);
} }
// Deal Damage // Deal Damage
if(k[4].contains("Damage")) { if(Effect[y].contains("Damage")) {
String AmountParse = k[4]; Command Proper_resolve = new Command() {
String S_Amount = AmountParse.split("/")[1];
int I_Amount = 0;
if(S_Amount.equals("Some random condition not implemented yet")) I_Amount = 2;
else I_Amount = Integer.valueOf(S_Amount);
int Multiple_Targets = 1;
if(k[8].contains("MultipleTargets")) {
Multiple_Targets = I_Amount;
I_Amount = 1;
}
final int F_Multiple_Targets = Multiple_Targets;
final int F_Amount = I_Amount;
final Object[] Targets = new Object[Multiple_Targets];
final int[] index = new int[1];
final Ability ability = new Ability(card, ManaCost) {
@Override
public void resolve() {
Whenever_ManaPaid(F_card, F_k, Proper_resolve, this);
}
public Command Proper_resolve = new Command() {
private static final long serialVersionUID = 151367344511590317L; private static final long serialVersionUID = 151367344511590317L;
public void execute() { public void execute() {
if(Whenever_Go(F_card,F_k) == true) if(AllZone.GameAction.isCardInPlay(F_card)) { if(Whenever_Go(F_card,F_k) == true) if(AllZone.GameAction.isCardInPlay(F_card)) {
if(F_card.getController().equals(Constant.Player.Human)) { if(F_card.getController().equals(Constant.Player.Human)) {
for(int z = 0; z < Targets.length; z++) { for(int z = 0; z < Targets_Multi.length; z++) {
if(!(Targets[z].equals(Constant.Player.Human) || Targets[z].equals(Constant.Player.Computer))) { if(!(Targets_Multi[z].equals(Constant.Player.Human) || Targets_Multi[z].equals(Constant.Player.Computer))) {
if(AllZone.GameAction.isCardInPlay((Card) Targets[z]) if(AllZone.GameAction.isCardInPlay((Card) Targets_Multi[z])
&& CardFactoryUtil.canTarget(F_card, (Card) Targets[z])) { && CardFactoryUtil.canTarget(F_card, (Card) Targets_Multi[z])) {
Card c = (Card) Targets[z]; Card c = (Card) Targets_Multi[z];
AllZone.GameAction.addDamage(c, F_card, F_Amount); AllZone.GameAction.addDamage(c, F_card, F_Amount);
} }
} else { } else {
AllZone.GameAction.addDamage( (String) Targets[z], F_Amount,F_card); AllZone.GameAction.addDamage( (String) Targets_Multi[z], F_Amount,F_card);
} }
} }
} }
@@ -1001,35 +1009,24 @@ public class GameAction {
}; };
}; };
}; Command_Effects[F_Target] = Proper_resolve;
if(F_Multiple_Targets != 1) StackDescription = StackDescription + "deals " + F_Amount*F_Multiple_Targets + " damage" + " divided among up to " + Multiple_Targets + " target creatures and/or players";
final Command paidCommand = new Command() { else StackDescription = StackDescription + "deals " + F_Amount*F_Multiple_Targets + " damage to "+ ((F_TargetCard[y] != null)? F_TargetCard[y]:"") + ((F_TargetPlayer[y] != null)? F_TargetPlayer[y]:"");
private static final long serialVersionUID = -83034517601871955L;
public void execute() {
MultiTarget_Cancelled = false;
for(int i = 0; i < F_Multiple_Targets; i++) {
AllZone.InputControl.setInput(CardFactoryUtil.input_MultitargetCreatureOrPlayer(ability , i , F_Amount*F_Multiple_Targets,new Command() {
private static final long serialVersionUID = -328305150127775L;
public void execute() {
Targets[index[0]] = ability.getTargetPlayer();
if(Targets[index[0]] == null) Targets[index[0]] = ability.getTargetCard();
index[0]++;
}
}));
}
AllZone.Stack.add(ability);
}
};
ability.setStackDescription(F_card.getName() + " - deals " + F_Amount*F_Multiple_Targets + " damage" + F_TargetPlayer + ((F_Multiple_Targets != 1)? " divided among up to " + Multiple_Targets + " target creatures and/or players":""));
Whenever_Input(F_card,F_k,paidCommand,ability);
} }
}
Effects_Count[0]++;
if(Effects_Count[0] != Effects) StackDescription = StackDescription + " and ";
else StackDescription = StackDescription + ".";
} // For
ability.setStackDescription(StackDescription);
for(int Check = 0; Check < Command_Effects.length; Check++)
if(!Command_Effects[Check].equals(Command.Blank)) {
Whenever_Input(F_card,F_k,CommandExecute[0],ability);
break;
}
} }
} }
}
} }
void Whenever_ManaPaid (Card Source, String[] Keyword_Details, final Command Proper_Resolve, SpellAbility ability) { void Whenever_ManaPaid (Card Source, String[] Keyword_Details, final Command Proper_Resolve, SpellAbility ability) {
String S_Amount = "0"; String S_Amount = "0";

View File

@@ -19,6 +19,9 @@ public class GameActionUtil {
upkeep_TabernacleUpkeepCost(); upkeep_TabernacleUpkeepCost();
upkeep_MagusTabernacleUpkeepCost(); upkeep_MagusTabernacleUpkeepCost();
// upkeep_CheckEmptyDeck_Lose(); //still a little buggy // upkeep_CheckEmptyDeck_Lose(); //still a little buggy
AllZone.GameAction.CheckWheneverKeyword(AllZone.CardFactory.HumanNullCard, "BeginningOfUpkeep", null);
upkeep_Genesis(); upkeep_Genesis();
upkeep_Phyrexian_Arena(); upkeep_Phyrexian_Arena();
upkeep_Master_of_the_Wild_Hunt(); upkeep_Master_of_the_Wild_Hunt();