-
Notifications
You must be signed in to change notification settings - Fork 855
Open
Labels
Description
Cases like this:
forge/forge-game/src/main/java/forge/game/zone/MagicStack.java
Lines 995 to 1016 in 31d38f6
| public final void addCastCommand(final String valid, final GameCommand c) { | |
| if (commandList.containsKey(valid)) { | |
| commandList.get(valid).add(0, c); | |
| } else { | |
| commandList.put(valid, Lists.newArrayList(c)); | |
| } | |
| } | |
| private void executeCastCommand(final Card cast) { | |
| for (Entry<String, List<GameCommand>> ev : commandList.entrySet()) { | |
| if (cast.getType().hasStringType(ev.getKey())) { | |
| execute(ev.getValue()); | |
| } | |
| } | |
| } | |
| private static void execute(final List<GameCommand> c) { | |
| final int length = c.size(); | |
| for (int i = 0; i < length; i++) { | |
| c.remove(0).run(); | |
| } | |
| } |
- First: why are the GameCommands are added in the front? That doesn't make much sense. (see later point)
- Second: why does execute removes them like that? Wouldn't it be better to iterate over the whole list, and then clean up all entries for the given key? (that might be problematic with new GameCommands added in the front? See above)
another example are player specific Phase Commands:
forge/forge-game/src/main/java/forge/game/phase/Phase.java
Lines 50 to 52 in 31d38f6
| private final HashMap<Player, ArrayList<GameCommand>> untilMap = new HashMap<>(); | |
| private final HashMap<Player, ArrayList<GameCommand>> untilEndMap = new HashMap<>(); | |
| private final HashMap<Player, ArrayList<GameCommand>> registerMap = new HashMap<>(); |
Reactions are currently unavailable