public void handle(int cell) { if (cell == -1) { return; } Char ch; Heap heap; if (Dungeon.level.map[cell] == Terrain.ALCHEMY && cell != pos) { curAction = new HeroAction.Cook(cell); } else if (Level.fieldOfView[cell] && (ch = Actor.findChar(cell)) instanceof Mob) { if (ch instanceof Mob.NPC) { curAction = new HeroAction.Interact((Mob.NPC) ch); } else { curAction = new HeroAction.Attack(ch); } } else if ((heap = Dungeon.level.heaps.get(cell)) != null) { switch (heap.type) { case HEAP: curAction = new HeroAction.PickUp(cell); break; case FOR_SALE: curAction = heap.size() == 1 && heap.peek().price() > 0 ? new HeroAction.Buy(cell) : new HeroAction.PickUp(cell); break; default: curAction = new HeroAction.OpenChest(cell); } } else if (Dungeon.level.map[cell] == Terrain.LOCKED_DOOR || Dungeon.level.map[cell] == Terrain.LOCKED_EXIT) { curAction = new HeroAction.Unlock(cell); } else if (cell == Dungeon.level.exit) { curAction = new HeroAction.Descend(cell); } else if (cell == Dungeon.level.entrance) { curAction = new HeroAction.Ascend(cell); } else { curAction = new HeroAction.Move(cell); lastAction = null; } act(); }
private void actBuy(HeroAction.Buy action) { int dst = action.dst; if (pos == dst || Level.adjacent(pos, dst)) { ready(); Heap heap = Dungeon.level.heaps.get(dst); if (heap != null && heap.type == Type.FOR_SALE && heap.size() == 1) { GameScene.show(new WndTradeItem(heap, true)); } } else if (getCloser(dst)) { } else { ready(); } }