aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/esieequest/controller/commands/DropCommand.java2
-rw-r--r--src/esieequest/controller/commands/TakeCommand.java2
-rw-r--r--src/esieequest/controller/commands/UseCommand.java2
-rw-r--r--src/esieequest/model/Text.java2
-rw-r--r--src/esieequest/model/items/Inventory.java2
-rw-r--r--src/esieequest/view/Viewable.java6
-rw-r--r--src/esieequest/view/app/UserInterface.java91
-rw-r--r--src/esieequest/view/text/TextInterface.java8
-rw-r--r--src/esieequest/view/web/WebInterface.java40
-rw-r--r--src/esieequest/view/web/WebInterface.ui.xml17
10 files changed, 129 insertions, 43 deletions
diff --git a/src/esieequest/controller/commands/DropCommand.java b/src/esieequest/controller/commands/DropCommand.java
index 09b2394..b253d98 100644
--- a/src/esieequest/controller/commands/DropCommand.java
+++ b/src/esieequest/controller/commands/DropCommand.java
@@ -31,6 +31,8 @@ public class DropCommand implements Executable {
31 final Item item = game.getPlayer().getInventory().takeItem(itemName); 31 final Item item = game.getPlayer().getInventory().takeItem(itemName);
32 game.getPlayer().getCurrentSide().getInventory().putItem(item); 32 game.getPlayer().getCurrentSide().getInventory().putItem(item);
33 33
34 view.updateInventory(game.getPlayer().getInventory());
35
34 } 36 }
35 37
36} 38}
diff --git a/src/esieequest/controller/commands/TakeCommand.java b/src/esieequest/controller/commands/TakeCommand.java
index 8b8a461..f83c218 100644
--- a/src/esieequest/controller/commands/TakeCommand.java
+++ b/src/esieequest/controller/commands/TakeCommand.java
@@ -47,6 +47,8 @@ public class TakeCommand implements Executable {
47 game.getPlayer().getCurrentRoom().removeItem(item); 47 game.getPlayer().getCurrentRoom().removeItem(item);
48 game.getPlayer().getInventory().putItem(item); 48 game.getPlayer().getInventory().putItem(item);
49 49
50 view.updateInventory(game.getPlayer().getInventory());
51
50 } 52 }
51 53
52} 54}
diff --git a/src/esieequest/controller/commands/UseCommand.java b/src/esieequest/controller/commands/UseCommand.java
index 00fc234..3328c7c 100644
--- a/src/esieequest/controller/commands/UseCommand.java
+++ b/src/esieequest/controller/commands/UseCommand.java
@@ -15,7 +15,7 @@ public class UseCommand implements Executable {
15 @Override 15 @Override
16 public void execute(final String argument, final Game game, final Viewable view) { 16 public void execute(final String argument, final Game game, final Viewable view) {
17 17
18 final String itemName = argument; 18 final String itemName = argument.toLowerCase();
19 19
20 if (itemName == null) { 20 if (itemName == null) {
21 view.echo(Text.NO_ITEM_SPECIFIED.getText()); 21 view.echo(Text.NO_ITEM_SPECIFIED.getText());
diff --git a/src/esieequest/model/Text.java b/src/esieequest/model/Text.java
index 1b47c6f..d46b4b1 100644
--- a/src/esieequest/model/Text.java
+++ b/src/esieequest/model/Text.java
@@ -53,6 +53,8 @@ public enum Text {
53 INVENTORY_WEIGHT_PREFIX("Total inventory weight: "), 53 INVENTORY_WEIGHT_PREFIX("Total inventory weight: "),
54 INVENTORY_WEIGHT_SUFFIX("."), 54 INVENTORY_WEIGHT_SUFFIX("."),
55 55
56 INVENTORY_EMPTY("Your inventory is empty."),
57
56 // formatting 58 // formatting
57 LIST_SEPARATOR(", "), 59 LIST_SEPARATOR(", "),
58 NEW_LINE("\n"), 60 NEW_LINE("\n"),
diff --git a/src/esieequest/model/items/Inventory.java b/src/esieequest/model/items/Inventory.java
index 68d1838..a4a0e84 100644
--- a/src/esieequest/model/items/Inventory.java
+++ b/src/esieequest/model/items/Inventory.java
@@ -4,6 +4,7 @@ import java.util.ArrayList;
4import java.util.Arrays; 4import java.util.Arrays;
5import java.util.Collection; 5import java.util.Collection;
6 6
7import lombok.Getter;
7import net.pacien.util.IntrinsicMap; 8import net.pacien.util.IntrinsicMap;
8 9
9import org.json.simple.JSONArray; 10import org.json.simple.JSONArray;
@@ -21,6 +22,7 @@ import esieequest.model.Text;
21 */ 22 */
22public class Inventory implements SerialisableList { 23public class Inventory implements SerialisableList {
23 24
25 @Getter
24 private final IntrinsicMap<String, Item> items; 26 private final IntrinsicMap<String, Item> items;
25 27
26 /** 28 /**
diff --git a/src/esieequest/view/Viewable.java b/src/esieequest/view/Viewable.java
index d2aeaff..0b23b8c 100644
--- a/src/esieequest/view/Viewable.java
+++ b/src/esieequest/view/Viewable.java
@@ -1,10 +1,8 @@
1package esieequest.view; 1package esieequest.view;
2 2
3import java.util.HashMap;
4
5import esieequest.controller.GameEngine; 3import esieequest.controller.GameEngine;
6import esieequest.model.events.Quest; 4import esieequest.model.events.Quest;
7import esieequest.model.items.SimpleItem; 5import esieequest.model.items.Inventory;
8import esieequest.model.map.Direction; 6import esieequest.model.map.Direction;
9import esieequest.model.map.Room; 7import esieequest.model.map.Room;
10import esieequest.model.map.Side; 8import esieequest.model.map.Side;
@@ -73,6 +71,6 @@ public interface Viewable {
73 * @param items 71 * @param items
74 * the items 72 * the items
75 */ 73 */
76 public void updateInventory(final HashMap<String, SimpleItem> items); 74 public void updateInventory(final Inventory inventory);
77 75
78} 76}
diff --git a/src/esieequest/view/app/UserInterface.java b/src/esieequest/view/app/UserInterface.java
index f492090..c4e072d 100644
--- a/src/esieequest/view/app/UserInterface.java
+++ b/src/esieequest/view/app/UserInterface.java
@@ -4,6 +4,7 @@ import java.awt.BorderLayout;
4import java.awt.Dimension; 4import java.awt.Dimension;
5import java.awt.Font; 5import java.awt.Font;
6import java.awt.Graphics; 6import java.awt.Graphics;
7import java.awt.GridLayout;
7import java.awt.event.ActionEvent; 8import java.awt.event.ActionEvent;
8import java.awt.event.ActionListener; 9import java.awt.event.ActionListener;
9import java.awt.image.BufferedImage; 10import java.awt.image.BufferedImage;
@@ -12,6 +13,7 @@ import java.util.HashMap;
12 13
13import javax.swing.JButton; 14import javax.swing.JButton;
14import javax.swing.JLabel; 15import javax.swing.JLabel;
16import javax.swing.JLayeredPane;
15import javax.swing.JPanel; 17import javax.swing.JPanel;
16import javax.swing.JTextField; 18import javax.swing.JTextField;
17import javax.swing.JTextPane; 19import javax.swing.JTextPane;
@@ -21,8 +23,10 @@ import com.wordpress.tipsforjava.swing.StretchIcon;
21 23
22import esieequest.controller.GameEngine; 24import esieequest.controller.GameEngine;
23import esieequest.controller.commands.Command; 25import esieequest.controller.commands.Command;
26import esieequest.model.Text;
24import esieequest.model.events.Quest; 27import esieequest.model.events.Quest;
25import esieequest.model.items.SimpleItem; 28import esieequest.model.items.Inventory;
29import esieequest.model.items.Item;
26import esieequest.model.map.Direction; 30import esieequest.model.map.Direction;
27import esieequest.model.map.Orientation; 31import esieequest.model.map.Orientation;
28import esieequest.model.map.Room; 32import esieequest.model.map.Room;
@@ -39,6 +43,8 @@ abstract class UserInterface implements Viewable, ActionListener {
39 private GameEngine gameEngine; 43 private GameEngine gameEngine;
40 44
41 private JPanel layout; 45 private JPanel layout;
46 private JPanel consolePanel;
47 private JPanel inventoryPanel;
42 48
43 private JTextPane questTextPane; 49 private JTextPane questTextPane;
44 private JTextPane infoTextPane; 50 private JTextPane infoTextPane;
@@ -110,20 +116,28 @@ abstract class UserInterface implements Viewable, ActionListener {
110 this.layout.add(userPanel, BorderLayout.SOUTH); 116 this.layout.add(userPanel, BorderLayout.SOUTH);
111 userPanel.setLayout(new BorderLayout(0, 0)); 117 userPanel.setLayout(new BorderLayout(0, 0));
112 118
113 final JPanel dispPanel = new JPanel(); 119 final JLayeredPane dispPanel = new JLayeredPane();
114 dispPanel.setBorder(new EmptyBorder(5, 5, 5, 0)); 120 dispPanel.setBorder(new EmptyBorder(5, 5, 5, 0));
115 userPanel.add(dispPanel, BorderLayout.CENTER); 121 userPanel.add(dispPanel, BorderLayout.CENTER);
116 dispPanel.setLayout(new BorderLayout(0, 0)); 122 dispPanel.setLayout(new BorderLayout(0, 0));
117 123
124 this.consolePanel = new JPanel();
125 dispPanel.add(this.consolePanel, BorderLayout.CENTER);
126 this.consolePanel.setLayout(new BorderLayout(0, 0));
127
118 this.infoTextPane = new JTextPane(); 128 this.infoTextPane = new JTextPane();
129 this.consolePanel.add(this.infoTextPane, BorderLayout.CENTER);
119 this.infoTextPane.setEditable(false); 130 this.infoTextPane.setEditable(false);
120 this.infoTextPane.setText("Welcome to ESIEEquest!"); 131 this.infoTextPane.setText("Welcome to ESIEEquest!");
121 dispPanel.add(this.infoTextPane);
122 132
123 this.inputField = new JTextField(); 133 this.inputField = new JTextField();
124 dispPanel.add(this.inputField, BorderLayout.SOUTH); 134 this.consolePanel.add(this.inputField, BorderLayout.SOUTH);
125 this.inputField.setColumns(10); 135 this.inputField.setColumns(10);
126 136
137 this.inventoryPanel = new JPanel();
138 dispPanel.add(this.inventoryPanel, BorderLayout.NORTH);
139 this.inventoryPanel.setLayout(new GridLayout(4, 3, 0, 0));
140
127 final JPanel controlPanel = new JPanel(); 141 final JPanel controlPanel = new JPanel();
128 controlPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); 142 controlPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
129 userPanel.add(controlPanel, BorderLayout.EAST); 143 userPanel.add(controlPanel, BorderLayout.EAST);
@@ -142,7 +156,7 @@ abstract class UserInterface implements Viewable, ActionListener {
142 156
143 final JButton inventoryButton = new JButton("⇱"); 157 final JButton inventoryButton = new JButton("⇱");
144 inventoryButton.setFont(font); 158 inventoryButton.setFont(font);
145 inventoryButton.setToolTipText("Use item"); 159 inventoryButton.setToolTipText("Open inventory");
146 topControlPanel.add(inventoryButton, BorderLayout.WEST); 160 topControlPanel.add(inventoryButton, BorderLayout.WEST);
147 161
148 final JButton actionButton = new JButton("⇲"); 162 final JButton actionButton = new JButton("⇲");