Commit 66c4769d authored by Michael Kamensky's avatar Michael Kamensky

- Added a way to add persistent mana in game states (for puzzles).

- Added basic logic for Evra, Halcyon Witness.
- Added puzzle PS_DOM9.
- Improved implementation for puzzle PS_DOM4.
parent edf5c132
......@@ -57,6 +57,8 @@ public abstract class GameState {
private String computerCounters = "";
private String humanManaPool = "";
private String computerManaPool = "";
private String humanPersistentMana = "";
private String computerPersistentMana = "";
private boolean puzzleCreatorState = false;
......@@ -498,6 +500,13 @@ public abstract class GameState {
computerManaPool = categoryValue;
}
else if (categoryName.endsWith("persistentmana")) {
if (isHuman)
humanPersistentMana = categoryValue;
else
computerPersistentMana = categoryValue;
}
else {
System.out.println("Unknown key: " + categoryName);
}
......@@ -534,8 +543,10 @@ public abstract class GameState {
// Set stack to resolving so things won't trigger/effects be checked right away
game.getStack().setResolving(true);
updateManaPool(human, humanManaPool);
updateManaPool(ai, computerManaPool);
updateManaPool(human, humanManaPool, true, false);
updateManaPool(ai, computerManaPool, true, false);
updateManaPool(human, humanPersistentMana, false, true);
updateManaPool(ai, computerPersistentMana, false, true);
if (!humanCounters.isEmpty()) {
applyCountersToGameEntity(human, humanCounters);
......@@ -589,15 +600,20 @@ public abstract class GameState {
return mana.trim();
}
private void updateManaPool(Player p, String manaDef) {
private void updateManaPool(Player p, String manaDef, boolean clearPool, boolean persistent) {
Game game = p.getGame();
p.getManaPool().clearPool(false);
if (clearPool) {
p.getManaPool().clearPool(false);
}
if (!manaDef.isEmpty()) {
final Card dummy = new Card(-777777, game);
dummy.setOwner(p);
final Map<String, String> produced = Maps.newHashMap();
produced.put("Produced", manaDef);
if (persistent) {
produced.put("PersistentMana", "True");
}
final AbilityManaPart abMana = new AbilityManaPart(dummy, produced);
game.getAction().invoke(new Runnable() {
@Override
......
......@@ -9,6 +9,7 @@ import forge.game.card.Card;
import forge.game.player.Player;
import forge.game.spellability.SpellAbility;
import forge.game.spellability.TargetRestrictions;
import forge.game.zone.MagicStack;
public class LifeExchangeVariantAi extends SpellAbilityAi {
......@@ -83,7 +84,25 @@ public class LifeExchangeVariantAi extends SpellAbilityAi {
return shouldDo;
}
else if ("Evra, Halcyon Witness".equals(sourceName)) {
// TODO add logic
if (!ai.canGainLife())
return false;
int aiLife = ai.getLife();
if (source.getNetPower() > aiLife) {
if (ComputerUtilCombat.lifeInSeriousDanger(ai, ai.getGame().getCombat())) {
return true;
}
// check the top of stack
MagicStack stack = ai.getGame().getStack();
if (!stack.isEmpty()) {
SpellAbility saTop = stack.peekAbility();
if (ComputerUtil.predictDamageFromSpell(saTop, ai) >= aiLife) {
return true;
}
}
}
}
return false;
......
[metadata]
# TODO: This puzzle does not indicate that the AI has 4 Islands on the battlefield, only that it has "open mana to cast Crafty Cutpurse",
# which can be implemented alternatively with an "aimanapool" line, but then the AI sometimes misses the opportunity to cast the card, loses
# the mana forever and never casts the Cutpurse. Maybe there's a better way?
Name:Possibility Storm - Dominaria #04
URL:http://www.possibilitystorm.com/wp-content/uploads/2018/05/063.DOM4_.jpg
Goal:Win
......@@ -12,10 +9,10 @@ Description:Win this turn. Your opponent has a Crafty Cutpurse in hand and has e
humanlife=20
ailife=5
turn=2
#aimanapool=U U U U
aipersistentmana=U U U U
activeplayer=human
activephase=MAIN1
humanhand=Voracious Vampire;Arcane Adaptation;Naban, Dean of Iteration;Deeproot Elite
humanbattlefield=Grand Warlord Radha;Forerunner of the Coalition;Forerunner of the Empire;Slimefoot, the Stowaway;Trespasser's Curse|EnchantingPlayer:AI;Sulfur Falls|Set:DOM;Sulfur Falls|Set:DOM;Sulfur Falls|Set:DOM;Sulfur Falls|Set:DOM;Blooming Marsh;Blooming Marsh;Blooming Marsh
aihand=Crafty Cutpurse
aibattlefield=Naban, Dean of Iteration;Academy Journeymage;Cold-Water Snapper;Island|Set:DOM;Island|Set:DOM;Island|Set:DOM;Island|Set:DOM
aibattlefield=Naban, Dean of Iteration;Academy Journeymage;Cold-Water Snapper
[metadata]
Name:Possibility Storm - Dominaria #09
URL:http://www.possibilitystorm.com/wp-content/uploads/2018/06/068.-DOM9.jpg
Goal:Win
Turns:1
Difficulty:Mythic
Description:Win this turn. Your opponent has access to 4 colorless mana, and you start with the City's Blessing.
[state]
humanlife=20
ailife=2
aipersistentmana=C C C C
turn=1
activeplayer=human
activephase=MAIN1
humanhand=Demystify;Ixalan's Binding;Nissa, Vital Force;Dive Down
humanbattlefield=Thrashing Brontodon|Id:999;Deep Freeze|Attaching:3;Slippery Scoundrel;Rhonas's Stalwart;Plains;Hinterland Harbor;Hinterland Harbor;Hinterland Harbor;Glacial Fortress;Glacial Fortress;Glacial Fortress
aibattlefield=Evra, Halcyon Witness;Ninth Bridge Patrol|Counters:P1P1=1;Lyra Dawnbringer|Id:3;Cast Out|ExecuteScript:TrigExile->999
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment