mirror of
https://github.com/magefree/mage.git
synced 2025-12-21 19:11:59 -08:00
Refactoring
See github line by line comments in 'File changed'
This commit is contained in:
parent
c526306c5b
commit
01bb9572e9
21 changed files with 31 additions and 34 deletions
|
|
@ -41,7 +41,7 @@ import java.util.Set;
|
|||
public class ChoiceImpl implements Choice, Serializable {
|
||||
|
||||
protected boolean chosen;
|
||||
protected boolean required;
|
||||
protected final boolean required;
|
||||
protected String choice;
|
||||
protected String choiceKey;
|
||||
protected Set<String> choices = new LinkedHashSet<>();
|
||||
|
|
|
|||
|
|
@ -48,5 +48,5 @@ public enum DependencyType {
|
|||
BecomePlains,
|
||||
BecomeSwamp,
|
||||
EnchantmentAddingRemoving,
|
||||
LooseDefenderEffect;
|
||||
LooseDefenderEffect
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,4 +24,4 @@ public enum ManaType {
|
|||
public String toString() {
|
||||
return text;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ public enum MatchTimeLimit {
|
|||
MIN__90(5400, "90 Minutes"),
|
||||
MIN_120(7200, "120 Minutes");
|
||||
|
||||
private int matchSeconds;
|
||||
private String name;
|
||||
private final int matchSeconds;
|
||||
private final String name;
|
||||
|
||||
MatchTimeLimit(int matchSeconds, String name) {
|
||||
this.matchSeconds = matchSeconds;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ public enum RangeOfInfluence {
|
|||
TWO(2),
|
||||
ALL(0);
|
||||
|
||||
private int range;
|
||||
private final int range;
|
||||
|
||||
RangeOfInfluence(int range) {
|
||||
this.range = range;
|
||||
|
|
|
|||
|
|
@ -33,5 +33,5 @@ package mage.constants;
|
|||
*/
|
||||
public enum SetTargetPointer {
|
||||
|
||||
NONE, PLAYER, SPELL, CARD, PERMANENT, ATTACHED_TO_CONTROLLER;
|
||||
NONE, PLAYER, SPELL, CARD, PERMANENT, ATTACHED_TO_CONTROLLER
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,8 +34,8 @@ package mage.counters;
|
|||
*/
|
||||
public class BoostCounter extends Counter {
|
||||
|
||||
protected int power;
|
||||
protected int toughness;
|
||||
protected final int power;
|
||||
protected final int toughness;
|
||||
|
||||
public BoostCounter(int power, int toughness) {
|
||||
this(power, toughness, 1);
|
||||
|
|
|
|||
|
|
@ -158,10 +158,7 @@ public class Counter implements Serializable {
|
|||
|
||||
Counter counter = (Counter) o;
|
||||
|
||||
if (count != counter.count) {
|
||||
return false;
|
||||
}
|
||||
return !(name != null ? !name.equals(counter.name) : counter.name != null);
|
||||
return count == counter.count && !(name != null ? !name.equals(counter.name) : counter.name != null);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ public enum CounterType {
|
|||
|
||||
private final String name;
|
||||
|
||||
private CounterType(String name) {
|
||||
CounterType(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ public abstract class Designation implements MageObject {
|
|||
|
||||
private static List emptyList = new ArrayList();
|
||||
private static ObjectColor emptyColor = new ObjectColor();
|
||||
private static ManaCosts emptyCost = new ManaCostsImpl();
|
||||
private static ManaCosts<ManaCost> emptyCost = new ManaCostsImpl();
|
||||
|
||||
private String name;
|
||||
private UUID id;
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ import mage.game.permanent.Permanent;
|
|||
*/
|
||||
public class FilterControlledCreatureInPlay extends FilterImpl<Object> implements FilterInPlay<Object> {
|
||||
|
||||
protected FilterCreaturePermanent creatureFilter;
|
||||
protected final FilterCreaturePermanent creatureFilter;
|
||||
|
||||
public FilterControlledCreatureInPlay() {
|
||||
this("creature");
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ import mage.players.Player;
|
|||
public class FilterCreatureOrPlayer extends FilterImpl<MageItem> implements FilterInPlay<MageItem> {
|
||||
|
||||
protected FilterCreaturePermanent creatureFilter;
|
||||
protected FilterPlayer playerFilter;
|
||||
protected final FilterPlayer playerFilter;
|
||||
|
||||
public FilterCreatureOrPlayer() {
|
||||
this("creature or player");
|
||||
|
|
|
|||
|
|
@ -42,8 +42,8 @@ import mage.players.Player;
|
|||
*/
|
||||
public class FilterPermanentOrPlayer extends FilterImpl<MageItem> implements FilterInPlay<MageItem> {
|
||||
|
||||
protected FilterPermanent permanentFilter;
|
||||
protected FilterPlayer playerFilter;
|
||||
protected final FilterPermanent permanentFilter;
|
||||
protected final FilterPlayer playerFilter;
|
||||
|
||||
public FilterPermanentOrPlayer() {
|
||||
this("player or permanent");
|
||||
|
|
|
|||
|
|
@ -46,8 +46,8 @@ import mage.players.Player;
|
|||
*/
|
||||
public class FilterPlaneswalkerOrPlayer extends FilterImpl<Object> {
|
||||
|
||||
protected FilterPlaneswalkerPermanent planeswalkerFilter;
|
||||
protected FilterPlayer playerFilter;
|
||||
protected final FilterPlaneswalkerPermanent planeswalkerFilter;
|
||||
protected final FilterPlayer playerFilter;
|
||||
|
||||
public FilterPlaneswalkerOrPlayer(Set<UUID> defenders) {
|
||||
super("planeswalker or player");
|
||||
|
|
|
|||
|
|
@ -36,8 +36,8 @@ import java.util.UUID;
|
|||
*/
|
||||
public class ObjectPlayer<T> {
|
||||
|
||||
protected T object;
|
||||
protected UUID playerId;
|
||||
protected final T object;
|
||||
protected final UUID playerId;
|
||||
|
||||
public ObjectPlayer(T object, UUID playerId) {
|
||||
this.object = object;
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ import java.util.UUID;
|
|||
*/
|
||||
public class ObjectSourcePlayer<T> extends ObjectPlayer<T> {
|
||||
|
||||
protected UUID sourceId;
|
||||
protected final UUID sourceId;
|
||||
|
||||
public ObjectSourcePlayer(T object, UUID sourceId, UUID playerId) {
|
||||
super(object, playerId);
|
||||
|
|
|
|||
|
|
@ -168,8 +168,8 @@ public final class Predicates {
|
|||
|
||||
@Override
|
||||
public boolean apply(T t, Game game) {
|
||||
for (int i = 0; i < components.size(); i++) {
|
||||
if (!components.get(i).apply(t, game)) {
|
||||
for (Predicate<? super T> component : components) {
|
||||
if (!component.apply(t, game)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -196,8 +196,8 @@ public final class Predicates {
|
|||
|
||||
@Override
|
||||
public boolean apply(T t, Game game) {
|
||||
for (int i = 0; i < components.size(); i++) {
|
||||
if (components.get(i).apply(t, game)) {
|
||||
for (Predicate<? super T> component : components) {
|
||||
if (component.apply(t, game)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -244,8 +244,8 @@ public final class Predicates {
|
|||
|
||||
private static String commaJoin(List components) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < components.size(); i++) {
|
||||
sb.append(components.get(i).toString());
|
||||
for (Object component : components) {
|
||||
sb.append(component.toString());
|
||||
}
|
||||
sb.deleteCharAt(sb.length() - 1);
|
||||
return sb.toString();
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ import mage.game.Game;
|
|||
*/
|
||||
public class FromSetPredicate<T extends MageItem> implements Predicate<T> {
|
||||
|
||||
protected Set<UUID> set;
|
||||
protected final Set<UUID> set;
|
||||
|
||||
public FromSetPredicate(Set<UUID> set) {
|
||||
this.set = set;
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ import mage.game.permanent.Permanent;
|
|||
*/
|
||||
public class AttachedToPredicate implements Predicate<Permanent> {
|
||||
|
||||
private FilterPermanent filter;
|
||||
private final FilterPermanent filter;
|
||||
|
||||
public AttachedToPredicate(FilterPermanent filter) {
|
||||
this.filter = filter;
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ import mage.game.permanent.Permanent;
|
|||
public class ControllerControlsIslandPredicate implements Predicate<Permanent> {
|
||||
|
||||
public static final FilterLandPermanent filter = new FilterLandPermanent("Island");
|
||||
{
|
||||
static {
|
||||
filter.add(new SubtypePredicate("Island"));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,6 +51,6 @@ public class PermanentIdPredicate implements Predicate<Permanent> {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new StringBuilder("PermanentId(").append(permanentId).append(")").toString() ;
|
||||
return "PermanentId(" + permanentId + ")";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue