Example #1
0
	def set_symbol(self, symbol_n, obj):
		symbol = clean_symbol(obj)
		
		if symbol_n == 1:
			self.symbol1 = symbol
			
		elif symbol_n == 2:
			self.symbol2 = symbol
Example #2
0
	def __init__(self, actor, symbol = None, *init_args, **init_kwargs):
		self.symbol = clean_symbol(symbol)
		self.duration = 0
		self.permanent = False
		self.type = type(self) # effects can overwrite this to create generalized effect types for use in combining effects
		self.actor = actor
		
		old_effect = actor.has_effect(self.type) # this won't behave properly if there is more than one effect of a single type - these should always either combine or not!
		self.applied = True
		
		if old_effect and hasattr(self, 'on_combine'):
			self.on_combine(old_effect)
		
		else:
			if hasattr(self, 'on_apply'):
				self.applied = self.on_apply()
			
			if self.applied:
				actor.effects.append(self)
				
				if not self.permanent and self.duration == 0:
					self.clear()
Example #3
0
def look(player):
	look_console = libtcod.console_new(50, 10)
	
	cursor_x = player.x
	cursor_y = player.y
	
	map = player.map
	memory = player.memory
	
	while True:
		draw_map(player)
		highlight_tile(cursor_x, cursor_y)
		
		can_see = player.fov.is_visible(cursor_x, cursor_y)
		
		actor = can_see and map.actor_at(cursor_x, cursor_y) or memory.actor_at(cursor_x, cursor_y)
		item = can_see and map.item_at(cursor_x, cursor_y) or memory.item_at(cursor_x, cursor_y)
		feature =  can_see and map.feature_at(cursor_x, cursor_y) or memory.feature_at(cursor_x, cursor_y)
		
		libtcod.console_clear(look_console)
		
		if actor or item or feature:
			if can_see:
				libtcod.console_print_left(look_console, 1, 1, libtcod.BKGND_NONE, 'You see:')
			
			else:
				libtcod.console_print_left(look_console, 1, 1, libtcod.BKGND_NONE, 'You recall:')
			
			offset = 0
			
			if actor:
				libtcod.console_put_char_ex(look_console, 1, 3, *clean_symbol(actor))
				libtcod.console_print_left(look_console, 3, 3, libtcod.BKGND_NONE, actor.name)
				
				offset += 1
			
			if item:
				libtcod.console_put_char_ex(look_console, 1, 3 + offset, *clean_symbol(item))
				libtcod.console_print_left(look_console, 3, 3 + offset, libtcod.BKGND_NONE, item.name)
				
				offset += 1
			
			if feature:
				libtcod.console_put_char_ex(look_console, 1, 3 + offset, *clean_symbol(feature))
				libtcod.console_print_left(look_console, 3, 3 + offset, libtcod.BKGND_NONE, feature.name)
		
		else:
			libtcod.console_print_left(look_console, 1, 1, libtcod.BKGND_NONE, 'You cannot see this location.')
			
		libtcod.console_blit(look_console, 0, 0, 50, 10, 0, 30, 40)
		
		libtcod.console_flush()
		
		key = libtcod.console_wait_for_keypress(True)
		
		if key.vk == libtcod.KEY_ESCAPE or key.c == ord('l'):
			break
		
		elif key.vk in DIRECTION_KEYS:
			dx, dy = DIRECTION_KEYS[key.vk]
			cursor_x += dx
			cursor_y += dy
			level = 0
		
		cursor_x %= 80 # mmmm hardcoded
		cursor_y %= 40
	
	libtcod.console_delete(look_console)