mirror of
https://github.com/correl/mage.git
synced 2024-12-26 11:09:27 +00:00
Fixed bug of ReturnToHandAllEffect, minor formating changes of Combat.
This commit is contained in:
parent
e8c44ed169
commit
8af2628094
2 changed files with 28 additions and 19 deletions
|
@ -58,7 +58,7 @@ public class ReturnToHandAllEffect extends OneShotEffect<ReturnToHandAllEffect>
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) {
|
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
|
||||||
permanent.moveToZone(Constants.Zone.HAND, source.getSourceId(), game, true);
|
permanent.moveToZone(Constants.Zone.HAND, source.getSourceId(), game, true);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
|
|
||||||
package mage.game.combat;
|
package mage.game.combat;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.*;
|
||||||
import mage.Constants.Outcome;
|
import mage.Constants.Outcome;
|
||||||
import mage.abilities.effects.RequirementEffect;
|
import mage.abilities.effects.RequirementEffect;
|
||||||
import mage.abilities.keyword.CantAttackAloneAbility;
|
import mage.abilities.keyword.CantAttackAloneAbility;
|
||||||
|
@ -44,9 +46,6 @@ import mage.target.common.TargetDefender;
|
||||||
import mage.util.Copyable;
|
import mage.util.Copyable;
|
||||||
import mage.util.trace.TraceUtil;
|
import mage.util.trace.TraceUtil;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
@ -129,8 +128,9 @@ public class Combat implements Serializable, Copyable<Combat> {
|
||||||
//20101001 - 508.1d
|
//20101001 - 508.1d
|
||||||
checkAttackRequirements(player, game);
|
checkAttackRequirements(player, game);
|
||||||
player.selectAttackers(game, attackerId);
|
player.selectAttackers(game, attackerId);
|
||||||
if (game.isPaused() || game.isGameOver())
|
if (game.isPaused() || game.isGameOver()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
checkAttackRestrictions(player, game);
|
checkAttackRestrictions(player, game);
|
||||||
resumeSelectAttackers(game);
|
resumeSelectAttackers(game);
|
||||||
}
|
}
|
||||||
|
@ -179,15 +179,15 @@ public class Combat implements Serializable, Copyable<Combat> {
|
||||||
if (count == 1) {
|
if (count == 1) {
|
||||||
for (CombatGroup group: groups) {
|
for (CombatGroup group: groups) {
|
||||||
List<UUID> tobeRemoved = new ArrayList<UUID>();
|
List<UUID> tobeRemoved = new ArrayList<UUID>();
|
||||||
for (UUID attackerId: group.getAttackers()) {
|
for (UUID attackingCreatureId: group.getAttackers()) {
|
||||||
Permanent attacker = game.getPermanent(attackerId);
|
Permanent attacker = game.getPermanent(attackingCreatureId);
|
||||||
if (attacker != null && attacker.getAbilities().containsKey(CantAttackAloneAbility.getInstance().getId())) {
|
if (attacker != null && attacker.getAbilities().containsKey(CantAttackAloneAbility.getInstance().getId())) {
|
||||||
game.informPlayers(attacker.getName() + " can't attack alone. Removing it from combat.");
|
game.informPlayers(attacker.getName() + " can't attack alone. Removing it from combat.");
|
||||||
tobeRemoved.add(attackerId);
|
tobeRemoved.add(attackingCreatureId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (UUID attackerId : tobeRemoved) {
|
for (UUID attackingCreatureId : tobeRemoved) {
|
||||||
group.remove(attackerId);
|
group.remove(attackingCreatureId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -332,8 +332,9 @@ public class Combat implements Serializable, Copyable<Combat> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void declareAttacker(UUID attackerId, UUID defenderId, Game game) {
|
public void declareAttacker(UUID attackerId, UUID defenderId, Game game) {
|
||||||
if (!defenders.contains(defenderId))
|
if (!defenders.contains(defenderId)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
Permanent defender = game.getPermanent(defenderId);
|
Permanent defender = game.getPermanent(defenderId);
|
||||||
CombatGroup newGroup = new CombatGroup(defenderId, defender != null);
|
CombatGroup newGroup = new CombatGroup(defenderId, defender != null);
|
||||||
newGroup.attackers.add(attackerId);
|
newGroup.attackers.add(attackerId);
|
||||||
|
@ -403,16 +404,18 @@ public class Combat implements Serializable, Copyable<Combat> {
|
||||||
|
|
||||||
public boolean hasFirstOrDoubleStrike(Game game) {
|
public boolean hasFirstOrDoubleStrike(Game game) {
|
||||||
for (CombatGroup group : groups) {
|
for (CombatGroup group : groups) {
|
||||||
if (group.hasFirstOrDoubleStrike(game))
|
if (group.hasFirstOrDoubleStrike(game)) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CombatGroup findGroup(UUID attackerId) {
|
public CombatGroup findGroup(UUID attackerId) {
|
||||||
for (CombatGroup group : groups) {
|
for (CombatGroup group : groups) {
|
||||||
if (group.getAttackers().contains(attackerId))
|
if (group.getAttackers().contains(attackerId)) {
|
||||||
return group;
|
return group;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -432,19 +435,22 @@ public class Combat implements Serializable, Copyable<Combat> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean noAttackers() {
|
public boolean noAttackers() {
|
||||||
if (groups.isEmpty() || getAttackers().isEmpty())
|
if (groups.isEmpty() || getAttackers().isEmpty()) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAttacked(UUID defenderId, Game game) {
|
public boolean isAttacked(UUID defenderId, Game game) {
|
||||||
for (CombatGroup group : groups) {
|
for (CombatGroup group : groups) {
|
||||||
if (group.getDefenderId().equals(defenderId))
|
if (group.getDefenderId().equals(defenderId)) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
if (group.defenderIsPlaneswalker) {
|
if (group.defenderIsPlaneswalker) {
|
||||||
Permanent permanent = game.getPermanent(group.getDefenderId());
|
Permanent permanent = game.getPermanent(group.getDefenderId());
|
||||||
if (permanent.getControllerId().equals(defenderId))
|
if (permanent.getControllerId().equals(defenderId)) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -466,8 +472,9 @@ public class Combat implements Serializable, Copyable<Combat> {
|
||||||
for (CombatGroup group : groups) {
|
for (CombatGroup group : groups) {
|
||||||
if (group.defenderIsPlaneswalker) {
|
if (group.defenderIsPlaneswalker) {
|
||||||
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());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
playerDefenders.add(group.getDefenderId());
|
playerDefenders.add(group.getDefenderId());
|
||||||
}
|
}
|
||||||
|
@ -510,13 +517,15 @@ public class Combat implements Serializable, Copyable<Combat> {
|
||||||
if (group.blockers.contains(blockerId)) {
|
if (group.blockers.contains(blockerId)) {
|
||||||
group.blockers.remove(blockerId);
|
group.blockers.remove(blockerId);
|
||||||
group.blockerOrder.remove(blockerId);
|
group.blockerOrder.remove(blockerId);
|
||||||
if (group.blockers.isEmpty())
|
if (group.blockers.isEmpty()) {
|
||||||
group.blocked = false;
|
group.blocked = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Permanent creature = game.getPermanent(blockerId);
|
Permanent creature = game.getPermanent(blockerId);
|
||||||
if (creature != null)
|
if (creature != null) {
|
||||||
creature.setBlocking(0);
|
creature.setBlocking(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getAttackerId() {
|
public UUID getAttackerId() {
|
||||||
|
|
Loading…
Reference in a new issue