- 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

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
// Clear out the auto created SpellPemanent spell
if (isSp) {

View File

@@ -64,6 +64,7 @@ public enum ApiType {
MustBlock (MustBlockEffect.class, MustBlockAi.class),
NameCard (ChooseCardNameEffect.class, ChooseCardNameAi.class),
PermanentCreature (PermanentCreatureEfect.class, PermanentCreatureAi.class),
PermanentNoncreature (PermanentNoncreatureEffect.class, PermanentNoncreatureAi.class),
Phases (PhasesEffect.class, PhasesAi.class),
Play (PlayEffect.class, PlayAi.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.card.spellability.Ability;
import forge.card.spellability.SpellAbility;
import forge.card.spellability.SpellPermanent;
import forge.control.input.Input;
import forge.game.GameLossReason;
import forge.game.player.Player;
@@ -33,24 +32,8 @@ class CardFactoryEnchantments {
*/
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 **************************
else if (cardName.equals("Night Soil")) {
if (cardName.equals("Night Soil")) {
final SpellAbility nightSoil = new Ability(card, "1") {
@Override
public void resolve() {
@@ -140,30 +123,6 @@ class CardFactoryEnchantments {
card.addSpellAbility(nightSoil);
} // *************** 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 **************************
else if (cardName.equals("Lich")) {
final SpellAbility loseAllLife = new Ability(card, "0") {