-
Notifications
You must be signed in to change notification settings - Fork 0
/
Classes.py
149 lines (127 loc) · 6.23 KB
/
Classes.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
146
147
148
149
from typing import Annotated
import pygame
import os
import random
from pygame.key import get_pressed, key_code
from pygame.display import update
pygame.init()
#* Default Width and Height of Character (GOOD)
character_width, character_height = 50, 60
#* Default Width and Height of Characters (BAD)
character_width_b, character_height_b = 100, 85
class Item:
def __str__(self):
return self.name
def __init__(self, name, attack_boost=0, health_boost=0):
self.attack_boost = attack_boost
self.health_boost = health_boost
self.name = name
def use_health_potion(self, target):
target.health += self.health_boost
def use_spell(self, spell, target):
spell(target)
class Spell:
def __str__(self):
return self.name
def __init__(self, name):
self.name = name
def use_spell(self, target):
hit = random.choice([True, False, False, False])
if hit == True:
amount_to_append = int(random.randint(100,150))
target.attack_amount.append(amount_to_append)
if hit == False:
target.skip_turn = True
class BadGuy:
def __init__(self, name, health=0, character_width=100, character_height=85 ):
self.name = name
self.health = health
self.width = character_width
self.height = character_height
class EnemyMage(BadGuy):
def __init__(self, name, health=0):
super().__init__('')
bad_warrior_import = pygame.image.load(os.path.join('Assets', 'badwiz.png'))
bad_warrior = pygame.transform.scale(bad_warrior_import, (character_width_b, character_height_b))
self.print = bad_warrior
self.name = name
self.attack_amount = []
self.skip_turn = False
self.health = health
self.is_alive = True
self.max_hp = 1500
#! Bad Guy Attack Function
def attack(self, target):
if self.skip_turn == True:
return
else:
amount_to_append = random.randint(350, 650)
self.attack_amount.append(amount_to_append)
target.health -= amount_to_append
class GoodGuy:
def __init__(self, name, health=3000, character_width=100, character_height=85):
self.name = name
self.health = health
self.height = character_height
self.width = character_width
self.attack_amount = []
self.regen_amount = []
self.is_alive = True
# def use_item(item):
class Wizard(GoodGuy):
#* How it calls on the images to be looped
def update(self):
self.current_sprite += 1
if self.current_sprite >= len(self.walk_down):
self.current_sprite = 0
self.wizard_down = self.walk_down[self.current_sprite]
self.wizard_up = self.walk_up[self.current_sprite]
self.wizard_left = self.walk_left[self.current_sprite]
self.wizard_right = self.walk_right[self.current_sprite]
#! Good Guy Attack Functions
def fire_blast(self, target):
attack_amount = random.randint(200, 350)
self.attack_amount.append(attack_amount)
target.health -= attack_amount
def regeneration_spell(self):
regeneration_amount = random.randint(130, 200)
self.regen_amount.append(regeneration_amount)
self.health += regeneration_amount
def lightning_blast(self, target):
attack_amount = random.randint(350, 500)
self.attack_amount.append(attack_amount)
target.health -= attack_amount
#! __INIT__ Function
def __init__(self, name, health=0):
super().__init__('Pelso', 3000)
self.name = name
self.health = health
self.max_hp = 3000
self.inventory = []
#* Walking function for Wizard.
self.walk_left = []
self.walk_right =[]
self.walk_up = []
self.walk_down = []
self.walk_down.append(pygame.transform.scale(pygame.image.load(os.path.join('Assets', 'Wizard_facing.png')), (character_width, character_height)))
self.walk_down.append(pygame.transform.scale(pygame.image.load(os.path.join('Assets', 'Wizard_facing2.png')), (character_width, character_height)))
self.walk_down.append(pygame.transform.scale(pygame.image.load(os.path.join('Assets', 'Wizard_facing3.png')), (character_width, character_height)))
self.walk_left.append(pygame.transform.scale(pygame.image.load(os.path.join('Assets', 'Wizard_left1.png')), (character_width, character_height)))
self.walk_left.append(pygame.transform.scale(pygame.image.load(os.path.join('Assets', 'Wizard_left2.png')), (character_width, character_height)))
self.walk_left.append(pygame.transform.scale(pygame.image.load(os.path.join('Assets', 'Wizard_left3.png')), (character_width, character_height)))
self.walk_right.append(pygame.transform.scale(pygame.image.load(os.path.join('Assets', 'Wizard_right1.png')), (character_width, character_height)))
self.walk_right.append(pygame.transform.scale(pygame.image.load(os.path.join('Assets', 'Wizard_right2.png')), (character_width, character_height)))
self.walk_right.append(pygame.transform.scale(pygame.image.load(os.path.join('Assets', 'Wizard_right3.png')), (character_width, character_height)))
self.walk_up.append(pygame.transform.scale(pygame.image.load(os.path.join('Assets', 'Wizard_up1.png')), (character_width, character_height)))
self.walk_up.append(pygame.transform.scale(pygame.image.load(os.path.join('Assets', 'Wizard_up2.png')), (character_width, character_height)))
self.walk_up.append(pygame.transform.scale(pygame.image.load(os.path.join('Assets', 'Wizard_up3.png')), (character_width, character_height)))
good_wizard = pygame.transform.scale(pygame.image.load(os.path.join('Assets', 'Wizard_facing.png')), (character_width, character_height))#Where to find wizard
self.current_sprite = 0
self.wizard_down = self.walk_down[self.current_sprite]
self.wizard_up = self.walk_up[self.current_sprite]
self.wizard_left = self.walk_left[self.current_sprite]
self.wizard_right = self.walk_right[self.current_sprite]
self.print = good_wizard
#! Good Guy Use Items Function
def use_item(self, item, target):
return item(target)