mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
Code cleanup
This commit is contained in:
@@ -57,7 +57,6 @@ public class Zone implements java.io.Serializable, Iterable<Card> {
|
|||||||
|
|
||||||
protected final transient MapOfLists<ZoneType, Card> cardsAddedThisTurn = new EnumMapOfLists<>(ZoneType.class, CollectionSuppliers.<Card>arrayLists());
|
protected final transient MapOfLists<ZoneType, Card> cardsAddedThisTurn = new EnumMapOfLists<>(ZoneType.class, CollectionSuppliers.<Card>arrayLists());
|
||||||
|
|
||||||
|
|
||||||
public Zone(final ZoneType zone, Game game) {
|
public Zone(final ZoneType zone, Game game) {
|
||||||
this.zoneType = zone;
|
this.zoneType = zone;
|
||||||
this.game = game;
|
this.game = game;
|
||||||
@@ -70,14 +69,11 @@ public class Zone implements java.io.Serializable, Iterable<Card> {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final void add(final Card c) {
|
public final void add(final Card c) {
|
||||||
add(c, null);
|
add(c, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void add(final Card c, final Integer index) {
|
public void add(final Card c, final Integer index) {
|
||||||
|
|
||||||
// Immutable cards are usually emblems and effects
|
// Immutable cards are usually emblems and effects
|
||||||
if (!c.isImmutable()) {
|
if (!c.isImmutable()) {
|
||||||
final Zone oldZone = game.getZoneOf(c);
|
final Zone oldZone = game.getZoneOf(c);
|
||||||
@@ -91,14 +87,15 @@ public class Zone implements java.io.Serializable, Iterable<Card> {
|
|||||||
}
|
}
|
||||||
c.setZone(this);
|
c.setZone(this);
|
||||||
|
|
||||||
if ( index == null )
|
if (index == null) {
|
||||||
this.cardList.add(c);
|
this.cardList.add(c);
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
this.cardList.add(index.intValue(), c);
|
this.cardList.add(index.intValue(), c);
|
||||||
|
}
|
||||||
game.fireEvent(new GameEventZone(zoneType, getPlayer(), EventValueChangeType.Added, c));
|
game.fireEvent(new GameEventZone(zoneType, getPlayer(), EventValueChangeType.Added, c));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final boolean contains(final Card c) {
|
public final boolean contains(final Card c) {
|
||||||
return this.cardList.contains(c);
|
return this.cardList.contains(c);
|
||||||
}
|
}
|
||||||
@@ -112,7 +109,6 @@ public class Zone implements java.io.Serializable, Iterable<Card> {
|
|||||||
game.fireEvent(new GameEventZone(zoneType, getPlayer(), EventValueChangeType.Removed, c));
|
game.fireEvent(new GameEventZone(zoneType, getPlayer(), EventValueChangeType.Removed, c));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final void setCards(final Iterable<Card> cards) {
|
public final void setCards(final Iterable<Card> cards) {
|
||||||
cardList.clear();
|
cardList.clear();
|
||||||
for (Card c : cards) {
|
for (Card c : cards) {
|
||||||
@@ -120,10 +116,8 @@ public class Zone implements java.io.Serializable, Iterable<Card> {
|
|||||||
cardList.add(c);
|
cardList.add(c);
|
||||||
}
|
}
|
||||||
game.fireEvent(new GameEventZone(zoneType, getPlayer(), EventValueChangeType.ComplexUpdate, null));
|
game.fireEvent(new GameEventZone(zoneType, getPlayer(), EventValueChangeType.ComplexUpdate, null));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final boolean is(final ZoneType zone) {
|
public final boolean is(final ZoneType zone) {
|
||||||
return zone == this.zoneType;
|
return zone == this.zoneType;
|
||||||
}
|
}
|
||||||
@@ -134,7 +128,6 @@ public class Zone implements java.io.Serializable, Iterable<Card> {
|
|||||||
return zoneType == zone && player == getPlayer();
|
return zoneType == zone && player == getPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final ZoneType getZoneType() {
|
public final ZoneType getZoneType() {
|
||||||
return this.zoneType;
|
return this.zoneType;
|
||||||
}
|
}
|
||||||
@@ -143,7 +136,6 @@ public class Zone implements java.io.Serializable, Iterable<Card> {
|
|||||||
return this.cardList.size();
|
return this.cardList.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public final Card get(final int index) {
|
public final Card get(final int index) {
|
||||||
return this.cardList.get(index);
|
return this.cardList.get(index);
|
||||||
}
|
}
|
||||||
@@ -153,7 +145,6 @@ public class Zone implements java.io.Serializable, Iterable<Card> {
|
|||||||
return this.getCards(true);
|
return this.getCards(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<Card> getCards(final boolean filter) {
|
public List<Card> getCards(final boolean filter) {
|
||||||
// Non-Battlefield PlayerZones don't care about the filter
|
// Non-Battlefield PlayerZones don't care about the filter
|
||||||
return this.roCardList;
|
return this.roCardList;
|
||||||
@@ -196,8 +187,9 @@ public class Zone implements java.io.Serializable, Iterable<Card> {
|
|||||||
|
|
||||||
// all cards if key == null
|
// all cards if key == null
|
||||||
final List<Card> ret = new ArrayList<Card>();
|
final List<Card> ret = new ArrayList<Card>();
|
||||||
for(Collection<Card> kv : cardsAddedThisTurn.values())
|
for (Collection<Card> kv : cardsAddedThisTurn.values()) {
|
||||||
ret.addAll(kv);
|
ret.addAll(kv);
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,6 +226,4 @@ public class Zone implements java.io.Serializable, Iterable<Card> {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return this.zoneType.toString();
|
return this.zoneType.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user