From 15e188b9f27c488ac121fb85d9509df540720183 Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Sat, 7 May 2022 11:57:08 -0700 Subject: [PATCH] Convert the keysym matching to match/case from if/elif --- roguebasin/events.py | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/roguebasin/events.py b/roguebasin/events.py index 49ecc1f..d729567 100644 --- a/roguebasin/events.py +++ b/roguebasin/events.py @@ -19,24 +19,24 @@ class EventHandler(tcod.event.EventDispatch[Action]): action: Optional[Action] = None sym = event.sym - - if sym == tcod.event.KeySym.b: - action = BumpAction(Direction.SouthWest) - elif sym == tcod.event.KeySym.h: - action = BumpAction(Direction.West) - elif sym == tcod.event.KeySym.j: - action = BumpAction(Direction.South) - elif sym == tcod.event.KeySym.k: - action = BumpAction(Direction.North) - elif sym == tcod.event.KeySym.l: - action = BumpAction(Direction.East) - elif sym == tcod.event.KeySym.n: - action = BumpAction(Direction.SouthEast) - elif sym == tcod.event.KeySym.u: - action = BumpAction(Direction.NorthEast) - elif sym == tcod.event.KeySym.y: - action = BumpAction(Direction.NorthWest) - elif sym == tcod.event.KeySym.SPACE: - action = RegenerateRoomsAction() + match sym: + case tcod.event.KeySym.b: + action = BumpAction(Direction.SouthWest) + case tcod.event.KeySym.h: + action = BumpAction(Direction.West) + case tcod.event.KeySym.j: + action = BumpAction(Direction.South) + case tcod.event.KeySym.k: + action = BumpAction(Direction.North) + case tcod.event.KeySym.l: + action = BumpAction(Direction.East) + case tcod.event.KeySym.n: + action = BumpAction(Direction.SouthEast) + case tcod.event.KeySym.u: + action = BumpAction(Direction.NorthEast) + case tcod.event.KeySym.y: + action = BumpAction(Direction.NorthWest) + case tcod.event.KeySym.SPACE: + action = RegenerateRoomsAction() return action