forked from External/mage
Refactor: replaced sourceId by source and introduced source param in some methods;
This commit is contained in:
parent
2bb472607b
commit
db239a1055
3205 changed files with 7080 additions and 6795 deletions
|
|
@ -23,6 +23,9 @@ import mage.filter.predicate.mageobject.NamePredicate;
|
|||
import mage.filter.predicate.permanent.AttackingSameNotBandedPredicate;
|
||||
import mage.filter.predicate.permanent.PermanentIdPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.AttackerDeclaredEvent;
|
||||
import mage.game.events.DeclareAttackerEvent;
|
||||
import mage.game.events.DeclareBlockerEvent;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
|
@ -272,13 +275,13 @@ public class Combat implements Serializable, Copyable<Combat> {
|
|||
Permanent attackingPermanent = game.getPermanent(attacker);
|
||||
if (attackingPermanent != null) {
|
||||
attackingPermanent.setTapped(false);
|
||||
attackingPermanent.tap(true, game); // to tap with event finally here is needed to prevent abusing of Vampire Envoy like cards
|
||||
attackingPermanent.tap(true, null, game); // to tap with event finally here is needed to prevent abusing of Vampire Envoy like cards
|
||||
}
|
||||
}
|
||||
handleBanding(attacker, game);
|
||||
// This can only be used to modify the event, the attack can't be replaced here
|
||||
game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.ATTACKER_DECLARED, group.defenderId, attacker, attackingPlayerId));
|
||||
game.addSimultaneousEvent(GameEvent.getEvent(GameEvent.EventType.ATTACKER_DECLARED, group.defenderId, attacker, attackingPlayerId));
|
||||
game.replaceEvent(new AttackerDeclaredEvent(group.defenderId, attacker, attackingPlayerId));
|
||||
game.addSimultaneousEvent(new AttackerDeclaredEvent(group.defenderId, attacker, attackingPlayerId));
|
||||
}
|
||||
}
|
||||
attackersTappedByAttack.clear();
|
||||
|
|
@ -452,8 +455,7 @@ public class Combat implements Serializable, Copyable<Combat> {
|
|||
Set<UUID> defendersCostlessAttackable = new HashSet<>(defenders);
|
||||
for (UUID defenderId : defenders) {
|
||||
if (game.getContinuousEffects().checkIfThereArePayCostToAttackBlockEffects(
|
||||
GameEvent.getEvent(GameEvent.EventType.DECLARE_ATTACKER,
|
||||
defenderId, creature.getId(), creature.getControllerId()), game)) {
|
||||
new DeclareAttackerEvent(defenderId, creature.getId(), creature.getControllerId()), game)) {
|
||||
defendersCostlessAttackable.remove(defenderId);
|
||||
defendersForcedToAttack.remove(defenderId);
|
||||
}
|
||||
|
|
@ -550,13 +552,13 @@ public class Combat implements Serializable, Copyable<Combat> {
|
|||
|
||||
public void selectBlockers(Game game) {
|
||||
if (!game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.DECLARING_BLOCKERS, attackingPlayerId, attackingPlayerId))) {
|
||||
game.getCombat().selectBlockers(null, game);
|
||||
game.getCombat().selectBlockers(null, null, game);
|
||||
}
|
||||
for (UUID attackingCreatureID : game.getCombat().getAttackers()) {
|
||||
Permanent permanent = game.getPermanent(attackingCreatureID);
|
||||
CombatGroup group = game.getCombat().findGroup(attackingCreatureID);
|
||||
if (permanent != null && group != null && !group.getBlocked()) {
|
||||
game.fireEvent(GameEvent.getEvent(EventType.UNBLOCKED_ATTACKER, attackingCreatureID, attackingPlayerId));
|
||||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.UNBLOCKED_ATTACKER, attackingCreatureID, attackingPlayerId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -568,7 +570,7 @@ public class Combat implements Serializable, Copyable<Combat> {
|
|||
* defender is the controller
|
||||
* @param game
|
||||
*/
|
||||
public void selectBlockers(Player blockController, Game game) {
|
||||
public void selectBlockers(Player blockController, Ability source, Game game) {
|
||||
Player attacker = game.getPlayer(attackingPlayerId);
|
||||
//20101001 - 509.1c
|
||||
game.getCombat().retrieveMustBlockAttackerRequirements(attacker, game);
|
||||
|
|
@ -583,7 +585,7 @@ public class Combat implements Serializable, Copyable<Combat> {
|
|||
controller = blockController;
|
||||
}
|
||||
while (choose) {
|
||||
controller.selectBlockers(game, defenderId);
|
||||
controller.selectBlockers(source, game, defenderId);
|
||||
if (game.isPaused() || game.checkIfGameIsOver() || game.executingRollback()) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -719,7 +721,7 @@ public class Combat implements Serializable, Copyable<Combat> {
|
|||
}
|
||||
// check if the possible blocker has to pay cost to block, if so don't force
|
||||
if (game.getContinuousEffects().checkIfThereArePayCostToAttackBlockEffects(
|
||||
GameEvent.getEvent(GameEvent.EventType.DECLARE_BLOCKER, attackingCreatureId, possibleBlocker.getId(), possibleBlocker.getControllerId()), game)) {
|
||||
new DeclareBlockerEvent(attackingCreatureId, possibleBlocker.getId(), possibleBlocker.getControllerId()), game)) {
|
||||
// has cost to block to pay so remove this attacker
|
||||
continue;
|
||||
}
|
||||
|
|
@ -1291,7 +1293,7 @@ public class Combat implements Serializable, Copyable<Combat> {
|
|||
public boolean declareAttacker(UUID creatureId, UUID defenderId, UUID playerId, Game game) {
|
||||
Permanent attacker = game.getPermanent(creatureId);
|
||||
if (attacker != null) {
|
||||
if (!game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.DECLARE_ATTACKER, defenderId, creatureId, playerId))) {
|
||||
if (!game.replaceEvent(new DeclareAttackerEvent(defenderId, creatureId, playerId))) {
|
||||
if (addAttackerToCombat(creatureId, defenderId, game)) {
|
||||
if (!attacker.hasAbility(VigilanceAbility.getInstance(), game)
|
||||
&& !attacker.hasAbility(JohanVigilanceAbility.getInstance(), game)) {
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ import mage.constants.Outcome;
|
|||
import mage.filter.StaticFilters;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.BlockerDeclaredEvent;
|
||||
import mage.game.events.DeclareBlockerEvent;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
|
@ -266,23 +268,23 @@ public class CombatGroup implements Serializable, Copyable<CombatGroup> {
|
|||
if (hasTrample(attacker)) {
|
||||
int lethalDamage = getLethalDamage(blocker, attacker, game);
|
||||
if (lethalDamage >= damage) {
|
||||
blocker.markDamage(damage, attacker.getId(), game, true, true);
|
||||
blocker.markDamage(damage, attacker.getId(), null, game, true, true);
|
||||
} else {
|
||||
int damageAssigned = player.getAmount(lethalDamage, damage, "Assign damage to " + blocker.getName(), game);
|
||||
blocker.markDamage(damageAssigned, attacker.getId(), game, true, true);
|
||||
blocker.markDamage(damageAssigned, attacker.getId(), null, game, true, true);
|
||||
damage -= damageAssigned;
|
||||
if (damage > 0) {
|
||||
defenderDamage(attacker, damage, game);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
blocker.markDamage(damage, attacker.getId(), game, true, true);
|
||||
blocker.markDamage(damage, attacker.getId(), null, game, true, true);
|
||||
}
|
||||
}
|
||||
if (canDamage(blocker, first)) {
|
||||
if (checkSoleBlockerAfter(blocker, game)) { // blocking several creatures handled separately
|
||||
if (!assignsDefendingPlayerAndOrDefendingCreaturesDividedDamage(blocker, blocker.getControllerId(), first, game, false)) {
|
||||
attacker.markDamage(blockerDamage, blocker.getId(), game, true, true);
|
||||
attacker.markDamage(blockerDamage, blocker.getId(), null, game, true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -349,20 +351,20 @@ public class CombatGroup implements Serializable, Copyable<CombatGroup> {
|
|||
// might be missing canDamage condition?
|
||||
Permanent blocker = game.getPermanent(blockerId);
|
||||
if (!assignsDefendingPlayerAndOrDefendingCreaturesDividedDamage(blocker, blocker.getControllerId(), first, game, false)) {
|
||||
attacker.markDamage(power, blockerId, game, true, true);
|
||||
attacker.markDamage(power, blockerId, null, game, true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Map.Entry<UUID, Integer> entry : assigned.entrySet()) {
|
||||
Permanent blocker = game.getPermanent(entry.getKey());
|
||||
blocker.markDamage(entry.getValue(), attacker.getId(), game, true, true);
|
||||
blocker.markDamage(entry.getValue(), attacker.getId(), null, game, true, true);
|
||||
}
|
||||
} else {
|
||||
for (UUID blockerId : blockerOrder) {
|
||||
Permanent blocker = game.getPermanent(blockerId);
|
||||
if (canDamage(blocker, first)) {
|
||||
if (!assignsDefendingPlayerAndOrDefendingCreaturesDividedDamage(blocker, blocker.getControllerId(), first, game, false)) {
|
||||
attacker.markDamage(getDamageValueFromPermanent(blocker, game), blocker.getId(), game, true, true);
|
||||
attacker.markDamage(getDamageValueFromPermanent(blocker, game), blocker.getId(), null, game, true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -402,7 +404,7 @@ public class CombatGroup implements Serializable, Copyable<CombatGroup> {
|
|||
if (damage > 0) {
|
||||
Player defendingPlayer = game.getPlayer(defendingPlayerId);
|
||||
if (defendingPlayer != null) {
|
||||
defendingPlayer.damage(damage, attacker.getId(), game, true, true);
|
||||
defendingPlayer.damage(damage, attacker.getId(), null, game, true, true);
|
||||
}
|
||||
}
|
||||
if (isAttacking) {
|
||||
|
|
@ -412,14 +414,14 @@ public class CombatGroup implements Serializable, Copyable<CombatGroup> {
|
|||
// might be missing canDamage condition?
|
||||
Permanent blocker = game.getPermanent(blockerId);
|
||||
if (!assignsDefendingPlayerAndOrDefendingCreaturesDividedDamage(blocker, blocker.getControllerId(), first, game, false)) {
|
||||
attacker.markDamage(power, blockerId, game, true, true);
|
||||
attacker.markDamage(power, blockerId, null, game, true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Map.Entry<UUID, Integer> entry : assigned.entrySet()) {
|
||||
Permanent defendingCreature = game.getPermanent(entry.getKey());
|
||||
defendingCreature.markDamage(entry.getValue(), attacker.getId(), game, true, true);
|
||||
defendingCreature.markDamage(entry.getValue(), attacker.getId(), null, game, true, true);
|
||||
}
|
||||
} else {
|
||||
if (isAttacking) {
|
||||
|
|
@ -427,7 +429,7 @@ public class CombatGroup implements Serializable, Copyable<CombatGroup> {
|
|||
Permanent blocker = game.getPermanent(blockerId);
|
||||
if (canDamage(blocker, first)) {
|
||||
if (!assignsDefendingPlayerAndOrDefendingCreaturesDividedDamage(blocker, blocker.getControllerId(), first, game, false)) {
|
||||
attacker.markDamage(getDamageValueFromPermanent(blocker, game), blocker.getId(), game, true, true);
|
||||
attacker.markDamage(getDamageValueFromPermanent(blocker, game), blocker.getId(), null, game, true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -475,7 +477,7 @@ public class CombatGroup implements Serializable, Copyable<CombatGroup> {
|
|||
if (blocker != null && attacker != null) {
|
||||
if (canDamage(blocker, first)) {
|
||||
int damage = getDamageValueFromPermanent(blocker, game);
|
||||
attacker.markDamage(damage, blocker.getId(), game, true, true);
|
||||
attacker.markDamage(damage, blocker.getId(), null, game, true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -531,7 +533,7 @@ public class CombatGroup implements Serializable, Copyable<CombatGroup> {
|
|||
|
||||
for (Map.Entry<UUID, Integer> entry : assigned.entrySet()) {
|
||||
Permanent attacker = game.getPermanent(entry.getKey());
|
||||
attacker.markDamage(entry.getValue(), blocker.getId(), game, true, true);
|
||||
attacker.markDamage(entry.getValue(), blocker.getId(), null, game, true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -540,12 +542,12 @@ public class CombatGroup implements Serializable, Copyable<CombatGroup> {
|
|||
if (this.defenderIsPlaneswalker) {
|
||||
Permanent defender = game.getPermanent(defenderId);
|
||||
if (defender != null) {
|
||||
defender.markDamage(amount, attacker.getId(), game, true, true);
|
||||
defender.markDamage(amount, attacker.getId(), null, game, true, true);
|
||||
}
|
||||
} else {
|
||||
Player defender = game.getPlayer(defenderId);
|
||||
if (defender != null) {
|
||||
defender.damage(amount, attacker.getId(), game, true, true);
|
||||
defender.damage(amount, attacker.getId(), null, game, true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -570,7 +572,7 @@ public class CombatGroup implements Serializable, Copyable<CombatGroup> {
|
|||
*/
|
||||
public void addBlocker(UUID blockerId, UUID playerId, Game game) {
|
||||
for (UUID attackerId : attackers) {
|
||||
if (game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.DECLARE_BLOCKER, attackerId, blockerId, playerId))) {
|
||||
if (game.replaceEvent(new DeclareBlockerEvent(attackerId, blockerId, playerId))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -690,7 +692,7 @@ public class CombatGroup implements Serializable, Copyable<CombatGroup> {
|
|||
}
|
||||
for (UUID blockerId : blockers) {
|
||||
for (UUID attackerId : attackers) {
|
||||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.BLOCKER_DECLARED, attackerId, blockerId, players.get(blockerId)));
|
||||
game.fireEvent(new BlockerDeclaredEvent(attackerId, blockerId, players.get(blockerId)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue