diff --git a/processors/render.py b/processors/render.py index 7625993..85cbf5f 100644 --- a/processors/render.py +++ b/processors/render.py @@ -12,6 +12,7 @@ class RenderProcessor(esper.Processor): def __init__(self): super().__init__() + self.item = None self.queue = Queue() self.queue.put({'redraw': True}) @@ -28,6 +29,10 @@ def process(self): _recompute_fov = True elif event.get('redraw'): _redraw = True + elif event.get('item'): + self.item = event['item'] + elif event.get('item') is False: + self.item = None if not _redraw: return 0 @@ -36,7 +41,7 @@ def process(self): render_stats(self.world) render_entities(self.world, _recompute_fov) render_popup_menu(self.world) - render_message_log(self.world) + render_message_log(self.world, self.item) render_tooltips(self.world) # Draw the gameover overlay. diff --git a/processors/skill.py b/processors/skill.py index 3dffa16..7141515 100644 --- a/processors/skill.py +++ b/processors/skill.py @@ -12,6 +12,7 @@ from processors.combat import CombatProcessor from processors.energy import EnergyProcessor from processors.movement import MovementProcessor +from processors.render import RenderProcessor from processors.state import StateProcessor from queue import Queue @@ -40,6 +41,7 @@ def process(self): results = self.get_tiles(ent) self.highlight_tiles(results['tiles']) self.world.get_processor(StateProcessor).queue.put({'skill_targeting': True}) + self.world.get_processor(RenderProcessor).queue.put({'item': self._item}) elif move: (dx, dy) = move @@ -62,6 +64,7 @@ def process(self): self._item = None self._direction = None self.world.get_processor(StateProcessor).queue.put({'exit': True}) + self.world.get_processor(RenderProcessor).queue.put({'item': False}) def find_item(self, ent, slot): eqp = self.world.component_for_entity(ent, EquipmentComponent) @@ -188,12 +191,12 @@ def do_skill(self, ent, direction, item, results): name = self.world.component_for_entity(item, NameComponent)._name turn = self.world.turn - if not results['targets'] and not results['destination']: - self.world.messages.append({'skill': (True, True, False, True, name, turn)}) - return 0 - elif not results['legal_target']: + if not results['legal_target']: self.world.messages.append({'skill': (True, True, True, False, name, turn)}) return 0 + elif not results['targets'] and not results['destination']: + self.world.messages.append({'skill': (True, True, False, True, name, turn)}) + return 0 if results['targets']: self.world.get_processor(CombatProcessor).queue.put({'ent': ent, 'defender_IDs': results['targets'], 'skill': True}) diff --git a/processors/sub/message_log.py b/processors/sub/message_log.py index 0af7099..cd81a16 100644 --- a/processors/sub/message_log.py +++ b/processors/sub/message_log.py @@ -6,34 +6,22 @@ from components.item.slot import SlotComponent from components.name import NameComponent -def render_message_log(world): +def render_message_log(world, item): if world.state == 'MainMenu': return 0 console, x, y, w, h = world.consoles['log'] # Hijack the message log to print skill descriptions. - if world.state == 'SkillTargeting': # TODO: If we lack this skill, we should not be in this state - return 0 # TODO: This will be an interesting issue to solve! + if world.state == 'SkillTargeting' and item: + item_name = world.component_for_entity(item, NameComponent)._name + item_skill_component = world.component_for_entity(item, ItemSkillComponent) + skill_name = item_skill_component.name + skill_description = item_skill_component.description - item_name = None - skill_name = None - skill_description = None - eqp_component = world.component_for_entity(1, EquipmentComponent) - - for item in eqp_component.equipment: - item_slot_component = world.component_for_entity(item, SlotComponent) - if item_slot_component.slot == slot: - - item_name = world.component_for_entity(item, NameComponent)._name - item_skill_component = world.component_for_entity(item, ItemSkillComponent) - skill_name = item_skill_component.name - skill_description = item_skill_component.description - - console.print(0, 0, item_name, LOG_COLORS['skill']) - console.print(0, 1, skill_name.capitalize(), LOG_COLORS['skill']) - console.print(0, 3, skill_description, LOG_COLORS['skill']) # TODO: Need some word wrap here. - break + console.print(0, 0, item_name, LOG_COLORS['skill']) + console.print(0, 1, skill_name.capitalize(), LOG_COLORS['skill']) + console.print(0, 3, skill_description, LOG_COLORS['skill']) # TODO: Need some word wrap here. return 0