- Added PermanentNoncreature AF

- Converted Standstill and Bridge from Below to script
This commit is contained in:
Sol
2012-11-27 04:42:05 +00:00
parent 0c5b73378c
commit 39ac4fe0ca
8 changed files with 79 additions and 43 deletions

2
.gitattributes vendored
View File

@@ -12650,6 +12650,7 @@ src/main/java/forge/card/abilityfactory/ai/MillAi.java -text
src/main/java/forge/card/abilityfactory/ai/MustAttackAi.java -text src/main/java/forge/card/abilityfactory/ai/MustAttackAi.java -text
src/main/java/forge/card/abilityfactory/ai/MustBlockAi.java -text src/main/java/forge/card/abilityfactory/ai/MustBlockAi.java -text
src/main/java/forge/card/abilityfactory/ai/PermanentCreatureAi.java -text src/main/java/forge/card/abilityfactory/ai/PermanentCreatureAi.java -text
src/main/java/forge/card/abilityfactory/ai/PermanentNoncreatureAi.java -text
src/main/java/forge/card/abilityfactory/ai/PhasesAi.java -text src/main/java/forge/card/abilityfactory/ai/PhasesAi.java -text
src/main/java/forge/card/abilityfactory/ai/PlayAi.java -text src/main/java/forge/card/abilityfactory/ai/PlayAi.java -text
src/main/java/forge/card/abilityfactory/ai/PoisonAi.java -text src/main/java/forge/card/abilityfactory/ai/PoisonAi.java -text
@@ -12748,6 +12749,7 @@ src/main/java/forge/card/abilityfactory/effects/MillEffect.java -text
src/main/java/forge/card/abilityfactory/effects/MustAttackEffect.java -text src/main/java/forge/card/abilityfactory/effects/MustAttackEffect.java -text
src/main/java/forge/card/abilityfactory/effects/MustBlockEffect.java -text src/main/java/forge/card/abilityfactory/effects/MustBlockEffect.java -text
src/main/java/forge/card/abilityfactory/effects/PermanentCreatureEfect.java -text src/main/java/forge/card/abilityfactory/effects/PermanentCreatureEfect.java -text
src/main/java/forge/card/abilityfactory/effects/PermanentNoncreatureEffect.java -text
src/main/java/forge/card/abilityfactory/effects/PhasesEffect.java -text src/main/java/forge/card/abilityfactory/effects/PhasesEffect.java -text
src/main/java/forge/card/abilityfactory/effects/PlayEffect.java -text src/main/java/forge/card/abilityfactory/effects/PlayEffect.java -text
src/main/java/forge/card/abilityfactory/effects/PoisonEffect.java -text src/main/java/forge/card/abilityfactory/effects/PoisonEffect.java -text

View File

@@ -2,6 +2,7 @@ Name:Bridge from Below
ManaCost:B B B ManaCost:B B B
Types:Enchantment Types:Enchantment
Text:no text Text:no text
A:SP$ PermanentNoncreature | Cost$ B B B | AILogic$ DontCast
T:Mode$ ChangesZone | Origin$ Battlefield | Destination$ Graveyard | ValidCard$ Creature.nonToken+YouOwn | Execute$ TrigToken | TriggerZones$ Graveyard | TriggerDescription$ Whenever a nontoken creature is put into your graveyard from the battlefield, if CARDNAME is in your graveyard, put a 2/2 black Zombie creature token onto the battlefield. T:Mode$ ChangesZone | Origin$ Battlefield | Destination$ Graveyard | ValidCard$ Creature.nonToken+YouOwn | Execute$ TrigToken | TriggerZones$ Graveyard | TriggerDescription$ Whenever a nontoken creature is put into your graveyard from the battlefield, if CARDNAME is in your graveyard, put a 2/2 black Zombie creature token onto the battlefield.
SVar:TrigToken:AB$ Token | Cost$ 0 | TokenAmount$ 1 | TokenName$ Zombie | TokenTypes$ Creature,Zombie | TokenOwner$ You | TokenColors$ Black | TokenPower$ 2 | TokenToughness$ 2 SVar:TrigToken:AB$ Token | Cost$ 0 | TokenAmount$ 1 | TokenName$ Zombie | TokenTypes$ Creature,Zombie | TokenOwner$ You | TokenColors$ Black | TokenPower$ 2 | TokenToughness$ 2
T:Mode$ ChangesZone | Origin$ Battlefield | Destination$ Graveyard | TriggerZones$ Graveyard | ValidCard$ Creature.OppOwn | Execute$ TrigChange | TriggerDescription$ When a creature is put into an opponent's graveyard from the battlefield, if CARDNAME is in your graveyard, exile Bridge from Below. T:Mode$ ChangesZone | Origin$ Battlefield | Destination$ Graveyard | TriggerZones$ Graveyard | ValidCard$ Creature.OppOwn | Execute$ TrigChange | TriggerDescription$ When a creature is put into an opponent's graveyard from the battlefield, if CARDNAME is in your graveyard, exile Bridge from Below.

View File

@@ -2,6 +2,7 @@ Name:Standstill
ManaCost:1 U ManaCost:1 U
Types:Enchantment Types:Enchantment
Text:no text Text:no text
A:SP$ PermanentNoncreature | Cost$ 1 U | AILogic$ MoreCreatures
T:Mode$ SpellCast | ValidActivatingPlayer$ You | TriggerZones$ Battlefield | Execute$ TrigSacYou | TriggerDescription$ When a player casts a spell, sacrifice CARDNAME. If you do, each of that player's opponents draws three cards. T:Mode$ SpellCast | ValidActivatingPlayer$ You | TriggerZones$ Battlefield | Execute$ TrigSacYou | TriggerDescription$ When a player casts a spell, sacrifice CARDNAME. If you do, each of that player's opponents draws three cards.
T:Mode$ SpellCast | ValidActivatingPlayer$ Opponent | TriggerZones$ Battlefield | Execute$ TrigSacOpp | Secondary$ True | TriggerDescription$ When a player casts a spell, sacrifice CARDNAME. If you do, each of that player's opponents draws three cards. T:Mode$ SpellCast | ValidActivatingPlayer$ Opponent | TriggerZones$ Battlefield | Execute$ TrigSacOpp | Secondary$ True | TriggerDescription$ When a player casts a spell, sacrifice CARDNAME. If you do, each of that player's opponents draws three cards.
#Must use SacrificeAll since regular sacrifice can't remember the sac'd cards atm. #Must use SacrificeAll since regular sacrifice can't remember the sac'd cards atm.

View File

