-
Notifications
You must be signed in to change notification settings - Fork 0
/
Location.java
93 lines (76 loc) · 2.17 KB
/
Location.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package sample;
/**
* Created by Sonia on 10/14/2015.
*/
import javafx.scene.control.Button;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
public abstract class Location implements ProcessInput
{
protected javafx.scene.control.TextArea outScreen;
protected String command;
public Location(TextArea outScreen, String command)
{
this.outScreen = outScreen;
this.command = command;
}
public void changeCommand(String newCom)
{
command = newCom;
}
public boolean processInput(String command, String keyword)
{
return command.contains(keyword);
}
public boolean processInput(String command, Player player)
{
boolean success=true;
if (command.contains("use")&&!command.contains("house"))
{
command.toLowerCase();
{
boolean found = false;
int i =0;
while (!found && i<player.getItems().size())
{
Item item = player.getItems().get(i);
if (command.contains(item.itemName.toLowerCase()) && item.getClass() == Elixir.class)
{
Elixir elix = (Elixir) item;
elix.use(player);
found = true;
}
i++;
}
}
}
else if (command.contains("unequip"))
{
player.unequip();
}
else if (command.contains("equip"))
{
boolean found = false;
int i =0;
while (!found && i<player.getItems().size())
{
Item item = player.getItems().get(i);
if (command.contains(item.itemName.toLowerCase()) && (item.getClass() == Weapon.class))
{
player.equip((Weapon)item);
found = true;
}
i++;
}
}
else
{
success = false;
}
return success;
}
public void write(String line)
{
outScreen.appendText(line+"\n");
}
}