1 /*
2  *  CVS: $Id: Event.java,v 1.6 2004/07/19 15:52:35 marcus Exp $
3  * 
4  *  This file is part of Zuul.
5  *
6  *  Zuul is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License, or
9  *  (at your option) any later version.
10 *
11 *  Zuul is distributed in the hope that it will be useful,
12 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 *  GNU General Public License for more details.
15 *
16 *  You should have received a copy of the GNU General Public License
17 *  along with Zuul; if not, write to the Free Software
18 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 * 
20 *  Copyrigth 2004 by marcus, leh
21 * 
22 */
23 
24package org.jzuul.engine;
25
26/**
27 * Diese Klasse definiert die Eventtypen in JZuul
28 * 
29 * 
30 * @version $Revision: 1.6 $
31 */
32public abstract class Event {
33    /**
34     * Das Default Event, wird vom Engine ausgelöst.
35     * Falls das Engine Threaded NPCs benutzt wird das Event von
36     * dem Thread ausgelöst, ansonsten nach jeder Runde.
37     */
38    public static final int DEFAULT = 0;
39    
40    /**
41     * Das Drop Event.
42     * Wird von dem Befehl "drop" ausgelöst.
43     */
44    public static final int DROP = 1;
45    
46    /**
47     * Das Takeup Event.
48     * Wird von dem Befehl "take" ausgelöst.
49     */
50    public static final int TAKEUP = 2;
51    
52    /**
53     * Das Playerenter Event.
54     * Wird von einem Room Objekt ausgelöst wenn der Spieler
55     * mit "go" in diesen Raum wechselt.
56     */
57    public static final int PLAYERENTER = 3;
58    
59    /**
60     * Das Playerleave Event.
61     * Wird von einem Room Objekt ausgelöst wenn der Spieler
62     * mit "go" den Raum verlässt.
63     */
64    public static final int PLAYERLEAVE = 4;
65    
66    /**
67     * Das Use Event.
68     * Wird von dem Befehl "use" ausgelöst.
69     */
70    public static final int USE = 5;
71
72    /**
73     * Ein Dialog Event.
74     * Wird von dem Dialogsystem aufgerufen wenn ein
75     * Dialog erfolgreich beendet wurde.
76     */
77    public final static int DIALOG_END_SUCCESS = 6;
78    
79    /**
80     * Ein Dialog Event.
81     * Wird von dem Dialogsystem ausgelöst wenn ein
82     * Dialog abgebrochen wird
83     */
84    public final static int DIALOG_END_FAILURE = 7;
85    
86    /**
87     * Ein Dialog Event.
88     * Wird von dem Dialogsystem ausgelöst wenn ein
89     * Satz zur nächsten Phase des Dialoges führt.
90     */
91    public final static int DIALOG_CONTINUE = 8;
92    
93    /**
94     * Ein Dialog Event.
95     * Wird vom Dialogsystem ausgelöst wenn das ausgewählte
96     * DialogObject zu einer aktion des Character Objekt führen soll.
97     */
98    public final static int DIALOG_NPC_GIVE = 9;
99    
00    /**
01     * Ein Dialog Event.
02     * 
03     * Wird vom Dialogsystem ausgelöst wenn das ausgewählte
04     * DialogObject dazu führen soll, das der Spieler dem Character
05     * Objekt etwas übergibt.
06     */
07    public final static int DIALOG_NPC_TAKE = 10;
08
09    /**
10     * Ein Dialog Event.
11     * 
12     * Kann in den XML Definitionen für eigene Aktionen definiert werden
13     */
14    public final static int DIALOG_CUSTOM_RESULT_1 = 11;
15
16    /**
17     * Ein Dialog Event.
18     * 
19     * Kann in den XML Definitionen für eigene Aktionen definiert werden
20     */
21    public final static int DIALOG_CUSTOM_RESULT_2 = 12;
22
23    /**
24     * Ein Dialog Event.
25     * 
26     * Kann in den XML Definitionen für eigene Aktionen definiert werden
27     */
28    public final static int DIALOG_CUSTOM_RESULT_3 = 13;
29
30    /**
31     * Das Use_Success Event.
32     * Wird ausgelöst wenn ein "use" oder "use with" Befehl zu einem
33     * positiven ergebnis geführt hat.
34     */
35    public static final int USE_SUCCESS = 14;
36    
37    /**
38     * Das Use_failure Event.
39     * Wird ausgelöst wenn ein "use" oder "use with" Befehlt fehlgeschlagen
40     * ist.
41     */
42    public static final int USE_FAILURE = 15;
43    
44    /**
45     * Das Timer event.
46     * Wird von dem Timer alle 3 Minuten ausgelöst.
47     */
48    public static final int TIMER = 16;
49    
50    public static final int DIALOG_ERROR = 17;
51    /**
52     * Die Anzahl der Events
53     */
54    public static final int COUNT=18;
55    
56    
57    
58    /**
59     * Wandelt einen Event Namen in die Event Nummer um
60     * 
61     * @param event der Name des events
62     * @return  die Nummer des Events, -1 bei unbekanntem Eventname.
63     */
64    public static int fromString(String event) {
65        if (event == null) throw new IllegalArgumentException("You can not get an id from a null value!");
66        if (event.equals("default")) return Event.DEFAULT;
67        if (event.equals("drop")) return Event.DROP;
68        if (event.equals("takeup")) return Event.TAKEUP;
69        if (event.equals("playerenter")) return Event.PLAYERENTER;
70        if (event.equals("playerleave")) return Event.PLAYERLEAVE;
71        if (event.equals("use")) return Event.USE;
72        
73        if (event.equals("dialog_end_failure")) return Event.DIALOG_END_FAILURE;
74        if (event.equals("dialog_end_success")) return Event.DIALOG_END_SUCCESS;
75        if (event.equals("dialog_continue")) return Event.DIALOG_CONTINUE;
76        if (event.equals("dialog_npc_give")) return Event.DIALOG_NPC_GIVE;
77        if (event.equals("dialog_npc_take")) return Event.DIALOG_NPC_TAKE;
78        if (event.equals("dialog_custom_result_1")) return Event.DIALOG_CUSTOM_RESULT_1;
79        if (event.equals("dialog_custom_result_2")) return Event.DIALOG_CUSTOM_RESULT_2;
80        if (event.equals("dialog_custom_result_3")) return Event.DIALOG_CUSTOM_RESULT_3;
81        if (event.equals("dialog_error")) return Event.DIALOG_ERROR;
82        
83        if (event.equals("use_success")) return Event.USE_SUCCESS;
84        if (event.equals("use_failure")) return Event.USE_FAILURE;
85        
86        if (event.equals("timer")) return Event.TIMER;
87        Engine.debug("Unimplemented event " + event + " fromString called, did you add it?",1);
88        return -1;
89    }
90}
91