View Javadoc

1   /**
2    * This program is free software; you can redistribute it and/or modify
3    * it under the terms of the GNU General Public License version 2 as 
4    * published by the Free Software Foundation;
5    */
6   
7   package net.curre.prefcount.gui.type;
8   
9   import static net.curre.prefcount.gui.type.Place.EAST;
10  import static net.curre.prefcount.gui.type.Place.NORTH;
11  import static net.curre.prefcount.gui.type.Place.SOUTH;
12  import static net.curre.prefcount.gui.type.Place.WEST;
13  
14  /**
15   * This enum represents score item on the score board
16   * to be used as keys in the score board location map.
17   * <p/>
18   * Created date: May 29, 2008
19   *
20   * @author Yevgeny Nyden
21   */
22  public enum ScoreItem {
23  
24    /** Key for the name's location. */
25    PLAYER_NAME(null, "pref.scoreboard.tooltip.player", false),
26  
27    /** Key for the mountain's location. */
28    PLAYER_MOUNT(null, "pref.scoreboard.tooltip.mount", false),
29  
30    /** Key for the new mountain's location. */
31    PLAYER_NEW_MOUNT(null, "pref.scoreboard.tooltip.newMount", false),
32  
33    /** Key for the amnisted mountain's location. */
34    PLAYER_AMNIST_MOUNT(null, "pref.scoreboard.tooltip.amnistMount", false),
35  
36    /** Key for the fixed mountain's location. */
37    PLAYER_FIXED_MOUNT(null, "pref.scoreboard.tooltip.mountFixed", false),
38  
39    /** Key for the pool's location. */
40    PLAYER_POOL(null, "pref.scoreboard.tooltip.pool", false),
41  
42    /** Key for the closed pool's location. */
43    PLAYER_POOL_CLOSED(null, "pref.scoreboard.tooltip.poolClosed", false),
44  
45    /** Key for the whist agains the North location. */
46    WHIST_NORTH(NORTH, "pref.scoreboard.tooltip.whist", true),
47  
48    /** Key for the whist agains the East location. */
49    WHIST_EAST(EAST, "pref.scoreboard.tooltip.whist", true),
50  
51    /** Key for the whist agains the South location. */
52    WHIST_SOUTH(SOUTH, "pref.scoreboard.tooltip.whist", true),
53  
54    /** Key for the whist agains the West location. */
55    WHIST_WEST(WEST, "pref.scoreboard.tooltip.whist", true),
56  
57    /** Key for the whist fix agains the North location. */
58    WHIST_FIX_NORTH(NORTH, "pref.scoreboard.tooltip.whistFix", true),
59  
60    /** Key for the whist fix agains the East location. */
61    WHIST_FIX_EAST(EAST, "pref.scoreboard.tooltip.whistFix", true),
62  
63    /** Key for the whist fix agains the South location. */
64    WHIST_FIX_SOUTH(SOUTH, "pref.scoreboard.tooltip.whistFix", true),
65  
66    /** Key for the whist fix agains the West location. */
67    WHIST_FIX_WEST(WEST, "pref.scoreboard.tooltip.whistFix", true),
68  
69    /** Key for the whist saldo with the North location. */
70    WHIST_NORTH_SALDO(NORTH, "pref.scoreboard.tooltip.whistSaldo", true),
71  
72    /** Key for the whist saldo with the East location. */
73    WHIST_EAST_SALDO(EAST, "pref.scoreboard.tooltip.whistSaldo", true),
74  
75    /** Key for the whist saldo with the South location. */
76    WHIST_SOUTH_SALDO(SOUTH, "pref.scoreboard.tooltip.whistSaldo", true),
77  
78    /** Key for the whist saldo with the West location. */
79    WHIST_WEST_SALDO(WEST, "pref.scoreboard.tooltip.whistSaldo", true),
80  
81    /** Key for the total whist saldo location. */
82    WHIST_SALDO_TOTAL(null, "pref.scoreboard.tooltip.whistSaldoAll", false),
83  
84    /** Key for the final mountain location. */
85    FINAL_MOUNT(null, "pref.scoreboard.tooltip.finalMount", false),
86  
87    /** Key for the final score location. */
88    FINAL_SCORE(null, "pref.scoreboard.tooltip.finalScore", false);
89  
90    /**
91     * This indicates that the item refers to a particular place
92     * (i.e. whists agains some player/place).
93     */
94    public final Place place;
95  
96    /** Resource key for this item. */
97    public final String key;
98  
99    /**
100    * Flag that indicates, when true, that other player's
101    * name or place is required as an argument for the resource key;
102    * false indicates that the current player's name or place
103    * should be used as an argument with the resource key.
104    */
105   public final boolean isOtherPlace;
106 
107   /**
108    * Constructs a new ScoreItem enum.
109    *
110    * @param place        optional place this item is associated with.
111    * @param key          resource key for this item.
112    * @param isOtherPlace other place flag value.
113    */
114   ScoreItem(Place place, String key, boolean isOtherPlace) {
115     this.place = place;
116     this.key = key;
117     this.isOtherPlace = isOtherPlace;
118   }
119 
120   /**
121    * Determines the whist fix score item for the given place.
122    *
123    * @param whist whist place.
124    * @return whist fix score item that corresponds to the given place.
125    * @throws IllegalArgumentException when the passed argument is not supported.
126    */
127   public static ScoreItem getWhistFixForWhist(Place whist) {
128     switch (whist) {
129       case EAST:
130         return WHIST_FIX_EAST;
131 
132       case SOUTH:
133         return WHIST_FIX_SOUTH;
134 
135       case WEST:
136         return WHIST_FIX_WEST;
137 
138       case NORTH:
139         return WHIST_FIX_NORTH;
140 
141       default:
142         throw new IllegalArgumentException("Unable to determine whist fix item for place: " + whist + "!");
143     }
144   }
145 
146 }