@@ -233,7 +233,7 @@ public class AbilityFactory {
} }
} }
else if (api == ApiType.PermanentCreature) { else if (api == ApiType.PermanentCreature || api == ApiType.PermanentNoncreature) {
// If API is a permanent type, and creating AF Spell // If API is a permanent type, and creating AF Spell
// Clear out the auto created SpellPemanent spell // Clear out the auto created SpellPemanent spell
if (isSp) { if (isSp) {

View File

@@ -64,6 +64,7 @@ public enum ApiType {
MustBlock (MustBlockEffect.class, MustBlockAi.class), MustBlock (MustBlockEffect.class, MustBlockAi.class),
NameCard (ChooseCardNameEffect.class, ChooseCardNameAi.class), NameCard (ChooseCardNameEffect.class, ChooseCardNameAi.class),
PermanentCreature (PermanentCreatureEfect.class, PermanentCreatureAi.class), PermanentCreature (PermanentCreatureEfect.class, PermanentCreatureAi.class),
PermanentNoncreature (PermanentNoncreatureEffect.class, PermanentNoncreatureAi.class),
Phases (PhasesEffect.class, PhasesAi.class), Phases (PhasesEffect.class, PhasesAi.class),
Play (PlayEffect.class, PlayAi.class), Play (PlayEffect.class, PlayAi.class),
Poison (PoisonEffect.class, PoisonAi.class), Poison (PoisonEffect.class, PoisonAi.class),

View File

@@ -0,0 +1,40 @@
package forge.card.abilityfactory.ai;
import forge.Singletons;
import forge.card.abilityfactory.SpellAiLogic;
import forge.card.spellability.SpellAbility;
import forge.game.GameState;
import forge.game.phase.PhaseType;
import forge.game.player.ComputerUtil;
import forge.game.player.Player;
/**
* AbilityFactory for Creature Spells.
*
*/
public class PermanentNoncreatureAi extends SpellAiLogic {
/* (non-Javadoc)
* @see forge.card.abilityfactory.SpellAiLogic#canPlayAI(forge.game.player.Player, forge.card.spellability.SpellAbility)
*/
@Override
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
String logic = sa.getParam("AILogic");
GameState game = Singletons.getModel().getGame();
if ("DontCast".equals(logic)) {
return false;
} else if ("MoreCreatures".equals(logic)) {
return (aiPlayer.getCreaturesInPlay().size() > aiPlayer.getOpponent().getCreaturesInPlay().size());
}
// Wait for Main2 if possible
if (game.getPhaseHandler().is(PhaseType.MAIN1)
&& !ComputerUtil.castPermanentInMain1(aiPlayer, sa)) {
return false;
}
// AI shouldn't be retricted all that much for Creatures for now
return true;
}
}

View File

@@ -0,0 +1,32 @@
package forge.card.abilityfactory.effects;
import forge.Card;
import forge.Singletons;
import forge.card.abilityfactory.SpellEffect;
import forge.card.spellability.SpellAbility;
import forge.game.zone.ZoneType;
/**
* TODO: Write javadoc for this type.
*
*/
public class PermanentNoncreatureEffect extends SpellEffect {
/* (non-Javadoc)
* @see forge.card.abilityfactory.SpellEffect#resolve(forge.card.spellability.SpellAbility)
*/
@Override
public void resolve(SpellAbility sa) {
sa.getSourceCard().addController(sa.getActivatingPlayer());
final Card c = Singletons.getModel().getGame().getAction().moveTo(sa.getActivatingPlayer().getZone(ZoneType.Battlefield), sa.getSourceCard());
sa.setSourceCard(c);
}
@Override
public String getStackDescription(final SpellAbility sa) {
final Card sourceCard = sa.getSourceCard();
final StringBuilder sb = new StringBuilder();
sb.append(sourceCard.getName());
return sb.toString();
}
}

View File

@@ -11,7 +11,6 @@ import forge.Command;
import forge.Singletons; import forge.Singletons;
import forge.card.spellability.Ability; import forge.card.spellability.Ability;
import forge.card.spellability.SpellAbility; import forge.card.spellability.SpellAbility;
import forge.card.spellability.SpellPermanent;
import forge.control.input.Input; import forge.control.input.Input;
import forge.game.GameLossReason; import forge.game.GameLossReason;
import forge.game.player.Player; import forge.game.player.Player;
@@ -33,24 +32,8 @@ class CardFactoryEnchantments {
*/ */
public static void buildCard(final Card card, final String cardName) { public static void buildCard(final Card card, final String cardName) {
if (cardName.equals("Bridge from Below")) {
final SpellAbility spell = new SpellPermanent(card) {
private static final long serialVersionUID = 7254358703158629514L;
@Override
public boolean canPlayAI() {
return false;
}
};
// Do not remove SpellAbilities created by AbilityFactory or
// Keywords.
card.clearFirstSpell();
card.addSpellAbility(spell);
}
// *************** START *********** START ************************** // *************** START *********** START **************************
else if (cardName.equals("Night Soil")) { if (cardName.equals("Night Soil")) {
final SpellAbility nightSoil = new Ability(card, "1") { final SpellAbility nightSoil = new Ability(card, "1") {
@Override @Override
public void resolve() { public void resolve() {
@@ -140,30 +123,6 @@ class CardFactoryEnchantments {
card.addSpellAbility(nightSoil); card.addSpellAbility(nightSoil);
} // *************** END ************ END ************************** } // *************** END ************ END **************************
// *************** START *********** START **************************
else if (cardName.equals("Standstill")) {
// Do not remove SpellAbilities created by AbilityFactory or
// Keywords.
card.clearFirstSpell();
card.addSpellAbility(new SpellPermanent(card) {
private static final long serialVersionUID = 6912683989507840172L;
@Override
public boolean canPlayAI() {
final List<Card> compCreats = getActivatingPlayer().getCreaturesInPlay();
final List<Card> humCreats = getActivatingPlayer().getOpponent().getCreaturesInPlay();
// only play standstill if comp controls more creatures than
// human
// this needs some additional rules, maybe add all power +
// toughness and compare
return (compCreats.size() > humCreats.size());
}
});
} // *************** END ************ END **************************
// *************** START *********** START ************************** // *************** START *********** START **************************
else if (cardName.equals("Lich")) { else if (cardName.equals("Lich")) {
final SpellAbility loseAllLife = new Ability(card, "0") { final SpellAbility loseAllLife = new Ability(card, "0") {