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 # Cases sampled from PEP 636 examples
5 ... # interpret action, obj
9 ... # interpret single-verb action
11 ... # interpret action, obj
13 match command.split():
18 current_room.describe()
20 character.get(obj, current_room)
21 case ["go", direction]:
22 current_room = current_room.neighbor(direction)
23 # The rest of your commands go here
25 match command.split():
26 case ["drop", *objects]:
28 character.drop(obj, current_room)
29 # The rest of your commands go here
31 match command.split():
34 case ["go", direction]:
35 print("Going:", direction)
36 case ["drop", *objects]:
37 print("Dropping: ", *objects)
39 print(f"Sorry, I couldn't understand {command!r}")
41 match command.split():
42 case ["north"] | ["go", "north"]:
43 current_room = current_room.neighbor("north")
44 case ["get", obj] | ["pick", "up", obj] | ["pick", obj, "up"]:
45 ... # Code for picking up the given object
47 match command.split():
48 case ["go", ("north" | "south" | "east" | "west")]:
49 current_room = current_room.neighbor(...)
50 # how do I know which direction to go?
52 match command.split():
53 case ["go", ("north" | "south" | "east" | "west") as direction]:
54 current_room = current_room.neighbor(direction)
56 match command.split():
57 case ["go", direction] if direction in current_room.exits:
58 current_room = current_room.neighbor(direction)
60 print("Sorry, you can't go that way")
63 case Click(position=(x, y)):
65 case KeyPress(key_name="Q") | Quit():
67 case KeyPress(key_name="up arrow"):
70 pass # Ignore other keystrokes
72 raise ValueError(f"Unrecognized event: {other_event}")
75 case Click((x, y), button=Button.LEFT): # This is a left click
78 pass # ignore other clicks
90 print("Somewhere else")