mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
Merge branch 'new-cards-2' into 'master'
Combat Calligrapher Closes #1795 See merge request core-developers/forge!4462
This commit is contained in:
@@ -352,17 +352,19 @@ public class CombatUtil {
|
||||
* @param c
|
||||
* a {@link forge.game.card.Card} object.
|
||||
*/
|
||||
public static void checkDeclaredAttacker(final Game game, final Card c, final Combat combat) {
|
||||
public static void checkDeclaredAttacker(final Game game, final Card c, final Combat combat, boolean triggers) {
|
||||
// Run triggers
|
||||
final Map<AbilityKey, Object> runParams = AbilityKey.newMap();
|
||||
runParams.put(AbilityKey.Attacker, c);
|
||||
final List<Card> otherAttackers = combat.getAttackers();
|
||||
otherAttackers.remove(c);
|
||||
runParams.put(AbilityKey.OtherAttackers, otherAttackers);
|
||||
runParams.put(AbilityKey.Attacked, combat.getDefenderByAttacker(c));
|
||||
runParams.put(AbilityKey.DefendingPlayer, combat.getDefenderPlayerByAttacker(c));
|
||||
runParams.put(AbilityKey.Defenders, combat.getDefenders());
|
||||
game.getTriggerHandler().runTrigger(TriggerType.Attacks, runParams, false);
|
||||
if (triggers) {
|
||||
final Map<AbilityKey, Object> runParams = AbilityKey.newMap();
|
||||
runParams.put(AbilityKey.Attacker, c);
|
||||
final List<Card> otherAttackers = combat.getAttackers();
|
||||
otherAttackers.remove(c);
|
||||
runParams.put(AbilityKey.OtherAttackers, otherAttackers);
|
||||
runParams.put(AbilityKey.Attacked, combat.getDefenderByAttacker(c));
|
||||
runParams.put(AbilityKey.DefendingPlayer, combat.getDefenderPlayerByAttacker(c));
|
||||
runParams.put(AbilityKey.Defenders, combat.getDefenders());
|
||||
game.getTriggerHandler().runTrigger(TriggerType.Attacks, runParams, false);
|
||||
}
|
||||
|
||||
c.getDamageHistory().setCreatureAttackedThisCombat(true);
|
||||
c.getDamageHistory().clearNotAttackedSinceLastUpkeepOf();
|
||||
|
||||
@@ -17,19 +17,11 @@
|
||||
*/
|
||||
package forge.game.phase;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
import java.util.*;
|
||||
|
||||
import com.google.common.collect.*;
|
||||
import org.apache.commons.lang3.time.StopWatch;
|
||||
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import forge.card.mana.ManaCost;
|
||||
import forge.game.Game;
|
||||
import forge.game.GameEntity;
|
||||
@@ -621,9 +613,16 @@ public class PhaseHandler implements java.io.Serializable {
|
||||
|
||||
// fire AttackersDeclared trigger
|
||||
if (!combat.getAttackers().isEmpty()) {
|
||||
List<GameEntity> attackedTarget = Lists.newArrayList();
|
||||
for (final Card c : combat.getAttackers()) {
|
||||
attackedTarget.add(combat.getDefenderByAttacker(c));
|
||||
List<GameEntity> attackedTarget = new ArrayList<>();
|
||||
for (GameEntity ge : combat.getDefenders()) {
|
||||
if (!combat.getAttackersOf(ge).isEmpty()) {
|
||||
final Map<AbilityKey, Object> runParams = AbilityKey.newMap();
|
||||
runParams.put(AbilityKey.Attackers, combat.getAttackersOf(ge));
|
||||
runParams.put(AbilityKey.AttackingPlayer, combat.getAttackingPlayer());
|
||||
runParams.put(AbilityKey.AttackedTarget, ge);
|
||||
attackedTarget.add(ge);
|
||||
game.getTriggerHandler().runTrigger(TriggerType.AttackersDeclaredOneTarget, runParams, false);
|
||||
}
|
||||
}
|
||||
final Map<AbilityKey, Object> runParams = AbilityKey.newMap();
|
||||
runParams.put(AbilityKey.Attackers, combat.getAttackers());
|
||||
@@ -633,7 +632,7 @@ public class PhaseHandler implements java.io.Serializable {
|
||||
}
|
||||
|
||||
for (final Card c : combat.getAttackers()) {
|
||||
CombatUtil.checkDeclaredAttacker(game, c, combat);
|
||||
CombatUtil.checkDeclaredAttacker(game, c, combat, true);
|
||||
}
|
||||
|
||||
game.getTriggerHandler().resetActiveTriggers();
|
||||
|
||||
@@ -22,6 +22,7 @@ public enum TriggerType {
|
||||
AttackerBlockedOnce(TriggerAttackerBlockedOnce.class),
|
||||
AttackerBlockedByCreature(TriggerAttackerBlockedByCreature.class),
|
||||
AttackersDeclared(TriggerAttackersDeclared.class),
|
||||
AttackersDeclaredOneTarget(TriggerAttackersDeclared.class),
|
||||
AttackerUnblocked(TriggerAttackerUnblocked.class),
|
||||
AttackerUnblockedOnce(TriggerAttackerUnblockedOnce.class),
|
||||
Attacks(TriggerAttacks.class),
|
||||
|
||||
Reference in New Issue
Block a user