1 /***
2 * Jetrix TetriNET Server
3 * Copyright (C) 2004-2005 Emmanuel Bourg
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
19
20 package net.jetrix.config;
21
22 import net.jetrix.Language;
23
24 import java.util.Locale;
25
26 /***
27 * Special blocks enumeration.
28 *
29 * @since 0.2
30 *
31 * @author Emmanuel Bourg
32 * @version $Revision: 833 $, $Date: 2010-03-08 10:04:45 +0100 (lun., 08 mars 2010) $
33 */
34 public enum Special
35 {
36 ADDLINE('a'),
37 CLEARLINE('c'),
38 NUKEFIELD('n'),
39 RANDOMCLEAR('r'),
40 SWITCHFIELD('s'),
41 CLEARSPECIAL('b'),
42 GRAVITY('g'),
43 QUAKEFIELD('q'),
44 BLOCKBOMB('o');
45
46 private final char letter;
47
48 Special(char letter)
49 {
50 this.letter = letter;
51 }
52
53 public char getLetter()
54 {
55 return letter;
56 }
57
58 public String getCode()
59 {
60 return name().toLowerCase();
61 }
62
63 public String getName(Locale locale)
64 {
65 return Language.getText("command.config.specials." + getCode(), locale);
66 }
67
68 /***
69 * Return the special matching the specified letter.
70 *
71 * @param letter the letter of the special
72 * @since 0.3
73 */
74 public static Special valueOf(char letter)
75 {
76 for (Special special : values())
77 {
78 if (special.getLetter() == letter)
79 {
80 return special;
81 }
82 }
83
84 return null;
85 }
86 }