-
Notifications
You must be signed in to change notification settings - Fork 1
/
object.py
115 lines (92 loc) · 2.57 KB
/
object.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
#coding:utf-8
# todo:完善基本对象接口需求
class ObjectNotFound:
pass
class BaseObject(object):
pass
class Detector(object):
def __init__(self):
self.maps = {1:Me}
def get(self, id):
if id in self.maps:
return self.maps[id]
else:
raise ObjectNotFound
class Me(object):
# todo:加入神经网络,模拟变异
def __init__(self, world, belong, id, coordinate, atk=0, gar=0, spd=0, car=0, sex=0, fld=0, is_base=False):
self.is_base = is_base
self.coordinate = coordinate
self.user_hash = belong
self.world = world # 处于哪个世界
self.type_id = 1
self.id = id
self.event = None
self.ATK = atk # 攻击力
self.bag = {}
self.GAR = gar # 防御力
self.SPD = spd # 速度
self.CAR = car # 运载力
self.SEX = sex # 性别
self.FLD = fld # 视野
def get_world(self):
return self.world
def set_coordinate(self,coordinate):
self.coordinate = coordinate
def get_coordinate(self):
return self.coordinate
def get_type(self):
return self.type_id
def get_event(self):
return self.event
def __calc_extra_attributes(self):
# 计算背包中装备对数值的加成
atk = self.ATK
gar = self.GAR
spd = self.SPD
car = self.CAR
sex = self.SEX
fld = self.FLD
if self.bag:
# calculate the equipment
pass
return {
"atk": atk,
"gar": gar,
"spd": spd,
"car": car,
"sex": sex,
"fld": fld
}
def attributes(self):
return {
"id": self.id,
"type": self.type_id,
"belong": self.user_hash,
"attribute": self.__calc_extra_attributes()
}
def stimulate(self, occurrence_direction, event):
# 外部接收到刺激
pass
def action(self, event=None):
# 记录事件
if event is None:
return self.event
else:
if self.event is not None:
old_event = self.event
self.event = event
return old_event
else:
self.event = event
return None
class Planet(object):
def __init__(self, id):
self.type_id = 2
self.id = id
self.store = 10000
self.water = 10000
def get_type(self):
return self.type_id
def action(self):
pass