Expanded the Whenever Keyword to allow it to trigger when a player gains life and added an object array to the Whenever keyword to store some data. Added Ageless Entity, Ajani Pridemate and Angelic Chorus

This commit is contained in:
jendave
2011-08-06 05:14:45 +00:00
parent f6357681fa
commit b3a1924ab9
8 changed files with 60 additions and 14 deletions

View File

@@ -38,6 +38,9 @@ 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_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
angelic_chorus.jpg http://www.wizards.com/global/images/magic/general/angelic_chorus.jpg
ajanis_pridemate.jpg http://www.wizards.com/global/images/magic/general/ajanis_pridemate.jpg
ageless_entity.jpg http://www.wizards.com/global/images/magic/general/ageless_entity.jpg
inferno_titan.jpg http://www.wizards.com/global/images/magic/general/inferno_titan.jpg
sylvan_ranger.jpg http://www.wizards.com/global/images/magic/general/sylvan_ranger.jpg
manic_vandal.jpg http://www.wizards.com/global/images/magic/general/manic_vandal.jpg

View File

@@ -1,3 +1,23 @@
Angelic Chorus
3 W W
Enchantment
no text
WheneverKeyword:EntersBattleField:Type/Creature:Play:ModifyLife/Toughness:ControllingPlayer_Self:ASAP:No Condition:Initiator - OwnedByController:Whenever a creature enters the battlefield under your control, you gain life equal to its toughness.
Ajani's Pridemate
1 W
Creature Cat Soldier
no text
2/2
WheneverKeyword:GainLife:No_Initiator:Play:+1+1 Counters/1:Self:ASAP:No_Condition:No Special Condition:Whenever you gain life, you may put a +1/+1 counter on Ajani's Pridemate.
Ageless Entity
3 G G
Creature Elemental
no text
4/4
WheneverKeyword:GainLife:No_Initiator:Play:+1+1 Counters/Life_Gained:Self:ASAP:No_Condition:No Special Condition:Whenever you gain life, put that many +1/+1 counters on Ageless Entity.
Inferno Titan
4 R R
Creature Giant

View File

@@ -28,6 +28,9 @@ public class CardFactory implements NewConstants {
private HashSet<String> removedCardList;
private Card blankCard = new Card(); //new code
// The Following "Cards" are used by the Whenever Keyword
public Card HumanNullCard = new Card();
public Card ComputerNullCard = new Card();
public CardFactory(String filename) {
this(new File(filename));
@@ -54,6 +57,11 @@ public class CardFactory implements NewConstants {
blankCard.setOwner(Constant.Player.Human);
blankCard.setController(Constant.Player.Human);
HumanNullCard.setOwner(Constant.Player.Human);
HumanNullCard.setController(Constant.Player.Human);
ComputerNullCard.setOwner(Constant.Player.Computer);
ComputerNullCard.setController(Constant.Player.Computer);
removedCardList = new HashSet<String>(FileUtil.readFile(ForgeProps.getFile(REMOVED)));

View File

@@ -852,7 +852,7 @@ public class CombatUtil {
//human does not have an "attackers_instantAbility" phase during his turn (yet), so triggers will happen at the beginning of declare blockers
if( /*AllZone.Phase.getPhase().equals("Declare Blockers") ||*/
AllZone.Phase.getPhase().equals(Constant.Phase.Combat_Declare_Attackers_InstantAbility)) {
AllZone.GameAction.CheckWheneverKeyword(c,"Attacks");
AllZone.GameAction.CheckWheneverKeyword(c,"Attacks",null);
//Annihilator:
if (!c.getCreatureAttackedThisCombat())
{

View File

@@ -1,6 +1,5 @@
package forge;
import java.util.ArrayList;
//import java.util.*;
//handles "until end of turn" and "at end of turn" commands from cards
@@ -18,7 +17,7 @@ public class EndOfTurn implements java.io.Serializable
public void executeAt()
{
AllZone.GameAction.CheckWheneverKeyword(new Card(),"BeginningOfEndStep");
AllZone.GameAction.CheckWheneverKeyword(AllZone.CardFactory.HumanNullCard,"BeginningOfEndStep",null);
//Pyrohemia and Pestilence
CardList all = new CardList();

View File

@@ -663,7 +663,7 @@ public class GameAction {
}
// Whenever Keyword
public void CheckWheneverKeyword(Card Triggering_Card,String Event) {
public void CheckWheneverKeyword(Card Triggering_Card,String Event, Object[] Custom_Parameters) {
CardList Cards_In_Play = new CardList();
Cards_In_Play.addAll(AllZone.getZone(Constant.Zone.Play, Constant.Player.Human).getCards());
Cards_In_Play.addAll(AllZone.getZone(Constant.Zone.Play, Constant.Player.Computer).getCards());
@@ -689,7 +689,7 @@ public class GameAction {
String parse = card.getKeyword().get(WheneverKeyword_Number[CKeywords]).toString();
String k[] = parse.split(":");
if((k[1].equals(Event))) {
RunWheneverKeyword(Triggering_Card, Event); // Beached
RunWheneverKeyword(Triggering_Card, Event, Custom_Parameters); // Beached
Triggered = true;
}
}
@@ -697,7 +697,8 @@ public class GameAction {
}
}
static boolean MultiTarget_Cancelled = false;
public void RunWheneverKeyword(Card c, String Event) {
public void RunWheneverKeyword(Card c, String Event, Object[] Custom_Parameters) {
final Card F_TriggeringCard = c;
CardList Cards_In_Play = new CardList();
Cards_In_Play.addAll(AllZone.getZone(Constant.Zone.Play, Constant.Player.Human).getCards());
Cards_In_Play.addAll(AllZone.getZone(Constant.Zone.Play, Constant.Player.Computer).getCards());
@@ -725,7 +726,8 @@ public class GameAction {
if((k[1].equals("PermanentIntoGraveyard")) && Event.equals("PermanentIntoGraveyard")
|| (k[1].equals("BeginningOfEndStep")) && Event.equals("BeginningOfEndStep")
|| (k[1].equals("Attacks")) && Event.equals("Attacks")
|| (k[1].equals("EntersBattleField")) && Event.equals("EntersBattleField"))
|| (k[1].equals("EntersBattleField")) && Event.equals("EntersBattleField")
|| (k[1].equals("GainLife")) && Event.equals("GainLife") && c.getController().equals(card.getController()))
{
if(k[2].contains("Self")) {
if(!card.equals(c)) k[4] = "Null";
@@ -738,6 +740,9 @@ public class GameAction {
if(k[8].contains("Initiator - Other than Self")) {
if(card.equals(c)) k[4] = "Null";
}
if(k[8].contains("Initiator - OwnedByController")) {
if(!c.getController().equals(card.getController())) k[4] = "Null";
}
if(k[8].contains("Initiator - Has Keyword")) {
boolean Nullified = true;
String KeywordParse = k[8];
@@ -754,17 +759,16 @@ public class GameAction {
if(k[5].equals("ControllingPlayer_Self")) TargetPlayer = card.getController();
final String F_TargetPlayer = TargetPlayer;
Card TargetCard = null;
final Card Destroyed = c;
if(k[5].equals("Self")) TargetCard = F_card;
final Card F_TargetCard = TargetCard;
// +1 +1 Counters
if(k[4].contains("+1+1 Counters")) {
String AmountParse = k[4];
String S_Amount = AmountParse.split("/")[1];
int I_Amount = 0;
if(S_Amount.equals("Power")) I_Amount = Destroyed.getNetAttack();
else I_Amount = Integer.valueOf(S_Amount);
if(S_Amount.equals("Power")) I_Amount = F_TriggeringCard.getNetAttack();
else if(S_Amount.equals("Life_Gained")) I_Amount = ((Integer)Custom_Parameters[0]);
else if(I_Amount == 0) I_Amount = Integer.valueOf(S_Amount);
final int F_Amount = I_Amount;
Ability ability = new Ability(F_TargetCard, "0") {
@Override
@@ -802,7 +806,7 @@ public class GameAction {
String AmountParse = k[4];
String S_Amount = AmountParse.split("/")[1];
int I_Amount = 0;
if(S_Amount.equals("Some random condition not implemented yet")) I_Amount = 3;
if(S_Amount.equals("Toughness")) I_Amount = F_TriggeringCard.getNetDefense();
else I_Amount = Integer.valueOf(S_Amount);
final int F_Amount = I_Amount;
Ability ability = new Ability(card, "0") {
@@ -993,7 +997,7 @@ public class GameAction {
}
});
CheckWheneverKeyword(c, "PermanentIntoGraveyard");
CheckWheneverKeyword(c, "PermanentIntoGraveyard",null);
for(int i = 0; i < list.size(); i++)
GameActionUtil.executeDestroyCardEffects(list.get(i), c);
for(int i = 0; i < grv.size(); i++)

View File

@@ -20,7 +20,19 @@ public class PlayerLife extends MyObservable implements java.io.Serializable
}
public void addLife(int life2)
{
Card WhoGainedLife = new Card();
if(AllZone.Human_Life.getLife() != AllZone.Computer_Life.getLife()) {
if(AllZone.Human_Life.getLife() == life) WhoGainedLife = AllZone.CardFactory.HumanNullCard;
else WhoGainedLife = AllZone.CardFactory.ComputerNullCard;
}
life += life2;
if(WhoGainedLife != AllZone.CardFactory.HumanNullCard && WhoGainedLife != AllZone.CardFactory.ComputerNullCard) {
if(AllZone.Human_Life.getLife() == life) WhoGainedLife = AllZone.CardFactory.HumanNullCard;
else WhoGainedLife = AllZone.CardFactory.ComputerNullCard;
}
Object[] Life_Whenever_Parameters = new Object[1];
Life_Whenever_Parameters[0] = life2;
AllZone.GameAction.CheckWheneverKeyword(WhoGainedLife, "GainLife", Life_Whenever_Parameters);
this.updateObservers();
}
public void subtractLife(int life2)

View File

@@ -46,7 +46,7 @@ public class PlayerZone_ComesIntoPlay extends DefaultPlayerZone {
if(trigger) {
c.setSickness(true);// summoning sickness
c.comesIntoPlay();
AllZone.GameAction.CheckWheneverKeyword(c,"EntersBattleField");
AllZone.GameAction.CheckWheneverKeyword(c,"EntersBattleField",null);
PlayerZone play = AllZone.getZone(Constant.Zone.Play, c.getController());
PlayerZone grave = AllZone.getZone(Constant.Zone.Graveyard, c.getController());