2022-03-30 08:33:56 +00:00
|
|
|
---@class Player : Object
|
2022-04-01 12:51:01 +00:00
|
|
|
---@field hp integer
|
|
|
|
---@field maxHp integer
|
|
|
|
---@field kingdom string
|
|
|
|
---@field role string
|
|
|
|
---@field general string
|
|
|
|
---@field handcard_num integer
|
|
|
|
---@field seat integer
|
|
|
|
---@field phase Phase
|
|
|
|
---@field faceup boolean
|
|
|
|
---@field chained boolean
|
|
|
|
---@field dying boolean
|
|
|
|
---@field dead boolean
|
|
|
|
---@field state string
|
|
|
|
---@field player_skills Skill[]
|
2022-03-27 06:49:41 +00:00
|
|
|
local Player = class("Player")
|
2022-03-25 04:28:07 +00:00
|
|
|
|
2022-04-01 12:51:01 +00:00
|
|
|
---@alias Phase integer
|
|
|
|
|
|
|
|
Player.RoundStart = 1
|
|
|
|
Player.Start = 2
|
|
|
|
Player.Judge = 3
|
|
|
|
Player.Draw = 4
|
|
|
|
Player.Play = 5
|
|
|
|
Player.Discard = 6
|
|
|
|
Player.Finish = 7
|
|
|
|
Player.NotActive = 8
|
|
|
|
Player.PhaseNone = 9
|
|
|
|
|
2022-03-25 04:28:07 +00:00
|
|
|
function Player:initialize()
|
2022-03-28 14:24:30 +00:00
|
|
|
self.hp = 0
|
|
|
|
self.maxHp = 0
|
|
|
|
self.kingdom = "qun"
|
|
|
|
self.role = ""
|
|
|
|
self.general = ""
|
|
|
|
self.handcard_num = 0
|
|
|
|
self.seat = 0
|
|
|
|
self.phase = Player.PhaseNone
|
|
|
|
self.faceup = true
|
|
|
|
self.chained = false
|
2022-03-25 04:28:07 +00:00
|
|
|
self.dying = false
|
|
|
|
self.dead = false
|
2022-03-30 06:14:40 +00:00
|
|
|
self.state = ""
|
2022-04-01 12:51:01 +00:00
|
|
|
|
|
|
|
self.player_skills = {}
|
2022-03-25 04:28:07 +00:00
|
|
|
end
|
|
|
|
|
2022-03-31 05:29:23 +00:00
|
|
|
---@param general General
|
|
|
|
---@param setHp boolean
|
|
|
|
---@param addSkills boolean
|
2022-03-25 04:28:07 +00:00
|
|
|
function Player:setGeneral(general, setHp, addSkills)
|
|
|
|
self.general = general
|
|
|
|
if setHp then
|
|
|
|
self.maxHp = general.maxHp
|
2022-03-31 05:29:23 +00:00
|
|
|
self.hp = general.hp
|
2022-03-25 04:28:07 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
if addSkills then
|
|
|
|
table.insertTable(self.playerSkills, general.skills)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-03-27 06:49:41 +00:00
|
|
|
return Player
|