summaryrefslogtreecommitdiffstats
path: root/Potion.py
blob: f63d6ef4f4c949311bee51d4597e2f99a9d2b042 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from Setup import *
import threading

class Potion:
    
    def __init__(self, player, heal_amount = 25):
        self.heal = heal_amount
        self.player = player

    def get_input(self, player):
        pressed_key = pg.key.get_pressed()
        if pressed_key[pg.K_1] and player.potion_cooldown == 0:
            self.consume_potion(player)
    
    def consume_potion(self, player):
        pg.mixer.Sound.play(player.potion_drink_sound)
        player.health += self.heal
        if player.health > 100:
            player.health = 100
            
        del self.player.potion_bag[0]
        self.player.potion_cooldown = 4
        threading.Thread(target = self.player.potion_cooldown_timer).start()