mirror of
https://github.com/magefree/mage.git
synced 2025-12-26 05:22:02 -08:00
reworked Clockwork creature implementations (fixes #8292)
This commit is contained in:
parent
2c8314932e
commit
2fa76fc7be
9 changed files with 211 additions and 185 deletions
|
|
@ -152,6 +152,8 @@ public interface Card extends MageObject {
|
|||
|
||||
boolean addCounters(Counter counter, UUID playerAddingCounters, Ability source, Game game, List<UUID> appliedEffects, boolean isEffect);
|
||||
|
||||
boolean addCounters(Counter counter, UUID playerAddingCounters, Ability source, Game game, List<UUID> appliedEffects, boolean isEffect, int maxCounters);
|
||||
|
||||
void removeCounters(String name, int amount, Ability source, Game game);
|
||||
|
||||
void removeCounters(Counter counter, Ability source, Game game);
|
||||
|
|
|
|||
|
|
@ -704,12 +704,21 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
|
|||
|
||||
@Override
|
||||
public boolean addCounters(Counter counter, UUID playerAddingCounters, Ability source, Game game, List<UUID> appliedEffects, boolean isEffect) {
|
||||
return addCounters(counter, playerAddingCounters, source, game, appliedEffects, isEffect, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
public boolean addCounters(Counter counter, UUID playerAddingCounters, Ability source, Game game, List<UUID> appliedEffects, boolean isEffect, int maxCounters) {
|
||||
boolean returnCode = true;
|
||||
GameEvent addingAllEvent = GameEvent.getEvent(GameEvent.EventType.ADD_COUNTERS, objectId, source, playerAddingCounters, counter.getName(), counter.getCount());
|
||||
addingAllEvent.setAppliedEffects(appliedEffects);
|
||||
addingAllEvent.setFlag(isEffect);
|
||||
if (!game.replaceEvent(addingAllEvent)) {
|
||||
int amount = addingAllEvent.getAmount();
|
||||
int amount;
|
||||
if (maxCounters < Integer.MAX_VALUE) {
|
||||
amount = Integer.min(addingAllEvent.getAmount(), maxCounters - this.getCounters(game).getCount(counter.getName()));
|
||||
} else {
|
||||
amount = addingAllEvent.getAmount();
|
||||
}
|
||||
boolean isEffectFlag = addingAllEvent.getFlag();
|
||||
int finalAmount = amount;
|
||||
for (int i = 0; i < amount; i++) {
|
||||
|
|
|
|||
|
|
@ -132,8 +132,8 @@ public abstract class ModalDoubleFacesCard extends CardImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean addCounters(Counter counter, UUID playerAddingCounters, Ability source, Game game, List<UUID> appliedEffects, boolean isEffect) {
|
||||
return leftHalfCard.addCounters(counter, playerAddingCounters, source, game, appliedEffects, isEffect);
|
||||
public boolean addCounters(Counter counter, UUID playerAddingCounters, Ability source, Game game, List<UUID> appliedEffects, boolean isEffect, int maxCounters) {
|
||||
return leftHalfCard.addCounters(counter, playerAddingCounters, source, game, appliedEffects, isEffect, maxCounters);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1009,6 +1009,11 @@ public class Spell extends StackObjectImpl implements Card {
|
|||
return card.addCounters(counter, playerAddingCounters, source, game, appliedEffects, isEffect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addCounters(Counter counter, UUID playerAddingCounters, Ability source, Game game, List<UUID> appliedEffects, boolean isEffect, int maxCounters) {
|
||||
return card.addCounters(counter, playerAddingCounters, source, game, appliedEffects, isEffect, maxCounters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeCounters(String name, int amount, Ability source, Game game) {
|
||||
card.removeCounters(name, amount, source, game);
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
package mage.watchers.common;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import mage.MageObjectReference;
|
||||
import mage.constants.WatcherScope;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.watchers.Watcher;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class AttackedOrBlockedThisCombatWatcher extends Watcher {
|
||||
|
|
@ -23,14 +23,16 @@ public class AttackedOrBlockedThisCombatWatcher extends Watcher {
|
|||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.BEGIN_COMBAT_STEP_PRE) {
|
||||
this.getAttackedThisTurnCreatures().clear();
|
||||
}
|
||||
if (event.getType() == GameEvent.EventType.ATTACKER_DECLARED) {
|
||||
this.getAttackedThisTurnCreatures().add(new MageObjectReference(event.getSourceId(), game));
|
||||
}
|
||||
if (event.getType() == GameEvent.EventType.BLOCKER_DECLARED) {
|
||||
this.getBlockedThisTurnCreatures().add(new MageObjectReference(event.getSourceId(), game));
|
||||
switch (event.getType()) {
|
||||
case BEGIN_COMBAT_STEP_PRE:
|
||||
this.attackedThisTurnCreatures.clear();
|
||||
this.blockedThisTurnCreatures.clear();
|
||||
return;
|
||||
case ATTACKER_DECLARED:
|
||||
this.attackedThisTurnCreatures.add(new MageObjectReference(event.getSourceId(), game));
|
||||
return;
|
||||
case BLOCKER_DECLARED:
|
||||
this.blockedThisTurnCreatures.add(new MageObjectReference(event.getSourceId(), game));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue