File size: 1,575 Bytes
0f3ad1b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import random

class Player:
    def __init__(self, name: str):
        self.name = name
        print(f"Player's Name is {name} and initialize all his attributes")
        self.hp = 75
        self.mp = 50
        self.coin = 20
        self.items = []
        self.frames = []

    def reduce_hp(self, amount: int):
        print(f'Reduce {amount} HP')
        self.hp = max(0, self.hp-amount)

    def add_hp(self, amount: int):
        print(f'Add {amount} HP')
        self.hp += amount

    def reduce_mp(self, amount: int):
        print(f'Reduce {amount} MP')
        self.mp = max(0, self.mp-amount)

    def add_mp(self, amount: int):
        print(f'Add {amount} MP')
        self.mp += amount

    def reduce_coin(self, amount: int):
        print(f'Reduce {amount} Coin')
        self.coin = max(0, self.coin-amount)

    def add_coin(self, amount: int):
        print(f'Add {amount} Coin')
        self.coin += amount

    def add_item(self, item):
        print(f'Add {item} to the item bag')
        self.items.append(item)

    def use_item(self, item):
        if item not in self.items:
            print(f'Could not use {item}')
        else:
            self.items.remove(item)
            print(f'Used up {item} and there are {len(item)} items left')

    def get_attribute(self) -> dict:
        return {'hp': self.hp, 'mp': self.mp, 'coin': self.coin}
    
    def set_name(self, name: str):
        self.name = name

    def append_file(self, filelist: list[str]):
        self.frames += filelist

    def get_images(self):
        return self.frames