mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 21:12:04 -08:00
some cleanups
This commit is contained in:
parent
63695f9b5b
commit
f0623d37c9
8 changed files with 24 additions and 53 deletions
|
|
@ -46,7 +46,7 @@ public enum BuybackCondition implements Condition {
|
|||
if (card != null) {
|
||||
return card.getAbilities().stream()
|
||||
.filter(a -> a instanceof BuybackAbility)
|
||||
.anyMatch(b -> ((BuybackAbility) b).isActivated());
|
||||
.anyMatch(Ability::isActivated);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,21 +52,12 @@ public enum SuspendedCondition implements Condition {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Card card = game.getCard(source.getSourceId());
|
||||
boolean found = false;
|
||||
if (card != null) {
|
||||
for (Ability ability: card.getAbilities()) {
|
||||
if (ability instanceof SuspendAbility) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
boolean found = card.getAbilities().stream().anyMatch(ability -> ability instanceof SuspendAbility);
|
||||
|
||||
if (!found) {
|
||||
for (Ability ability: game.getState().getAllOtherAbilities(source.getSourceId())) {
|
||||
if (ability instanceof SuspendAbility) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
found = game.getState().getAllOtherAbilities(source.getSourceId()).stream().anyMatch(ability -> ability instanceof SuspendAbility);
|
||||
|
||||
}
|
||||
if (found) {
|
||||
if (game.getState().getZone(card.getId()) == Zone.EXILED &&
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ public class XorLessLifeCondition implements Condition {
|
|||
}
|
||||
break;
|
||||
case CONTROLLER:
|
||||
conditionApplies |= game.getPlayer(source.getControllerId()).getLife() <= amount;
|
||||
conditionApplies = game.getPlayer(source.getControllerId()).getLife() <= amount;
|
||||
break;
|
||||
case TARGET_OPPONENT:
|
||||
//TODO: Implement this.
|
||||
|
|
@ -78,7 +78,7 @@ public class XorLessLifeCondition implements Condition {
|
|||
}
|
||||
}
|
||||
}
|
||||
conditionApplies |= maxLife <= amount;
|
||||
conditionApplies = maxLife <= amount;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ public class ContinuousEffectsList<T extends ContinuousEffect> extends ArrayList
|
|||
}
|
||||
|
||||
public void removeEndOfCombatEffects() {
|
||||
|
||||
for (Iterator<T> i = this.iterator(); i.hasNext(); ) {
|
||||
T entry = i.next();
|
||||
if (entry.getDuration() == Duration.EndOfCombat) {
|
||||
|
|
|
|||
|
|
@ -27,15 +27,16 @@
|
|||
*/
|
||||
package mage.players;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.game.Game;
|
||||
import mage.util.RandomUtil;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
|
|
@ -138,9 +139,7 @@ public class Library implements Serializable {
|
|||
public void putOnBottom(Card card, Game game) {
|
||||
if (card.getOwnerId().equals(playerId)) {
|
||||
card.setZone(Zone.LIBRARY, game);
|
||||
if (library.contains(card.getId())) {
|
||||
library.remove(card.getId());
|
||||
}
|
||||
library.remove(card.getId());
|
||||
library.add(card.getId());
|
||||
} else {
|
||||
game.getPlayer(card.getOwnerId()).getLibrary().putOnBottom(card, game);
|
||||
|
|
|
|||
|
|
@ -27,11 +27,6 @@
|
|||
*/
|
||||
package mage.watchers.common;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.constants.WatcherScope;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
|
|
@ -39,6 +34,8 @@ import mage.game.events.GameEvent;
|
|||
import mage.game.stack.Spell;
|
||||
import mage.watchers.Watcher;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
|
|
@ -66,7 +63,7 @@ public class CastFromGraveyardWatcher extends Watcher {
|
|||
if (event.getType() == GameEvent.EventType.SPELL_CAST && event.getZone() == Zone.GRAVEYARD) {
|
||||
Spell spell = (Spell) game.getObject(event.getTargetId());
|
||||
if (spell != null) {
|
||||
HashSet<Integer> zcc = spellsCastFromGraveyard.computeIfAbsent(spell.getSourceId(), k -> new HashSet<>());
|
||||
Set<Integer> zcc = spellsCastFromGraveyard.computeIfAbsent(spell.getSourceId(), k -> new HashSet<>());
|
||||
zcc.add(spell.getZoneChangeCounter(game));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue