mirror of
https://github.com/correl/mage.git
synced 2024-12-26 11:09:27 +00:00
added a removeIf and streams
This commit is contained in:
parent
ddc43d05f6
commit
e205fef785
1 changed files with 7 additions and 18 deletions
|
@ -29,6 +29,8 @@ package mage.game;
|
|||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.*;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
|
@ -170,7 +172,7 @@ public class GameState implements Serializable, Copyable<GameState> {
|
|||
this.watchers = state.watchers.copy();
|
||||
for (Map.Entry<String, Object> entry : state.values.entrySet()) {
|
||||
if (entry.getValue() instanceof HashSet) {
|
||||
this.values.put(entry.getKey(), (HashSet) ((HashSet) entry.getValue()).clone());
|
||||
this.values.put(entry.getKey(), ((HashSet) entry.getValue()).clone());
|
||||
} else {
|
||||
this.values.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
@ -882,22 +884,12 @@ public class GameState implements Serializable, Copyable<GameState> {
|
|||
}
|
||||
|
||||
public void removeDelayedTriggeredAbility(UUID abilityId) {
|
||||
for (DelayedTriggeredAbility ability : delayed) {
|
||||
if (ability.getId().equals(abilityId)) {
|
||||
delayed.remove(ability);
|
||||
break;
|
||||
}
|
||||
}
|
||||
delayed.removeIf(ability -> ability.getId().equals(abilityId));
|
||||
}
|
||||
|
||||
public List<TriggeredAbility> getTriggered(UUID controllerId) {
|
||||
List<TriggeredAbility> triggereds = new ArrayList<>();
|
||||
for (TriggeredAbility ability : triggered) {
|
||||
if (ability.getControllerId().equals(controllerId)) {
|
||||
triggereds.add(ability);
|
||||
}
|
||||
}
|
||||
return triggereds;
|
||||
return triggered.stream().filter(triggeredAbility -> triggeredAbility.getControllerId().equals(controllerId))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public DelayedTriggeredAbilities getDelayed() {
|
||||
|
@ -1089,10 +1081,7 @@ public class GameState implements Serializable, Copyable<GameState> {
|
|||
}
|
||||
|
||||
public int getZoneChangeCounter(UUID objectId) {
|
||||
if (this.zoneChangeCounter.containsKey(objectId)) {
|
||||
return this.zoneChangeCounter.get(objectId);
|
||||
}
|
||||
return 1;
|
||||
return zoneChangeCounter.getOrDefault(objectId, 1);
|
||||
}
|
||||
|
||||
public void updateZoneChangeCounter(UUID objectId) {
|
||||
|
|
Loading…
Reference in a new issue