Skip to content

Commit

Permalink
Selecting a skill now properly hijacks the view log window
Browse files Browse the repository at this point in the history
  • Loading branch information
Shoes01 committed May 21, 2019
1 parent 776c027 commit 3eafdc5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 26 deletions.
7 changes: 6 additions & 1 deletion processors/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
class RenderProcessor(esper.Processor):
def __init__(self):
super().__init__()
self.item = None
self.queue = Queue()
self.queue.put({'redraw': True})

Expand All @@ -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
Expand All @@ -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.
Expand Down
11 changes: 7 additions & 4 deletions processors/skill.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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})
Expand Down
30 changes: 9 additions & 21 deletions processors/sub/message_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 3eafdc5

Please sign in to comment.