@@ -12,7 +12,7 @@ import string;
12
12
import io;
13
13
14
14
const int COMMAND_SIZE = 8 ;
15
- string commands COMMAND_SIZE;
15
+ const string commands COMMAND_SIZE;
16
16
commands[0 ] = " help" ;
17
17
commands[1 ] = " take" ;
18
18
commands[2 ] = " use" ;
@@ -27,7 +27,6 @@ struct "player";
27
27
string inventory 5;
28
28
int inventoryIndex;
29
29
int inventoryCapacity;
30
- int index;
31
30
struct;
32
31
33
32
struct "item";
@@ -140,30 +139,30 @@ return newRoom;
140
139
141
140
function useItem : string as toUse;
142
141
int i = 0;
143
- p1. index = 0;
142
+ int index = 0;
144
143
145
144
while i < p1.inventoryCapacity;
146
- string item = p1.inventory[ index] ;
145
+ string item = p1.inventory[ useItem. index] ;
147
146
148
147
if item != "";
149
148
if item.name == toUse;
150
149
println "Used: ", item.name;
151
150
152
- p1.inventory[ index] = "";
151
+ p1.inventory[ useItem. index] = "";
153
152
p1.health += item.healValue;
154
153
155
154
println "Health: ", p1.health;
156
155
end;
157
156
end;
158
157
159
- p1. index += 1;
158
+ index += 1;
160
159
i += 1;
161
160
end;
162
161
return;
163
162
164
163
function takeItem : string as currentRoom, string as item;
165
164
if p1.inventoryIndex < p1.inventoryCapacity;
166
- p1.inventory[ inventoryIndex] = item;
165
+ p1.inventory[ p1. inventoryIndex] = item;
167
166
p1.inventoryIndex += 1;
168
167
169
168
currentRoom.item = "";
@@ -204,7 +203,7 @@ while input != "exit";
204
203
if input == "help";
205
204
println "Type name of exit to go to new room.";
206
205
int cs = 2;
207
- call printHelp;
206
+ call printHelp : COMMAND_SIZE, commands ;
208
207
209
208
break 7;
210
209
end;
0 commit comments