mirror of
https://github.com/rr-/pq-cli.git
synced 2026-09-28 22:33:59 -06:00
ui/curses: implement cheats
This commit is contained in:
@@ -3,7 +3,7 @@ import curses
|
||||
import datetime
|
||||
import typing as T
|
||||
|
||||
from pqcli.mechanic import Player, Simulation
|
||||
from pqcli.mechanic import Player, SignalMixin, Simulation
|
||||
from pqcli.roster import Roster
|
||||
from pqcli.ui.curses.event_handler import EventHandler
|
||||
from pqcli.ui.curses.util import KEYS_DOWN, KEYS_LEFT, KEYS_RIGHT, KEYS_UP
|
||||
@@ -87,6 +87,22 @@ class GameView(BaseView):
|
||||
elif focused == self._inventory_win:
|
||||
self.focus(self._quest_book_win)
|
||||
|
||||
elif self._args.cheats and key == ord("t"):
|
||||
self._simulation.tick()
|
||||
|
||||
elif self._args.cheats and key == ord("T"):
|
||||
for _ in range(100):
|
||||
self._simulation.tick()
|
||||
|
||||
elif self._args.cheats and key == curses.ascii.DC4: # ^t
|
||||
old = SignalMixin.emit
|
||||
SignalMixin.emit = lambda *_: None
|
||||
for _ in range(10000):
|
||||
self._simulation.tick()
|
||||
SignalMixin.emit = old
|
||||
for child in self._children:
|
||||
child.sync()
|
||||
|
||||
else:
|
||||
super().keypress(key)
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ class CharacterSheetWindow(Focusable, DataTableProgressBarWindow):
|
||||
self._player.stats.connect("change", self._sync_traits)
|
||||
self._player.exp_bar.connect("change", self._sync_exp)
|
||||
|
||||
self._sync()
|
||||
self.sync()
|
||||
|
||||
def stop(self) -> None:
|
||||
super().stop()
|
||||
@@ -38,7 +38,7 @@ class CharacterSheetWindow(Focusable, DataTableProgressBarWindow):
|
||||
self._player.stats.disconnect("change", self._sync_traits)
|
||||
self._player.exp_bar.disconnect("change", self._sync_exp)
|
||||
|
||||
def _sync(self) -> None:
|
||||
def sync(self) -> None:
|
||||
self._sync_traits()
|
||||
self._sync_exp()
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ class EquipmentWindow(Focusable, WindowWrapper):
|
||||
self._player = player
|
||||
self._player.equipment.connect("change", self.sync_equipment_change)
|
||||
|
||||
self._sync()
|
||||
self.sync()
|
||||
|
||||
def stop(self) -> None:
|
||||
super().stop()
|
||||
@@ -26,7 +26,7 @@ class EquipmentWindow(Focusable, WindowWrapper):
|
||||
|
||||
self._player.equipment.disconnect("change", self.sync_equipment_change)
|
||||
|
||||
def _sync(self) -> None:
|
||||
def sync(self) -> None:
|
||||
self._data_table.clear()
|
||||
for equipment_type in EquipmentType:
|
||||
self._data_table.add(
|
||||
|
||||
@@ -39,7 +39,7 @@ class InventoryWindow(Focusable, DataTableProgressBarWindow):
|
||||
"change", self._sync_encumbrance
|
||||
)
|
||||
|
||||
self._sync()
|
||||
self.sync()
|
||||
|
||||
def stop(self) -> None:
|
||||
super().stop()
|
||||
@@ -63,7 +63,7 @@ class InventoryWindow(Focusable, DataTableProgressBarWindow):
|
||||
self._data_table.scroll_page_down()
|
||||
self._render()
|
||||
|
||||
def _sync(self) -> None:
|
||||
def sync(self) -> None:
|
||||
self._sync_gold()
|
||||
self._sync_items()
|
||||
self._sync_encumbrance()
|
||||
|
||||
@@ -22,7 +22,7 @@ class PlotWindow(Focusable, ListBoxProgressBarWindow):
|
||||
self._player.quest_book.connect("start_act", self._sync_act_add)
|
||||
self._player.quest_book.plot_bar.connect("change", self._sync_position)
|
||||
|
||||
self._sync()
|
||||
self.sync()
|
||||
|
||||
def stop(self) -> None:
|
||||
super().stop()
|
||||
@@ -41,7 +41,7 @@ class PlotWindow(Focusable, ListBoxProgressBarWindow):
|
||||
self._list_box.scroll_page_down()
|
||||
self._render()
|
||||
|
||||
def _sync(self) -> None:
|
||||
def sync(self) -> None:
|
||||
self._sync_acts()
|
||||
self._sync_position()
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ class QuestBookWindow(Focusable, ListBoxProgressBarWindow):
|
||||
"change", self._sync_position
|
||||
)
|
||||
|
||||
self._sync()
|
||||
self.sync()
|
||||
|
||||
def stop(self) -> None:
|
||||
super().stop()
|
||||
@@ -40,7 +40,7 @@ class QuestBookWindow(Focusable, ListBoxProgressBarWindow):
|
||||
self._list_box.scroll_page_down()
|
||||
self._render()
|
||||
|
||||
def _sync(self) -> None:
|
||||
def sync(self) -> None:
|
||||
self._sync_quests()
|
||||
self._sync_position()
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ class SpellBookWindow(Focusable, WindowWrapper):
|
||||
self._player.spell_book.connect("add", self._sync_spell_add)
|
||||
self._player.spell_book.connect("change", self._sync_spell_change)
|
||||
|
||||
self._sync()
|
||||
self.sync()
|
||||
|
||||
def stop(self) -> None:
|
||||
super().stop()
|
||||
@@ -37,7 +37,7 @@ class SpellBookWindow(Focusable, WindowWrapper):
|
||||
self._data_table.scroll_page_down()
|
||||
self._render()
|
||||
|
||||
def _sync(self) -> None:
|
||||
def sync(self) -> None:
|
||||
self._data_table.clear()
|
||||
for spell in self._player.spell_book:
|
||||
self._data_table.add(spell.name, to_roman(spell.level))
|
||||
|
||||
@@ -24,8 +24,7 @@ class TaskProgressWindow(Focusable, WindowWrapper):
|
||||
self._player.connect("new_task", self._sync_task_name)
|
||||
self._player.task_bar.connect("change", self._sync_position)
|
||||
|
||||
self._sync_task_name()
|
||||
self._sync_position()
|
||||
self.sync()
|
||||
|
||||
def stop(self) -> None:
|
||||
super().stop()
|
||||
@@ -36,6 +35,10 @@ class TaskProgressWindow(Focusable, WindowWrapper):
|
||||
self._player.disconnect("new_task", self._sync_task_name)
|
||||
self._player.task_bar.disconnect("change", self._sync_position)
|
||||
|
||||
def sync(self) -> None:
|
||||
self._sync_task_name()
|
||||
self._sync_position()
|
||||
|
||||
def _sync_task_name(self) -> None:
|
||||
self._desc_win.set_text(
|
||||
f"{self._player.task.description}..." if self._player.task else "?"
|
||||
|
||||
Reference in New Issue
Block a user