mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
- Added a way to specify AILifeThreshold for cards which do not have a life cost but which deal damage or make the player lose life.
- Added AI life activation threshold to Smallpox and Pox to prevent the AI from killing itself with them.
This commit is contained in:
@@ -626,6 +626,9 @@ public class AiController {
|
|||||||
|
|
||||||
public AiPlayDecision canPlaySa(SpellAbility sa) {
|
public AiPlayDecision canPlaySa(SpellAbility sa) {
|
||||||
final Card card = sa.getHostCard();
|
final Card card = sa.getHostCard();
|
||||||
|
if (!checkAiSpecificRestrictions(player, sa)) {
|
||||||
|
return AiPlayDecision.CantPlayAi;
|
||||||
|
}
|
||||||
if (sa instanceof WrappedAbility) {
|
if (sa instanceof WrappedAbility) {
|
||||||
return canPlaySa(((WrappedAbility) sa).getWrappedAbility());
|
return canPlaySa(((WrappedAbility) sa).getWrappedAbility());
|
||||||
}
|
}
|
||||||
@@ -1612,5 +1615,19 @@ public class AiController {
|
|||||||
}
|
}
|
||||||
return ComputerUtil.chooseSacrificeType(player, type, ability, ability.getTargetCard(), amount);
|
return ComputerUtil.chooseSacrificeType(player, type, ability, ability.getTargetCard(), amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean checkAiSpecificRestrictions(final Player ai, final SpellAbility sa) {
|
||||||
|
// AI-specific restrictions specified as activation parameters in spell abilities
|
||||||
|
|
||||||
|
if (sa.hasParam("AILifeThreshold")) {
|
||||||
|
System.out.println("threshold");
|
||||||
|
if (ai.getLife() <= Integer.parseInt(sa.getParam("AILifeThreshold"))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
Name:Pox
|
Name:Pox
|
||||||
ManaCost:B B B
|
ManaCost:B B B
|
||||||
Types:Sorcery
|
Types:Sorcery
|
||||||
A:SP$ RepeatEach | Cost$ B B B | RepeatPlayers$ Player | RepeatSubAbility$ DBLoseLife | SpellDescription$ Each player loses a third of his or her life, then discards a third of the cards in his or her hand, then sacrifices a third of the creatures he or she controls, then sacrifices a third of the lands he or she controls. Round up each time.
|
A:SP$ RepeatEach | Cost$ B B B | RepeatPlayers$ Player | RepeatSubAbility$ DBLoseLife | AILifeThreshold$ 1 | SpellDescription$ Each player loses a third of his or her life, then discards a third of the cards in his or her hand, then sacrifices a third of the creatures he or she controls, then sacrifices a third of the lands he or she controls. Round up each time.
|
||||||
SVar:DBLoseLife:DB$ LoseLife | LifeAmount$ A | References$ A | Defined$ Player.IsRemembered | SubAbility$ DBDiscard
|
SVar:DBLoseLife:DB$ LoseLife | LifeAmount$ A | References$ A | Defined$ Player.IsRemembered | SubAbility$ DBDiscard
|
||||||
SVar:DBDiscard:DB$ Discard | NumCards$ C | References$ C | Defined$ Player.IsRemembered | Mode$ TgtChoose | SubAbility$ DBCreature
|
SVar:DBDiscard:DB$ Discard | NumCards$ C | References$ C | Defined$ Player.IsRemembered | Mode$ TgtChoose | SubAbility$ DBCreature
|
||||||
SVar:DBCreature:DB$ Sacrifice | SacValid$ Creature | Amount$ E | References$ E | Defined$ Player.IsRemembered | SubAbility$ DBLand
|
SVar:DBCreature:DB$ Sacrifice | SacValid$ Creature | Amount$ E | References$ E | Defined$ Player.IsRemembered | SubAbility$ DBLand
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
Name:Smallpox
|
Name:Smallpox
|
||||||
ManaCost:B B
|
ManaCost:B B
|
||||||
Types:Sorcery
|
Types:Sorcery
|
||||||
A:SP$ LoseLife | Cost$ B B | Defined$ Player | LifeAmount$ 1 | SpellDescription$ Each player loses 1 life, discards a card, sacrifices a creature, then sacrifices a land. | SubAbility$ DBDiscard
|
A:SP$ LoseLife | Cost$ B B | Defined$ Player | LifeAmount$ 1 | AILifeThreshold$ 1 | SpellDescription$ Each player loses 1 life, discards a card, sacrifices a creature, then sacrifices a land. | SubAbility$ DBDiscard
|
||||||
SVar:DBDiscard:DB$Discard | NumCards$ 1 | Mode$ TgtChoose | Defined$ Player | SubAbility$ DBSacCreature
|
SVar:DBDiscard:DB$Discard | NumCards$ 1 | Mode$ TgtChoose | Defined$ Player | SubAbility$ DBSacCreature
|
||||||
SVar:DBSacCreature:DB$Sacrifice | SacValid$ Creature | Defined$ Player | SubAbility$ DBSacLand
|
SVar:DBSacCreature:DB$Sacrifice | SacValid$ Creature | Defined$ Player | SubAbility$ DBSacLand
|
||||||
SVar:DBSacLand:DB$Sacrifice | SacValid$ Land | Defined$ Player
|
SVar:DBSacLand:DB$Sacrifice | SacValid$ Land | Defined$ Player
|
||||||
|
|||||||
Reference in New Issue
Block a user