mirror of
https://github.com/correl/mage.git
synced 2024-12-26 03:00:11 +00:00
parent
7eb1ccfebd
commit
e28bb36b72
1 changed files with 15 additions and 27 deletions
|
@ -298,9 +298,12 @@ public class Combat implements Serializable, Copyable<Combat> {
|
||||||
private void handleBanding(UUID creatureId, Game game) {
|
private void handleBanding(UUID creatureId, Game game) {
|
||||||
Player player = game.getPlayer(attackingPlayerId);
|
Player player = game.getPlayer(attackingPlayerId);
|
||||||
Permanent attacker = game.getPermanent(creatureId);
|
Permanent attacker = game.getPermanent(creatureId);
|
||||||
if (attacker != null && player != null) {
|
if (attacker != null
|
||||||
|
&& player != null) {
|
||||||
CombatGroup combatGroup = findGroup(attacker.getId());
|
CombatGroup combatGroup = findGroup(attacker.getId());
|
||||||
if (combatGroup != null && attacker.getBandedCards().isEmpty() && getAttackers().size() > 1) {
|
if (combatGroup != null
|
||||||
|
&& attacker.getBandedCards().isEmpty()
|
||||||
|
&& getAttackers().size() > 1) {
|
||||||
boolean canBand = attacker.getAbilities().containsKey(BandingAbility.getInstance().getId());
|
boolean canBand = attacker.getAbilities().containsKey(BandingAbility.getInstance().getId());
|
||||||
List<Ability> bandsWithOther = new ArrayList<>();
|
List<Ability> bandsWithOther = new ArrayList<>();
|
||||||
for (Ability ability : attacker.getAbilities()) {
|
for (Ability ability : attacker.getAbilities()) {
|
||||||
|
@ -315,7 +318,8 @@ public class Combat implements Serializable, Copyable<Combat> {
|
||||||
filter.add(Predicates.not(new PermanentIdPredicate(creatureId)));
|
filter.add(Predicates.not(new PermanentIdPredicate(creatureId)));
|
||||||
filter.add(new AttackingSameNotBandedPredicate(combatGroup.getDefenderId())); // creature that isn't already banded, and is attacking the same player or planeswalker
|
filter.add(new AttackingSameNotBandedPredicate(combatGroup.getDefenderId())); // creature that isn't already banded, and is attacking the same player or planeswalker
|
||||||
List<Predicate<MageObject>> predicates = new ArrayList<>();
|
List<Predicate<MageObject>> predicates = new ArrayList<>();
|
||||||
if (!canBand && canBandWithOther) {
|
if (!canBand
|
||||||
|
&& canBandWithOther) {
|
||||||
for (Ability ab : bandsWithOther) {
|
for (Ability ab : bandsWithOther) {
|
||||||
BandsWithOtherAbility ability = (BandsWithOtherAbility) ab;
|
BandsWithOtherAbility ability = (BandsWithOtherAbility) ab;
|
||||||
if (ability.getSubtype() != null) {
|
if (ability.getSubtype() != null) {
|
||||||
|
@ -337,12 +341,16 @@ public class Combat implements Serializable, Copyable<Combat> {
|
||||||
canBandWithOther &= target.canChoose(attackingPlayerId, game);
|
canBandWithOther &= target.canChoose(attackingPlayerId, game);
|
||||||
if (game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.DECLARING_ATTACKERS, attackingPlayerId, attackingPlayerId))
|
if (game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.DECLARING_ATTACKERS, attackingPlayerId, attackingPlayerId))
|
||||||
|| (!canBand && !canBandWithOther)
|
|| (!canBand && !canBandWithOther)
|
||||||
|| !player.chooseUse(Outcome.Benefit, "Do you wish to " + (isBanded ? "band " + attacker.getLogName() + " with another " : "form a band with " + attacker.getLogName() + " and an ") + "attacking creature?", null, game)) {
|
|| !player.chooseUse(Outcome.Benefit,
|
||||||
|
"Do you wish to " + (isBanded ? "band " + attacker.getLogName()
|
||||||
|
+ " with another " : "form a band with " + attacker.getLogName() + " and an ")
|
||||||
|
+ "attacking creature?", null, game)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canBand && canBandWithOther) {
|
if (canBand && canBandWithOther) {
|
||||||
if (player.chooseUse(Outcome.Detriment, "Choose type of banding ability to apply:", attacker.getLogName(), "Banding", "Bands with other", null, game)) {
|
if (player.chooseUse(Outcome.Detriment, "Choose type of banding ability to apply:",
|
||||||
|
attacker.getLogName(), "Banding", "Bands with other", null, game)) {
|
||||||
canBandWithOther = false;
|
canBandWithOther = false;
|
||||||
} else {
|
} else {
|
||||||
canBand = false;
|
canBand = false;
|
||||||
|
@ -463,7 +471,6 @@ public class Combat implements Serializable, Copyable<Combat> {
|
||||||
target.setRequired(true);
|
target.setRequired(true);
|
||||||
target.setTargetName("planeswalker or player for " + creature.getLogName() + " to attack");
|
target.setTargetName("planeswalker or player for " + creature.getLogName() + " to attack");
|
||||||
if (player.chooseTarget(Outcome.Damage, target, null, game)) {
|
if (player.chooseTarget(Outcome.Damage, target, null, game)) {
|
||||||
//System.out.println("The player " + player.getName() + " declares an attacker here. " + creature.getName());
|
|
||||||
player.declareAttacker(creature.getId(), target.getFirstTarget(), game, false);
|
player.declareAttacker(creature.getId(), target.getFirstTarget(), game, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -556,7 +563,7 @@ public class Combat implements Serializable, Copyable<Combat> {
|
||||||
/**
|
/**
|
||||||
* Handle the blocker selection process
|
* Handle the blocker selection process
|
||||||
*
|
*
|
||||||
* @param blockController player that controlls how to block, if null the
|
* @param blockController player that controls how to block, if null the
|
||||||
* defender is the controller
|
* defender is the controller
|
||||||
* @param game
|
* @param game
|
||||||
*/
|
*/
|
||||||
|
@ -1038,21 +1045,6 @@ public class Combat implements Serializable, Copyable<Combat> {
|
||||||
// ignore creatures controlled by other players
|
// ignore creatures controlled by other players
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// // check if creature has to pay a cost to block so it's not mandatory to block
|
|
||||||
// boolean removedAttacker = false;
|
|
||||||
// for (Iterator<UUID> iterator = entry.getValue().iterator(); iterator.hasNext();) {
|
|
||||||
// UUID possibleAttackerId = iterator.next();
|
|
||||||
// if (game.getContinuousEffects().checkIfThereArePayCostToAttackBlockEffects(
|
|
||||||
// GameEvent.getEvent(GameEvent.EventType.DECLARE_BLOCKER, possibleAttackerId, creatureForcedToBlock.getId(), creatureForcedToBlock.getControllerId()), game)) {
|
|
||||||
// // has cost to block to pay so remove this attacker
|
|
||||||
// iterator.remove();
|
|
||||||
// removedAttacker = true;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if (removedAttacker && entry.getValue().isEmpty()) {
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// creature does not block -> not allowed
|
// creature does not block -> not allowed
|
||||||
// Check if blocker is really able to block one or more attackers (maybe not if the attacker has menace) - if not continue with the next forced blocker
|
// Check if blocker is really able to block one or more attackers (maybe not if the attacker has menace) - if not continue with the next forced blocker
|
||||||
// TODO: Probably there is some potential to abuse the check if forced blockers are assigned to differnt attackers with e.g. menace.
|
// TODO: Probably there is some potential to abuse the check if forced blockers are assigned to differnt attackers with e.g. menace.
|
||||||
|
@ -1588,10 +1580,7 @@ public class Combat implements Serializable, Copyable<Combat> {
|
||||||
public Set<UUID> getPlayerDefenders(Game game) {
|
public Set<UUID> getPlayerDefenders(Game game) {
|
||||||
Set<UUID> playerDefenders = new HashSet<>();
|
Set<UUID> playerDefenders = new HashSet<>();
|
||||||
for (CombatGroup group : groups) {
|
for (CombatGroup group : groups) {
|
||||||
if (!group.defenderIsPlaneswalker) {
|
if (group.defenderIsPlaneswalker) {
|
||||||
playerDefenders.add(group.getDefenderId());
|
|
||||||
}
|
|
||||||
/* The planeswalker was attacked, not the player. So I believe the code is incorrect.
|
|
||||||
Permanent permanent = game.getPermanent(group.getDefenderId());
|
Permanent permanent = game.getPermanent(group.getDefenderId());
|
||||||
if (permanent != null) {
|
if (permanent != null) {
|
||||||
playerDefenders.add(permanent.getControllerId());
|
playerDefenders.add(permanent.getControllerId());
|
||||||
|
@ -1599,7 +1588,6 @@ public class Combat implements Serializable, Copyable<Combat> {
|
||||||
} else {
|
} else {
|
||||||
playerDefenders.add(group.getDefenderId());
|
playerDefenders.add(group.getDefenderId());
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
return playerDefenders;
|
return playerDefenders;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue