123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- import { Framework } from "../../framework/Framework";
- import { ItemEnum } from "../common/InterfaceAddEnum";
- import { LoginMgr } from "../common/LoginManager";
- import { FateattridConf } from "../config/FateattridConf";
- import { FateConf } from "../config/FateConf";
- import { RoleData } from "../data/RoleData";
- import { RoleConf } from "../ui/tower/conf/RoleConf";
- import { GoodsManager } from "./GoodsManager";
- //角色管理器
- export class RoleManager {
- //抽一个英雄
- static getNewRole() {
- LoginMgr.sendPost('tavern', 'get', (data) => {
- console.log(data);
- }, {})
- return false;
- }
- //英雄升星
- static sendRoleAdvance(args: { hid: number }, callback) {
- LoginMgr.sendPost('role', 'grade_up', (data) => {
- console.log(data);
- let rData = RoleData.getRoleDataByID(args.hid);
- rData.grade = data.grade;
- RoleData.setRoleDataByID(args.hid, rData)
- if(data.awards){
- Framework.unionManager.parseServerAwards(data.awards);
- }
- callback();
- }, args)
- }
- static sendFateLevelUp(args: { id: number }, callback){
- LoginMgr.sendPost('role', 'fate_level_up', (data) => {
- console.log(data);
- this.setFateData(data.fate);
- if(data.awards){
- Framework.unionManager.parseServerAwards(data.awards);
- }
- callback();
- }, args)
- }
- static getRolesRaceGroup() {
- let roles = {};
- let roleConf = RoleConf.data
- for (const rId in roleConf) {
- if (Object.prototype.hasOwnProperty.call(roleConf, rId)) {
- const element = roleConf[rId];
- let rData = RoleData.getRoleDataByID(rId);
- if (roles[element.Race]) {
- if (rData) {
- roles[element.Race].push(rData);
- } else {
- roles[element.Race].push({ conf: element });
- }
- } else {
- roles[element.Race] = [];
- if (rData) {
- roles[element.Race].push(rData);
- } else {
- roles[element.Race].push({ conf: element });
- }
- }
- }
- }
- for (const key in roles) {
- if (Object.prototype.hasOwnProperty.call(roles, key)) {
- const element = roles[key];
- element.sort((a, b) => {
- return Number(a.conf.Id) < Number(b.conf.Id) ? -1 : 1;
- });
- }
- }
- return roles;
- }
- static getRoleById(rId: number) {
- let roleConf = RoleConf.data[rId]
- if (roleConf){
- let rData = RoleData.getRoleDataByID(rId);
- if (rData) {
- return rData;
- } else {
- return { conf: roleConf, type: ItemEnum.role};
- }
- }
- return null;
- }
-
- static setFateData(data: { [key: string]: number }) {
- let fateData = {};
- let conf = FateConf.data;
- let atteConf = FateattridConf.data;
- for (const key in conf) {
- if (Object.prototype.hasOwnProperty.call(conf, key)) {
- const element = conf[key];
- fateData[key] = {
- id:key,
- conf:element,
- level:0
- };
- if (data[key]) {
- fateData[key].level = data[key];
- }
- }
- }
- RoleData.fate = fateData;
- }
- }
|