-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathperson.lua
More file actions
54 lines (42 loc) · 924 Bytes
/
person.lua
File metadata and controls
54 lines (42 loc) · 924 Bytes
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
require "gameVal"
--person.lua
local oo = require "loop.base"
local Person = oo.class{}
function Person:OnFightTurn(turn)
--for npc do ai!
print(self.name,turn,self:GetHP())
end
function Person:OnFightEnd()
--for npc do ai!
print(self.name,turn,'OnFightEnd')
end
function Person:OnFightTurnObs(turn)
--for npc do ai!
print(self.name,'OnFightTurnObs')
end
function Person:IsDie()
return self:GetHP() <= 0
end
function Person:GetHP()
return csv_get_value(self,val_life)
end
function Person:SetHP(value)
return csv_set_value(self,val_life,value)
end
function Person:OnDamage(hp)
self:SetHP(self:GetHP() - hp)
end
function Person:Init()
self:SetHP(csv_get_value(self,val_life_max))
end
--得到当前指令的speed
function Person:GetFightCmdSpeed()
return 10
end
function init_person(n,csv,level)
local p = Person{name = n}
csv_init(p,csv)
csv_change_value(p,val_level,level)
p:Init()
return p
end