mirror of
https://github.com/correl/mage.git
synced 2025-03-16 01:06:34 -09: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.io.Serializable;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.abilities.*;
|
import mage.abilities.*;
|
||||||
import mage.abilities.effects.ContinuousEffect;
|
import mage.abilities.effects.ContinuousEffect;
|
||||||
|
@ -170,7 +172,7 @@ public class GameState implements Serializable, Copyable<GameState> {
|
||||||
this.watchers = state.watchers.copy();
|
this.watchers = state.watchers.copy();
|
||||||
for (Map.Entry<String, Object> entry : state.values.entrySet()) {
|
for (Map.Entry<String, Object> entry : state.values.entrySet()) {
|
||||||
if (entry.getValue() instanceof HashSet) {
|
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 {
|
} else {
|
||||||
this.values.put(entry.getKey(), entry.getValue());
|
this.values.put(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
|
@ -882,22 +884,12 @@ public class GameState implements Serializable, Copyable<GameState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeDelayedTriggeredAbility(UUID abilityId) {
|
public void removeDelayedTriggeredAbility(UUID abilityId) {
|
||||||
for (DelayedTriggeredAbility ability : delayed) {
|
delayed.removeIf(ability -> ability.getId().equals(abilityId));
|
||||||
if (ability.getId().equals(abilityId)) {
|
|
||||||
delayed.remove(ability);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TriggeredAbility> getTriggered(UUID controllerId) {
|
public List<TriggeredAbility> getTriggered(UUID controllerId) {
|
||||||
List<TriggeredAbility> triggereds = new ArrayList<>();
|
return triggered.stream().filter(triggeredAbility -> triggeredAbility.getControllerId().equals(controllerId))
|
||||||
for (TriggeredAbility ability : triggered) {
|
.collect(Collectors.toList());
|
||||||
if (ability.getControllerId().equals(controllerId)) {
|
|
||||||
triggereds.add(ability);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return triggereds;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DelayedTriggeredAbilities getDelayed() {
|
public DelayedTriggeredAbilities getDelayed() {
|
||||||
|
@ -1089,10 +1081,7 @@ public class GameState implements Serializable, Copyable<GameState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getZoneChangeCounter(UUID objectId) {
|
public int getZoneChangeCounter(UUID objectId) {
|
||||||
if (this.zoneChangeCounter.containsKey(objectId)) {
|
return zoneChangeCounter.getOrDefault(objectId, 1);
|
||||||
return this.zoneChangeCounter.get(objectId);
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateZoneChangeCounter(UUID objectId) {
|
public void updateZoneChangeCounter(UUID objectId) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue