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
01bb9572e9
commit
c0cf22bbf7
31 changed files with 51 additions and 53 deletions
|
|
@ -132,7 +132,7 @@ public interface Game extends MageItem, Serializable {
|
|||
|
||||
void setZone(UUID objectId, Zone zone);
|
||||
|
||||
void addPlayer(Player player, Deck deck) throws GameException;
|
||||
void addPlayer(Player player, Deck deck);
|
||||
|
||||
Player getPlayer(UUID playerId);
|
||||
|
||||
|
|
@ -437,7 +437,7 @@ public interface Game extends MageItem, Serializable {
|
|||
// controlling the behaviour of replacement effects while permanents entering the battlefield
|
||||
void setScopeRelevant(boolean scopeRelevant);
|
||||
|
||||
public boolean getScopeRelevant();
|
||||
boolean getScopeRelevant();
|
||||
|
||||
// players' timers
|
||||
void initTimer(UUID playerId);
|
||||
|
|
|
|||
|
|
@ -335,7 +335,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void addPlayer(Player player, Deck deck) throws GameException {
|
||||
public void addPlayer(Player player, Deck deck) {
|
||||
player.useDeck(deck, this);
|
||||
state.addPlayer(player);
|
||||
}
|
||||
|
|
@ -1937,7 +1937,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
Player controller = this.getPlayer(planeswalker.getControllerId());
|
||||
if (controller != null) {
|
||||
Target targetPlaneswalkerToKeep = new TargetPermanent(filterPlaneswalker);
|
||||
targetPlaneswalkerToKeep.setTargetName(new StringBuilder(planeswalker.getName()).append(" to keep?").toString());
|
||||
targetPlaneswalkerToKeep.setTargetName(planeswalker.getName() + " to keep?");
|
||||
controller.chooseTarget(Outcome.Benefit, targetPlaneswalkerToKeep, null, this);
|
||||
for (Permanent dupPlaneswalker : this.getBattlefield().getActivePermanents(filterPlaneswalker, planeswalker.getControllerId(), this)) {
|
||||
if (!targetPlaneswalkerToKeep.getTargets().contains(dupPlaneswalker.getId())) {
|
||||
|
|
@ -2345,12 +2345,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
}
|
||||
// Then, if that player controlled any objects on the stack not represented by cards, those objects cease to exist.
|
||||
this.getState().getContinuousEffects().removeInactiveEffects(this);
|
||||
for (Iterator<StackObject> it = getStack().iterator(); it.hasNext();) {
|
||||
StackObject object = it.next();
|
||||
if (object.getControllerId().equals(playerId)) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
getStack().removeIf(object -> object.getControllerId().equals(playerId));
|
||||
// Then, if there are any objects still controlled by that player, those objects are exiled.
|
||||
applyEffects(); // to remove control from effects removed meanwhile
|
||||
List<Permanent> permanents = this.getBattlefield().getAllActivePermanents(playerId);
|
||||
|
|
@ -2594,10 +2589,10 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
if (object instanceof Permanent) {
|
||||
Map<Integer, MageObject> lkiExtendedMap = lkiExtended.get(objectId);
|
||||
if (lkiExtendedMap != null) {
|
||||
lkiExtendedMap.put(((Permanent) object).getZoneChangeCounter(this), copy);
|
||||
lkiExtendedMap.put(object.getZoneChangeCounter(this), copy);
|
||||
} else {
|
||||
lkiExtendedMap = new HashMap<>();
|
||||
lkiExtendedMap.put(((Permanent) object).getZoneChangeCounter(this), copy);
|
||||
lkiExtendedMap.put(object.getZoneChangeCounter(this), copy);
|
||||
lkiExtended.put(objectId, lkiExtendedMap);
|
||||
}
|
||||
}
|
||||
|
|
@ -2689,7 +2684,7 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
permanent.entersBattlefield(permanent.getId(), this, Zone.OUTSIDE, false);
|
||||
getBattlefield().addPermanent(permanent);
|
||||
getPermanentsEntering().remove(permanent.getId());
|
||||
((PermanentImpl) permanent).removeSummoningSickness();
|
||||
permanent.removeSummoningSickness();
|
||||
if (card.isTapped()) {
|
||||
permanent.setTapped(true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,9 +64,8 @@ public class Table implements Serializable {
|
|||
private TableRecorder recorder;
|
||||
|
||||
public interface TableRecorder {
|
||||
|
||||
void record(Table table);
|
||||
};
|
||||
}
|
||||
|
||||
protected TableEventSource tableEventSource = new TableEventSource();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package mage.game;
|
||||
|
||||
import mage.cards.MeldCard;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.stack.Spell;
|
||||
|
||||
|
|
|
|||
|
|
@ -52,11 +52,7 @@ public class ZonesHandler {
|
|||
}
|
||||
}
|
||||
}
|
||||
for (Iterator<ZoneChangeInfo> itr = zoneChangeInfos.iterator(); itr.hasNext();) {
|
||||
if (!maybeRemoveFromSourceZone(itr.next(), game)) {
|
||||
itr.remove();
|
||||
}
|
||||
}
|
||||
zoneChangeInfos.removeIf(zoneChangeInfo -> !maybeRemoveFromSourceZone(zoneChangeInfo, game));
|
||||
for (ZoneChangeInfo zoneChangeInfo : zoneChangeInfos) {
|
||||
placeInDestinationZone(zoneChangeInfo, game);
|
||||
if (game.getPhase() != null) { // moving cards to zones before game started does not need events
|
||||
|
|
|
|||
|
|
@ -983,7 +983,7 @@ public class Combat implements Serializable, Copyable<Combat> {
|
|||
for (Ability ability : entry.getValue()) {
|
||||
if (!effect.canBlockCheckAfter(ability, game)) {
|
||||
if (controller.isHuman()) {
|
||||
game.informPlayer(controller, new StringBuilder(blockingCreature.getLogName()).append(" can't block this way.").toString());
|
||||
game.informPlayer(controller, blockingCreature.getLogName() + " can't block this way.");
|
||||
return false;
|
||||
} else {
|
||||
// remove blocking creatures for AI
|
||||
|
|
@ -1003,7 +1003,7 @@ public class Combat implements Serializable, Copyable<Combat> {
|
|||
for (Ability ability : entry.getValue()) {
|
||||
if (!effect.canBeBlockedCheckAfter(attackingCreature, ability, game)) {
|
||||
if (controller.isHuman()) {
|
||||
game.informPlayer(controller, new StringBuilder(attackingCreature.getLogName()).append(" can't be blocked this way.").toString());
|
||||
game.informPlayer(controller, attackingCreature.getLogName() + " can't be blocked this way.");
|
||||
return false;
|
||||
} else {
|
||||
// remove blocking creatures for AI
|
||||
|
|
@ -1030,7 +1030,7 @@ public class Combat implements Serializable, Copyable<Combat> {
|
|||
switch (game.getAttackOption()) {
|
||||
case LEFT:
|
||||
players = game.getState().getPlayerList(attackingPlayerId);
|
||||
while (true && attackingPlayer.isInGame()) {
|
||||
while (attackingPlayer.isInGame()) {
|
||||
Player opponent = players.getNext(game);
|
||||
if (attackingPlayer.hasOpponent(opponent.getId(), game)) {
|
||||
addDefender(opponent.getId(), game);
|
||||
|
|
@ -1040,7 +1040,7 @@ public class Combat implements Serializable, Copyable<Combat> {
|
|||
break;
|
||||
case RIGHT:
|
||||
players = game.getState().getPlayerList(attackingPlayerId);
|
||||
while (true && attackingPlayer.isInGame()) {
|
||||
while (attackingPlayer.isInGame()) {
|
||||
Player opponent = players.getPrevious(game);
|
||||
if (attackingPlayer.hasOpponent(opponent.getId(), game)) {
|
||||
addDefender(opponent.getId(), game);
|
||||
|
|
|
|||
|
|
@ -457,7 +457,7 @@ public class CombatGroup implements Serializable, Copyable<CombatGroup> {
|
|||
Player player = game.getPlayer(playerId);
|
||||
List<UUID> blockerList = new ArrayList<>(blockers);
|
||||
blockerOrder.clear();
|
||||
while (true && player.canRespond()) {
|
||||
while (player.canRespond()) {
|
||||
if (blockerList.size() == 1) {
|
||||
blockerOrder.add(blockerList.get(0));
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ package mage.game.draft;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import mage.cards.Card;
|
||||
import mage.cards.repository.CardCriteria;
|
||||
import mage.cards.repository.CardInfo;
|
||||
|
|
|
|||
|
|
@ -302,7 +302,7 @@ public class GameEvent implements Serializable {
|
|||
COMBAT_DAMAGE_APPLIED,
|
||||
SELECTED_ATTACKER, SELECTED_BLOCKER,
|
||||
//custom events
|
||||
CUSTOM_EVENT;
|
||||
CUSTOM_EVENT
|
||||
}
|
||||
|
||||
private GameEvent(EventType type, UUID customEventType,
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ public interface Match {
|
|||
|
||||
void submitDeck(UUID playerId, Deck deck);
|
||||
void updateDeck(UUID playerId, Deck deck);
|
||||
void startMatch() throws GameException;
|
||||
void startMatch();
|
||||
void startGame() throws GameException;
|
||||
void sideboard();
|
||||
void endGame();
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
import mage.cards.decks.Deck;
|
||||
import mage.game.Game;
|
||||
|
|
@ -121,7 +120,7 @@ public abstract class MatchImpl implements Match {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void startMatch() throws GameException {
|
||||
public void startMatch() {
|
||||
this.startTime = new Date();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -174,7 +174,7 @@ public interface Permanent extends Card, Controllable {
|
|||
|
||||
boolean canLoyaltyBeUsed(Game game);
|
||||
|
||||
public void resetControl();
|
||||
void resetControl();
|
||||
|
||||
boolean changeControllerId(UUID controllerId, Game game);
|
||||
|
||||
|
|
|
|||
|
|
@ -981,7 +981,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
moveToZone(Zone.GRAVEYARD, sourceId, game, false);
|
||||
Player player = game.getPlayer(getControllerId());
|
||||
if (player != null && !game.isSimulation()) {
|
||||
game.informPlayers(new StringBuilder(player.getLogName()).append(" sacrificed ").append(this.getLogName()).toString());
|
||||
game.informPlayers(player.getLogName() + " sacrificed " + this.getLogName());
|
||||
}
|
||||
game.fireEvent(GameEvent.getEvent(EventType.SACRIFICED_PERMANENT, objectId, sourceId, controllerId));
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
package mage.game.permanent.token;
|
||||
|
||||
import java.util.Random;
|
||||
import mage.constants.CardType;
|
||||
import mage.MageInt;
|
||||
import mage.util.RandomUtil;
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@
|
|||
package mage.game.permanent.token;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.DiesTriggeredAbility;
|
||||
|
|
@ -44,7 +46,7 @@ public class DevilToken extends Token {
|
|||
|
||||
public DevilToken() {
|
||||
super("Devil", "1/1 red Devil creature with \"When this creature dies, it deals 1 damage to target creature or player.\"");
|
||||
availableImageSetCodes.addAll(Arrays.asList("SOI"));
|
||||
availableImageSetCodes.addAll(Collections.singletonList("SOI"));
|
||||
cardType.add(CardType.CREATURE);
|
||||
subtype.add("Devil");
|
||||
color.setRed(true);
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@
|
|||
package mage.game.permanent.token;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.constants.CardType;
|
||||
|
||||
|
|
@ -39,7 +41,7 @@ public class DroidToken extends Token {
|
|||
|
||||
public DroidToken() {
|
||||
super("Droid", "1/1 colorless Droid creature token");
|
||||
availableImageSetCodes.addAll(Arrays.asList("SWS"));
|
||||
availableImageSetCodes.addAll(Collections.singletonList("SWS"));
|
||||
|
||||
cardType.add(CardType.CREATURE);
|
||||
cardType.add(CardType.ARTIFACT);
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ package mage.game.permanent.token;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import mage.MageInt;
|
||||
import mage.constants.CardType;
|
||||
|
|
@ -42,7 +43,7 @@ public class EldraziHorrorToken extends Token {
|
|||
final static private List<String> tokenImageSets = new ArrayList<>();
|
||||
|
||||
static {
|
||||
tokenImageSets.addAll(Arrays.asList("EMN"));
|
||||
tokenImageSets.addAll(Collections.singletonList("EMN"));
|
||||
}
|
||||
|
||||
public EldraziHorrorToken() {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ package mage.game.permanent.token;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.Mana;
|
||||
import mage.abilities.costs.common.SacrificeSourceCost;
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ package mage.game.permanent.token;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.Mana;
|
||||
import mage.abilities.costs.common.SacrificeSourceCost;
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@
|
|||
package mage.game.permanent.token;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
import mage.constants.CardType;
|
||||
|
||||
/**
|
||||
|
|
@ -38,7 +40,7 @@ public class EwokToken extends Token {
|
|||
|
||||
public EwokToken() {
|
||||
super("Ewok", "1/1 green Ewok creature tokens", 1, 1);
|
||||
availableImageSetCodes.addAll(Arrays.asList("SWS"));
|
||||
availableImageSetCodes.addAll(Collections.singletonList("SWS"));
|
||||
|
||||
cardType.add(CardType.CREATURE);
|
||||
subtype.add("Ewok");
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ package mage.game.permanent.token;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import mage.MageInt;
|
||||
import mage.constants.CardType;
|
||||
|
|
@ -42,7 +43,7 @@ public class PrismToken extends Token {
|
|||
final static private List<String> tokenImageSets = new ArrayList<>();
|
||||
|
||||
static {
|
||||
tokenImageSets.addAll(Arrays.asList("VIS"));
|
||||
tokenImageSets.addAll(Collections.singletonList("VIS"));
|
||||
}
|
||||
|
||||
public PrismToken() {
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ package mage.game.permanent.token;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import mage.MageInt;
|
||||
import mage.constants.CardType;
|
||||
|
|
@ -43,7 +44,7 @@ public class ServoToken extends Token {
|
|||
final static private List<String> tokenImageSets = new ArrayList<>();
|
||||
|
||||
static {
|
||||
tokenImageSets.addAll(Arrays.asList("KLD"));
|
||||
tokenImageSets.addAll(Collections.singletonList("KLD"));
|
||||
}
|
||||
|
||||
public ServoToken() {
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ package mage.game.permanent.token;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import mage.MageInt;
|
||||
import mage.constants.CardType;
|
||||
|
|
@ -42,7 +43,7 @@ public class SquirrelToken extends Token {
|
|||
final static private List<String> tokenImageSets = new ArrayList<>();
|
||||
|
||||
static {
|
||||
tokenImageSets.addAll(Arrays.asList("CNS"));
|
||||
tokenImageSets.addAll(Collections.singletonList("CNS"));
|
||||
}
|
||||
|
||||
public SquirrelToken() {
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ package mage.game.permanent.token;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import mage.MageInt;
|
||||
import mage.constants.CardType;
|
||||
|
|
@ -43,7 +44,7 @@ public class ThrullToken extends Token {
|
|||
final static private List<String> tokenImageSets = new ArrayList<>();
|
||||
|
||||
static {
|
||||
tokenImageSets.addAll(Arrays.asList("MM2"));
|
||||
tokenImageSets.addAll(Collections.singletonList("MM2"));
|
||||
}
|
||||
|
||||
public ThrullToken() {
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@
|
|||
package mage.game.permanent.token;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.constants.CardType;
|
||||
|
||||
|
|
@ -39,7 +41,7 @@ public class TrooperToken extends Token {
|
|||
|
||||
public TrooperToken() {
|
||||
super("Trooper", "1/1 white Trooper creature token");
|
||||
availableImageSetCodes.addAll(Arrays.asList("SWS"));
|
||||
availableImageSetCodes.addAll(Collections.singletonList("SWS"));
|
||||
|
||||
cardType.add(CardType.CREATURE);
|
||||
subtype.add("Trooper");
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
package mage.game.permanent.token;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Random;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.constants.CardType;
|
||||
import mage.util.RandomUtil;
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ package mage.game.permanent.token;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.constants.CardType;
|
||||
import mage.util.RandomUtil;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ import java.util.HashSet;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import mage.cards.ExpansionSet;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
package mage.game.tournament;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import mage.constants.MultiplayerAttackOption;
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ public abstract class Step implements Serializable {
|
|||
protected StepPart stepPart;
|
||||
|
||||
public enum StepPart {
|
||||
PRE, PRIORITY, POST;
|
||||
PRE, PRIORITY, POST
|
||||
}
|
||||
|
||||
public abstract Step copy();
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ public class TurnMods extends ArrayList<TurnMod> {
|
|||
ListIterator<TurnMod> it = this.listIterator(this.size());
|
||||
while (it.hasPrevious()) {
|
||||
TurnMod turnMod = it.previous();
|
||||
if (turnMod.isExtraTurn() == true && turnMod.getPlayerId().equals(playerId)) {
|
||||
if (turnMod.isExtraTurn() && turnMod.getPlayerId().equals(playerId)) {
|
||||
it.remove();
|
||||
return turnMod.getId();
|
||||
}
|
||||
|
|
@ -64,7 +64,7 @@ public class TurnMods extends ArrayList<TurnMod> {
|
|||
ListIterator<TurnMod> it = this.listIterator(this.size());
|
||||
while (it.hasPrevious()) {
|
||||
TurnMod turnMod = it.previous();
|
||||
if (turnMod.isExtraTurn() == true) {
|
||||
if (turnMod.isExtraTurn()) {
|
||||
it.remove();
|
||||
return turnMod;
|
||||
}
|
||||
|
|
@ -76,7 +76,7 @@ public class TurnMods extends ArrayList<TurnMod> {
|
|||
ListIterator<TurnMod> it = this.listIterator(this.size());
|
||||
while (it.hasPrevious()) {
|
||||
TurnMod turnMod = it.previous();
|
||||
if (turnMod.isSkipTurn() == true && turnMod.getPlayerId().equals(playerId)) {
|
||||
if (turnMod.isSkipTurn() && turnMod.getPlayerId().equals(playerId)) {
|
||||
it.remove();
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue