mirror of
https://github.com/correl/mage.git
synced 2024-11-15 11:09:30 +00:00
Defensive Formation slight cleanup
This commit is contained in:
parent
47ef2a4ce4
commit
b48c37ea8f
1 changed files with 25 additions and 41 deletions
|
@ -144,13 +144,7 @@ public class CombatGroup implements Serializable, Copyable<CombatGroup> {
|
||||||
if (!attackers.isEmpty() && (!first || hasFirstOrDoubleStrike(game))) {
|
if (!attackers.isEmpty() && (!first || hasFirstOrDoubleStrike(game))) {
|
||||||
Permanent attacker = game.getPermanent(attackers.get(0));
|
Permanent attacker = game.getPermanent(attackers.get(0));
|
||||||
if (attacker.getAbilities().containsKey(ControllerDivideCombatDamageAbility.getInstance().getId())) { // for handling Butcher Orgg
|
if (attacker.getAbilities().containsKey(ControllerDivideCombatDamageAbility.getInstance().getId())) { // for handling Butcher Orgg
|
||||||
Player player = game.getPlayer(attacker.getControllerId());
|
Player player = game.getPlayer(defenderControlsDefensiveFormation(game) ? defendingPlayerId : attacker.getControllerId());
|
||||||
for (Permanent defensiveFormation : game.getBattlefield().getAllActivePermanents(defendingPlayerId)) { // for handling Defensive Formation
|
|
||||||
if (defensiveFormation.getAbilities().containsKey(ControllerAssignCombatDamageToBlockersAbility.getInstance().getId())) {
|
|
||||||
player = game.getPlayer(defendingPlayerId);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (player.chooseUse(Outcome.Damage, "Do you wish to divide " + attacker.getLogName() + "'s combat damage among defending player and/or any number of defending creatures?", null, game)) {
|
if (player.chooseUse(Outcome.Damage, "Do you wish to divide " + attacker.getLogName() + "'s combat damage among defending player and/or any number of defending creatures?", null, game)) {
|
||||||
butcherOrggDamage(attacker, player, first, game);
|
butcherOrggDamage(attacker, player, first, game);
|
||||||
return;
|
return;
|
||||||
|
@ -160,13 +154,7 @@ public class CombatGroup implements Serializable, Copyable<CombatGroup> {
|
||||||
unblockedDamage(first, game);
|
unblockedDamage(first, game);
|
||||||
} else {
|
} else {
|
||||||
if (attacker.getAbilities().containsKey(DamageAsThoughNotBlockedAbility.getInstance().getId())) { // for handling creatures like Thorn Elemental
|
if (attacker.getAbilities().containsKey(DamageAsThoughNotBlockedAbility.getInstance().getId())) { // for handling creatures like Thorn Elemental
|
||||||
Player player = game.getPlayer(attacker.getControllerId());
|
Player player = game.getPlayer(defenderControlsDefensiveFormation(game) ? defendingPlayerId : attacker.getControllerId());
|
||||||
for (Permanent defensiveFormation : game.getBattlefield().getAllActivePermanents(defendingPlayerId)) { // for handling Defensive Formation
|
|
||||||
if (defensiveFormation.getAbilities().containsKey(ControllerAssignCombatDamageToBlockersAbility.getInstance().getId())) {
|
|
||||||
player = game.getPlayer(defendingPlayerId);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (player.chooseUse(Outcome.Damage, "Do you wish to assign damage for " + attacker.getLogName() + " as though it weren't blocked?", null, game)) {
|
if (player.chooseUse(Outcome.Damage, "Do you wish to assign damage for " + attacker.getLogName() + " as though it weren't blocked?", null, game)) {
|
||||||
blocked = false;
|
blocked = false;
|
||||||
unblockedDamage(first, game);
|
unblockedDamage(first, game);
|
||||||
|
@ -188,13 +176,7 @@ public class CombatGroup implements Serializable, Copyable<CombatGroup> {
|
||||||
for (UUID blockerId : blockers) {
|
for (UUID blockerId : blockers) {
|
||||||
Permanent blocker = game.getPermanent(blockerId);
|
Permanent blocker = game.getPermanent(blockerId);
|
||||||
if (blocker.getAbilities().containsKey(ControllerDivideCombatDamageAbility.getInstance().getId())) { // for handling Butcher Orgg
|
if (blocker.getAbilities().containsKey(ControllerDivideCombatDamageAbility.getInstance().getId())) { // for handling Butcher Orgg
|
||||||
Player player = game.getPlayer(blocker.getControllerId());
|
Player player = game.getPlayer(defenderControlsDefensiveFormation(game) ? defendingPlayerId : blocker.getControllerId()); // the difference should only rarely come up
|
||||||
for (Permanent defensiveFormation : game.getBattlefield().getAllActivePermanents(defendingPlayerId)) { // for handling Defensive Formation
|
|
||||||
if (defensiveFormation.getAbilities().containsKey(ControllerAssignCombatDamageToBlockersAbility.getInstance().getId())) {
|
|
||||||
player = game.getPlayer(defendingPlayerId);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (player.chooseUse(Outcome.Damage, "Do you wish to divide " + blocker.getLogName() + "'s combat damage among defending player and/or any number of defending creatures?", null, game)) { Permanent attacker = game.getPermanent(attackers.get(0));
|
if (player.chooseUse(Outcome.Damage, "Do you wish to divide " + blocker.getLogName() + "'s combat damage among defending player and/or any number of defending creatures?", null, game)) { Permanent attacker = game.getPermanent(attackers.get(0));
|
||||||
butcherOrggDamage(blocker, player, first, game);
|
butcherOrggDamage(blocker, player, first, game);
|
||||||
altDamageMethod = true;
|
altDamageMethod = true;
|
||||||
|
@ -343,13 +325,7 @@ public class CombatGroup implements Serializable, Copyable<CombatGroup> {
|
||||||
if (lethalDamage >= damage) {
|
if (lethalDamage >= damage) {
|
||||||
blocker.markDamage(damage, attacker.getId(), game, true, true);
|
blocker.markDamage(damage, attacker.getId(), game, true, true);
|
||||||
} else {
|
} else {
|
||||||
Player player = game.getPlayer(attacker.getControllerId());
|
Player player = game.getPlayer(defenderControlsDefensiveFormation(game) ? defendingPlayerId : attacker.getControllerId());
|
||||||
for (Permanent defensiveFormation : game.getBattlefield().getAllActivePermanents(defendingPlayerId)) { // for handling Defensive Formation
|
|
||||||
if (defensiveFormation.getAbilities().containsKey(ControllerAssignCombatDamageToBlockersAbility.getInstance().getId())) {
|
|
||||||
player = game.getPlayer(defendingPlayerId);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int damageAssigned = player.getAmount(lethalDamage, damage, "Assign damage to " + blocker.getName(), game);
|
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(), game, true, true);
|
||||||
damage -= damageAssigned;
|
damage -= damageAssigned;
|
||||||
|
@ -377,12 +353,9 @@ public class CombatGroup implements Serializable, Copyable<CombatGroup> {
|
||||||
}
|
}
|
||||||
boolean oldRuleDamage = false;
|
boolean oldRuleDamage = false;
|
||||||
Player player = game.getPlayer(attacker.getControllerId());
|
Player player = game.getPlayer(attacker.getControllerId());
|
||||||
for (Permanent defensiveFormation : game.getBattlefield().getAllActivePermanents(defendingPlayerId)) { // for handling Defensive Formation
|
if (defenderControlsDefensiveFormation(game)) {
|
||||||
if (defensiveFormation.getAbilities().containsKey(ControllerAssignCombatDamageToBlockersAbility.getInstance().getId())) {
|
|
||||||
player = game.getPlayer(defendingPlayerId);
|
player = game.getPlayer(defendingPlayerId);
|
||||||
oldRuleDamage = true;
|
oldRuleDamage = true;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
int damage = getDamageValueFromPermanent(attacker, game);
|
int damage = getDamageValueFromPermanent(attacker, game);
|
||||||
if (canDamage(attacker, first)) {
|
if (canDamage(attacker, first)) {
|
||||||
|
@ -590,13 +563,14 @@ public class CombatGroup implements Serializable, Copyable<CombatGroup> {
|
||||||
if (blockers.isEmpty()) {
|
if (blockers.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Player player = game.getPlayer(playerId);
|
Player player = game.getPlayer(defenderControlsDefensiveFormation(game) ? defendingPlayerId : playerId);
|
||||||
for (Permanent defensiveFormation : game.getBattlefield().getAllActivePermanents(defendingPlayerId)) { // for handling Defensive Formation
|
//~ Player player = game.getPlayer(playerId);
|
||||||
if (defensiveFormation.getAbilities().containsKey(ControllerAssignCombatDamageToBlockersAbility.getInstance().getId())) {
|
//~ for (Permanent defensiveFormation : game.getBattlefield().getAllActivePermanents(defendingPlayerId)) { // for handling Defensive Formation
|
||||||
player = game.getPlayer(defendingPlayerId);
|
//~ if (defensiveFormation.getAbilities().containsKey(ControllerAssignCombatDamageToBlockersAbility.getInstance().getId())) {
|
||||||
break;
|
//~ player = game.getPlayer(defendingPlayerId);
|
||||||
}
|
//~ break;
|
||||||
}
|
//~ }
|
||||||
|
//~ }
|
||||||
List<UUID> blockerList = new ArrayList<>(blockers);
|
List<UUID> blockerList = new ArrayList<>(blockers);
|
||||||
blockerOrder.clear();
|
blockerOrder.clear();
|
||||||
while (player.canRespond()) {
|
while (player.canRespond()) {
|
||||||
|
@ -819,4 +793,14 @@ public class CombatGroup implements Serializable, Copyable<CombatGroup> {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean defenderControlsDefensiveFormation(Game game) {
|
||||||
|
// for handling Defensive Formation
|
||||||
|
for (Permanent defensiveFormation : game.getBattlefield().getAllActivePermanents(defendingPlayerId)) {
|
||||||
|
if (defensiveFormation.getAbilities().containsKey(ControllerAssignCombatDamageToBlockersAbility.getInstance().getId())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue