@@ -127,7 +127,7 @@ impl GameState for State {
127127 newrunstate = RunState :: AwaitingInput ;
128128 }
129129 RunState :: ShowInventory => {
130- let result = show_inventory ( self , ctx) ;
130+ let result = show_inventory ( self , ctx, "Inventory: Use Item" ) ;
131131 match result. 0 {
132132 gui:: ItemMenuResult :: Cancel => newrunstate = RunState :: AwaitingInput ,
133133 gui:: ItemMenuResult :: NoResponse => { }
@@ -147,16 +147,38 @@ impl GameState for State {
147147 let names = self . ecs . read_storage :: < Name > ( ) ;
148148 let mut gamelog = self . ecs . fetch_mut :: < gamelog:: GameLog > ( ) ;
149149 gamelog. entries . push ( format ! (
150- "You try to use the {}, but it isn't written yet! " ,
150+ "You use the {}. " ,
151151 names. get( item_entity) . unwrap( ) . name,
152152 ) ) ;
153153 newrunstate = RunState :: PlayerTurn ;
154154 }
155155 }
156156 }
157157 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+ }
160182 }
161183 }
162184 {
0 commit comments