- - Adding PeekAndReveal AF. It was simpler to create this subset of Dig than force Kinship cards to have a complex and ugly script.

This commit is contained in:
Sol
2013-01-05 23:04:08 +00:00
parent 0e8ce8e50d
commit 914c5a060f
4 changed files with 110 additions and 0 deletions

2
.gitattributes vendored
View File

@@ -13168,6 +13168,7 @@ src/main/java/forge/card/abilityfactory/ai/LifeSetAi.java -text
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/MustBlockAi.java -text
src/main/java/forge/card/abilityfactory/ai/PeekAndRevealAi.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
@@ -13269,6 +13270,7 @@ src/main/java/forge/card/abilityfactory/effects/ManaReflectedEffect.java -text
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/MustBlockEffect.java -text
src/main/java/forge/card/abilityfactory/effects/PeekAndRevealEffect.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

View File

@@ -65,6 +65,7 @@ public enum ApiType {
MustAttack (MustAttackEffect.class, MustAttackAi.class),
MustBlock (MustBlockEffect.class, MustBlockAi.class),
NameCard (ChooseCardNameEffect.class, ChooseCardNameAi.class),
PeekAndReveal (PeekAndRevealEffect.class, PeekAndRevealAi.class),
PermanentCreature (PermanentCreatureEfect.class, PermanentCreatureAi.class),
PermanentNoncreature (PermanentNoncreatureEffect.class, PermanentNoncreatureAi.class),
Phases (PhasesEffect.class, PhasesAi.class),

View File

@@ -0,0 +1,23 @@
package forge.card.abilityfactory.ai;
import forge.card.abilityfactory.SpellAiLogic;
import forge.card.spellability.SpellAbility;
import forge.game.player.Player;
/**
* TODO: Write javadoc for this type.
*
*/
public class PeekAndRevealAi 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) {
// So far this only appears on Triggers, but will expand
// once things get converted from Dig + NoMove
return false;
}
}

View File

@@ -0,0 +1,84 @@
package forge.card.abilityfactory.effects;
import java.util.ArrayList;
import java.util.List;
import forge.Card;
import forge.CardLists;
import forge.GameActionUtil;
import forge.card.abilityfactory.AbilityFactory;
import forge.card.abilityfactory.SpellEffect;
import forge.card.spellability.AbilitySub;
import forge.card.spellability.SpellAbility;
import forge.game.player.Player;
import forge.game.zone.PlayerZone;
import forge.game.zone.ZoneType;
import forge.gui.GuiChoose;
/**
* PeeakAndReveal is a simplified why of handling something that could
* be done with dig and NoMove$ . All of the Kinship cards are going to use this
* And there's probably a bunch of existing cards that would have simpler scripts
* by just using PeekAndReveal
*
*/
public class PeekAndRevealEffect extends SpellEffect {
/* (non-Javadoc)
* @see forge.card.abilityfactory.SpellEffect#resolve(forge.card.spellability.SpellAbility)
*/
@Override
public void resolve(SpellAbility sa) {
//RevealValid$ Card.sharesCreatureTypeWith | RevealOptional$ True | RememberRevealed$ True
Card source = sa.getSourceCard();
boolean revealOptional = sa.hasParam("RevealOptional");
boolean rememberRevealed = sa.hasParam("RememberRevealed");
String revealValid = sa.hasParam("RevealValid") ? sa.getParam("RevealValid") : "Card";
String peekAmount = sa.hasParam("PeekAmount") ? sa.getParam("PeekAmount") : "1";
int numPeek = AbilityFactory.calculateAmount(sa.getSourceCard(), peekAmount, sa);
// Right now, this is only used on your own library.
Player libraryToPeek = sa.getActivatingPlayer();
Player peekingPlayer = sa.getActivatingPlayer();
final PlayerZone library = libraryToPeek.getZone(ZoneType.Library);
numPeek = Math.min(numPeek, library.size());
List<Card> peekCards = new ArrayList<Card>();
for(int i = 0; i < numPeek; i++) {
peekCards.add(library.get(i));
}
List<Card> revealableCards = CardLists.getValidCards(peekCards, revealValid, sa.getActivatingPlayer(), sa.getSourceCard());
boolean doReveal = !revealableCards.isEmpty();
//peekingPlayer.showCards(peekCards)
if (peekingPlayer.isHuman()) {
GuiChoose.one(source + "Revealing cards from library", peekCards);
if (doReveal && revealOptional) {
StringBuilder question = new StringBuilder();
question.append("Reveal cards to other players?");
doReveal = GameActionUtil.showYesNoDialog(source, question.toString());
}
} else {
if (doReveal && revealOptional) {
// If
AbilitySub subAb = sa.getSubAbility();
doReveal = subAb != null && subAb.chkAIDrawback();
}
}
if (doReveal) {
if (!peekingPlayer.isHuman()) {
GuiChoose.one(source + "Revealing cards from library", revealableCards);
}
// Singletons.getModel().getGameAction().revealCardsToOtherPlayers(peekingPlayer, revealableCards);
if (rememberRevealed) {
for(Card c : revealableCards) {
source.addRemembered(c);
}
}
}
}
}