mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +00:00
- Somewhat better LifeSetAi logic for Torgaar which accounts for possible different starting life.
This commit is contained in:
@@ -126,11 +126,10 @@ public class LifeSetAi extends SpellAbilityAi {
|
|||||||
|
|
||||||
// special cases when amount can't be calculated without targeting first
|
// special cases when amount can't be calculated without targeting first
|
||||||
if (amount == 0 && "TargetedPlayer$StartingLife/HalfDown".equals(source.getSVar(amountStr))) {
|
if (amount == 0 && "TargetedPlayer$StartingLife/HalfDown".equals(source.getSVar(amountStr))) {
|
||||||
// TODO: this assumes equal starting life for all players, which is not true e.g. for Archenemy
|
// e.g. Torgaar, Famine Incarnate
|
||||||
amount = ai.getStartingLife() / 2;
|
return doHalfStartingLifeLogic(ai, opponent, sa);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (sourceName.equals("Eternity Vessel")
|
if (sourceName.equals("Eternity Vessel")
|
||||||
&& (opponent.isCardInPlay("Vampire Hexmage") || (source.getCounters(CounterType.CHARGE) == 0))) {
|
&& (opponent.isCardInPlay("Vampire Hexmage") || (source.getCounters(CounterType.CHARGE) == 0))) {
|
||||||
return false;
|
return false;
|
||||||
@@ -160,4 +159,36 @@ public class LifeSetAi extends SpellAbilityAi {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean doHalfStartingLifeLogic(Player ai, Player opponent, SpellAbility sa) {
|
||||||
|
int aiAmount = ai.getStartingLife() / 2;
|
||||||
|
int oppAmount = opponent.getStartingLife() / 2;
|
||||||
|
int aiLife = ai.getLife();
|
||||||
|
int oppLife = opponent.getLife();
|
||||||
|
|
||||||
|
sa.resetTargets();
|
||||||
|
|
||||||
|
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||||
|
if (tgt != null) {
|
||||||
|
if (tgt.canOnlyTgtOpponent()) {
|
||||||
|
if (oppLife > oppAmount) {
|
||||||
|
sa.getTargets().add(opponent);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (aiAmount > ai.getLife() && aiLife <= 10) {
|
||||||
|
sa.getTargets().add(ai);
|
||||||
|
} else if (oppLife > oppAmount) {
|
||||||
|
sa.getTargets().add(opponent);
|
||||||
|
} else if (aiAmount > aiLife) {
|
||||||
|
sa.getTargets().add(ai);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user