mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 19:41:59 -08:00
Fixed that no event was send for removing counters from players.
This commit is contained in:
parent
162ac957c6
commit
22dbb1ef38
8 changed files with 49 additions and 30 deletions
|
|
@ -64,7 +64,6 @@ public class Leeches extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
class LeechesEffect extends OneShotEffect {
|
||||
|
||||
public LeechesEffect() {
|
||||
|
|
@ -91,7 +90,7 @@ class LeechesEffect extends OneShotEffect {
|
|||
|
||||
int countPoisonCounters = targetPlayer.getCounters().getCount(CounterType.POISON);
|
||||
if (countPoisonCounters > 0) {
|
||||
targetPlayer.getCounters().removeCounter(CounterType.POISON, countPoisonCounters);
|
||||
targetPlayer.removeCounters(CounterType.POISON.getName(), countPoisonCounters, source, game);
|
||||
targetPlayer.damage(countPoisonCounters, source.getSourceId(), game, false, true);
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1441,6 +1441,11 @@ public class TestPlayer implements Player {
|
|||
computerPlayer.addCounters(counter, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeCounters(String name, int amount, Ability source, Game game) {
|
||||
computerPlayer.removeCounters(name, amount, source, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Abilities<Ability> getAbilities() {
|
||||
return computerPlayer.getAbilities();
|
||||
|
|
|
|||
|
|
@ -348,7 +348,6 @@ public class PlayerStub implements Player {
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean getPassedAllTurns() {
|
||||
return false;
|
||||
|
|
@ -1019,6 +1018,11 @@ public class PlayerStub implements Player {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeCounters(String name, int amount, Ability source, Game game) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UUID> getAttachments() {
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ public class PayLoyaltyCost extends CostImpl {
|
|||
if (amount > 0) {
|
||||
planeswalker.getCounters().addCounter(CounterType.LOYALTY.createInstance(amount));
|
||||
} else if (amount < 0) {
|
||||
planeswalker.getCounters().removeCounter(CounterType.LOYALTY, Math.abs(amount));
|
||||
planeswalker.removeCounters(CounterType.LOYALTY.getName(), Math.abs(amount), game);
|
||||
}
|
||||
planeswalker.addLoyaltyUsed();
|
||||
this.paid = true;
|
||||
|
|
|
|||
|
|
@ -98,24 +98,22 @@ public class RemoveCounterCost extends CostImpl {
|
|||
|
||||
if (counterTypeToRemove != null) {
|
||||
counterName = counterTypeToRemove.getName();
|
||||
} else {
|
||||
if (permanent.getCounters().size() > 1 && counterTypeToRemove == null) {
|
||||
Choice choice = new ChoiceImpl(true);
|
||||
Set<String> choices = new HashSet<>();
|
||||
for (Counter counter : permanent.getCounters().values()) {
|
||||
if (permanent.getCounters().getCount(counter.getName()) > 0) {
|
||||
choices.add(counter.getName());
|
||||
}
|
||||
} else if (permanent.getCounters().size() > 1 && counterTypeToRemove == null) {
|
||||
Choice choice = new ChoiceImpl(true);
|
||||
Set<String> choices = new HashSet<>();
|
||||
for (Counter counter : permanent.getCounters().values()) {
|
||||
if (permanent.getCounters().getCount(counter.getName()) > 0) {
|
||||
choices.add(counter.getName());
|
||||
}
|
||||
choice.setChoices(choices);
|
||||
choice.setMessage("Choose a counter to remove from " + permanent.getLogName());
|
||||
controller.choose(Outcome.UnboostCreature, choice, game);
|
||||
counterName = choice.getChoice();
|
||||
} else {
|
||||
for (Counter counter : permanent.getCounters().values()) {
|
||||
if (counter.getCount() > 0) {
|
||||
counterName = counter.getName();
|
||||
}
|
||||
}
|
||||
choice.setChoices(choices);
|
||||
choice.setMessage("Choose a counter to remove from " + permanent.getLogName());
|
||||
controller.choose(Outcome.UnboostCreature, choice, game);
|
||||
counterName = choice.getChoice();
|
||||
} else {
|
||||
for (Counter counter : permanent.getCounters().values()) {
|
||||
if (counter.getCount() > 0) {
|
||||
counterName = counter.getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -129,6 +127,7 @@ public class RemoveCounterCost extends CostImpl {
|
|||
}
|
||||
permanent.removeCounters(counterName, numberOfCountersSelected, game);
|
||||
if (permanent.getCounters().getCount(counterName) == 0) {
|
||||
// this removes only the item with number = 0 from the collection
|
||||
permanent.getCounters().removeCounter(counterName);
|
||||
}
|
||||
countersRemoved += numberOfCountersSelected;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
@ -62,12 +61,11 @@ public class RemoveAllCountersSourceEffect extends OneShotEffect {
|
|||
@java.lang.Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
||||
if(sourcePermanent != null) {
|
||||
if (sourcePermanent != null) {
|
||||
int count = sourcePermanent.getCounters().getCount(counterType);
|
||||
sourcePermanent.getCounters().removeCounter(counterType, count);
|
||||
sourcePermanent.removeCounters(counterType.getName(), count, game);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -582,6 +582,8 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
|
||||
void addCounters(Counter counter, Game game);
|
||||
|
||||
void removeCounters(String name, int amount, Ability source, Game game);
|
||||
|
||||
List<UUID> getAttachments();
|
||||
|
||||
boolean addAttachment(UUID permanentId, Game game);
|
||||
|
|
|
|||
|
|
@ -1839,6 +1839,18 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeCounters(String name, int amount, Ability source, Game game) {
|
||||
for (int i = 0; i < amount; i++) {
|
||||
counters.removeCounter(name, 1);
|
||||
GameEvent event = GameEvent.getEvent(GameEvent.EventType.COUNTER_REMOVED,
|
||||
getId(), (source == null ? null : source.getSourceId()), (source == null ? null : source.getControllerId()));
|
||||
event.setData(name);
|
||||
event.setAmount(1);
|
||||
game.fireEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean canDamage(MageObject source, Game game) {
|
||||
for (ProtectionAbility ability : abilities.getProtectionAbilities()) {
|
||||
if (!ability.canTarget(source, game)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue