增加角色Character相关操作方法

This commit is contained in:
yoimiya-kokomi 2022-03-24 22:40:59 +08:00
parent 8b99085065
commit 8e641fe0bb
3 changed files with 54 additions and 15 deletions

View File

@ -1,5 +1,5 @@
/*
import Character from "./models/Character"; import Character from "./models/Character.js";
export {Character}; export {Character};
*/

View File

@ -0,0 +1 @@
export default class Base{}

View File

@ -1,22 +1,60 @@
import Base from "./Base.js"; import Base from "./Base.js";
import {roleId} from "../../../config/roleId.js" import { roleId, abbr } from "../../../config/genshin/roleId.js";
let CharacterMap = {}; import lodash from "lodash";
import fs from "fs";
let characterMap = {};
let characterAttr = {}; let characterAttr = {};
class Character extends Base{ const characterMeta = JSON.parse(fs.readFileSync("../meta/characters.json", "utf8"));
constructor(name){
super();
lodash.forEach(characterMeta, (meta)=>{
characterMap[meta.Name] = new Character(name, meta)
});
lodash.forEach(roleId, function(names, id){
if(characterMap[names[0]]){
characterMap[names[0]].id = id;
} }
get sortName(){ });
class Character extends Base {
constructor(name, meta) {
super();
let key = "".split();
this._meta = meta;
}
get sortName() {
return characterAttr[this.name] || this.name; return characterAttr[this.name] || this.name;
} }
get id(){
for(let id in roleId){
if(roleId[id] && role[id][0] === this.name){
return id;
}
}
}
getData(key){
}
} }
Character.get= function(val){
console.log(roleId) Character.get = function (val) {
let name = YunzaiApps.mysInfo.roleIdToName(val);
if(!name){
return false;
}
if(!characterMap[name]){
//characterMap[name] =
}
}; };
export default Character; export default Character;