generated from github/codespaces-blank
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path# Initialize game variables.py
130 lines (97 loc) · 4.07 KB
/
# Initialize game variables.py
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
# Initialize game variables
suitcases_collected = []
wallet_balance = 100
available_disks = ['A', 'B', 'C']
available_airports = ['Airport 1', 'Airport 2', 'Airport 3']
# Player 1 selects starting airport and flips a suitcase
current_player = 1
print("Player 1's turn.")
selected_airport = input("Select a starting airport (1, 2, or 3): ")
selected_airport_name = available_airports[int(selected_airport) - 1]
print("You selected", selected_airport_name)
suitcase_number = input("Select a suitcase to flip (1-10): ")
if suitcase_number == "Q":
print("Terminating the game. Thanks for playing!")
quit()
if suitcase_number == str(len(suitcases_collected) + 1):
print("You found suitcase number", suitcase_number)
suitcases_collected.append(suitcase_number)
else:
print("Sorry, that is not the suitcase you need.")
# Player 2 selects starting airport and flips a suitcase
current_player = 2
print("Player 2's turn.")
selected_airport = input("Select a starting airport (1, 2, or 3): ")
selected_airport_name = available_airports[int(selected_airport) - 1]
print("You selected", selected_airport_name)
suitcase_number = input("Select a suitcase to flip (1-10): ")
if suitcase_number == "Q":
print("Terminating the game. Thanks for playing!")
quit()
if suitcase_number == str(len(suitcases_collected) + 1):
print("You found suitcase number", suitcase_number)
suitcases_collected.append(suitcase_number)
else:
print("Sorry, that is not the suitcase you need.")
# Game continues until win or lose condition is met
while True:
# Alternate turns
if current_player == 1:
current_player = 2
else:
current_player = 1
print("Player", current_player, "'s turn.")
# Check for win condition
if len(suitcases_collected) == 10:
print("Congratulations, you have won the game!")
break
# Check for lose condition
if wallet_balance < 0 or not available_airports or not available_disks or wallet_balance < 50:
print("You have lost the game. Your opponent wins!")
break
# Check if player can move to a different airport
if len(suitcases_collected) > 0:
move_to_airport = input("Do you want to move to a different airport? (Y/N): ")
if move_to_airport.upper() == "Y":
print("Select an airport to move to:")
for index, airport in enumerate(available_airports):
print(index + 1, "-", airport)
selected_airport = input()
selected_airport_name = available_airports[int(selected_airport) - 1]
print("You moved to", selected_airport_name)
available_airports.remove(selected_airport_name)
# Check if player can use an obstacle disk
if len(available_disks) > 0:
use_disk = input("Do you want to use an obstacle disk? (Y/N): ")
if use_disk.upper() == "Y":
print("Select a disk to use:")
for index, disk in enumerate(available_disks):
print(index + 1, "-", disk)
while True:
play_game = input("Do you want to play a new game? (Y/N): ")
if play_game.upper() == "Y":
# code to start a new game goes here
print("Starting a new game...")
elif play_game.upper() == "N":
print("Exiting the game. Thanks for playing!")
break
elif play_game.upper() == "Q":
print("Terminating the program. Thanks for playing!")
quit()
else:
print("Invalid input. Please enter Y, N or Q.")
if game_mode == 1:
can_play_obstacle = True
can_ask_opponent_to_leave = True
elif game_mode == 2:
can_play_obstacle = False
can_ask_opponent_to_leave = False
# Assuming some conditions to check for can_fly and can_stay
if player_has_enough_fuel() and not player_is_at_maximum_altitude():
can_fly = True
else:
can_fly = False
if player_is_on_airport() and not player_has_used_all_turns():
can_stay = True
else:
can_stay = False