View Javadoc

1   /*
2    *   Magic-Project is a turn based strategy simulator
3    *   Copyright (C) 2003-2007 Fabrice Daugan
4    *
5    *   This program is free software; you can redistribute it and/or modify it 
6    * under the terms of the GNU General Public License as published by the Free 
7    * Software Foundation; either version 2 of the License, or (at your option) any
8    * later version.
9    *
10   *   This program is distributed in the hope that it will be useful, but WITHOUT 
11   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12   * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more 
13   * details.
14   *
15   *   You should have received a copy of the GNU General Public License along  
16   * with this program; if not, write to the Free Software Foundation, Inc., 
17   * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18   */
19  package net.sf.magicproject.event;
20  
21  import java.io.IOException;
22  import java.io.InputStream;
23  import java.io.OutputStream;
24  
25  /***
26   * This interface contains all events supported
27   * 
28   * @since 0.1
29   * @see net.sf.magicproject.event.EventFactory
30   */
31  public enum Event {
32  
33  	/***
34  	 * 
35  	 */
36  	BECOMING_UNTAPPED,
37  
38  	/***
39  	 * 
40  	 */
41  	BEFORE_PHASE,
42  
43  	/***
44  	 * 
45  	 */
46  	BEGINNING_PHASE,
47  
48  	/***
49  	 * 
50  	 */
51  	EOP,
52  
53  	/***
54  	 * 
55  	 */
56  	DETACHED_CARD,
57  
58  	/***
59  	 * 
60  	 */
61  	EXCEPTION,
62  
63  	/***
64  	 * 
65  	 */
66  	LETHAL_DAMAGE,
67  
68  	/***
69  	 * 
70  	 */
71  	UPDATE_LIFE,
72  
73  	/***
74  	 * 
75  	 */
76  	LOSING_GAME,
77  
78  	/***
79  	 * 
80  	 */
81  	MODIFIED_PROPERTY,
82  
83  	/***
84  	 * 
85  	 */
86  	MODIFIED_IDCARD,
87  
88  	/***
89  	 * 
90  	 */
91  	MODIFIED_IDCOLOR,
92  
93  	/***
94  	 * 
95  	 */
96  	MODIFIED_OWNER,
97  
98  	/***
99  	 * 
100 	 */
101 	MODIFIED_CONTROLLER,
102 
103 	/***
104 	 * 
105 	 */
106 	ATTACHED_TO,
107 
108 	/***
109 	 * 
110 	 */
111 	MODIFIED_REGISTER,
112 
113 	/***
114 	 * 
115 	 */
116 	DECLARED_BLOCKING,
117 
118 	/***
119 	 * 
120 	 */
121 	CASTING,
122 
123 	/***
124 	 * 
125 	 */
126 	DECLARED_ATTACKING,
127 	/***
128 	 * 
129 	 */
130 	BECOMING_TAPPED,
131 
132 	/***
133 	 * 
134 	 */
135 	NEVER_ACTIVATED,
136 
137 	/***
138 	 * 
139 	 */
140 	UPDATE_TOUGHNESS,
141 
142 	/***
143 	 * 
144 	 */
145 	TARGETED,
146 
147 	/***
148 	 * 
149 	 */
150 	CAN_CAST_CARD,
151 
152 	/***
153 	 * 
154 	 */
155 	DEALTING_DAMAGE,
156 
157 	/***
158 	 * 
159 	 */
160 	MOVING_CARD,
161 
162 	/***
163 	 * 
164 	 */
165 	GIVEN_MANA,
166 
167 	/***
168 	 * 
169 	 */
170 	ARRANGED_ZONE,
171 
172 	/***
173 	 * 
174 	 */
175 	FACED_UP,
176 
177 	/***
178 	 * 
179 	 */
180 	FACED_DOWN,
181 
182 	/***
183 	 * 
184 	 */
185 	MODIFIED_REGISTER_RANGE;
186 
187 	/***
188 	 * Wrtite this enum to the given outputstream.
189 	 * 
190 	 * @param out
191 	 *          the stream ths enum would be written.
192 	 * @throws IOException
193 	 *           error while writting event's id
194 	 */
195 	public void write(OutputStream out) throws IOException {
196 		out.write(ordinal());
197 	}
198 
199 	/***
200 	 * Read and return the enum from the given inputstream.
201 	 * 
202 	 * @param input
203 	 *          the stream containing the enum to read.
204 	 * @return the enum from the given inputstream.
205 	 * @throws IOException
206 	 *           error while reading event's id.
207 	 */
208 	public static Event valueOf(InputStream input) throws IOException {
209 		return values()[input.read()];
210 	}
211 
212 }