| CommandAlias.java |
1 /*
2 * CVS: $Id: CommandAlias.java,v 1.7 2004/07/25 18:08:14 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
26import org.jzuul.engine.commands.Command;
27
28/**
29 * Diese Klasse bietet eine einfache Möglichkeite, einen Alias auf ein anderes
30 * Kommando inklusive Argumenten zu setzen.
31 *
32 *
33 * @version $Revision: 1.7 $
34 */
35public class CommandAlias extends Command {
36 /**
37 * Das Command Objekt, für das dieser Alias gesetzt ist
38 */
39 Command command;
40
41 /**
42 * Die Parameter, die dem Command Objekt als Befehlsparameter übergeben werden
43 */
44 String parameters;
45
46 /**
47 * Erstellt einen neuen Alias
48 *
49 * @param alias der Alias (z.B. inv)
50 * @param command das eigentliche Kommando (z.B. inspect)
51 * @param parameters die Parameter zu diesem Kommando (z.B. inventory)
52 */
53 public CommandAlias(String alias, Command command, String parameters) {
54 super();
55 this.name = alias;
56 this.parameters = parameters;
57 this.command = command;
58 this.gameAction = command.isGameAction();
59 this.isAppletSave = command.isAppletSave();
60 }
61
62 /**
63 * @see org.jzuul.engine.commands.Command#action()
64 */
65 protected boolean action() {
66 command.doAction(Engine.player, parameters.split(" "));
67 return false;
68 }
69
70 /**
71 * @see org.jzuul.engine.commands.Command#help()
72 */
73 public void help() {
74 command.help();
75 }
76
77}
78