mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
- [C17] Added O-Kagachi, Vengeful Kami.
This commit is contained in:
@@ -23,6 +23,7 @@ import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.eventbus.EventBus;
|
||||
|
||||
@@ -90,6 +91,9 @@ public class Game {
|
||||
private CardCollection lastStateBattlefield = new CardCollection();
|
||||
private CardCollection lastStateGraveyard = new CardCollection();
|
||||
|
||||
private Map<Player, PlayerCollection> attackedThisTurn = Maps.newHashMap();
|
||||
private Map<Player, PlayerCollection> attackedLastTurn = Maps.newHashMap();
|
||||
|
||||
private Player monarch = null;
|
||||
private Player monarchBeginTurn = null;
|
||||
|
||||
@@ -120,6 +124,28 @@ public class Game {
|
||||
this.monarchBeginTurn = monarchBeginTurn;
|
||||
}
|
||||
|
||||
public Map<Player, PlayerCollection> getPlayersAttackedThisTurn() {
|
||||
return attackedThisTurn;
|
||||
}
|
||||
|
||||
public Map<Player, PlayerCollection> getPlayersAttackedLastTurn() {
|
||||
return attackedLastTurn;
|
||||
}
|
||||
|
||||
public void addPlayerAttackedThisTurn(Player attacker, Player defender) {
|
||||
PlayerCollection atk = attackedThisTurn.get(attacker);
|
||||
if (atk == null) {
|
||||
attackedThisTurn.put(attacker, new PlayerCollection());
|
||||
}
|
||||
attackedThisTurn.get(attacker).add(defender);
|
||||
}
|
||||
|
||||
public void resetPlayersAttackedOnNextTurn() {
|
||||
attackedLastTurn.clear();
|
||||
attackedLastTurn.putAll(attackedThisTurn);
|
||||
attackedThisTurn.clear();
|
||||
}
|
||||
|
||||
public CardCollectionView getLastStateBattlefield() {
|
||||
return lastStateBattlefield;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ 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.*;
|
||||
import forge.game.card.Card;
|
||||
@@ -45,7 +44,6 @@ import forge.util.CollectionSuppliers;
|
||||
import forge.util.collect.FCollectionView;
|
||||
import forge.util.maps.HashMapOfLists;
|
||||
import forge.util.maps.MapOfLists;
|
||||
|
||||
import org.apache.commons.lang3.time.StopWatch;
|
||||
|
||||
import java.util.*;
|
||||
@@ -273,6 +271,14 @@ public class PhaseHandler implements java.io.Serializable {
|
||||
&& !game.getTriggerHandler().hasDelayedTriggers()) {
|
||||
endCombat();
|
||||
}
|
||||
|
||||
if (combat != null) {
|
||||
for (Card c : combat.getAttackers()) {
|
||||
if (combat.getDefenderByAttacker(c) instanceof Player) {
|
||||
game.addPlayerAttackedThisTurn(c.getController(), (Player)combat.getDefenderByAttacker(c));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
givePriorityToPlayer = inCombat();
|
||||
@@ -328,6 +334,10 @@ public class PhaseHandler implements java.io.Serializable {
|
||||
if (playerTurn.getController().isAI()) {
|
||||
playerTurn.getController().resetAtEndOfTurn();
|
||||
}
|
||||
|
||||
// Reset the attackers this turn/last turn
|
||||
game.resetPlayersAttackedOnNextTurn();
|
||||
|
||||
game.getEndOfTurn().executeAt();
|
||||
break;
|
||||
|
||||
|
||||
@@ -362,6 +362,25 @@ public abstract class Trigger extends TriggerReplacementBase {
|
||||
this.getHostCard().getController(), this.getHostCard(), null)) {
|
||||
return false;
|
||||
}
|
||||
} else if ("AttackedPlayerWhoAttackedYouLastTurn".equals(condition)) {
|
||||
GameEntity attacked = (GameEntity) runParams.get("Attacked");
|
||||
if (attacked == null) {
|
||||
// Check "Defender" too because once triggering objects are set on TriggerAttacks, the value of Attacked
|
||||
// ends up being in Defender at that point.
|
||||
attacked = (GameEntity) runParams.get("DefendingPlayer");
|
||||
}
|
||||
Player attacker = this.getHostCard().getController();
|
||||
|
||||
boolean valid = false;
|
||||
if (game.getPlayersAttackedLastTurn().containsKey(attacked)) {
|
||||
if (game.getPlayersAttackedLastTurn().get(attacked).contains(attacker)) {
|
||||
valid = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (attacked == null || !valid) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user