forked from External/mage
move static function to CardImpl, and other api fixes
This commit is contained in:
parent
0791283a6b
commit
6f8f10fcc3
32 changed files with 177 additions and 296 deletions
|
|
@ -27,24 +27,15 @@
|
|||
*/
|
||||
package mage.cards;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.game.Game;
|
||||
import mage.util.RandomUtil;
|
||||
import mage.util.ThreadLocalStringBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class CardsImpl extends LinkedHashSet<UUID> implements Cards, Serializable {
|
||||
|
|
@ -129,13 +120,8 @@ public class CardsImpl extends LinkedHashSet<UUID> implements Cards, Serializabl
|
|||
|
||||
@Override
|
||||
public int count(FilterCard filter, UUID playerId, Game game) {
|
||||
int result = 0;
|
||||
for (UUID card : this) {
|
||||
if (filter.match(game.getCard(card), playerId, game)) {
|
||||
result++;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return (int) this.stream().filter(card -> filter.match(game.getCard(card), playerId, game)).count();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -143,13 +129,8 @@ public class CardsImpl extends LinkedHashSet<UUID> implements Cards, Serializabl
|
|||
if (sourceId == null) {
|
||||
return count(filter, playerId, game);
|
||||
}
|
||||
int result = 0;
|
||||
for (UUID card : this) {
|
||||
if (filter.match(game.getCard(card), sourceId, playerId, game)) {
|
||||
result++;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return (int) this.stream().filter(card -> filter.match(game.getCard(card), sourceId, playerId, game)).count();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -182,7 +163,7 @@ public class CardsImpl extends LinkedHashSet<UUID> implements Cards, Serializabl
|
|||
@Override
|
||||
public Set<Card> getCards(Game game) {
|
||||
Set<Card> cards = new LinkedHashSet<>();
|
||||
for (Iterator<UUID> it = this.iterator(); it.hasNext();) { // Changed to iterator because of ConcurrentModificationException
|
||||
for (Iterator<UUID> it = this.iterator(); it.hasNext(); ) { // Changed to iterator because of ConcurrentModificationException
|
||||
UUID cardId = it.next();
|
||||
|
||||
Card card = game.getCard(cardId);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue