Пример #1
0
def use_item():
	if not game.player.inventory:
		game.message.new('Your inventory is empty.', game.turns)
	else:
		output = util.item_stacking(game.player.inventory)
		choice = game.messages.box('Use an item', 'Up/down to select, ENTER to use, ESC to exit', 'center_mapx', 'center_mapy', 65, max(19, len(output) + 4), output, inv=True, step=2, mouse_exit=True)
		util.reset_quantity(game.player.inventory)
		if choice != -1:
			output[choice].use()
	game.draw_gui = True
Пример #2
0
def equip_item():
	if not any(item.is_equippable() for item in game.player.inventory):
		game.message.new("You don't have any equippable items.", game.turns)
	else:
		output = util.item_stacking(game.player.inventory, True)
		choice = game.messages.box('Wear/Equip an item', 'Up/down to select, ENTER to equip, ESC to exit', 'center_mapx', 'center_mapy', 65, max(19, len(output) + 4), output, inv=True, step=2, mouse_exit=True)
		util.reset_quantity(game.player.inventory)
		if choice != -1:
			game.player.equip_item(output[choice])
	game.draw_gui = True
Пример #3
0
def character_sheet_inventory(con, width, height):
	character_sheet_ui(con, width, height, ' Inventory ')
	libtcod.console_set_color_control(libtcod.COLCTRL_1, libtcod.gray, libtcod.black)
	output = util.item_stacking(game.player.inventory)
	for i in range(len(output)):
		text_left = output[i].get_name()
		if output[i].duration > 0:
			text_left += ' (' + str(output[i].duration) + ' turns left)'
		text_right = str(round(output[i].weight * output[i].quantity, 1)) + ' lbs'
		if output[i].is_identified() and output[i].quality == 0:
			libtcod.console_print(con, 2, i + 2, '%c%s%c' % (libtcod.COLCTRL_1, text_left, libtcod.COLCTRL_STOP))
			libtcod.console_print_ex(con, width - 3, i + 2, libtcod.BKGND_SET, libtcod.RIGHT, '%c%s%c' % (libtcod.COLCTRL_1, text_right, libtcod.COLCTRL_STOP))
		else:
			libtcod.console_print(con, 2, i + 2, text_left)
			libtcod.console_print_ex(con, width - 3, i + 2, libtcod.BKGND_SET, libtcod.RIGHT, text_right)
	util.reset_quantity(game.player.inventory)
Пример #4
0
def pickup_item():
	nb_items, itempos = [], []
	for i in range(len(game.current_map.objects)):
		if game.current_map.objects[i].x == game.char.x and game.current_map.objects[i].y == game.char.y and game.current_map.objects[i].can_be_pickup:
			game.current_map.objects[i].item.turn_created = game.current_map.objects[i].first_appearance
			nb_items.append(game.current_map.objects[i].item)
			itempos.append(i)

	if not nb_items and not game.current_map.tile[game.char.x][game.char.y]['type'] == 'rock':
		game.message.new('There is nothing to pick up.', game.turns)
	elif not nb_items and game.current_map.tile[game.char.x][game.char.y]['type'] == 'rock':
		item = game.baseitems.create_item('uncursed ', '', 'stone', '', 'identified')
		item.turns_created = game.turns
		game.player.inventory.append(item)
		game.message.new('You pick up a stone.', game.turns, libtcod.green)
	elif len(nb_items) == 1:
		nb_items[0].pick_up(nb_items[0].turn_created)
		game.current_map.objects.pop(itempos[0])
	else:
		qty = 1
		output = util.item_stacking(nb_items)
		choice = game.messages.box('Get an item', 'Up/down to select, ENTER to get, ESC to exit', 'center_mapx', 'center_mapy', 65, max(19, len(output) + 4), output, inv=True, step=2, mouse_exit=True)
		if choice != -1:
			if output[choice].quantity > 1 and output[choice].type != 'money':
				libtcod.console_print(0, game.PLAYER_STATS_WIDTH + 2, 1, 'Pickup how many: _')
				libtcod.console_flush()
				qty = game.messages.input('', 0, game.PLAYER_STATS_WIDTH + 19, 1)
				if qty == '' or not qty.isdigit():
					choice = -1
				elif int(qty) < 1 or int(qty) > output[choice].quantity:
					choice = -1
			if output[choice].quantity > 1 and output[choice].type == 'money':
				qty = output[choice].quantity
		if choice != -1:
			x = 0
			for i in range(len(nb_items) - 1, -1, -1):
				if nb_items[i] == output[choice] and x < int(qty):
					nb_items[i].pick_up(nb_items[i].turn_created)
					game.current_map.objects.pop(itempos[i])
					x += 1
		util.reset_quantity(nb_items)
		game.draw_gui = True
Пример #5
0
def drop_item():
	qty = 1
	if not game.player.inventory:
		game.message.new('Your inventory is empty.', game.turns)
	else:
		output = util.item_stacking(game.player.inventory)
		choice = game.messages.box('Drop item', 'Up/down to select, ENTER to drop, ESC to exit', 'center_mapx', 'center_mapy', 65, max(19, len(output) + 4), output, inv=True, step=2, mouse_exit=True)
		if choice != -1:
			if output[choice].quantity > 1:
				libtcod.console_print(0, game.PLAYER_STATS_WIDTH + 2, 1, 'Drop how many: _')
				libtcod.console_flush()
				qty = game.messages.input('', 0, game.PLAYER_STATS_WIDTH + 17, 1)
				if qty == '' or not qty.isdigit():
					choice = -1
				elif int(qty) < 1 or int(qty) > output[choice].quantity:
					choice = -1
		util.reset_quantity(game.player.inventory)
		if choice != -1:
			game.player.drop_item(output[choice], int(qty))
	game.draw_gui = True