mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-10-09 00:26:11 +00:00
提交开宝箱
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
import { TD, app } from "../../../App";
|
||||
import { PetEquip, PlayerPetOV } from "../../../consts/API";
|
||||
import GRoleValues from "./GRoleValues";
|
||||
import GAttribute from "./attribute/GAttribute";
|
||||
import GPetAttribute from "./attribute/role/GPetAttribute";
|
||||
import GPetEquipAttribute from "./attribute/role/GPetEquipAttribute";
|
||||
|
||||
//战斗传入数据
|
||||
export interface GBattleDataInfo{
|
||||
//宠物
|
||||
pets?:PlayerPetOV[],
|
||||
//宠物装备
|
||||
petEquips?:PetEquip[]
|
||||
}
|
||||
|
||||
export enum GBattleDataEnum{
|
||||
UPDATE = "GBattleData_UPDATE"
|
||||
}
|
||||
|
||||
//战斗数据类
|
||||
export default class GAttributeData{
|
||||
|
||||
info:GBattleDataInfo;
|
||||
isEmit:boolean;
|
||||
|
||||
constructor(info:GBattleDataInfo = {},isEmit:boolean = false){
|
||||
this.isEmit = isEmit;
|
||||
this.update(info);
|
||||
}
|
||||
|
||||
update(info:GBattleDataInfo){
|
||||
//初始化数据
|
||||
info.pets = info.pets || [];
|
||||
info.petEquips = info.petEquips || [];
|
||||
this.info = info;
|
||||
if(this.isEmit)
|
||||
app.event.emit(GBattleDataEnum.UPDATE)
|
||||
}
|
||||
|
||||
assets(info:GBattleDataInfo){
|
||||
Object.assign(this.info,info);
|
||||
if(this.isEmit)
|
||||
app.event.emit(GBattleDataEnum.UPDATE)
|
||||
}
|
||||
|
||||
//计算总战力数值
|
||||
getAllFC(){
|
||||
let fc = 0;
|
||||
Object.values(this.info.pets).forEach(pet => {
|
||||
let attribute = this.getPetAttribute(pet.petId);
|
||||
//计算战力
|
||||
fc += GAttributeData.FC(attribute);
|
||||
})
|
||||
return fc;
|
||||
}
|
||||
|
||||
//获取共享属性
|
||||
|
||||
//获取指定宠物的属性
|
||||
getPetAttribute(petId:number){
|
||||
let pet = this.info.pets.filter(item => item.petId == petId)[0];
|
||||
if(!pet) return new GAttribute();
|
||||
|
||||
let value = new GAttribute();
|
||||
value.add(new GPetAttribute(pet));
|
||||
value.add(new GPetEquipAttribute(this.info.petEquips.filter(item => item.equipPetId == petId)));
|
||||
value.update();
|
||||
|
||||
return value;
|
||||
|
||||
}
|
||||
|
||||
//根据属性计算战力
|
||||
static FC(info:GAttribute){
|
||||
|
||||
let fc = 0;
|
||||
|
||||
TD.TbGAttribute.getDataList().forEach(item => {
|
||||
let value = info.info[item.id] || 0;
|
||||
fc += TD.TbGAttributeFC.get(item.id).value * value;
|
||||
})
|
||||
|
||||
return fc;
|
||||
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user