mirror of
https://github.com/rr-/pq-cli.git
synced 2026-09-29 06:44:00 -06:00
ui: address pylint complaints
This commit is contained in:
+2
-2
@@ -2,8 +2,8 @@ import random
|
|||||||
import typing as T
|
import typing as T
|
||||||
|
|
||||||
|
|
||||||
def seed(seed: T.Any) -> None:
|
def seed(source: T.Any) -> None:
|
||||||
random.seed(seed)
|
random.seed(source)
|
||||||
|
|
||||||
|
|
||||||
def choice(source: T.Iterable[T.Any]) -> T.Any:
|
def choice(source: T.Iterable[T.Any]) -> T.Any:
|
||||||
|
|||||||
+16
-13
@@ -8,17 +8,6 @@ from pqcli.ui.new_game_view import NewGameView
|
|||||||
from pqcli.ui.roster_view import RosterView
|
from pqcli.ui.roster_view import RosterView
|
||||||
|
|
||||||
|
|
||||||
for key, direction in {
|
|
||||||
"k": "up",
|
|
||||||
"j": "down",
|
|
||||||
"h": "left",
|
|
||||||
"l": "right",
|
|
||||||
}.items():
|
|
||||||
for key_variant in {key, key.upper()}:
|
|
||||||
urwid.command_map[key_variant] = f"cursor {direction}"
|
|
||||||
urwid.command_map["tab"] = f"cursor down"
|
|
||||||
urwid.command_map["shift tab"] = f"cursor up"
|
|
||||||
|
|
||||||
PALETTE: T.List[T.Tuple[str, str, str]] = [
|
PALETTE: T.List[T.Tuple[str, str, str]] = [
|
||||||
("button", "", ""),
|
("button", "", ""),
|
||||||
("button-focus", "light red", "black"),
|
("button-focus", "light red", "black"),
|
||||||
@@ -29,8 +18,23 @@ PALETTE: T.List[T.Tuple[str, str, str]] = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def bind_commands() -> None:
|
||||||
|
for key, direction in {
|
||||||
|
"k": "up",
|
||||||
|
"j": "down",
|
||||||
|
"h": "left",
|
||||||
|
"l": "right",
|
||||||
|
}.items():
|
||||||
|
for key_variant in {key, key.upper()}:
|
||||||
|
urwid.command_map[key_variant] = f"cursor {direction}"
|
||||||
|
urwid.command_map["tab"] = f"cursor down"
|
||||||
|
urwid.command_map["shift tab"] = f"cursor up"
|
||||||
|
|
||||||
|
|
||||||
class Ui:
|
class Ui:
|
||||||
def __init__(self, roster: Roster) -> None:
|
def __init__(self, roster: Roster) -> None:
|
||||||
|
bind_commands()
|
||||||
|
|
||||||
self.roster = roster
|
self.roster = roster
|
||||||
self.loop = urwid.MainLoop(
|
self.loop = urwid.MainLoop(
|
||||||
None, PALETTE, unhandled_input=self.unhandled_input
|
None, PALETTE, unhandled_input=self.unhandled_input
|
||||||
@@ -57,7 +61,6 @@ class Ui:
|
|||||||
def switch_to_roster_view(self) -> None:
|
def switch_to_roster_view(self) -> None:
|
||||||
self.loop.widget = RosterView(
|
self.loop.widget = RosterView(
|
||||||
self.roster,
|
self.roster,
|
||||||
self.loop,
|
|
||||||
on_exit=self.switch_to_exit_view,
|
on_exit=self.switch_to_exit_view,
|
||||||
on_new_game=self.switch_to_new_game_view,
|
on_new_game=self.switch_to_new_game_view,
|
||||||
on_resume_game=self.switch_to_game_view,
|
on_resume_game=self.switch_to_game_view,
|
||||||
@@ -76,7 +79,7 @@ class Ui:
|
|||||||
)
|
)
|
||||||
|
|
||||||
def switch_to_game_view(self, player_name: str) -> None:
|
def switch_to_game_view(self, player_name: str) -> None:
|
||||||
...
|
raise NotImplementedError("not implemented")
|
||||||
|
|
||||||
def exit(self) -> None:
|
def exit(self) -> None:
|
||||||
raise urwid.ExitMainLoop()
|
raise urwid.ExitMainLoop()
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import typing as T
|
|||||||
|
|
||||||
import urwid
|
import urwid
|
||||||
|
|
||||||
from pqcli.mechanic import Roster
|
|
||||||
from pqcli.ui.button import MenuButton
|
from pqcli.ui.button import MenuButton
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -15,4 +15,4 @@ class LineBox(urwid.AttrWrap):
|
|||||||
),
|
),
|
||||||
"linebox",
|
"linebox",
|
||||||
"linebox-focus",
|
"linebox-focus",
|
||||||
),
|
)
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import urwid
|
|||||||
import urwid_readline
|
import urwid_readline
|
||||||
|
|
||||||
from pqcli.config import CLASSES, PRIME_STATS, RACES
|
from pqcli.config import CLASSES, PRIME_STATS, RACES
|
||||||
from pqcli.mechanic import Stats, StatsBuilder, generate_name
|
from pqcli.mechanic import StatsBuilder, generate_name
|
||||||
from pqcli.ui.button import MenuButton
|
from pqcli.ui.button import MenuButton
|
||||||
from pqcli.ui.line_box import LineBox
|
from pqcli.ui.line_box import LineBox
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ class RosterView(urwid.Filler):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
roster: Roster,
|
roster: Roster,
|
||||||
loop: urwid.MainLoop,
|
|
||||||
on_new_game: T.Callable,
|
on_new_game: T.Callable,
|
||||||
on_resume_game: T.Callable,
|
on_resume_game: T.Callable,
|
||||||
on_exit: T.Callable,
|
on_exit: T.Callable,
|
||||||
|
|||||||
Reference in New Issue
Block a user