v0.7.2a: added a safety check to buying an item

This commit is contained in:
Evan Debenham 2019-03-21 00:37:45 -04:00
parent 8a4fd11eb9
commit 220d21c5b5

View File

@ -259,13 +259,13 @@ public class WndTradeItem extends Window {
private void buy( Heap heap ) { private void buy( Heap heap ) {
Hero hero = Dungeon.hero;
Item item = heap.pickUp(); Item item = heap.pickUp();
if (item == null) return;
int price = price( item ); int price = price( item );
Dungeon.gold -= price; Dungeon.gold -= price;
if (!item.doPickUp( hero )) { if (!item.doPickUp( Dungeon.hero )) {
Dungeon.level.drop( item, heap.pos ).sprite.drop(); Dungeon.level.drop( item, heap.pos ).sprite.drop();
} }
} }