mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
- Added AI logic for Berserk.
- Some minor cleanup.
This commit is contained in:
@@ -43,6 +43,7 @@ public enum AiProps { /** */
|
|||||||
ALWAYS_COUNTER_SPELLS_FROM_NAMED_CARDS (""), /** */
|
ALWAYS_COUNTER_SPELLS_FROM_NAMED_CARDS (""), /** */
|
||||||
ACTIVELY_DESTROY_ARTS_AND_NONAURA_ENCHS ("false"), /** */
|
ACTIVELY_DESTROY_ARTS_AND_NONAURA_ENCHS ("false"), /** */
|
||||||
PRIORITY_REDUCTION_FOR_STORM_SPELLS ("0"), /** */
|
PRIORITY_REDUCTION_FOR_STORM_SPELLS ("0"), /** */
|
||||||
|
USE_BERSERK_AGGRESSIVELY ("false"), /** */
|
||||||
MIN_COUNT_FOR_STORM_SPELLS ("0"); /** */
|
MIN_COUNT_FOR_STORM_SPELLS ("0"); /** */
|
||||||
|
|
||||||
private final String strDefaultVal;
|
private final String strDefaultVal;
|
||||||
|
|||||||
@@ -1087,6 +1087,7 @@ public class ComputerUtilCard {
|
|||||||
final Game game = ai.getGame();
|
final Game game = ai.getGame();
|
||||||
final PhaseHandler phase = game.getPhaseHandler();
|
final PhaseHandler phase = game.getPhaseHandler();
|
||||||
final Combat combat = phase.getCombat();
|
final Combat combat = phase.getCombat();
|
||||||
|
final boolean isBerserk = "Berserk".equals(sa.getParam("AILogic"));
|
||||||
|
|
||||||
if (!c.canBeTargetedBy(sa)) {
|
if (!c.canBeTargetedBy(sa)) {
|
||||||
return false;
|
return false;
|
||||||
@@ -1173,6 +1174,9 @@ public class ComputerUtilCard {
|
|||||||
List<Card> opposing = null;
|
List<Card> opposing = null;
|
||||||
boolean pumpedWillDie = false;
|
boolean pumpedWillDie = false;
|
||||||
final boolean isAttacking = combat.isAttacking(c);
|
final boolean isAttacking = combat.isAttacking(c);
|
||||||
|
|
||||||
|
if (isBerserk && isAttacking) { pumpedWillDie = true; }
|
||||||
|
|
||||||
if (isAttacking) {
|
if (isAttacking) {
|
||||||
pumpedCombat.addAttacker(pumped, opp);
|
pumpedCombat.addAttacker(pumped, opp);
|
||||||
opposing = combat.getBlockers(c);
|
opposing = combat.getBlockers(c);
|
||||||
@@ -1302,6 +1306,17 @@ public class ComputerUtilCard {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isBerserk) {
|
||||||
|
// if we got here, Berserk will result in the pumped creature dying at EOT and the opponent will not lose
|
||||||
|
if (ai.getController() instanceof PlayerControllerAi) {
|
||||||
|
boolean aggr = ((PlayerControllerAi)ai.getController()).getAi().getBooleanProperty(AiProps.USE_BERSERK_AGGRESSIVELY);
|
||||||
|
if (!aggr) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return MyRandom.getRandom().nextFloat() < chance;
|
return MyRandom.getRandom().nextFloat() < chance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1329,8 +1344,12 @@ public class ComputerUtilCard {
|
|||||||
kws.add(kw);
|
kws.add(kw);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final boolean isBerserk = "Berserk".equals(sa.getParam("AILogic"));
|
||||||
|
final int berserkPower = isBerserk ? c.getCurrentPower() : 0;
|
||||||
|
|
||||||
pumped.addNewPT(c.getCurrentPower(), c.getCurrentToughness(), timestamp);
|
pumped.addNewPT(c.getCurrentPower(), c.getCurrentToughness(), timestamp);
|
||||||
pumped.addTempPowerBoost(c.getTempPowerBoost() + power);
|
pumped.addTempPowerBoost(c.getTempPowerBoost() + power + berserkPower);
|
||||||
pumped.addTempToughnessBoost(c.getTempToughnessBoost() + toughness);
|
pumped.addTempToughnessBoost(c.getTempToughnessBoost() + toughness);
|
||||||
pumped.addChangedCardKeywords(kws, new ArrayList<String>(), false, timestamp);
|
pumped.addChangedCardKeywords(kws, new ArrayList<String>(), false, timestamp);
|
||||||
Set<CounterType> types = c.getCounters().keySet();
|
Set<CounterType> types = c.getCounters().keySet();
|
||||||
|
|||||||
@@ -1308,7 +1308,7 @@ public class ComputerUtilMana {
|
|||||||
* @param shardColor
|
* @param shardColor
|
||||||
* a mana shard to specifically test for.
|
* a mana shard to specifically test for.
|
||||||
* @return a int.
|
* @return a int.
|
||||||
* @since 1.0.15
|
* @since 1.5.59
|
||||||
*/
|
*/
|
||||||
public static int determineLeftoverMana(final SpellAbility sa, final Player player, final String shardColor) {
|
public static int determineLeftoverMana(final SpellAbility sa, final Player player, final String shardColor) {
|
||||||
ManaCost origCost = sa.getPayCosts().getTotalMana();
|
ManaCost origCost = sa.getPayCosts().getTotalMana();
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
package forge.ai.ability;
|
package forge.ai.ability;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.collect.Iterables;
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import forge.ai.AiController;
|
import forge.ai.AiController;
|
||||||
@@ -36,7 +34,6 @@ import forge.game.phase.PhaseHandler;
|
|||||||
import forge.game.phase.PhaseType;
|
import forge.game.phase.PhaseType;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.player.PlayerActionConfirmMode;
|
import forge.game.player.PlayerActionConfirmMode;
|
||||||
import forge.game.player.PlayerPredicates;
|
|
||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
import forge.game.spellability.SpellAbilityRestriction;
|
import forge.game.spellability.SpellAbilityRestriction;
|
||||||
import forge.game.spellability.TargetRestrictions;
|
import forge.game.spellability.TargetRestrictions;
|
||||||
@@ -144,6 +141,7 @@ public class PumpAi extends PumpAiBase {
|
|||||||
final String aiLogic = sa.getParam("AILogic");
|
final String aiLogic = sa.getParam("AILogic");
|
||||||
|
|
||||||
final boolean isFight = "Fight".equals(aiLogic) || "PowerDmg".equals(aiLogic);
|
final boolean isFight = "Fight".equals(aiLogic) || "PowerDmg".equals(aiLogic);
|
||||||
|
final boolean isBerserk = "Berserk".equals(aiLogic);
|
||||||
|
|
||||||
if ("MoveCounter".equals(aiLogic)) {
|
if ("MoveCounter".equals(aiLogic)) {
|
||||||
final SpellAbility moveSA = sa.findSubAbilityByType(ApiType.MoveCounter);
|
final SpellAbility moveSA = sa.findSubAbilityByType(ApiType.MoveCounter);
|
||||||
@@ -337,7 +335,7 @@ public class PumpAi extends PumpAiBase {
|
|||||||
attack = AbilityUtils.calculateAmount(sa.getHostCard(), numAttack, sa);
|
attack = AbilityUtils.calculateAmount(sa.getHostCard(), numAttack, sa);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((numDefense.contains("X") && defense == 0) || (numAttack.contains("X") && attack == 0)) {
|
if ((numDefense.contains("X") && defense == 0) || (numAttack.contains("X") && attack == 0 && !isBerserk)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
PLAY_AGGRO=false
|
PLAY_AGGRO=false
|
||||||
|
USE_BERSERK_AGGRESSIVELY=false
|
||||||
|
|
||||||
MULLIGAN_THRESHOLD=5
|
MULLIGAN_THRESHOLD=5
|
||||||
CHEAT_WITH_MANA_ON_SHUFFLE=true
|
CHEAT_WITH_MANA_ON_SHUFFLE=true
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
PLAY_AGGRO=false
|
PLAY_AGGRO=false
|
||||||
|
USE_BERSERK_AGGRESSIVELY=false
|
||||||
|
|
||||||
MULLIGAN_THRESHOLD=4
|
MULLIGAN_THRESHOLD=4
|
||||||
CHEAT_WITH_MANA_ON_SHUFFLE=true
|
CHEAT_WITH_MANA_ON_SHUFFLE=true
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
PLAY_AGGRO=true
|
PLAY_AGGRO=true
|
||||||
|
USE_BERSERK_AGGRESSIVELY=true
|
||||||
|
|
||||||
MULLIGAN_THRESHOLD=3
|
MULLIGAN_THRESHOLD=3
|
||||||
CHEAT_WITH_MANA_ON_SHUFFLE=true
|
CHEAT_WITH_MANA_ON_SHUFFLE=true
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
Name:Berserk
|
Name:Berserk
|
||||||
ManaCost:G
|
ManaCost:G
|
||||||
Types:Instant
|
Types:Instant
|
||||||
A:SP$ Pump | Cost$ G | ValidTgts$ Creature | TgtPrompt$ Select target creature | NumAtt$ X | KW$ Trample | ActivationPhases$ Upkeep->Declare Blockers | References$ X | SubAbility$ DelTrig | SpellDescription$ Cast CARDNAME only before the combat damage step. Target creature gains trample and gets +X/+0 until end of turn, where X is its power. At the beginning of the next end step, destroy that creature if it attacked this turn.
|
A:SP$ Pump | Cost$ G | ValidTgts$ Creature | TgtPrompt$ Select target creature | NumAtt$ X | KW$ Trample | ActivationPhases$ Upkeep->Declare Blockers | References$ X | SubAbility$ DelTrig | AILogic$ Berserk | SpellDescription$ Cast CARDNAME only before the combat damage step. Target creature gains trample and gets +X/+0 until end of turn, where X is its power. At the beginning of the next end step, destroy that creature if it attacked this turn.
|
||||||
SVar:DelTrig:DB$ DelayedTrigger | Mode$ Phase | Phase$ End Of Turn | Execute$ TrigDestroy | RememberObjects$ Targeted | TriggerDescription$ At the beginning of the next end step, destroy that creature if it attacked this turn. | AILogic$ Always
|
SVar:DelTrig:DB$ DelayedTrigger | Mode$ Phase | Phase$ End Of Turn | Execute$ TrigDestroy | RememberObjects$ Targeted | TriggerDescription$ At the beginning of the next end step, destroy that creature if it attacked this turn. | AILogic$ Always
|
||||||
SVar:TrigDestroy:DB$ Destroy | Defined$ DelayTriggerRemembered | ConditionDefined$ DelayTriggerRemembered | ConditionPresent$ Card.attackedThisTurn | ConditionCompare$ GE1
|
SVar:TrigDestroy:DB$ Destroy | Defined$ DelayTriggerRemembered | ConditionDefined$ DelayTriggerRemembered | ConditionPresent$ Card.attackedThisTurn | ConditionCompare$ GE1
|
||||||
SVar:X:Targeted$CardPower
|
SVar:X:Targeted$CardPower
|
||||||
SVar:RemAIDeck:True
|
|
||||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/berserk.jpg
|
SVar:Picture:http://www.wizards.com/global/images/magic/general/berserk.jpg
|
||||||
Oracle:Cast Berserk only before the combat damage step.\nTarget creature gains trample and gets +X/+0 until end of turn, where X is its power. At the beginning of the next end step, destroy that creature if it attacked this turn.
|
Oracle:Cast Berserk only before the combat damage step.\nTarget creature gains trample and gets +X/+0 until end of turn, where X is its power. At the beginning of the next end step, destroy that creature if it attacked this turn.
|
||||||
|
|||||||
Reference in New Issue
Block a user