forked from chrisowensdev/terminal-kombat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
145 lines (121 loc) · 3.8 KB
/
main.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
import random
import time
from text import story, title, fight_text, game_over, fatality, loading, ending_story, choose
from classes import Character
from functions import player_selection, ending, character_list, sound, player_defeated, opponent_dead_action
import sys
# Music
from pygame import mixer
mixer.init()
mixer.music.load("audio/TK_Intro_2.wav")
mixer.music.play(-1)
def keep_playing():
while len(opponent_list) >= 1:
keep_playing = input("Do you want to keep fighting? (y or n) ")
if keep_playing == 'y':
player.health = 50
print("\nYou have absorbed power from your opponent!")
print("You're back to Full Health: %d \n" % (player.health))
print("Your next opponent is: %s" % (opponent_list[0]))
play_list.pop(0)
for num in play_list:
if num == play_list[0]:
sound("round" + num + ".wav")
time.sleep(2)
fight_text()
sound("fight.wav")
fight()
elif keep_playing == 'n':
print("Quitters never win!\n\n")
sound("laugh.wav")
game_over()
sys.exit(0)
else:
sound("gong.wav")
print("Typing is hard, yo!\n")
def attack(type, opponent_list):
# Player attacks opponent
type(opponent_list[0])
# mixer.Sound.play(special_se)
time.sleep(1.5)
if opponent_list[0].is_alive() == False:
opponent_dead_action(opponent_list)
if len(opponent_list) >= 1:
keep_playing()
play_list.pop(0)
else:
ending()
# Game Fight function
def fight():
while opponent_list[0].health > 0 and player.health > 0:
if opponent_list[0].health < 15:
if opponent_list[0].sex == "F":
sound("finish_her.wav")
else:
sound("finish_him.wav")
print("\nWhat do you want to do?")
print("1. Kick")
print("2. Punch")
print("3. %s" % (player.special_name))
print("4. Flee")
print(">>> ",)
user_input = input()
# Kick
if user_input == "1":
attack(player.kick, opponent_list)
# Punch
elif user_input == "2":
attack(player.punch, opponent_list)
# Special
elif user_input == "3":
attack(player.special, opponent_list)
# RUN AWAY!!!!
elif user_input == "4":
print("QUITTERS NEVER WIN!")
sound("laugh.wav")
time.sleep(3)
sys.exit(0)
else:
sound("gong.wav")
print(
"Your keyboard skills need some work! You missed your chance to attack!\n")
time.sleep(1.5)
# Computer ATTACKS!
if player.health > 0:
# Opponent attacks player
opponent_list[0].rand_attack(player)
if player.is_alive() == False:
player_defeated(player)
# print title screen
title()
time.sleep(2)
sound("gong.wav")
input("Press enter to continue\n \n \n")
choose()
player = player_selection()
character_list = character_list()
opponent_list = []
for character in character_list:
if player != character:
opponent_list.append(character)
play_list = ['1', '2', '3', '4', '5', '6', '7', '8']
# when user selects a character, it moves remaining characters to opponents list for battle
print("You have choosen %s" % (player))
sound("excellent.wav")
print()
time.sleep(1)
story()
time.sleep(3)
sound("test_your_luck.wav")
ready = input("\nAre you ready to fight? (y or n) ")
if ready == "y":
print("\nGET READY!\n")
sound("round1.wav")
else:
print("\nToo bad! Time to fight!\n")
sound("laugh.wav")
print("\nYour first opponent is: %s" % (opponent_list[0]))
time.sleep(2)
fight_text()
sound("fight.wav")
fight()