-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
164 lines (131 loc) · 7.03 KB
/
main.py
File metadata and controls
164 lines (131 loc) · 7.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# Written by Aaron Douglass and Kane McCrory
import random
class Suspect:
def __init__(self, name, occupation, is_guilty=False):
self.alibi = None
self.name = name
self.occupation = occupation
self.is_guilty = is_guilty
def talk(self):
# Student Task: Make the dialogue change if they are guilty!
return print(f"{self.name} - ({self.occupation}): {self.alibi}")
def intro(self):
return print(f"{self.name} - ({self.occupation})")
class MysteryGame:
suspect_names = []
suspect_occupations = []
# Storage of Random Alibis for each character that also include hidden clues
captain_alibis = [
"I was on the bridge reviewing the navigation charts and consulting Officer Miller on our destination.",
"I was in my personal cabin making an urgent phone call to Chef Pierre about dinner arrangements.",
"I was in my bathroom sick. I think I got food poisoning!",
"I was in a safety drill with Officer Miller and Dr. Aris on Deck 3.",
"I was on the bridge. I had to move an out of place crowbar when I realized someone had broken the compass!", #Guilty
"I was talking on the phone with port security, when I had to duck out briefly to swing by the maintenance closet." #Guilty - sometimes
]
chef_alibis = [
"I was in ze kitchen preparing ze toothfish and my delicious, legendary, incredible sourdough bread!",
"I was talking with ze Captain Sterling, and he requested that I make him some stew.",
"I was contacting ze doctor that our captain is sick, and it was definitely not ze fault of me!",
"I saw a a a rat in my hat guiding my actions to create ratatouille and... something else. That'ze all I remember.", #Guilty
"I was using the restroom to wash ze hands near the bridge and saw the doctor leaving frantically.",
"I heard about ze Captain's condition, and I sent to talk to him myself! I headed to see him on ze bridge." #Guilty
]
doctor_alibis = [
"I was treating thy fellow crew member to relieve them of a cut on their poor leg.",
"I was speaking with thy Officer Miller on thy condition of my dear office! He left quite a mess!",
"I spoke with thy Chef about Captain Sterling's condition, and he fears it was thy stew that he hadeth prepared.",
"I was in a safety drill with thy fellows Officer Miller and Captain Sterling.",
"I was walking near the bridge and saw Chef Pierre go into the restroom.", #Guilty
"I was treating a patient, and I had to run to my supply closet to get more medicine." #Guilty
]
security_alibis = [
"I was hanging around on that them there bridge with Captain Sterling talking bout them navigation charts.",
"I had to borrow them there a crowbar to fix one of them doors that was stuck, couldn't find the WD-40.", #Guilty
"I heard that the Chef got the Captain sick, seems kinda suspecious to these old eyes, might want to check them two fellers out. *steps away*", #Guilty
"I seen that Chef actin' strangely down in the kitchen when I headed to the safety drill he didn't show up either.",
"I saw them there Doc running down the deck and said 'Woah there, slow the horses down' and he didn't like that.",
"I heard some crowbar messed up the compass, but honestly I think that the Captain did it to his own ship."
]
def __init__(self):
self.suspects = [
Suspect("Captain Sterling", "Captain"),
Suspect("Chef Pierre", "Executive Chef"),
Suspect("Dr. Aris", "Ship Doctor"),
Suspect("Officer Miller", "Security")
]
for s in self.suspects:
self.suspect_names.append(s.name)
self.suspect_occupations.append(s.occupation)
self.killer = None
self.attempted = 0
def setup_game(self):
# Randomly assign the saboteur
self.killer = random.choice(self.suspects)
self.killer.is_guilty = True
if self.killer.occupation == "Captain":
num = random.choice([4, 5])
self.killer.alibi = self.captain_alibis[num]
self.suspects[1].alibi = self.chef_alibis[random.choice([0, 1])]
self.suspects[2].alibi = self.doctor_alibis[random.choice([0, 1])]
self.suspects[3].alibi = self.security_alibis[random.choice([4, 5])]
if self.killer.occupation == "Executive Chef":
num = random.choice([3, 5])
self.killer.alibi = self.chef_alibis[num]
self.suspects[0].alibi = self.captain_alibis[random.choice([0, 2, 3])]
self.suspects[2].alibi = self.doctor_alibis[random.choice([0, 1, 3])]
self.suspects[3].alibi = self.security_alibis[random.choice([0, 3])]
if self.killer.occupation == "Ship Doctor":
num = random.choice([4, 5])
self.killer.alibi = self.doctor_alibis[num]
self.suspects[0].alibi = self.captain_alibis[random.choice([0, 1, 2])]
self.suspects[1].alibi = self.chef_alibis[random.choice([0, 1, 4])]
self.suspects[3].alibi = self.security_alibis[random.choice([0, 4, 5])]
else:
num = random.choice([1, 2])
self.killer.alibi = self.security_alibis[num]
self.suspects[0].alibi = self.captain_alibis[random.choice([0, 1, 2])]
self.suspects[1].alibi = self.chef_alibis[random.choice([0, 1, 2])]
self.suspects[2].alibi = self.doctor_alibis[random.choice([1])]
def play(self):
print("--- CRUISE SHIP MYSTERY: THE BROKEN COMPASS ---")
print("Someone sabotaged the ship's bridge! You have 3 questions.")
# Student Task: Create the game loop here
# 1. Show list of suspects
for s in self.suspects:
s.intro()
# 2. Take user input for who to interview
while self.attempted < 3:
suspect = self.get_suspect()
suspect.talk()
self.attempted += 1
# 4. Final Accusation Logic
print(f"Who would you like to accuse?")
accuse = input()
while accuse not in self.suspect_names:
print(f"{accuse} is not a valid accusation. Try Again.")
accuse = input()
if accuse != self.killer.name:
print(f"{accuse} is incorrect.")
print(f"{self.killer.name} was the saboteur.")
else:
print(f"{accuse} is correct. You Win!")
pass
def get_suspect(self):
cont = True
suspect = None
while cont:
print(f"Who would you like to interview? (Interview #{self.attempted + 1})")
text = input()
for s in self.suspects:
if s.name == text or s.occupation == text:
suspect = s
cont = False
break
if suspect is None:
print(f"{text} is not a valid suspect name or occupation. Try Again.")
return suspect
if __name__ == "__main__":
game = MysteryGame()
game.setup_game()
game.play()