@@ -127,7 +127,7 @@ impl GameState for State {
127
127
newrunstate = RunState :: AwaitingInput ;
128
128
}
129
129
RunState :: ShowInventory => {
130
- let result = show_inventory ( self , ctx) ;
130
+ let result = show_inventory ( self , ctx, "Inventory: Use Item" ) ;
131
131
match result. 0 {
132
132
gui:: ItemMenuResult :: Cancel => newrunstate = RunState :: AwaitingInput ,
133
133
gui:: ItemMenuResult :: NoResponse => { }
@@ -147,16 +147,38 @@ impl GameState for State {
147
147
let names = self . ecs . read_storage :: < Name > ( ) ;
148
148
let mut gamelog = self . ecs . fetch_mut :: < gamelog:: GameLog > ( ) ;
149
149
gamelog. entries . push ( format ! (
150
- "You try to use the {}, but it isn't written yet! " ,
150
+ "You use the {}. " ,
151
151
names. get( item_entity) . unwrap( ) . name,
152
152
) ) ;
153
153
newrunstate = RunState :: PlayerTurn ;
154
154
}
155
155
}
156
156
}
157
157
RunState :: ShowDropItem => {
158
- let todo = true ;
159
- todo ! ( )
158
+ let result = gui:: show_inventory ( self , ctx, "Inventory: Drop Item" ) ;
159
+ match result. 0 {
160
+ gui:: ItemMenuResult :: Cancel => newrunstate = RunState :: AwaitingInput ,
161
+ gui:: ItemMenuResult :: NoResponse => { }
162
+ gui:: ItemMenuResult :: Selected => {
163
+ let item_entity = result
164
+ . 1
165
+ . unwrap_or_else ( || panic ! ( "Item selected but not found!" ) ) ;
166
+ let mut intent = self . ecs . write_storage :: < EventWantsToDropItem > ( ) ;
167
+ intent
168
+ . insert (
169
+ get_player_unwrap ( & self . ecs , PLAYER_NAME ) ,
170
+ EventWantsToDropItem { item : item_entity } ,
171
+ )
172
+ . unwrap_or_else ( |_| panic ! ( "Tried to drop item but failed!" ) ) ;
173
+ let names = self . ecs . read_storage :: < Name > ( ) ;
174
+ let mut gamelog = self . ecs . fetch_mut :: < gamelog:: GameLog > ( ) ;
175
+ gamelog. entries . push ( format ! (
176
+ "You drop the {}." ,
177
+ names. get( item_entity) . unwrap( ) . name,
178
+ ) ) ;
179
+ newrunstate = RunState :: PlayerTurn ;
180
+ }
181
+ }
160
182
}
161
183
}
162
184
{
0 commit comments