// 关卡表 import {decodeArrayListStr, readWarJsonFileList} from '../util' import { ABI_TYPE } from '../../consts'; import { Attributes } from '../interface'; export interface DicWarJson { // 关卡id readonly warId: number; // 武将编号 readonly actorId: number; // 武将名字 readonly actorName: string; // 战场中指向该角色的唯一代码 readonly dataId: number; // 角色属于我方/敌方/友军 readonly relation: number; // 上阵时的方向 readonly direction: number; // 客户端存入数组的顺序 readonly outIndex: number; // x坐标 readonly x: number; // y坐标 readonly y: number; // 剧本中调用角色时的变量 readonly var: number; // 角色等级 readonly lv: number; // 是否隐藏 readonly hide: number; // 角色使用的AI类型 readonly initial_ai: number; // 属性 readonly attribute: Attributes; // 武将技能 readonly skill: string; // 武将被动技能 readonly seid: string; // 角色星级 readonly star: number; // s动画 readonly spine: string; // boss阶段 readonly bossStage: number; // 召唤技能的召唤物 readonly callSkillData: string; } export const dicWarJson = new Map>(); readWarJsonFileList().forEach(str => { let arr = JSON.parse(str); let warjson = new Array(); let warid = 0; arr.forEach(o => { o.attribute = parseAttribute(o.attribute); warid = o.warId; warjson.push(o); }); dicWarJson.set(warid, warjson); }) function parseAttribute(str: string) { let attribute: Attributes = {}; if(!str) return attribute; let arr = decodeArrayListStr(str); for(let [id, value] of arr) { if(isNaN(parseInt(id)) || isNaN(parseInt(value))) { throw new Error('data table format wrong'); } let _id = parseInt(id), _value = parseInt(value); switch(_id) { case ABI_TYPE.ABI_HP: attribute.hp = _value; break; case ABI_TYPE.ABI_ATK: attribute.atk = _value; break; case ABI_TYPE.ABI_MATK: attribute.matk = _value; break; case ABI_TYPE.ABI_DEF: attribute.def = _value; break; case ABI_TYPE.ABI_MDEF: attribute.mdef = _value; break; case ABI_TYPE.ABI_AGI: attribute.agi = _value; break; case ABI_TYPE.ABI_LUK: attribute.luk = _value; break; case ABI_TYPE.ABI_SPEED: attribute.speed = _value; break; case ABI_TYPE.ABI_HIT: attribute.hit = _value; break; case ABI_TYPE.ABI_CRI: attribute.cri = _value; break; case ABI_TYPE.ABI_FLEE: attribute.flee = _value; break; case ABI_TYPE.ABI_ANT_CRI: attribute.antCri = _value; break; case ABI_TYPE.ABI_DAMAGE_INCREASE: attribute.damageIncrease = _value; break; case ABI_TYPE.ABI_DAMAGE_DECREASE: attribute.damageDecrease = _value; break; case ABI_TYPE.ABI_DEF_IGNORE: attribute.defIngnore = _value; break; case ABI_TYPE.ABI_BLOOD_SUCK: attribute.bloodSuck = _value; break; case ABI_TYPE.ABI_AP: attribute.ap = _value; break; default: break; } } }