All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 # flags: --minimum-version=3.10
2 # Cases sampled from PEP 636 examples
6 ... # interpret action, obj
10 ... # interpret single-verb action
12 ... # interpret action, obj
14 match command.split():
19 current_room.describe()
21 character.get(obj, current_room)
22 case ["go", direction]:
23 current_room = current_room.neighbor(direction)
24 # The rest of your commands go here
26 match command.split():
27 case ["drop", *objects]:
29 character.drop(obj, current_room)
30 # The rest of your commands go here
32 match command.split():
35 case ["go", direction]:
36 print("Going:", direction)
37 case ["drop", *objects]:
38 print("Dropping: ", *objects)
40 print(f"Sorry, I couldn't understand {command!r}")
42 match command.split():
43 case ["north"] | ["go", "north"]:
44 current_room = current_room.neighbor("north")
45 case ["get", obj] | ["pick", "up", obj] | ["pick", obj, "up"]:
46 ... # Code for picking up the given object
48 match command.split():
49 case ["go", ("north" | "south" | "east" | "west")]:
50 current_room = current_room.neighbor(...)
51 # how do I know which direction to go?
53 match command.split():
54 case ["go", ("north" | "south" | "east" | "west") as direction]:
55 current_room = current_room.neighbor(direction)
57 match command.split():
58 case ["go", direction] if direction in current_room.exits:
59 current_room = current_room.neighbor(direction)
61 print("Sorry, you can't go that way")
64 case Click(position=(x, y)):
66 case KeyPress(key_name="Q") | Quit():
68 case KeyPress(key_name="up arrow"):
71 pass # Ignore other keystrokes
73 raise ValueError(f"Unrecognized event: {other_event}")
76 case Click((x, y), button=Button.LEFT): # This is a left click
79 pass # ignore other clicks
91 print("Somewhere else")