-
Notifications
You must be signed in to change notification settings - Fork 0
/
Obj.py
79 lines (55 loc) · 2.06 KB
/
Obj.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
import os
import pygame
from Human import *
from abc import ABC, abstractmethod
class AbstractObj(ABC):
img = None
def __init__(self, need_item, colony_owner):
self.need_item = need_item
self.level = 1
self.health = 100
self.colony_owner = colony_owner
self.field = None
@abstractmethod
def level_up(self):
pass
def get_img(self):
return self.__class__.img
def get_type(self):
return self.__class__.__name__
def field_state(self, field):
self.field = field
class House(AbstractObj):
img = pygame.transform.rotate(
pygame.transform.scale(pygame.image.load(os.path.join('image', 'village_house.png')), (18, 18)), 0)
def __init__(self, colony_owner):
super().__init__({"Tree": 50}, colony_owner)
def level_up(self):
self.health += 50
self.need_item["Tree"] += 100
# def owner_human(self, human):
class Barn(AbstractObj):
img = pygame.transform.rotate(
pygame.transform.scale(pygame.image.load(os.path.join('image', 'barn.png')), (18, 18)), 0)
def __init__(self, colony_owner):
super().__init__({"Tree": 20}, colony_owner)
def level_up(self):
self.health += 50
self.need_item["Tree"] += 150
class Tavern(AbstractObj):
img = pygame.transform.rotate(
pygame.transform.scale(pygame.image.load(os.path.join('image', 'tavern.png')), (18, 18)), 0)
def __init__(self, colony_owner):
super().__init__({"Tree": 80, "Stone": 50}, colony_owner)
def level_up(self):
self.health += 50
self.need_item["Tree"] += 120
self.need_item["Stone"] += 60
class Farm(AbstractObj):
img = pygame.transform.rotate(
pygame.transform.scale(pygame.image.load(os.path.join('image', 'farm.png')), (18, 18)), 0)
def __init__(self, colony_owner):
super().__init__({"Tree": 15}, colony_owner)
def level_up(self):
self.health += 50
self.need_item["Tree"] += 20