mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 10:46:17 +00:00
基础的数值计算
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
import { TD } from "../../../../App";
|
||||
import GAttributeBase from "./GAttributeBase";
|
||||
|
||||
//属性类型
|
||||
export enum GAttributeType{
|
||||
Attack = 110001, //攻击
|
||||
Defend = 110002, //防御
|
||||
Blood = 110003, //血量
|
||||
}
|
||||
|
||||
//属性类
|
||||
export default class GAttribute {
|
||||
|
||||
attributes:GAttributeBase[] = [];
|
||||
|
||||
//属性最终信息 {属性Id:属性值}
|
||||
info:{[key:number]:number} = {};
|
||||
|
||||
//添加一个属性类
|
||||
add(info:GAttributeBase){
|
||||
this.attributes.push(info);
|
||||
}
|
||||
|
||||
//重置
|
||||
reset(){
|
||||
this.attributes = [];
|
||||
this.update();
|
||||
}
|
||||
|
||||
//刷新属性
|
||||
update(){
|
||||
|
||||
this.info = {};
|
||||
|
||||
TD.TbGAttribute.getDataList().forEach(attr => {
|
||||
//初始化属性
|
||||
this.info[attr.id] = 0;
|
||||
});
|
||||
|
||||
//累加全部属性
|
||||
this.attributes.forEach((attribute) => {
|
||||
attribute.update();
|
||||
for (const key in attribute.attributes) {
|
||||
if(this.info[key]){
|
||||
this.info[key] = this.info[key] + attribute.attributes[key];
|
||||
}else{
|
||||
this.info[key] = attribute.attributes[key];
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "72467729-defa-485b-bd75-3bbe791ebea3",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
|
||||
//属性 基类
|
||||
export default abstract class GAttributeBase{
|
||||
|
||||
//属性 {属性Id:属性值}
|
||||
attributes:{[key:number]:number} = {};
|
||||
|
||||
//刷新属性
|
||||
abstract update();
|
||||
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "a0ef91dd-110a-4622-8a6d-4c16a6255d5f",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "54170ba9-5142-4612-9335-28436a7ddc08",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
import { TD } from "../../../../../App";
|
||||
import { PlayerPetOV } from "../../../../../consts/API";
|
||||
import GAttributeBase from "../GAttributeBase";
|
||||
|
||||
//宠物属性
|
||||
export default class GPetAttribute extends GAttributeBase{
|
||||
|
||||
//宠物信息
|
||||
pet:PlayerPetOV;
|
||||
|
||||
constructor(pet:PlayerPetOV){
|
||||
|
||||
super();
|
||||
this.pet = pet;
|
||||
|
||||
//固定属性直接计算
|
||||
this.compute();
|
||||
|
||||
}
|
||||
|
||||
//计算属性
|
||||
compute(){
|
||||
|
||||
this.attributes = {};
|
||||
//*************** 宠物初始属性 **************************
|
||||
let baseAttribute = TD.TbGRoleBaseAttribute.get(this.pet.petTbId) || TD.TbGRoleBaseAttribute.get(0);
|
||||
|
||||
//获取全部属性信息
|
||||
TD.TbGAttribute.getDataList().forEach(attr => {
|
||||
//保存初始属性 如果没有默认 0
|
||||
this.attributes[attr.id] = baseAttribute[attr.sign] || 0;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
//刷新属性
|
||||
update(): void { }
|
||||
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "a66f3d1e-b975-4cf3-a666-54194eeda220",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
Reference in New Issue
Block a user