mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-14 09:48:02 +00:00
- ChooseNumberAi: logic for By Invitation Only.
This commit is contained in:
@@ -1892,6 +1892,12 @@ public class AiController {
|
||||
return AbilityUtils.calculateAmount(source, source.getSVar("EnergyToPay"), sa);
|
||||
} else if ("Vermin".equals(logic)) {
|
||||
return MyRandom.getRandom().nextInt(Math.max(player.getLife() - 5, 0));
|
||||
} else if ("SweepCreatures".equals(logic)) {
|
||||
int maxCreatures = 0;
|
||||
for (Player opp : player.getOpponents()) {
|
||||
maxCreatures = Math.max(maxCreatures, opp.getCreaturesInPlay().size());
|
||||
}
|
||||
return Math.min(13, maxCreatures);
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
@@ -11,9 +11,21 @@ public class ChooseNumberAi extends SpellAbilityAi {
|
||||
|
||||
@Override
|
||||
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) {
|
||||
if (!sa.hasParam("AILogic")) {
|
||||
String aiLogic = sa.getParamOrDefault("AILogic", "");
|
||||
|
||||
if (aiLogic.isEmpty()) {
|
||||
return false;
|
||||
} else if (aiLogic.equals("SweepCreatures")) {
|
||||
int ownCreatureCount = aiPlayer.getCreaturesInPlay().size();
|
||||
int oppMaxCreatureCount = 0;
|
||||
for (Player opp : aiPlayer.getOpponents()) {
|
||||
oppMaxCreatureCount = Math.max(oppMaxCreatureCount, opp.getCreaturesInPlay().size());
|
||||
}
|
||||
|
||||
// TODO: maybe check if the AI is actually pressured and/or check the total value of the creatures on both sides of the board
|
||||
return ownCreatureCount > oppMaxCreatureCount + 2 || ownCreatureCount < oppMaxCreatureCount;
|
||||
}
|
||||
|
||||
TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||
if (tgt != null) {
|
||||
sa.resetTargets();
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
Name:By Invitation Only
|
||||
ManaCost:3 W W
|
||||
Types:Sorcery
|
||||
A:SP$ ChooseNumber | Defined$ You | Min$ 0 | Max$ 13 | SubAbility$ DBSac | StackDescription$ SpellDescription | SpellDescription$ Choose a number between 0 and 13. Each player sacrifices that many creatures.
|
||||
A:SP$ ChooseNumber | Defined$ You | Min$ 0 | Max$ 13 | SubAbility$ DBSac | AILogic$ SweepCreatures | StackDescription$ SpellDescription | SpellDescription$ Choose a number between 0 and 13. Each player sacrifices that many creatures.
|
||||
SVar:DBSac:DB$ Sacrifice | Defined$ Player | SacValid$ Creature | Amount$ X | StackDescription$ None
|
||||
SVar:X:Count$ChosenNumber
|
||||
AI:RemoveDeck:All
|
||||
Oracle:Choose a number between 0 and 13. Each player sacrifices that many creatures.
|
||||
|
||||
Reference in New Issue
Block a user