2025-04-24 17:03:28 +08:00

198 lines
4.8 KiB
TypeScript

class Attr {
name = "" //姓名
sex = 0 // 性別 0女 1男
battle = false //是否參戰
qualitites = 0 //氣質
fame = 0 //名氣
endurance = 0 //耐力
moral = 0 //道德
intelligence = 0 //智力
rebel = 0 //叛逆
internalForce = 0 //內力
bosom = 0 //親密
filial = 0 // 孝心
foodFull = 0 //溫飽
busy = 0 //疲勞值
}
class Skill {
name: string
desp: string
grade: string
class: string
type: string
mod: string
id: number
level: number
pos: number
}
export default class Baby {
ID = 0 //todo:寶寶唯一識別ID
BattleSkillList: number[] = [] //天地人 012
PannelSkillList: number[] = [] //命盤技能
BlessSkillList: Skill[] = [] //已經許願的技能庫, 只在許願中保持技能副本,其它一律使用技能ID
Attr = new Attr()
UpdateData(data: any) {
this.Attr = data.attr
this.BattleSkillList = data.battleSkillList
this.PannelSkillList = data.pannelSkillList
this.BlessSkillList = data.blessSkillList
this.ID = data.id
}
GetObject(): any {
return {
id: this.ID,
attr: this.Attr,
battleSkillList: this.BattleSkillList,
pannelSkillList: this.PannelSkillList,
blessSkillList: this.BlessSkillList
}
}
GetSkillListByType(type: string): Skill[] {
let list = []
for (let index = 0; index < this.BlessSkillList.length; index++) {
let skill = this.BlessSkillList[index]
if (skill.type == type) {
list.push(skill)
}
}
return list
}
GetSkillByPos(pos: number): Skill {
for (let index = 0; index < this.BlessSkillList.length; index++) {
let skill = this.BlessSkillList[index];
if (skill.pos == pos) {
return skill
}
}
return null;
}
GetSkillByID(id: number): Skill {
for (let index = 0; index < this.BlessSkillList.length; index++) {
let skill = this.BlessSkillList[index];
if (skill.id == id) {
return skill
}
}
return null;
}
RemoveSkillByID(id: number) {
for (let index = 0; index < this.BlessSkillList.length; index++) {
let skill = this.BlessSkillList[index];
if (skill.id == id) {
this.BlessSkillList.splice(index, 1)
return
}
}
}
Bless(skill: Skill) {
for (let index = 0; index < this.PannelSkillList.length; index++) {
let id = this.PannelSkillList[index];
let _skill = this.GetSkillByID(id)
if (skill.pos == _skill.pos) {
_skill.pos = 0
this.PannelSkillList.splice(index, 1)
break
}
}
this.RemoveSkillByID(skill.id)
this.BlessSkillList.push(skill)
this.PannelSkillList.push(skill.id)
}
UpgradeSkill(skill: Skill) {
this.RemoveSkillByID(skill.id)
this.BlessSkillList.push(skill)
}
SkillBattle(skill: Skill) {
this.RemoveSkillByID(skill.id)
this.BlessSkillList.push(skill)
for (let index = 0; index < this.BattleSkillList.length; index++) {
let battle_id = this.BattleSkillList[index];
let battle_skill = this.GetSkillByID(battle_id)
if (skill.type == battle_skill.type) {
this.BattleSkillList.splice(index, 1)
break
}
}
this.BattleSkillList.push(skill.id)
}
GetScore(): number {
let list = ["qualitites", "fame", "endurance", "moral", "intelligence", "internalForce", "bosom", "filial"]
for (let index = 0; index < list.length; index++) {
let attr = list[index];
if (this.Attr[attr] < 300) {
return 0
}
}
for (let index = 0; index < list.length; index++) {
let attr = list[index];
if (this.Attr[attr] < 600) {
return 3000
}
}
for (let index = 0; index < list.length; index++) {
let attr = list[index];
if (this.Attr[attr] < 900) {
return 4000
}
}
return 5000
}
GetSkillBuff(): number {
let score = this.GetScore()
if (score == 0) {
return 0.05
}
if (score == 3000) {
return 0.1
}
if (score == 4000) {
return 0.15
}
return 0.2
}
GetIconID(): number {
if (this.ID == 0) {
return 6190
}
if (this.ID == 1) {
return 6222
}
if (this.ID == 2) {
return 6224
}
return 6190
}
}