-
Notifications
You must be signed in to change notification settings - Fork 0
/
NPC.java
148 lines (126 loc) · 3.45 KB
/
NPC.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
import java.util.Scanner;
import java.util.ArrayList;
/**
*
*/
/** NPC is the class defining non-player characters that can interact with the
* player via combat and trade. NPC objects can move around the Dungeon and only
* appear in the Dungeon at certain light levels according to the Daytime class.
* @author Team Red
*
*/
class NPC {
static class NoNPCException extends Exception {}
private String name;
private Room currentRoom;
private boolean isHostile;
private int health;
private boolean isAlive;
private int maxLightLevelToSpawn;
private ArrayList<Item> inventory;
/** Creates a new NPC from a given Scanner connected to a .bork file
*
* @param scan Scanner connected to the .bork file to read the NPC information from
* @param d The containing Dungeon object, necessary to retrieve Item objects.
* @param initState Whether or not the NPC should be set to its initial state, or set to a saved state from a .sav file
* @throws NoNPCException Thrown when a parsing line marking the end of the NPC section in the file is reached
*/
public NPC(Scanner scan, Dungeon d, boolean initState) throws NoNPCException
{
}
/** Determines if the NPC goes by the paramater name
*
* @param name Name to check against NPC's name
* @return True if this name is the same as the parameter name, false otherwise
*/
public boolean goesBy(String name)
{
}
/** Returns the NPC's name
*
* @return name
*/
public String getName()
{
return name;
}
/** Returns whether or not the NPC is currently alive
*
* @return isAlive
*/
public boolean getIsAlive()
{
return isAlive;
}
/** Returns whether or not the NPC is hostile to the player
*
* @return isHostile
*/
public boolean getIsHostile()
{
return isHostile;
}
/** Returns the Room the NPC is currently in, null if it has not spawned yet
*
* @return currentRoom
*/
public Room getCurrentRoom()
{
return currentRoom;
}
/** A list of the names of the Item's in the NPC's inventory
*
* @return An ArrayList<String> of all the names of the Items in inventory
*/
public ArrayList<String> getInventoryNames()
{
}
/** Trades the parameter Item with the first Item in the NPC's inventory, will not be enacted if the NPC's inventory is empty
*
* @param itemToTrade Item that the NPC will receive
* @return Item that the NPC will give in return
*/
public Item trade(Item itemToTrade)
{
}
/** Adds an Item to the NPC's inventory
*
* @param item Item to add to inventory
*/
public void addToInventory(Item item)
{
inventory.add(item);
}
/** Removes an Item from the NPC's inventory
*
* @param item Item remove from inventory
*/
private void removeFromInventory(Item item)
{
inventory.remove(item);
}
/** Returns an Item from the NPC's inventory going by the parameter name
*
* @param name Name of the Item to search for in inventory
* @return The Item going by the parameter name if it is in inventory
* @throws NoItemException If there is no Item in inventory that goes by the parameter name
*/
public Item getItemFromInventoryNamed(String name) throws NoItemException
{
}
/** Adjusts this NPC's health by the parameter amount
*
* @param change Amount to change this NPC's health by (negative to increase health)
*/
public void changeHealth(int wound)
{
health -= wound;
}
/** Moves the NPC to a new Room
*
* @return The Room the NPC moved to
*/
public Room move()
{
}
}