mirror of
https://github.com/magefree/mage.git
synced 2026-01-24 12:19:59 -08:00
* Fixed that spells with targets cast without paying mana could simply be canceled by canceling the target selection (e.g. player was able to cancel a spell cast by suspend what's not allowed by the rules).
This commit is contained in:
parent
963f371c12
commit
69dc4f10ac
6 changed files with 118 additions and 119 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.effects.common.counter;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
|
|
@ -40,8 +39,8 @@ import mage.game.permanent.Permanent;
|
|||
*
|
||||
* @author Loki
|
||||
*/
|
||||
|
||||
public class RemoveCounterSourceEffect extends OneShotEffect {
|
||||
|
||||
private final Counter counter;
|
||||
|
||||
public RemoveCounterSourceEffect(Counter counter) {
|
||||
|
|
@ -57,25 +56,24 @@ public class RemoveCounterSourceEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent p = game.getPermanent(source.getSourceId());
|
||||
if (p != null && p.getCounters().getCount(counter.getName()) >= counter.getCount()) {
|
||||
p.removeCounters(counter.getName(), counter.getCount(), game);
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null && permanent.getCounters().getCount(counter.getName()) >= counter.getCount()) {
|
||||
permanent.removeCounters(counter.getName(), counter.getCount(), game);
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(new StringBuilder("Removed ").append(counter.getCount()).append(" ").append(counter.getName())
|
||||
.append(" counter from ").append(p.getName()).toString());
|
||||
game.informPlayers("Removed " + counter.getCount() + " " + counter.getName() + " counter from " + permanent.getLogName());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
Card c = game.getCard(source.getSourceId());
|
||||
if (c != null && c.getCounters(game).getCount(counter.getName()) >= counter.getCount()) {
|
||||
c.removeCounters(counter.getName(), counter.getCount(), game);
|
||||
Card card = game.getCard(source.getSourceId());
|
||||
if (card != null && card.getCounters(game).getCount(counter.getName()) >= counter.getCount()) {
|
||||
card.removeCounters(counter.getName(), counter.getCount(), game);
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(new StringBuilder("Removed ").append(counter.getCount()).append(" ").append(counter.getName())
|
||||
.append(" counter from ").append(c.getName())
|
||||
.append(" (").append(c.getCounters(game).getCount(counter.getName())).append(" left)").toString());
|
||||
game.informPlayers("Removed " + counter.getCount() + " " + counter.getName()
|
||||
+ " counter from " + card.getLogName()
|
||||
+ " (" + card.getCounters(game).getCount(counter.getName()) + " left)");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -84,7 +82,7 @@ public class RemoveCounterSourceEffect extends OneShotEffect {
|
|||
return new RemoveCounterSourceEffect(this);
|
||||
}
|
||||
|
||||
private void setText() {
|
||||
private void setText() {
|
||||
if (counter.getCount() > 1) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("remove ").append(Integer.toString(counter.getCount())).append(" ").append(counter.getName()).append(" counters from {this}");
|
||||
|
|
|
|||
|
|
@ -1,58 +1,57 @@
|
|||
/*
|
||||
* 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
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* 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.
|
||||
*/
|
||||
|
||||
* 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
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* 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.target;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.constants.Outcome;
|
||||
import mage.abilities.Ability;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class Targets extends ArrayList<Target> {
|
||||
|
||||
public Targets() {}
|
||||
public Targets() {
|
||||
}
|
||||
|
||||
public Targets(final Targets targets) {
|
||||
for (Target target: targets) {
|
||||
for (Target target : targets) {
|
||||
this.add(target.copy());
|
||||
}
|
||||
}
|
||||
|
||||
public List<Target> getUnchosen() {
|
||||
List<Target> unchosen = new ArrayList<>();
|
||||
for (Target target: this) {
|
||||
for (Target target : this) {
|
||||
if (!target.isChosen()) {
|
||||
unchosen.add(target);
|
||||
}
|
||||
|
|
@ -61,13 +60,13 @@ public class Targets extends ArrayList<Target> {
|
|||
}
|
||||
|
||||
public void clearChosen() {
|
||||
for (Target target: this) {
|
||||
for (Target target : this) {
|
||||
target.clearChosen();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isChosen() {
|
||||
for (Target target: this) {
|
||||
for (Target target : this) {
|
||||
if (!target.isChosen()) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -90,7 +89,7 @@ public class Targets extends ArrayList<Target> {
|
|||
return true;
|
||||
}
|
||||
|
||||
public boolean chooseTargets(Outcome outcome, UUID playerId, Ability source, Game game) {
|
||||
public boolean chooseTargets(Outcome outcome, UUID playerId, Ability source, boolean noMana, Game game) {
|
||||
if (this.size() > 0) {
|
||||
if (!canChoose(source.getSourceId(), playerId, game)) {
|
||||
return false;
|
||||
|
|
@ -101,6 +100,9 @@ public class Targets extends ArrayList<Target> {
|
|||
if (target.getTargetController() != null) { // some targets can have controller different than ability controller
|
||||
targetController = target.getTargetController();
|
||||
}
|
||||
if (noMana) { // if cast without mana (e.g. by supend you may notr be able to cancel the casting if you are able to cast it
|
||||
target.setRequired(true);
|
||||
}
|
||||
if (!target.chooseTarget(outcome, targetController, source, game)) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -113,7 +115,7 @@ public class Targets extends ArrayList<Target> {
|
|||
// 608.2
|
||||
// The spell or ability is countered if all its targets, for every instance of the word "target," are now illegal
|
||||
int illegalCount = 0;
|
||||
for (Target target: this) {
|
||||
for (Target target : this) {
|
||||
if (!target.isLegal(source, game)) {
|
||||
illegalCount++;
|
||||
}
|
||||
|
|
@ -123,8 +125,8 @@ public class Targets extends ArrayList<Target> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Checks if there are enough targets that can be chosen. Should only be used
|
||||
* for Ability targets since this checks for protection, shroud etc.
|
||||
* Checks if there are enough targets that can be chosen. Should only be
|
||||
* used for Ability targets since this checks for protection, shroud etc.
|
||||
*
|
||||
* @param sourceId - the target event source
|
||||
* @param sourceControllerId - controller of the target event source
|
||||
|
|
@ -132,7 +134,7 @@ public class Targets extends ArrayList<Target> {
|
|||
* @return - true if enough valid targets exist
|
||||
*/
|
||||
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
for (Target target: this) {
|
||||
for (Target target : this) {
|
||||
if (!target.canChoose(sourceId, sourceControllerId, game)) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -141,15 +143,16 @@ public class Targets extends ArrayList<Target> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Checks if there are enough objects that can be selected. Should not be used
|
||||
* for Ability targets since this does not check for protection, shroud etc.
|
||||
* Checks if there are enough objects that can be selected. Should not be
|
||||
* used for Ability targets since this does not check for protection, shroud
|
||||
* etc.
|
||||
*
|
||||
* @param sourceControllerId - controller of the select event
|
||||
* @param game
|
||||
* @return - true if enough valid objects exist
|
||||
*/
|
||||
public boolean canChoose(UUID sourceControllerId, Game game) {
|
||||
for (Target target: this) {
|
||||
for (Target target : this) {
|
||||
if (!target.canChoose(sourceControllerId, game)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue