| Look.java |
1 /*
2 * CVS: $Id: Look.java,v 1.5 2004/07/25 21:40:55 marcus Exp $
3 *
4 * This file is part of JZuul.
5 *
6 * JZuul 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 * JZuul 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.commands;
25
26import org.jzuul.engine.exceptions.GuiNotInitializedException;
27import org.jzuul.engine.*;
28import org.jzuul.engine.Engine;
29
30/**
31 *
32 *
33 * To change the template for this generated type comment go to
34 * Window>Preferences>Java>Code Generation>Code and Comments
35 */
36public class Look extends Command {
37
38 /**
39 *
40 */
41 public Look() {
42 super();
43 this.name = "look"; //$NON-NLS-1$
44 this.arguments = Command.VARARG_COMMAND;
45 this.gameAction = false;
46 this.desc = Messages.getString("LOOK_HELP"); //$NON-NLS-1$
47 }
48
49 protected boolean action() {
50 if (args.length == 0) {
51 try {
52 currentRoom.printBeschreibung();
53 } catch (GuiNotInitializedException e) {
54 System.err.println(e.getMessage());
55 }
56 return true;
57 }
58 if (args.length == 1) {
59 String desc = currentRoom.getWayDescriptionByDirection(args[0]);
60 if (desc == null) {
61 //maybe an object?
62 if (player.findGameObject(args[0]) != null) {
63 return new Inspect().doAction(player,args);
64 } else {
65 player.say(Messages.getString("LOOK_NOTHING")); //$NON-NLS-1$
66 return false;
67 }
68
69 } else {
70 player.say(Messages.getString("LOOK_YOU_SEE") + desc); //$NON-NLS-1$
71 return true;
72 }
73 }
74 Engine.gui.println(Messages.getString("LOOK_ERROR")); //$NON-NLS-1$
75 this.help();
76 return false;
77 }
78
79 public void help() {
80 super.help();
81 Engine.gui.println(Messages.getString("LOOK_HELP_USAGE")); //$NON-NLS-1$
82 }
83
84}
85