mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
- Added RepeatEach AF
- Converted Rhys the Redeemed to script
This commit is contained in:
@@ -595,6 +595,10 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
public final void addRemembered(final Object o) {
|
||||
this.rememberedObjects.add(o);
|
||||
}
|
||||
|
||||
public final void removeRemembered(final Object o) {
|
||||
this.rememberedObjects.remove(o);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
||||
@@ -81,6 +81,7 @@ public enum ApiType {
|
||||
RemoveCounterAll ( CountersRemoveAllEffect.class, CannotPlayAi.class ),
|
||||
RemoveFromCombat ( RemoveFromCombatEffect.class, RemoveFromCombatAi.class ),
|
||||
Repeat ( RepeatEffect.class, RepeatAi.class ),
|
||||
RepeatEach ( RepeatEachEffect.class, RepeatEachAi.class ),
|
||||
RestartGame ( RestartGameEffect.class, RestartGameAi.class ),
|
||||
Reveal ( RevealEffect.class, RevealAi.class ),
|
||||
RevealHand ( RevealHandEffect.class, RevealHandAi.class ),
|
||||
|
||||
39
src/main/java/forge/card/abilityfactory/ai/RepeatEachAi.java
Normal file
39
src/main/java/forge/card/abilityfactory/ai/RepeatEachAi.java
Normal file
@@ -0,0 +1,39 @@
|
||||
package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CardPredicates.Presets;
|
||||
import forge.card.abilityfactory.SpellAiLogic;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.player.Player;
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this type.
|
||||
*
|
||||
*/
|
||||
public class RepeatEachAi 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");
|
||||
|
||||
if ("CloneTokens".equals(logic)) {
|
||||
List<Card> allTokens = aiPlayer.getCreaturesInPlay();
|
||||
allTokens = CardLists.filter(allTokens, Presets.TOKEN);
|
||||
|
||||
if (allTokens.size() < 2) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO Add some normal AI variability here
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package forge.card.abilityfactory.effects;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.Singletons;
|
||||
import forge.card.abilityfactory.AbilityFactory;
|
||||
import forge.card.abilityfactory.SpellEffect;
|
||||
import forge.card.spellability.AbilitySub;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.GameState;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.ZoneType;
|
||||
|
||||
public class RepeatEachEffect extends SpellEffect {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.card.abilityfactory.SpellEffect#resolve(forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
public void resolve(SpellAbility sa) {
|
||||
final AbilityFactory afRepeat = new AbilityFactory();
|
||||
Card source = sa.getSourceCard();
|
||||
|
||||
// setup subability to repeat
|
||||
final SpellAbility repeat = afRepeat.getAbility(sa.getSourceCard().getSVar(sa.getParam("RepeatSubAbility")), source);
|
||||
repeat.setActivatingPlayer(sa.getActivatingPlayer());
|
||||
((AbilitySub) repeat).setParent(sa);
|
||||
|
||||
GameState game = Singletons.getModel().getGame();
|
||||
|
||||
if (sa.hasParam("RepeatCards")) {
|
||||
ZoneType zone = sa.hasParam("Zone") ? ZoneType.smartValueOf(sa.getParam("Zone")) : ZoneType.Battlefield;
|
||||
|
||||
final List<Card> repeatCards = CardLists.getValidCards(game.getCardsIn(zone),
|
||||
sa.getParam("RepeatCards"), source.getController(), source);
|
||||
|
||||
for(Card card : repeatCards) {
|
||||
source.addRemembered(card);
|
||||
AbilityFactory.resolve(repeat, false);
|
||||
source.removeRemembered(card);
|
||||
}
|
||||
}
|
||||
|
||||
if (sa.hasParam("RepeatPlayers")) {
|
||||
final List<Player> repeatPlayers = AbilityFactory.getDefinedPlayers(source, sa.getParam("RepeatPlayers"), sa);
|
||||
|
||||
for(Player player : repeatPlayers) {
|
||||
source.addRemembered(player);
|
||||
AbilityFactory.resolve(repeat, false);
|
||||
source.removeRemembered(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -312,56 +312,6 @@ public class CardFactoryCreatures {
|
||||
});
|
||||
}
|
||||
|
||||
private static void getCard_RhysTheRedeemed(final Card card) {
|
||||
final Cost abCost = new Cost(card, "4 GW GW T", true);
|
||||
class RhysTheRedeemedAbility extends AbilityActivated {
|
||||
public RhysTheRedeemedAbility(final Card ca, final Cost co, final Target t) {
|
||||
super(ca, co, t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbilityActivated getCopy() {
|
||||
return new RhysTheRedeemedAbility(getSourceCard(),
|
||||
getPayCosts(), new Target(getTarget()));
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 6297992502069547478L;
|
||||
|
||||
@Override
|
||||
public void resolve() {
|
||||
List<Card> allTokens = card.getController().getCreaturesInPlay();
|
||||
allTokens = CardLists.filter(allTokens, Presets.TOKEN);
|
||||
|
||||
CardFactoryUtil.copyTokens(allTokens);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlayAI() {
|
||||
List<Card> allTokens = getActivatingPlayer().getCreaturesInPlay();
|
||||
allTokens = CardLists.filter(allTokens, Presets.TOKEN);
|
||||
|
||||
return allTokens.size() >= 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
final StringBuilder sbDesc = new StringBuilder();
|
||||
sbDesc.append(abCost).append("For each creature token you control, ");
|
||||
sbDesc.append("put a token that's a copy of that creature onto the battlefield.");
|
||||
return sbDesc.toString();
|
||||
}
|
||||
}
|
||||
final AbilityActivated copyTokens1 = new RhysTheRedeemedAbility(card, abCost, null);
|
||||
|
||||
card.addSpellAbility(copyTokens1);
|
||||
|
||||
final StringBuilder sbStack = new StringBuilder();
|
||||
sbStack.append(card.getName());
|
||||
sbStack.append(" - For each creature token you control, put a token ");
|
||||
sbStack.append("that's a copy of that creature onto the battlefield.");
|
||||
copyTokens1.setStackDescription(sbStack.toString());
|
||||
}
|
||||
|
||||
private static void getCard_SphinxJwar(final Card card) {
|
||||
final SpellAbility ability1 = new AbilityStatic(card, "0") {
|
||||
@Override
|
||||
@@ -1262,8 +1212,6 @@ public class CardFactoryCreatures {
|
||||
getCard_PainterServant(card);
|
||||
} else if (cardName.equals("Stangg")) {
|
||||
getCard_Stangg(card);
|
||||
} else if (cardName.equals("Rhys the Redeemed")) {
|
||||
getCard_RhysTheRedeemed(card);
|
||||
} else if (cardName.equals("Sphinx of Jwar Isle")) {
|
||||
getCard_SphinxJwar(card);
|
||||
} else if (cardName.equals("Master of the Wild Hunt")) {
|
||||
|
||||
Reference in New Issue
Block a user