mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 18:58:00 +00:00
Merge branch 'sacrifice' into 'master'
getPlayers: use APNAP order See merge request core-developers/forge!5510
This commit is contained in:
@@ -405,7 +405,6 @@ public class Game {
|
||||
sbaCheckedCommandList.clear();
|
||||
}
|
||||
|
||||
|
||||
public final PhaseHandler getPhaseHandler() {
|
||||
return phaseHandler;
|
||||
}
|
||||
@@ -766,8 +765,7 @@ public class Game {
|
||||
iAlive = ingamePlayers.indexOf(allPlayers.get(iPlayer));
|
||||
} while (iAlive < 0);
|
||||
iPlayer = iAlive;
|
||||
}
|
||||
else { // for the case playerTurn hasn't died
|
||||
} else { // for the case playerTurn hasn't died
|
||||
final int numPlayersInGame = ingamePlayers.size();
|
||||
iPlayer = (iPlayer + shift) % numPlayersInGame;
|
||||
if (iPlayer < 0) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package forge.game.ability;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -198,13 +199,19 @@ public abstract class SpellAbilityEffect {
|
||||
// Players
|
||||
protected final static PlayerCollection getTargetPlayers(final SpellAbility sa) { return getPlayers(false, "Defined", sa); }
|
||||
protected final static PlayerCollection getTargetPlayers(final SpellAbility sa, final String definedParam) { return getPlayers(false, definedParam, sa); }
|
||||
protected final static PlayerCollection getDefinedPlayersOrTargeted(final SpellAbility sa) { return getPlayers(true, "Defined", sa); }
|
||||
protected final static PlayerCollection getDefinedPlayersOrTargeted(final SpellAbility sa) { return getPlayers(true, "Defined", sa); }
|
||||
protected final static PlayerCollection getDefinedPlayersOrTargeted(final SpellAbility sa, final String definedParam) { return getPlayers(true, definedParam, sa); }
|
||||
|
||||
private static PlayerCollection getPlayers(final boolean definedFirst, final String definedParam, final SpellAbility sa) {
|
||||
final boolean useTargets = sa.usesTargeting() && (!definedFirst || !sa.hasParam(definedParam));
|
||||
return useTargets ? new PlayerCollection(sa.getTargets().getTargetPlayers())
|
||||
PlayerCollection players = useTargets ? new PlayerCollection(sa.getTargets().getTargetPlayers())
|
||||
: AbilityUtils.getDefinedPlayers(sa.getHostCard(), sa.getParam(definedParam), sa);
|
||||
// try sort in APNAP order
|
||||
int indexAP = players.indexOf(sa.getHostCard().getGame().getPhaseHandler().getPlayerTurn());
|
||||
if (indexAP != -1) {
|
||||
Collections.rotate(players, - indexAP);
|
||||
}
|
||||
return players;
|
||||
}
|
||||
|
||||
// Spells
|
||||
@@ -219,8 +226,8 @@ public abstract class SpellAbilityEffect {
|
||||
}
|
||||
|
||||
// Targets of card or player type
|
||||
protected final static List<GameEntity> getTargetEntities(final SpellAbility sa) { return getEntities(false, "Defined", sa); }
|
||||
protected final static List<GameEntity> getTargetEntities(final SpellAbility sa, final String definedParam) { return getEntities(false, definedParam, sa); }
|
||||
protected final static List<GameEntity> getTargetEntities(final SpellAbility sa) { return getEntities(false, "Defined", sa); }
|
||||
protected final static List<GameEntity> getTargetEntities(final SpellAbility sa, final String definedParam) { return getEntities(false, definedParam, sa); }
|
||||
protected final static List<GameEntity> getDefinedEntitiesOrTargeted(SpellAbility sa, final String definedParam) { return getEntities(true, definedParam, sa); }
|
||||
|
||||
private static List<GameEntity> getEntities(final boolean definedFirst, final String definedParam, final SpellAbility sa) {
|
||||
|
||||
@@ -95,20 +95,11 @@ public class SacrificeEffect extends SpellAbilityEffect {
|
||||
final boolean exploit = sa.hasParam("Exploit");
|
||||
final boolean sacEachValid = sa.hasParam("SacEachValid");
|
||||
|
||||
String valid = sa.getParam("SacValid");
|
||||
if (valid == null) {
|
||||
valid = "Self";
|
||||
}
|
||||
|
||||
String msg = sa.getParam("SacMessage");
|
||||
if (msg == null) {
|
||||
msg = valid;
|
||||
}
|
||||
String valid = sa.getParamOrDefault("SacValid", "Self");
|
||||
String msg = sa.getParamOrDefault("SacMessage", valid);
|
||||
|
||||
final boolean destroy = sa.hasParam("Destroy");
|
||||
final boolean remSacrificed = sa.hasParam("RememberSacrificed");
|
||||
final String remSVar = sa.getParam("RememberSacrificedSVar");
|
||||
int countSacrificed = 0;
|
||||
CardZoneTable table = new CardZoneTable();
|
||||
Map<AbilityKey, Object> params = AbilityKey.newMap();
|
||||
params.put(AbilityKey.LastStateBattlefield, game.copyLastStateBattlefield());
|
||||
@@ -116,7 +107,6 @@ public class SacrificeEffect extends SpellAbilityEffect {
|
||||
if (valid.equals("Self") && game.getZoneOf(card) != null) {
|
||||
if (game.getZoneOf(card).is(ZoneType.Battlefield)) {
|
||||
if (game.getAction().sacrifice(card, sa, table, params) != null) {
|
||||
countSacrificed++;
|
||||
if (remSacrificed) {
|
||||
card.addRemembered(card);
|
||||
}
|
||||
@@ -198,22 +188,12 @@ public class SacrificeEffect extends SpellAbilityEffect {
|
||||
game.getTriggerHandler().runTrigger(TriggerType.Exploited, runParams, false);
|
||||
}
|
||||
if (wasDestroyed || wasSacrificed) {
|
||||
countSacrificed++;
|
||||
if (remSacrificed) {
|
||||
card.addRemembered(lKICopy);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (remSVar != null) {
|
||||
card.setSVar(remSVar, String.valueOf(countSacrificed));
|
||||
SpellAbility root = sa;
|
||||
do {
|
||||
root.setSVar(remSVar, String.valueOf(countSacrificed));
|
||||
root = root.getSubAbility();
|
||||
} while (root != null);
|
||||
}
|
||||
}
|
||||
|
||||
table.triggerChangesZoneAll(game, sa);
|
||||
@@ -225,13 +205,9 @@ public class SacrificeEffect extends SpellAbilityEffect {
|
||||
|
||||
final List<Player> tgts = getTargetPlayers(sa);
|
||||
|
||||
String valid = sa.getParam("SacValid");
|
||||
if (valid == null) {
|
||||
valid = "Self";
|
||||
}
|
||||
String valid = sa.getParamOrDefault("SacValid", "Self");
|
||||
String num = sa.getParamOrDefault("Amount", "1");
|
||||
|
||||
String num = sa.getParam("Amount");
|
||||
num = (num == null) ? "1" : num;
|
||||
final int amount = AbilityUtils.calculateAmount(sa.getHostCard(), num, sa);
|
||||
|
||||
if (valid.equals("Self")) {
|
||||
@@ -244,10 +220,7 @@ public class SacrificeEffect extends SpellAbilityEffect {
|
||||
sb.append(p.getName()).append(" ");
|
||||
}
|
||||
|
||||
String msg = sa.getParam("SacMessage");
|
||||
if (msg == null) {
|
||||
msg = valid;
|
||||
}
|
||||
String msg = sa.getParamOrDefault("SacMessage", valid);
|
||||
|
||||
if (sa.hasParam("Destroy")) {
|
||||
sb.append("Destroys ");
|
||||
|
||||
Reference in New Issue
Block a user