forked from External/mage
Phase stops - done.
This commit is contained in:
parent
8a454d38a7
commit
b26db98817
10 changed files with 706 additions and 85 deletions
75
Mage.Client/src/main/java/mage/client/util/PhaseManager.java
Normal file
75
Mage.Client/src/main/java/mage/client/util/PhaseManager.java
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
package mage.client.util;
|
||||
|
||||
import mage.client.MageFrame;
|
||||
import mage.view.GameView;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.prefs.Preferences;
|
||||
|
||||
public class PhaseManager {
|
||||
|
||||
private static final PhaseManager fInstance = new PhaseManager();
|
||||
|
||||
public static String DEFAULT_PLAYER_NAME = "player";
|
||||
|
||||
public static String PHASE_ON = "on";
|
||||
public static String PHASE_OFF = "off";
|
||||
public static String UPKEEP_YOU = "upkeepYou";
|
||||
public static String DRAW_YOU = "drawYou";
|
||||
public static String MAIN_YOU = "mainYou";
|
||||
public static String BEFORE_COMBAT_YOU = "beforeCombatYou";
|
||||
public static String END_OF_COMBAT_YOU = "endOfCombatYou";
|
||||
public static String MAIN_2_YOU = "main2You";
|
||||
public static String END_OF_TURN_YOU = "endOfTurnYou";
|
||||
|
||||
public static String UPKEEP_OTHERS = "upkeepOthers";
|
||||
public static String DRAW_OTHERS = "drawOthers";
|
||||
public static String MAIN_OTHERS = "mainOthers";
|
||||
public static String BEFORE_COMBAT_OTHERS = "beforeCombatOthers";
|
||||
public static String END_OF_COMBAT_OTHERS = "endOfCombatOthers";
|
||||
public static String MAIN_2_OTHERS = "main2Others";
|
||||
public static String END_OF_TURN_OTHERS = "endOfTurnOthers";
|
||||
|
||||
private static Map<String, String> mapYou = new HashMap<String, String>() {{
|
||||
put("Upkeep - play instants and activated abilities.", UPKEEP_YOU);
|
||||
put("Draw - play instants and activated abilities.", DRAW_YOU);
|
||||
put("Precombat Main - play spells and sorceries.", MAIN_YOU);
|
||||
put("Begin Combat - play instants and activated abilities.", BEFORE_COMBAT_YOU);
|
||||
put("End Combat - play instants and activated abilities.", END_OF_COMBAT_YOU);
|
||||
put("Postcombat Main - play spells and sorceries.", MAIN_2_YOU);
|
||||
put("End Turn - play instants and activated abilities.", END_OF_TURN_YOU);
|
||||
}};
|
||||
|
||||
private static Map<String, String> mapOthers = new HashMap<String, String>() {{
|
||||
put("Upkeep - play instants and activated abilities.", UPKEEP_OTHERS);
|
||||
put("Draw - play instants and activated abilities.", DRAW_OTHERS);
|
||||
put("Precombat Main - play spells and sorceries.", MAIN_OTHERS);
|
||||
put("Begin Combat - play instants and activated abilities.", BEFORE_COMBAT_OTHERS);
|
||||
put("End Combat - play instants and activated abilities.", END_OF_COMBAT_OTHERS);
|
||||
put("Postcombat Main - play spells and sorceries.", MAIN_2_OTHERS);
|
||||
put("End Turn - play instants and activated abilities.", END_OF_TURN_OTHERS);
|
||||
}};
|
||||
|
||||
private String yourName;
|
||||
|
||||
public static PhaseManager getInstance() {
|
||||
return fInstance;
|
||||
}
|
||||
|
||||
public void setName(String yourName) {
|
||||
this.yourName = yourName;
|
||||
}
|
||||
|
||||
public boolean isSkip(GameView gameView, String message) {
|
||||
Map<String, String> map = gameView.getActivePlayerName().equals(DEFAULT_PLAYER_NAME) ? mapYou : mapOthers;
|
||||
for (Map.Entry<String, String> entry : map.entrySet()) {
|
||||
if (message.equals(entry.getKey())) {
|
||||
Preferences prefs = MageFrame.getPreferences();
|
||||
String prop = prefs.get(entry.getValue(), PHASE_ON);
|
||||
return !prop.equals(PHASE_ON);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue