mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
Fixed some problems with possible ConcurrentModificationExceptions and some minor changes.
This commit is contained in:
parent
d97f6c6cd1
commit
81af372bc1
144 changed files with 410 additions and 429 deletions
|
|
@ -25,7 +25,6 @@
|
|||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.abilities.condition.common;
|
||||
|
||||
import java.util.UUID;
|
||||
|
|
@ -52,10 +51,10 @@ public class CardsInAnyLibraryCondition implements Condition {
|
|||
public final boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
for (UUID playerId: controller.getInRange()) {
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
switch(type) {
|
||||
switch (type) {
|
||||
case GreaterThan:
|
||||
if (player.getLibrary().size() > value) {
|
||||
return true;
|
||||
|
|
@ -81,15 +80,15 @@ public class CardsInAnyLibraryCondition implements Condition {
|
|||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder("a library has ");
|
||||
switch(type) {
|
||||
switch (type) {
|
||||
case GreaterThan:
|
||||
sb.append(value+1).append(" or more cards in it ");
|
||||
sb.append(value + 1).append(" or more cards in it ");
|
||||
break;
|
||||
case Equal:
|
||||
sb.append(value).append(" cards in it ");
|
||||
break;
|
||||
case LessThan:
|
||||
sb.append(value-1).append(" or fewer cards in it ");
|
||||
sb.append(value - 1).append(" or fewer cards in it ");
|
||||
break;
|
||||
}
|
||||
return sb.toString();
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public class CardsInHandCondition implements Condition {
|
|||
public static enum CountType {
|
||||
MORE_THAN, FEWER_THAN, EQUAL_TO
|
||||
};
|
||||
|
||||
|
||||
private Condition condition;
|
||||
private CountType type;
|
||||
private int count;
|
||||
|
|
@ -60,7 +60,7 @@ public class CardsInHandCondition implements Condition {
|
|||
public CardsInHandCondition(CountType type, int count) {
|
||||
this(type, count, null);
|
||||
}
|
||||
|
||||
|
||||
public CardsInHandCondition(CountType type, int count, Condition conditionToDecorate) {
|
||||
this(type, count, conditionToDecorate, TargetController.YOU);
|
||||
}
|
||||
|
|
@ -73,7 +73,7 @@ public class CardsInHandCondition implements Condition {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
public boolean apply(Game game, Ability source) {
|
||||
boolean conditionApplies = false;
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
|
|
@ -95,7 +95,7 @@ public class CardsInHandCondition implements Condition {
|
|||
boolean conflict = false;
|
||||
switch (this.type) {
|
||||
case FEWER_THAN:
|
||||
for (UUID playerId :controller.getInRange()) {
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
if (player.getHand().size() >= this.count) {
|
||||
|
|
@ -103,10 +103,10 @@ public class CardsInHandCondition implements Condition {
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MORE_THAN:
|
||||
for (UUID playerId :controller.getInRange()) {
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
if (player.getHand().size() <= this.count) {
|
||||
|
|
@ -114,10 +114,10 @@ public class CardsInHandCondition implements Condition {
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EQUAL_TO:
|
||||
for (UUID playerId :controller.getInRange()) {
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
if (player.getHand().size() != this.count) {
|
||||
|
|
@ -127,11 +127,11 @@ public class CardsInHandCondition implements Condition {
|
|||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
conditionApplies = !conflict;
|
||||
break;
|
||||
default:
|
||||
throw new UnsupportedOperationException("Value of TargetController not supported for this class.");
|
||||
throw new UnsupportedOperationException("Value of TargetController not supported for this class.");
|
||||
}
|
||||
|
||||
//If a decorated condition exists, check it as well and apply them together.
|
||||
|
|
@ -163,7 +163,7 @@ public class CardsInHandCondition implements Condition {
|
|||
case MORE_THAN:
|
||||
sb.append(" more than ");
|
||||
break;
|
||||
case EQUAL_TO:
|
||||
case EQUAL_TO:
|
||||
sb.append(" exactly ");
|
||||
break;
|
||||
}
|
||||
|
|
@ -171,9 +171,9 @@ public class CardsInHandCondition implements Condition {
|
|||
sb.append("no");
|
||||
} else {
|
||||
sb.append(CardUtil.numberToText(workCount));
|
||||
}
|
||||
}
|
||||
sb.append(" cards in hand");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@
|
|||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.abilities.costs.common;
|
||||
|
||||
import java.util.UUID;
|
||||
|
|
@ -57,7 +56,7 @@ public class GainLifePlayersCost extends CostImpl {
|
|||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
Player controller = game.getPlayer(controllerId);
|
||||
if (controller != null) {
|
||||
for (UUID playerId: controller.getInRange()) {
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
if (!playerId.equals(controllerId)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && !player.isCanGainLife()) {
|
||||
|
|
@ -67,7 +66,7 @@ public class GainLifePlayersCost extends CostImpl {
|
|||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -75,7 +74,7 @@ public class GainLifePlayersCost extends CostImpl {
|
|||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
Player controller = game.getPlayer(controllerId);
|
||||
if (controller != null) {
|
||||
for (UUID playerId: controller.getInRange()) {
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
if (!playerId.equals(controllerId)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ public class CardsInAllGraveyardsCount implements DynamicValue {
|
|||
int amount = 0;
|
||||
Player controller = game.getPlayer(sourceAbility.getControllerId());
|
||||
if (controller != null) {
|
||||
for (UUID playerUUID : controller.getInRange()) {
|
||||
for (UUID playerUUID : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
Player player = game.getPlayer(playerUUID);
|
||||
if (player != null) {
|
||||
amount += player.getGraveyard().count(filter, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game);
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ public class CardsInAllHandsCount implements DynamicValue {
|
|||
@Override
|
||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||
int count = 0;
|
||||
for (UUID playerId : game.getPlayer(sourceAbility.getControllerId()).getInRange()) {
|
||||
for (UUID playerId : game.getState().getPlayersInRange(sourceAbility.getControllerId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ public class DamageEverythingEffect extends OneShotEffect {
|
|||
for (Permanent permanent: permanents) {
|
||||
permanent.damage(damage, damageSource == null ? source.getSourceId(): damageSource, game, false, true);
|
||||
}
|
||||
for (UUID playerId: game.getPlayer(source.getControllerId()).getInRange()) {
|
||||
for (UUID playerId: game.getState().getPlayersInRange(source.getControllerId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
player.damage(damage, damageSource == null ? source.getSourceId(): damageSource, game, false, true);
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ public class DamagePlayersEffect extends OneShotEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
switch (controller) {
|
||||
case ANY:
|
||||
for (UUID playerId: game.getPlayer(source.getControllerId()).getInRange()) {
|
||||
for (UUID playerId: game.getState().getPlayersInRange(source.getControllerId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
player.damage(amount.calculate(game, source, this), source.getSourceId(), game, false, true);
|
||||
|
|
|
|||
|
|
@ -45,8 +45,8 @@ import mage.util.CardUtil;
|
|||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class DoUnlessAnyPlayerPaysEffect extends OneShotEffect {
|
||||
|
||||
protected Effects executingEffects = new Effects();
|
||||
private final Cost cost;
|
||||
private String chooseUseText;
|
||||
|
|
@ -81,7 +81,7 @@ public class DoUnlessAnyPlayerPaysEffect extends OneShotEffect {
|
|||
String message;
|
||||
if (chooseUseText == null) {
|
||||
String effectText = executingEffects.getText(source.getModes().getMode());
|
||||
message = "Pay " + cost.getText() + " to prevent (" + effectText.substring(0, effectText.length() -1) + ")?";
|
||||
message = "Pay " + cost.getText() + " to prevent (" + effectText.substring(0, effectText.length() - 1) + ")?";
|
||||
} else {
|
||||
message = chooseUseText;
|
||||
}
|
||||
|
|
@ -89,13 +89,14 @@ public class DoUnlessAnyPlayerPaysEffect extends OneShotEffect {
|
|||
boolean result = true;
|
||||
boolean doEffect = true;
|
||||
// check if any player is willing to pay
|
||||
for (UUID playerId: controller.getInRange()) {
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && cost.canPay(source, source.getSourceId(), player.getId(), game) && player.chooseUse(Outcome.Detriment, message, source, game)) {
|
||||
cost.clearPaid();
|
||||
if (cost.pay(source, game, source.getSourceId(), player.getId(), false, null)) {
|
||||
if (!game.isSimulation())
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(player.getLogName() + " pays the cost to prevent the effect");
|
||||
}
|
||||
doEffect = false;
|
||||
break;
|
||||
}
|
||||
|
|
@ -103,12 +104,11 @@ public class DoUnlessAnyPlayerPaysEffect extends OneShotEffect {
|
|||
}
|
||||
// do the effects if nobody paid
|
||||
if (doEffect) {
|
||||
for(Effect effect: executingEffects) {
|
||||
for (Effect effect : executingEffects) {
|
||||
effect.setTargetPointer(this.targetPointer);
|
||||
if (effect instanceof OneShotEffect) {
|
||||
result &= effect.apply(game, source);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
game.addEffect((ContinuousEffect) effect, source);
|
||||
}
|
||||
}
|
||||
|
|
@ -128,11 +128,11 @@ public class DoUnlessAnyPlayerPaysEffect extends OneShotEffect {
|
|||
return staticText;
|
||||
}
|
||||
String effectsText = executingEffects.getText(mode);
|
||||
return effectsText.substring(0, effectsText.length() -1) + " unless any player pays " + cost.getText();
|
||||
return effectsText.substring(0, effectsText.length() - 1) + " unless any player pays " + cost.getText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DoUnlessAnyPlayerPaysEffect copy() {
|
||||
return new DoUnlessAnyPlayerPaysEffect(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
|
|
@ -20,12 +20,11 @@
|
|||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import java.util.UUID;
|
||||
|
|
@ -51,7 +50,7 @@ public class DrawCardAllEffect extends OneShotEffect {
|
|||
public DrawCardAllEffect(int amount) {
|
||||
this(amount, TargetController.ANY);
|
||||
}
|
||||
|
||||
|
||||
public DrawCardAllEffect(DynamicValue amount) {
|
||||
this(amount, TargetController.ANY);
|
||||
}
|
||||
|
|
@ -80,10 +79,10 @@ public class DrawCardAllEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player sourcePlayer = game.getPlayer(source.getControllerId());
|
||||
switch(targetController) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
switch (targetController) {
|
||||
case ANY:
|
||||
for (UUID playerId: sourcePlayer.getInRange()) {
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
player.drawCards(amount.calculate(game, source, this), game);
|
||||
|
|
@ -91,12 +90,12 @@ public class DrawCardAllEffect extends OneShotEffect {
|
|||
}
|
||||
break;
|
||||
case OPPONENT:
|
||||
for (UUID playerId: game.getOpponents(sourcePlayer.getId())) {
|
||||
for (UUID playerId : game.getOpponents(controller.getId())) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
player.drawCards(amount.calculate(game, source, this), game);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
|
|
@ -104,7 +103,7 @@ public class DrawCardAllEffect extends OneShotEffect {
|
|||
|
||||
private String setText() {
|
||||
StringBuilder sb = new StringBuilder("Each ");
|
||||
switch(targetController) {
|
||||
switch (targetController) {
|
||||
case ANY:
|
||||
sb.append("player");
|
||||
break;
|
||||
|
|
@ -115,9 +114,9 @@ public class DrawCardAllEffect extends OneShotEffect {
|
|||
throw new UnsupportedOperationException("Not supported value for targetController");
|
||||
}
|
||||
sb.append(" draws ");
|
||||
sb.append(CardUtil.numberToText(amount.toString(),"a"));
|
||||
sb.append(CardUtil.numberToText(amount.toString(), "a"));
|
||||
sb.append(" card");
|
||||
sb.append(amount.toString().equals("1")?"":"s");
|
||||
sb.append(amount.toString().equals("1") ? "" : "s");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,16 +41,17 @@ import mage.players.Player;
|
|||
* @author Jgod
|
||||
*/
|
||||
public class ExileGraveyardAllPlayersEffect extends OneShotEffect {
|
||||
|
||||
public ExileGraveyardAllPlayersEffect() {
|
||||
super(Outcome.Detriment);
|
||||
staticText = "exile all cards from all graveyards";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ExileGraveyardAllPlayersEffect copy() {
|
||||
return new ExileGraveyardAllPlayersEffect();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
|
|
@ -58,7 +59,7 @@ public class ExileGraveyardAllPlayersEffect extends OneShotEffect {
|
|||
return false;
|
||||
}
|
||||
|
||||
for (UUID playerId : controller.getInRange()) {
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
for (UUID cid : player.getGraveyard().copy()) {
|
||||
|
|
@ -71,4 +72,4 @@ public class ExileGraveyardAllPlayersEffect extends OneShotEffect {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ public class LoseLifeAllPlayersEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
for (UUID playerId: game.getPlayer(source.getControllerId()).getInRange()) {
|
||||
for (UUID playerId: game.getState().getPlayersInRange(source.getControllerId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
player.loseLife(amount.calculate(game, source, this), game);
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@
|
|||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
|
|
@ -39,8 +38,6 @@ import mage.players.Player;
|
|||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
|
||||
public class PreventAllDamageToPlayersEffect extends PreventionEffectImpl {
|
||||
|
||||
public PreventAllDamageToPlayersEffect(Duration duration, boolean onlyCombat) {
|
||||
|
|
@ -66,7 +63,7 @@ public class PreventAllDamageToPlayersEffect extends PreventionEffectImpl {
|
|||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (super.applies(event, source, game) && event.getType().equals(GameEvent.EventType.DAMAGE_PLAYER)) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null && controller.getInRange().contains(event.getTargetId())){
|
||||
if (controller != null && game.getState().getPlayersInRange(controller.getId(), game).contains(event.getTargetId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,14 +35,12 @@ import mage.constants.Outcome;
|
|||
import mage.constants.Zone;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class ReturnToHandFromGraveyardAllEffect extends OneShotEffect {
|
||||
|
||||
private final FilterCard filter;
|
||||
|
|
@ -62,10 +60,10 @@ public class ReturnToHandFromGraveyardAllEffect extends OneShotEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
for (UUID playerId : controller.getInRange()) {
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
for (Card card :player.getGraveyard().getCards(filter, source.getSourceId(), source.getControllerId(), game)) {
|
||||
for (Card card : player.getGraveyard().getCards(filter, source.getSourceId(), source.getControllerId(), game)) {
|
||||
card.moveToZone(Zone.HAND, playerId, game, false);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
|
|
@ -20,12 +20,11 @@
|
|||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -43,7 +42,6 @@ import mage.players.Player;
|
|||
import mage.target.common.TargetControlledPermanent;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
|
@ -56,6 +54,7 @@ public class SacrificeAllEffect extends OneShotEffect {
|
|||
public SacrificeAllEffect(FilterControlledPermanent filter) {
|
||||
this(1, filter);
|
||||
}
|
||||
|
||||
public SacrificeAllEffect(int amount, FilterControlledPermanent filter) {
|
||||
this(new StaticValue(amount), filter);
|
||||
}
|
||||
|
|
@ -86,7 +85,7 @@ public class SacrificeAllEffect extends OneShotEffect {
|
|||
}
|
||||
|
||||
List<UUID> perms = new ArrayList<>();
|
||||
for (UUID playerId : controller.getInRange()) {
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
int numTargets = Math.min(amount.calculate(game, source, this), game.getBattlefield().countAll(filter, player.getId(), game));
|
||||
|
|
|
|||
|
|
@ -58,10 +58,10 @@ public class SetPlayerLifeAllEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player sourcePlayer = game.getPlayer(source.getControllerId());
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
switch (targetController) {
|
||||
case ANY:
|
||||
for (UUID playerId : sourcePlayer.getInRange()) {
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
player.setLife(amount.calculate(game, source, this), game);
|
||||
|
|
@ -69,7 +69,7 @@ public class SetPlayerLifeAllEffect extends OneShotEffect {
|
|||
}
|
||||
break;
|
||||
case OPPONENT:
|
||||
for (UUID playerId : game.getOpponents(sourcePlayer.getId())) {
|
||||
for (UUID playerId : game.getOpponents(controller.getId())) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
player.setLife(amount.calculate(game, source, this), game);
|
||||
|
|
|
|||
|
|
@ -43,13 +43,13 @@ import mage.players.Player;
|
|||
* @author LevelX2
|
||||
*/
|
||||
public class CantGainLifeAllEffect extends ContinuousEffectImpl {
|
||||
|
||||
|
||||
private TargetController targetController;
|
||||
|
||||
|
||||
public CantGainLifeAllEffect() {
|
||||
this(Duration.WhileOnBattlefield);
|
||||
}
|
||||
|
||||
|
||||
public CantGainLifeAllEffect(Duration duration) {
|
||||
this(duration, TargetController.ANY);
|
||||
}
|
||||
|
|
@ -58,7 +58,7 @@ public class CantGainLifeAllEffect extends ContinuousEffectImpl {
|
|||
super(duration, Layer.PlayerEffects, SubLayer.NA, Outcome.Benefit);
|
||||
this.targetController = targetController;
|
||||
staticText = setText();
|
||||
|
||||
|
||||
}
|
||||
|
||||
public CantGainLifeAllEffect(final CantGainLifeAllEffect effect) {
|
||||
|
|
@ -74,21 +74,21 @@ public class CantGainLifeAllEffect extends ContinuousEffectImpl {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
if (controller != null) {
|
||||
switch (targetController) {
|
||||
case YOU:
|
||||
controller.setCanGainLife(false);
|
||||
break;
|
||||
break;
|
||||
case NOT_YOU:
|
||||
for (UUID playerId: controller.getInRange()) {
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && !player.equals(controller)) {
|
||||
player.setCanGainLife(false);
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case OPPONENT:
|
||||
for (UUID playerId: controller.getInRange()) {
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
if (controller.hasOpponent(playerId, game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
|
|
@ -96,15 +96,15 @@ public class CantGainLifeAllEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case ANY:
|
||||
for (UUID playerId: controller.getInRange()) {
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
player.setCanGainLife(false);
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -116,17 +116,17 @@ public class CantGainLifeAllEffect extends ContinuousEffectImpl {
|
|||
switch (targetController) {
|
||||
case YOU:
|
||||
sb.append("You");
|
||||
break;
|
||||
break;
|
||||
case NOT_YOU:
|
||||
sb.append("Other players");
|
||||
break;
|
||||
break;
|
||||
case OPPONENT:
|
||||
sb.append("Your opponents");
|
||||
break;
|
||||
break;
|
||||
case ANY:
|
||||
sb.append("Players");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
sb.append(" can't gain life");
|
||||
if (!this.duration.toString().isEmpty()) {
|
||||
sb.append(" ");
|
||||
|
|
@ -135,8 +135,8 @@ public class CantGainLifeAllEffect extends ContinuousEffectImpl {
|
|||
} else {
|
||||
sb.append(duration.toString());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return sb.toString();
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,13 +28,13 @@
|
|||
package mage.abilities.effects.common.continuous;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Layer;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubLayer;
|
||||
import mage.constants.TargetController;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.util.CardUtil;
|
||||
|
|
@ -44,7 +44,9 @@ import mage.util.CardUtil;
|
|||
*/
|
||||
public class MaximumHandSizeControllerEffect extends ContinuousEffectImpl {
|
||||
|
||||
public static enum HandSizeModification { SET, INCREASE, REDUCE };
|
||||
public static enum HandSizeModification {
|
||||
SET, INCREASE, REDUCE
|
||||
};
|
||||
|
||||
protected int handSize;
|
||||
protected HandSizeModification handSizeModification;
|
||||
|
|
@ -54,14 +56,14 @@ public class MaximumHandSizeControllerEffect extends ContinuousEffectImpl {
|
|||
* @param handSize Maximum hand size to set or to reduce by
|
||||
* @param duration Effect duration
|
||||
* @param handSizeModification SET, INCREASE, REDUCE
|
||||
*
|
||||
*
|
||||
*/
|
||||
public MaximumHandSizeControllerEffect(int handSize, Duration duration, HandSizeModification handSizeModification) {
|
||||
this(handSize, duration, handSizeModification, TargetController.YOU);
|
||||
}
|
||||
|
||||
public MaximumHandSizeControllerEffect(int handSize, Duration duration, HandSizeModification handSizeModification, TargetController targetController) {
|
||||
super(duration, Layer.PlayerEffects, SubLayer.NA, defineOutcome(handSizeModification, targetController));
|
||||
super(duration, Layer.PlayerEffects, SubLayer.NA, defineOutcome(handSizeModification, targetController));
|
||||
this.handSize = handSize;
|
||||
this.handSizeModification = handSizeModification;
|
||||
this.targetController = targetController;
|
||||
|
|
@ -79,7 +81,7 @@ public class MaximumHandSizeControllerEffect extends ContinuousEffectImpl {
|
|||
public MaximumHandSizeControllerEffect copy() {
|
||||
return new MaximumHandSizeControllerEffect(this);
|
||||
}
|
||||
|
||||
|
||||
protected static Outcome defineOutcome(HandSizeModification handSizeModification, TargetController targetController) {
|
||||
Outcome newOutcome = Outcome.Benefit;
|
||||
if ((targetController.equals(TargetController.YOU) || targetController.equals(TargetController.ANY))
|
||||
|
|
@ -93,14 +95,14 @@ public class MaximumHandSizeControllerEffect extends ContinuousEffectImpl {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
switch(targetController) {
|
||||
switch (targetController) {
|
||||
case ANY:
|
||||
for (UUID playerId: controller.getInRange()) {
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
setHandSize(game, playerId);
|
||||
}
|
||||
break;
|
||||
case OPPONENT:
|
||||
for (UUID playerId: game.getOpponents(source.getControllerId())) {
|
||||
for (UUID playerId : game.getOpponents(source.getControllerId())) {
|
||||
setHandSize(game, playerId);
|
||||
}
|
||||
break;
|
||||
|
|
@ -118,7 +120,7 @@ public class MaximumHandSizeControllerEffect extends ContinuousEffectImpl {
|
|||
private void setHandSize(Game game, UUID playerId) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
switch(handSizeModification) {
|
||||
switch (handSizeModification) {
|
||||
case SET:
|
||||
player.setMaxHandSize(handSize);
|
||||
break;
|
||||
|
|
@ -134,7 +136,7 @@ public class MaximumHandSizeControllerEffect extends ContinuousEffectImpl {
|
|||
|
||||
private void setText() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
switch(targetController) {
|
||||
switch (targetController) {
|
||||
case ANY:
|
||||
if (handSize == Integer.MAX_VALUE) {
|
||||
sb.append("All players have no ");
|
||||
|
|
@ -158,9 +160,9 @@ public class MaximumHandSizeControllerEffect extends ContinuousEffectImpl {
|
|||
break;
|
||||
}
|
||||
sb.append("maximum hand size");
|
||||
if (handSizeModification.equals(HandSizeModification.INCREASE)){
|
||||
if (handSizeModification.equals(HandSizeModification.INCREASE)) {
|
||||
sb.append(" is increased by ");
|
||||
} else if (handSizeModification.equals(HandSizeModification.REDUCE)){
|
||||
} else if (handSizeModification.equals(HandSizeModification.REDUCE)) {
|
||||
sb.append(" is reduced by ");
|
||||
} else if (handSize != Integer.MAX_VALUE) {
|
||||
sb.append(" is ");
|
||||
|
|
|
|||
|
|
@ -63,15 +63,15 @@ public class PlayWithHandRevealedEffect extends ContinuousEffectImpl {
|
|||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
Iterable<UUID> affectedPlayers;
|
||||
switch(who) {
|
||||
switch (who) {
|
||||
case ANY:
|
||||
affectedPlayers = controller.getInRange();
|
||||
affectedPlayers = game.getState().getPlayersInRange(controller.getId(), game);
|
||||
break;
|
||||
case OPPONENT:
|
||||
affectedPlayers = game.getOpponents(source.getControllerId());
|
||||
break;
|
||||
case YOU:
|
||||
ArrayList tmp = new ArrayList<UUID>();
|
||||
ArrayList tmp = new ArrayList<>();
|
||||
tmp.add(source.getControllerId());
|
||||
affectedPlayers = tmp;
|
||||
break;
|
||||
|
|
@ -79,7 +79,7 @@ public class PlayWithHandRevealedEffect extends ContinuousEffectImpl {
|
|||
return false;
|
||||
}
|
||||
|
||||
for(UUID playerID: affectedPlayers) {
|
||||
for (UUID playerID : affectedPlayers) {
|
||||
Player player = game.getPlayer(playerID);
|
||||
if (player != null) {
|
||||
player.revealCards(player.getName() + "'s hand cards", player.getHand(), game, false);
|
||||
|
|
@ -100,7 +100,7 @@ public class PlayWithHandRevealedEffect extends ContinuousEffectImpl {
|
|||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
switch(who) {
|
||||
switch (who) {
|
||||
case ANY:
|
||||
return "Players play with their hands revealed";
|
||||
case OPPONENT:
|
||||
|
|
|
|||
|
|
@ -53,8 +53,7 @@ public class PlayWithTheTopCardRevealedEffect extends ContinuousEffectImpl {
|
|||
this.allPlayers = allPlayers;
|
||||
if (allPlayers) {
|
||||
staticText = "Players play with the top card of their libraries revealed.";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
staticText = "Play with the top card of your library revealed";
|
||||
}
|
||||
}
|
||||
|
|
@ -69,14 +68,13 @@ public class PlayWithTheTopCardRevealedEffect extends ContinuousEffectImpl {
|
|||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
if (allPlayers) {
|
||||
for (UUID playerId : controller.getInRange()) {
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
player.setTopCardRevealed(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
controller.setTopCardRevealed(true);
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ public class DiscardEachPlayerEffect extends OneShotEffect {
|
|||
}
|
||||
}
|
||||
// discard all choosen cards
|
||||
for (UUID playerId : controller.getInRange()) {
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
Cards cardsPlayer = cardsToDiscard.get(playerId);
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@
|
|||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.abilities.keyword;
|
||||
|
||||
import java.util.UUID;
|
||||
|
|
@ -38,13 +37,16 @@ import mage.game.events.GameEvent;
|
|||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
* Dethrone triggers whenever a creature with dethrone attacks the player with the most life or tied
|
||||
* for the most life. When the ability resolves, you put a +1/+1 counter on the creature. This happens
|
||||
* before blockers are declared. Once the ability triggers, it doesn't matter what happens to anybody's
|
||||
* life total. If the defending player doesn't have the most life when the ability resolves, the creature
|
||||
* will still get the +1/+1 counter. Note that dethrone won't trigger if the creature attacks a Planeswalker.
|
||||
* You're going after the crown, after all, not the royal advisors. If you have the most life, your dethrone
|
||||
* abilities won't trigger, but you may find a few choice ways to avoid that situation.
|
||||
* Dethrone triggers whenever a creature with dethrone attacks the player with
|
||||
* the most life or tied for the most life. When the ability resolves, you put a
|
||||
* +1/+1 counter on the creature. This happens before blockers are declared.
|
||||
* Once the ability triggers, it doesn't matter what happens to anybody's life
|
||||
* total. If the defending player doesn't have the most life when the ability
|
||||
* resolves, the creature will still get the +1/+1 counter. Note that dethrone
|
||||
* won't trigger if the creature attacks a Planeswalker. You're going after the
|
||||
* crown, after all, not the royal advisors. If you have the most life, your
|
||||
* dethrone abilities won't trigger, but you may find a few choice ways to avoid
|
||||
* that situation.
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
|
@ -76,7 +78,7 @@ public class DethroneAbility extends TriggeredAbilityImpl {
|
|||
Player controller = game.getPlayer(getControllerId());
|
||||
if (attackedPlayer != null && controller != null) {
|
||||
int mostLife = Integer.MIN_VALUE;
|
||||
for (UUID playerId: controller.getInRange()) {
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
if (player.getLife() > mostLife) {
|
||||
|
|
|
|||
|
|
@ -33,14 +33,12 @@ import mage.filter.predicate.ObjectPlayer;
|
|||
import mage.filter.predicate.ObjectPlayerPredicate;
|
||||
import mage.game.Controllable;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.watchers.common.PlayerDamagedBySourceWatcher;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class DamagedPlayerThisTurnPredicate implements ObjectPlayerPredicate<ObjectPlayer<Controllable>> {
|
||||
|
||||
private final TargetController controller;
|
||||
|
|
@ -56,40 +54,34 @@ public class DamagedPlayerThisTurnPredicate implements ObjectPlayerPredicate<Obj
|
|||
|
||||
switch (controller) {
|
||||
case YOU:
|
||||
PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get("PlayerDamagedBySource",playerId);
|
||||
if (watcher != null ) {
|
||||
PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get("PlayerDamagedBySource", playerId);
|
||||
if (watcher != null) {
|
||||
return watcher.hasSourceDoneDamage(object.getId(), game);
|
||||
}
|
||||
break;
|
||||
case OPPONENT:
|
||||
for (UUID opponentId : game.getOpponents(playerId)) {
|
||||
watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get("PlayerDamagedBySource",opponentId);
|
||||
if (watcher != null ) {
|
||||
watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get("PlayerDamagedBySource", opponentId);
|
||||
if (watcher != null) {
|
||||
return watcher.hasSourceDoneDamage(object.getId(), game);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case NOT_YOU:
|
||||
Player you = game.getPlayer(playerId);
|
||||
if (you != null) {
|
||||
for (UUID notYouId : you.getInRange()) {
|
||||
if (!notYouId.equals(playerId)) {
|
||||
watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get("PlayerDamagedBySource",notYouId);
|
||||
if (watcher != null ) {
|
||||
return watcher.hasSourceDoneDamage(object.getId(), game);
|
||||
}
|
||||
for (UUID notYouId : game.getState().getPlayersInRange(playerId, game)) {
|
||||
if (!notYouId.equals(playerId)) {
|
||||
watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get("PlayerDamagedBySource", notYouId);
|
||||
if (watcher != null) {
|
||||
return watcher.hasSourceDoneDamage(object.getId(), game);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ANY:
|
||||
you = game.getPlayer(playerId);
|
||||
if (you != null) {
|
||||
for (UUID anyId : you.getInRange()) {
|
||||
watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get("PlayerDamagedBySource",anyId);
|
||||
if (watcher != null ) {
|
||||
return watcher.hasSourceDoneDamage(object.getId(), game);
|
||||
}
|
||||
for (UUID anyId : game.getState().getPlayersInRange(playerId, game)) {
|
||||
watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get("PlayerDamagedBySource", anyId);
|
||||
if (watcher != null) {
|
||||
return watcher.hasSourceDoneDamage(object.getId(), game);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ public abstract class GameCommanderImpl extends GameImpl {
|
|||
@Override
|
||||
public Set<UUID> getOpponents(UUID playerId) {
|
||||
Set<UUID> opponents = new HashSet<>();
|
||||
for (UUID opponentId : this.getPlayer(playerId).getInRange()) {
|
||||
for (UUID opponentId : getState().getPlayersInRange(playerId, this)) {
|
||||
if (!opponentId.equals(playerId)) {
|
||||
opponents.add(opponentId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2734,9 +2734,11 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
public void setDraw(UUID playerId) {
|
||||
Player player = getPlayer(playerId);
|
||||
if (player != null) {
|
||||
for (UUID playerToSetId : player.getInRange()) {
|
||||
for (UUID playerToSetId : getState().getPlayersInRange(playerId, this)) {
|
||||
Player playerToDraw = getPlayer(playerToSetId);
|
||||
playerToDraw.lostForced(this);
|
||||
if (playerToDraw != null) {
|
||||
playerToDraw.lostForced(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@
|
|||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.game;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
|
@ -57,8 +56,8 @@ import mage.watchers.common.CommanderInfoWatcher;
|
|||
*
|
||||
* @author JRHerlehy
|
||||
*/
|
||||
public abstract class GameTinyLeadersImpl extends GameImpl{
|
||||
|
||||
public abstract class GameTinyLeadersImpl extends GameImpl {
|
||||
|
||||
protected boolean alsoHand; // replace also commander going to library
|
||||
protected boolean alsoLibrary; // replace also commander going to library
|
||||
protected boolean startingPlayerSkipsDraw = true;
|
||||
|
|
@ -72,14 +71,14 @@ public abstract class GameTinyLeadersImpl extends GameImpl{
|
|||
this.alsoHand = game.alsoHand;
|
||||
this.startingPlayerSkipsDraw = game.startingPlayerSkipsDraw;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void init(UUID choosingPlayerId) {
|
||||
Ability ability = new SimpleStaticAbility(Zone.COMMAND, new InfoEffect("Commander effects"));
|
||||
//Move tiny leader to command zone
|
||||
for (UUID playerId: state.getPlayerList(startingPlayerId)) {
|
||||
for (UUID playerId : state.getPlayerList(startingPlayerId)) {
|
||||
Player player = getPlayer(playerId);
|
||||
if (player != null){
|
||||
if (player != null) {
|
||||
Card commander = getCommanderCard(player.getMatchPlayer().getDeck().getName(), player.getId());
|
||||
if (commander != null) {
|
||||
Set<Card> cards = new HashSet<>();
|
||||
|
|
@ -95,7 +94,7 @@ public abstract class GameTinyLeadersImpl extends GameImpl{
|
|||
getState().getWatchers().add(watcher);
|
||||
watcher.addCardInfoToCommander(this);
|
||||
} else {
|
||||
throw new UnknownError("Commander card could not be created. Name: [" + player.getMatchPlayer().getDeck().getName() +"]");
|
||||
throw new UnknownError("Commander card could not be created. Name: [" + player.getMatchPlayer().getDeck().getName() + "]");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -109,14 +108,14 @@ public abstract class GameTinyLeadersImpl extends GameImpl{
|
|||
|
||||
/**
|
||||
* Name of Tiny Leader comes from the deck name (it's not in the sideboard)
|
||||
* Additionally, it was taken into account that WOTC had missed a few color combinations
|
||||
* when making Legendary Creatures at 3 CMC. There are two Commanders available to use
|
||||
* for the missing color identities:
|
||||
* Sultai [UBG 3/3] and Glass [colorless 3/3]
|
||||
* Additionally, it was taken into account that WOTC had missed a few color
|
||||
* combinations when making Legendary Creatures at 3 CMC. There are two
|
||||
* Commanders available to use for the missing color identities: Sultai [UBG
|
||||
* 3/3] and Glass [colorless 3/3]
|
||||
*
|
||||
* @param commanderName
|
||||
* @param ownerId
|
||||
* @return
|
||||
* @return
|
||||
*/
|
||||
public static Card getCommanderCard(String commanderName, UUID ownerId) {
|
||||
Card commander = null;
|
||||
|
|
@ -141,7 +140,7 @@ public abstract class GameTinyLeadersImpl extends GameImpl{
|
|||
@Override
|
||||
public Set<UUID> getOpponents(UUID playerId) {
|
||||
Set<UUID> opponents = new HashSet<>();
|
||||
for (UUID opponentId: this.getPlayer(playerId).getInRange()) {
|
||||
for (UUID opponentId : getState().getPlayersInRange(playerId, this)) {
|
||||
if (!opponentId.equals(playerId)) {
|
||||
opponents.add(opponentId);
|
||||
}
|
||||
|
|
@ -151,7 +150,7 @@ public abstract class GameTinyLeadersImpl extends GameImpl{
|
|||
|
||||
@Override
|
||||
public boolean isOpponent(Player player, UUID playerToCheck) {
|
||||
return !player.getId().equals(playerToCheck);
|
||||
return !player.getId().equals(playerToCheck);
|
||||
}
|
||||
|
||||
public void setAlsoHand(boolean alsoHand) {
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ public class TargetCard extends TargetObject {
|
|||
@Override
|
||||
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
int possibleTargets = 0;
|
||||
for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) {
|
||||
for (UUID playerId: game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
switch (zone) {
|
||||
|
|
@ -156,7 +156,7 @@ public class TargetCard extends TargetObject {
|
|||
@Override
|
||||
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
Set<UUID> possibleTargets = new HashSet<>();
|
||||
for (UUID playerId : game.getPlayer(sourceControllerId).getInRange()) {
|
||||
for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
switch (zone) {
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ public class TargetPlayer extends TargetImpl {
|
|||
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
int count = 0;
|
||||
MageObject targetSource = game.getObject(sourceId);
|
||||
for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) {
|
||||
for (UUID playerId: game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && !player.hasLeft() && filter.match(player, sourceId, sourceControllerId, game)) {
|
||||
if (player.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||
|
|
@ -114,7 +114,7 @@ public class TargetPlayer extends TargetImpl {
|
|||
@Override
|
||||
public boolean canChoose(UUID sourceControllerId, Game game) {
|
||||
int count = 0;
|
||||
for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) {
|
||||
for (UUID playerId: game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && !player.hasLeft() && filter.match(player, game)) {
|
||||
count++;
|
||||
|
|
@ -130,7 +130,7 @@ public class TargetPlayer extends TargetImpl {
|
|||
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
Set<UUID> possibleTargets = new HashSet<>();
|
||||
MageObject targetSource = game.getObject(sourceId);
|
||||
for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) {
|
||||
for (UUID playerId: game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && !player.hasLeft() && filter.match(player, sourceId, sourceControllerId, game)) {
|
||||
if (isNotTarget() || player.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||
|
|
@ -144,7 +144,7 @@ public class TargetPlayer extends TargetImpl {
|
|||
@Override
|
||||
public Set<UUID> possibleTargets(UUID sourceControllerId, Game game) {
|
||||
Set<UUID> possibleTargets = new HashSet<>();
|
||||
for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) {
|
||||
for (UUID playerId: game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && !player.hasLeft() && filter.match(player, game)) {
|
||||
possibleTargets.add(playerId);
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ public class TargetSource extends TargetObject {
|
|||
public boolean canChoose(UUID sourceControllerId, Game game) {
|
||||
int count = 0;
|
||||
for (StackObject stackObject: game.getStack()) {
|
||||
if (game.getPlayer(sourceControllerId).getInRange().contains(stackObject.getControllerId()) && filter.match(stackObject, game)) {
|
||||
if (game.getState().getPlayersInRange(sourceControllerId, game).contains(stackObject.getControllerId()) && filter.match(stackObject, game)) {
|
||||
count++;
|
||||
if (count >= this.minNumberOfTargets) {
|
||||
return true;
|
||||
|
|
@ -158,7 +158,7 @@ public class TargetSource extends TargetObject {
|
|||
public Set<UUID> possibleTargets(UUID sourceControllerId, Game game) {
|
||||
Set<UUID> possibleTargets = new HashSet<>();
|
||||
for (StackObject stackObject: game.getStack()) {
|
||||
if (game.getPlayer(sourceControllerId).getInRange().contains(stackObject.getControllerId()) && filter.match(stackObject, game)) {
|
||||
if (game.getState().getPlayersInRange(sourceControllerId, game).contains(stackObject.getControllerId()) && filter.match(stackObject, game)) {
|
||||
possibleTargets.add(stackObject.getId());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ public class TargetSpell extends TargetObject {
|
|||
|
||||
private boolean canBeChosen(StackObject stackObject, UUID sourceID, UUID sourceControllerId, Game game) {
|
||||
return stackObject instanceof Spell
|
||||
&& game.getPlayer(sourceControllerId).getInRange().contains(stackObject.getControllerId())
|
||||
&& game.getState().getPlayersInRange(sourceControllerId, game).contains(stackObject.getControllerId())
|
||||
&& filter.match((Spell) stackObject, sourceID, sourceControllerId, game);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ public class TargetStackObject extends TargetObject {
|
|||
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
int count = 0;
|
||||
for (StackObject stackObject: game.getStack()) {
|
||||
if (game.getPlayer(sourceControllerId).getInRange().contains(stackObject.getControllerId()) && filter.match(stackObject, sourceId, sourceControllerId, game)) {
|
||||
if (game.getState().getPlayersInRange(sourceControllerId, game).contains(stackObject.getControllerId()) && filter.match(stackObject, sourceId, sourceControllerId, game)) {
|
||||
count++;
|
||||
if (count >= this.minNumberOfTargets) {
|
||||
return true;
|
||||
|
|
@ -108,7 +108,7 @@ public class TargetStackObject extends TargetObject {
|
|||
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
Set<UUID> possibleTargets = new HashSet<>();
|
||||
for (StackObject stackObject: game.getStack()) {
|
||||
if (game.getPlayer(sourceControllerId).getInRange().contains(stackObject.getControllerId()) && filter.match(stackObject, sourceId, sourceControllerId, game)) {
|
||||
if (game.getState().getPlayersInRange(sourceControllerId, game).contains(stackObject.getControllerId()) && filter.match(stackObject, sourceId, sourceControllerId, game)) {
|
||||
possibleTargets.add(stackObject.getId());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ public class TargetActivatedAbility extends TargetObject {
|
|||
for (StackObject stackObject : game.getStack()) {
|
||||
if (stackObject.getStackAbility() != null
|
||||
&& stackObject.getStackAbility().getAbilityType().equals(AbilityType.ACTIVATED)
|
||||
&& game.getPlayer(sourceControllerId).getInRange().contains(stackObject.getStackAbility().getControllerId())) {
|
||||
&& game.getState().getPlayersInRange(sourceControllerId, game).contains(stackObject.getStackAbility().getControllerId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -92,7 +92,7 @@ public class TargetActivatedAbility extends TargetObject {
|
|||
public Set<UUID> possibleTargets(UUID sourceControllerId, Game game) {
|
||||
Set<UUID> possibleTargets = new HashSet<>();
|
||||
for (StackObject stackObject : game.getStack()) {
|
||||
if (stackObject.getStackAbility().getAbilityType().equals(AbilityType.ACTIVATED) && game.getPlayer(sourceControllerId).getInRange().contains(stackObject.getStackAbility().getControllerId())) {
|
||||
if (stackObject.getStackAbility().getAbilityType().equals(AbilityType.ACTIVATED) && game.getState().getPlayersInRange(sourceControllerId, game).contains(stackObject.getStackAbility().getControllerId())) {
|
||||
possibleTargets.add(stackObject.getStackAbility().getId());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ public class TargetCardInOpponentsGraveyard extends TargetCard {
|
|||
@Override
|
||||
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
int possibleTargets = 0;
|
||||
for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) {
|
||||
for (UUID playerId: game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||
if (!playerId.equals(sourceControllerId)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ public class TargetCreatureOrPlayer extends TargetImpl {
|
|||
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
int count = 0;
|
||||
MageObject targetSource = game.getObject(sourceId);
|
||||
for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) {
|
||||
for (UUID playerId: game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && player.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(player, game)) {
|
||||
count++;
|
||||
|
|
@ -166,7 +166,7 @@ public class TargetCreatureOrPlayer extends TargetImpl {
|
|||
@Override
|
||||
public boolean canChoose(UUID sourceControllerId, Game game) {
|
||||
int count = 0;
|
||||
for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) {
|
||||
for (UUID playerId: game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && filter.match(player, game)) {
|
||||
count++;
|
||||
|
|
@ -190,7 +190,7 @@ public class TargetCreatureOrPlayer extends TargetImpl {
|
|||
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
Set<UUID> possibleTargets = new HashSet<>();
|
||||
MageObject targetSource = game.getObject(sourceId);
|
||||
for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) {
|
||||
for (UUID playerId: game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null
|
||||
&& player.canBeTargetedBy(targetSource, sourceControllerId, game)
|
||||
|
|
@ -210,7 +210,7 @@ public class TargetCreatureOrPlayer extends TargetImpl {
|
|||
@Override
|
||||
public Set<UUID> possibleTargets(UUID sourceControllerId, Game game) {
|
||||
Set<UUID> possibleTargets = new HashSet<>();
|
||||
for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) {
|
||||
for (UUID playerId: game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && filter.getPlayerFilter().match(player, game)) {
|
||||
possibleTargets.add(playerId);
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ public class TargetCreatureOrPlayerAmount extends TargetAmount {
|
|||
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
int count = 0;
|
||||
MageObject targetSource = game.getObject(sourceId);
|
||||
for (UUID playerId : game.getPlayer(sourceControllerId).getInRange()) {
|
||||
for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && player.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(player, game)) {
|
||||
count++;
|
||||
|
|
@ -146,7 +146,7 @@ public class TargetCreatureOrPlayerAmount extends TargetAmount {
|
|||
@Override
|
||||
public boolean canChoose(UUID sourceControllerId, Game game) {
|
||||
int count = 0;
|
||||
for (UUID playerId : game.getPlayer(sourceControllerId).getInRange()) {
|
||||
for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && filter.match(player, game)) {
|
||||
count++;
|
||||
|
|
@ -170,7 +170,7 @@ public class TargetCreatureOrPlayerAmount extends TargetAmount {
|
|||
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
Set<UUID> possibleTargets = new HashSet<>();
|
||||
MageObject targetSource = game.getObject(sourceId);
|
||||
for (UUID playerId : game.getPlayer(sourceControllerId).getInRange()) {
|
||||
for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && player.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(player, game)) {
|
||||
possibleTargets.add(playerId);
|
||||
|
|
@ -187,7 +187,7 @@ public class TargetCreatureOrPlayerAmount extends TargetAmount {
|
|||
@Override
|
||||
public Set<UUID> possibleTargets(UUID sourceControllerId, Game game) {
|
||||
Set<UUID> possibleTargets = new HashSet<>();
|
||||
for (UUID playerId : game.getPlayer(sourceControllerId).getInRange()) {
|
||||
for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && filter.match(player, game)) {
|
||||
possibleTargets.add(playerId);
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ public class TargetDefender extends TargetImpl {
|
|||
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
int count = 0;
|
||||
MageObject targetSource = game.getObject(sourceId);
|
||||
for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) {
|
||||
for (UUID playerId: game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
// removed canBeTargeted because it's not correct to check it for attacking target
|
||||
if (player != null && player.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(player, game)) {
|
||||
|
|
@ -109,7 +109,7 @@ public class TargetDefender extends TargetImpl {
|
|||
@Override
|
||||
public boolean canChoose(UUID sourceControllerId, Game game) {
|
||||
int count = 0;
|
||||
for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) {
|
||||
for (UUID playerId: game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && filter.match(player, game)) {
|
||||
count++;
|
||||
|
|
@ -133,7 +133,7 @@ public class TargetDefender extends TargetImpl {
|
|||
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
Set<UUID> possibleTargets = new HashSet<>();
|
||||
MageObject targetSource = game.getObject(sourceId);
|
||||
for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) {
|
||||
for (UUID playerId: game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && player.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(player, game)) {
|
||||
possibleTargets.add(playerId);
|
||||
|
|
@ -150,7 +150,7 @@ public class TargetDefender extends TargetImpl {
|
|||
@Override
|
||||
public Set<UUID> possibleTargets(UUID sourceControllerId, Game game) {
|
||||
Set<UUID> possibleTargets = new HashSet<>();
|
||||
for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) {
|
||||
for (UUID playerId: game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && filter.match(player, game)) {
|
||||
possibleTargets.add(playerId);
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ public class TargetPermanentOrPlayer extends TargetImpl {
|
|||
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
int count = 0;
|
||||
MageObject targetSource = game.getObject(sourceId);
|
||||
for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) {
|
||||
for (UUID playerId: game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && player.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(player, game)) {
|
||||
count++;
|
||||
|
|
@ -187,7 +187,7 @@ public class TargetPermanentOrPlayer extends TargetImpl {
|
|||
@Override
|
||||
public boolean canChoose(UUID sourceControllerId, Game game) {
|
||||
int count = 0;
|
||||
for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) {
|
||||
for (UUID playerId: game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && filter.match(player, game)) {
|
||||
count++;
|
||||
|
|
@ -211,7 +211,7 @@ public class TargetPermanentOrPlayer extends TargetImpl {
|
|||
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
Set<UUID> possibleTargets = new HashSet<>();
|
||||
MageObject targetSource = game.getObject(sourceId);
|
||||
for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) {
|
||||
for (UUID playerId: game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && (notTarget || player.canBeTargetedBy(targetSource, sourceControllerId, game)) && filter.match(player, game)) {
|
||||
possibleTargets.add(playerId);
|
||||
|
|
@ -228,7 +228,7 @@ public class TargetPermanentOrPlayer extends TargetImpl {
|
|||
@Override
|
||||
public Set<UUID> possibleTargets(UUID sourceControllerId, Game game) {
|
||||
Set<UUID> possibleTargets = new HashSet<>();
|
||||
for (UUID playerId: game.getPlayer(sourceControllerId).getInRange()) {
|
||||
for (UUID playerId: game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && filter.match(player, game)) {
|
||||
possibleTargets.add(playerId);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue