1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- import { Framework } from "../../framework/Framework";
- import { LoginMgr } from "../common/LoginManager";
- 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 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;
- }
- }
|