mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
- Adding Karn Liberated (albeit with limited AI support for AF_RestartGame)
This commit is contained in:
@@ -763,6 +763,11 @@ public class AbilityFactory {
|
||||
se = new RepeatEffect();
|
||||
}
|
||||
|
||||
else if (this.api.equals("RestartGame")) {
|
||||
ai = new RestartGameAi();
|
||||
se = new RestartGameEffect();
|
||||
}
|
||||
|
||||
else if (this.api.equals("Reveal")) {
|
||||
ai = new RevealAi();
|
||||
se = new RevealEffect();
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package forge.card.abilityfactory.ai;
|
||||
|
||||
import java.util.Map;
|
||||
import forge.card.abilityfactory.SpellAiLogic;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.player.Player;
|
||||
|
||||
public class RestartGameAi extends SpellAiLogic {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* forge.card.abilityfactory.AbilityFactoryAlterLife.SpellAiLogic#canPlayAI
|
||||
* (forge.game.player.Player, java.util.Map,
|
||||
* forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
public boolean canPlayAI(Player ai, Map<String, String> params, SpellAbility sa) {
|
||||
// The only card that uses this is Karn Liberated
|
||||
|
||||
// TODO Add Logic, check if AI is losing game state, or life
|
||||
|
||||
// TODO Add Logic, check if any good cards will be available to be returned
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doTriggerAI(Player ai, Map<String, String> params, SpellAbility sa, boolean mandatory) {
|
||||
// This trigger AI is completely unused, but return true just in case
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package forge.card.abilityfactory.effects;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CardPredicates;
|
||||
import forge.Singletons;
|
||||
import forge.card.abilityfactory.SpellEffect;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.GameNew;
|
||||
import forge.game.GameState;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.ZoneType;
|
||||
|
||||
public class RestartGameEffect extends SpellEffect {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.card.abilityfactory.AbilityFactoryAlterLife.SpellEffect#resolve(java.util.Map, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
public void resolve(Map<String, String> params, SpellAbility sa) {
|
||||
GameState game = Singletons.getModel().getGame();
|
||||
List<Player> players = game.getPlayers();
|
||||
Map<Player, List<Card>> playerLibraries = new HashMap<Player, List<Card>>();
|
||||
|
||||
// Don't grab Ante Zones
|
||||
List<ZoneType> restartZones = new ArrayList<ZoneType>(Arrays.asList(ZoneType.Battlefield,
|
||||
ZoneType.Library, ZoneType.Graveyard, ZoneType.Hand, ZoneType.Exile, ZoneType.Command));
|
||||
|
||||
ZoneType leaveZone = ZoneType.smartValueOf(params.containsKey("RestrictFromZone") ? params.get("RestrictFromZone") : null);
|
||||
restartZones.remove(leaveZone);
|
||||
String leaveRestriction = params.containsKey("RestrictFromValid") ? params.get("RestrictFromValid") : "Card";
|
||||
|
||||
for(Player p : players) {
|
||||
List<Card> newLibrary = new ArrayList<Card>(p.getCardsIn(restartZones));
|
||||
List<Card> filteredCards = null;
|
||||
if (leaveZone != null) {
|
||||
filteredCards = CardLists.filter(p.getCardsIn(leaveZone),
|
||||
CardPredicates.restriction(leaveRestriction.split(","), p, sa.getSourceCard()));
|
||||
}
|
||||
|
||||
newLibrary.addAll(filteredCards);
|
||||
playerLibraries.put(p, newLibrary);
|
||||
}
|
||||
|
||||
GameNew.restartGame(game, sa.getActivatingPlayer(), playerLibraries);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.card.abilityfactory.AbilityFactoryAlterLife.SpellEffect#getStackDescription(java.util.Map, forge.card.spellability.SpellAbility)
|
||||
*/
|
||||
@Override
|
||||
public String getStackDescription(Map<String, String> params, SpellAbility sa) {
|
||||
String desc = params.get("SpellDescription");
|
||||
|
||||
if (desc == null) {
|
||||
desc = "Restart the game.";
|
||||
}
|
||||
|
||||
return desc.replace("CARDNAME", sa.getSourceCard().getName());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user