123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857 |
- import i18n from "../../../i18n/i18n";
- import { ReveData } from "../../../util/CHttp";
- import { FFAttr } from "../FFCalAttr";
- /**
- * 主角信息
- */
- export interface __RoleData {
- id: number,
- name: string,
- icon: string,
- act: string,
- post: number,
- group: number,
- atk: number,
- def: number,
- hp: number,
- sp: number,
- skill: number,
- }
- //头像/框/称号
- export interface __RoleIcon {
- id: number,
- type: number,
- name: string,
- icon: string,
- about: string,
- atk: number,
- def: number,
- hp: number,
- sp: number,
- }
- /**
- * 道具
- */
- export interface __GoodData {
- id: number,
- name: string,
- type: number,
- pz: number,
- icon: string,
- atk: number,
- def: number,
- hp: number,
- sp: number,
- water: number,
- fire: number,
- light: number,
- earth: number,
- dark: number,
- wind: number,
- thunder: number,
- howGet: number,
- about: string,
- sell: number,
- buy: number,
- }
- /**
- * 装备
- */
- export interface __EquipData {
- id: number,
- name: string,
- about: string,
- level: number,//当前最高强化等级
- icon: string,
- bulletEffect: string,
- pz: number,
- occ: number,
- atk: number,
- def: number,
- hp: number,
- sp: number,
- sd: number,
- type: number,
- suit: number
- skill: number
- qh_exp: number//消耗后获得的强化经验
- qh_max: number//强化突破次数
- }
- /**
- * 装备强化
- */
- export interface __EquipQHData {
- id: number
- type: number
- occ: number
- level: number
- exp: number
- atk: number
- def: number
- hp: number
- sp: number
- money: number
- }
- /**
- * 装备套装
- */
- export interface __EquipSuitData {
- id: number
- name: string
- about: string
- suitId: number
- effect: string
- value1_1: number
- value1_2: number
- value1_3: number
- value2_1: number
- value2_2: number
- value2_3: number
- }
- /**
- * 技能
- */
- export interface __SkillData {
- id: number,
- name: string,
- about: string,
- type: number
- icon: string,
- effect: string,
- time: number,
- value1: number,
- value2: number,
- value3: number
- value4: number
- }
- /**
- * 装备附加属性
- */
- export interface __EquipAttrData {
- id: number,
- name: string,
- }
- /**
- * 怪物
- */
- export interface __MonsterData {
- id: number,
- name: string,
- group: number,
- type: number,
- career: number,
- icon: string,
- act: string,
- level: number,
- atk: number,
- def: number,
- hp: number,
- sp: number,
- skill: number,
- }
- /**
- * 场景
- */
- export interface __SceneData {
- id: number,
- name: string,
- about: string,
- startIndex: number
- list: Array<__StageData>
- }
- /**
- * 关卡
- */
- export interface __StageData {
- id: number,
- zid: number,
- name: string,
- about: string,
- mapId: string,
- goodId1: number,
- goodCount1: number,
- goodId2: number,
- goodCount2: number,
- goodId3: number,
- goodCount3: number,
- taskText: string,
- music: string
- }
- /**
- * 任务
- */
- export interface __TaskData {
- id: number,
- name: string,
- reward: string,
- }
- /**
- * 神卡
- */
- export interface __GodCard {
- id: number
- name: string
- about: string
- type: number
- pz: number
- max_star: number
- goodId: number
- goodCount: number
- water: number
- fire: number
- wind: number
- thunder: number
- earth: number
- job: number
- atk: number
- def: number
- hp: number
- sp: number
- feature: string
- value1: number
- value2: number
- value3: number
- feature_about: string
- feature_max: string
- list: Array<__GodCardLevel>
- godReborn: __GodReborn
- }
- /**
- * 神卡升级
- */
- export interface __GodCardLevel {
- id: number
- godCardId: number
- star: number
- type: number
- attrType: number
- goodId1: number
- goodCount1: number
- goodId2: number
- goodCount2: number
- goodId3: number
- goodCount3: number
- water: number
- fire: number
- wind: number
- thunder: number
- earth: number
- job: number
- atk: number
- def: number
- hp: number
- sp: number
- }
- /**
- * 满星后重生
- */
- export interface __GodReborn {
- id: number
- godCardId: number
- goodId1: number
- goodCount1: number
- goodId2: number
- goodCount2: number
- water: number
- fire: number
- wind: number
- thunder: number
- earth: number
- job: number
- atk: number
- def: number
- hp: number
- sp: number
- }
- /**
- * 魔盒
- */
- export interface __MagicBox {
- id: number
- type: number
- icon: string
- name: string
- about: string
- consumeType: number
- goodId: number
- goodCount: number
- rewardId: number
- list: Array<__MagicBoxReward>
- maxPR: number
- }
- /**
- * 魔盒奖励
- */
- export interface __MagicBoxReward {
- id: number
- magicBoxId: number
- type: number
- value1: number
- value2: number
- value3: number
- PR: number
- }
- export interface __PayData {
- id: number,//商品编号
- type: number,//类型
- iosId: string,//苹果商品id
- googleId: string,//谷歌商店唯一id
- name: string,//商品名字
- rmb: string,//RMB
- usd: string,//美刀
- gold: number//兑换的钻石
- firstGive: number//首次充值额外奖励钻石
- }
- export interface __BuyCoinData {
- id: number,//商品编号
- name: string,//商品名字
- maxCount: number,//限购次数
- gold: number //花费钻石
- money: number // 获得
- gave: number // 赠送
- }
- export interface __BuyPowerData {
- id: number,//商品编号
- maxCount: number,//限购次数
- gold: number //花费钻石
- power: number // 获得
- }
- export interface __BuyPandoraData {
- id: number,//商品编号
- name: string, //名字
- adCount: number,//广告次数
- flushTime: number //刷新时间
- goodId: number // 花费紫水晶ID
- }
- export interface __FirstPayData {
- id: number,//商品编号
- name: string, //名字
- reward: string, // 奖励
- }
- export interface __FirstPayRewardData {
- icon: string,
- count: number,
- frame: number,
- }
- export interface __WishData {
- id: number, //商品编号
- name: string, //名字
- payId: string, //充值id
- maxCount: number //每日限购次数
- reward: string, //奖励
- }
- /**
- * 从服务器获取的奖励
- * type:0,
- icon:'icon/good/3001',
- count:data._role._money,
- id:0,
- pz:0,
- star:0
- */
- export interface RewardData {
- type: number,//0:money,1:gole,2:good
- icon: string,//图标
- count: number,//数量
- id: number,//道具对应的id
- pz: 0,
- star: 0
- PR: 0
- name: ''
- }
- /**
- * 系统数据管理
- */
- export default class SManage {
- /**
- * 角色数据
- */
- private roleDataMap: Map<number, __RoleData> = new Map();
- /**
- * 头像/框/称号
- */
- private roleIcons: Array<__RoleIcon> = [];
- /**
- * 道具
- */
- private goodMap: Map<number, __GoodData> = new Map();
- /**
- * 装备
- */
- private equipMap: Map<number, __EquipData> = new Map();
- /**
- * 装备强化
- * key : int 装备类型
- * vaule: list 强化数据列表
- */
- private equipQHMap: Map<string, Array<__EquipQHData>> = new Map();
- /**
- * 附属性
- */
- private attrMap: Map<number, __EquipAttrData> = new Map();
- /**
- * 技能
- */
- private skillMap: Map<number, __SkillData> = new Map();
- /**
- * 怪物
- */
- private monsterMap: Map<number, __MonsterData> = new Map();
- /**
- * 关卡数据
- */
- private sceneLists: Array<__SceneData> = null;
- private stageLists: Array<__StageData> = null;
- /**
- * 神卡
- */
- public godCards: Array<__GodCard> = null;
- /**
- * 魔盒
- */
- public magicBoxs: Array<__MagicBox> = null;
- /**
- * 充值数据
- */
- public payDatas: Array<__PayData> = null;
- /**
- * 任务列表
- */
- private taskLists: Array<__TaskData> = null;
- constructor(data) {
- this.initRoleData(data.roleData);
- this.roleIcons = data.roleIcon;
- this.initGood(data.good);
- this.initEquip(data.equip);
- this.initEquipQH(data.equipQH);
- this.initEquipAttr(data.eAttr);
- this.initSkillData(data.skill);
- this.initMonster(data.monster);
- this.sceneLists = data.scene;
- this.stageLists = data.stage;
- this.initScene();
- this.initGodCard(data.godCard)
- this.initGodCardLevel(data.godCardLevel)
- this.initGodReborn(data.godReborn)
- this.magicBoxs = data.magicBox
- this.initMaigcBoxReward(data.magicBoxReward)
- this.payDatas = data.payData
- this.taskLists = data.task;
- }
- private initMaigcBoxReward(list: Array<__MagicBoxReward>) {
- for (let i = 0; i < this.magicBoxs.length; i++) {
- const element = this.magicBoxs[i];
- for (let j = 0; j < list.length; j++) {
- const tmp = list[j];
- if (tmp.magicBoxId == element.rewardId) {
- if (element.list == undefined) {
- element.list = []
- }
- element.list.push(tmp)
- }
- }
- }
- }
- private initGodReborn(list: Array<__GodReborn>) {
- list.forEach(element => {
- let godCard = this.getGodCardById(element.godCardId)
- godCard.godReborn = element
- });
- }
- private initGodCardLevel(list: Array<__GodCardLevel>) {
- for (let i = 0; i < list.length; i++) {
- const element = list[i];
- let godCard = this.getGodCardById(element.godCardId)
- if (!godCard.list) {
- godCard.list = []
- }
- godCard.list.push(element)
- }
- }
- private initGodCard(list: Array<__GodCard>) {
- this.godCards = list
- }
- private initSkillData(list: Array<__SkillData>) {
- list.forEach(element => {
- this.skillMap.set(element.id, element);
- });
- }
- public getRoleIconById(id) {
- for (let i = 0; i < this.roleIcons.length; i++) {
- const element = this.roleIcons[i];
- if (element.id == id) {
- return element;
- }
- }
- }
- private initRoleData(roleDataLists: Array<__RoleData>) {
- roleDataLists.forEach(element => {
- this.roleDataMap.set(element.id, element);
- });
- }
- private initGood(lists: Array<__GoodData>) {
- lists.forEach(element => {
- this.goodMap.set(element.id, element);
- });
- }
- private initEquipAttr(lists: Array<__EquipAttrData>) {
- lists.forEach(element => {
- this.attrMap.set(element.id, element);
- });
- }
- private initEquip(lists: Array<__EquipData>) {
- lists.forEach(element => {
- this.equipMap.set(element.id, element);
- });
- }
- private initEquipQH(lists: Array<__EquipQHData>) {
- lists.forEach(element => {
- let key = element.occ + '@' + element.type
- let list = this.equipQHMap.get(key)
- if (list) {
- list.push(element)
- } else {
- list = []
- list.push(element)
- this.equipQHMap.set(key, list)
- }
- });
- }
- private initMonster(monsters: Array<__MonsterData>) {
- monsters.forEach(element => {
- this.monsterMap.set(element.id, element);
- });
- }
- private initScene() {
- for (let i = 0; i < this.stageLists.length; i++) {
- const element = this.stageLists[i];
- let scene = this.getSceneById(element.zid);
- if (scene.list == null) {
- scene.list = [];
- scene.startIndex = i;
- }
- scene.list.push(element);
- }
- }
- public getGodCardById(id): __GodCard {
- for (let i = 0; i < this.godCards.length; i++) {
- const element = this.godCards[i];
- if (element.id == id) {
- return element;
- }
- }
- }
- public getSceneById(id) {
- for (let i = 0; i < this.sceneLists.length; i++) {
- const element = this.sceneLists[i];
- if (element.id == id) {
- return element;
- }
- }
- }
- public getSceneByStage(stage: __StageData) {
- if (stage == null) {
- return this.sceneLists[this.sceneLists.length - 1];
- }
- return this.getSceneById(stage.zid);
- }
- public getScene() {
- return this.sceneLists;
- }
- public getStage() {
- return this.stageLists;
- }
- /**
- * 获取关卡
- * @param index
- */
- public getStageByIndex(index: number) {
- if (index >= this.stageLists.length) {
- return null;
- }
- return this.stageLists[index];
- }
- /**
- * 获取怪物数据
- * @param id
- */
- public getMonsterData(id: number): FFAttr {
- let monsterData = this.monsterMap.get(id);
- let fd1 = {
- id: id,
- type: monsterData.type,
- post: monsterData.career,
- path: "prefab/monster/" + monsterData.act,
- atk: monsterData.atk,
- def: monsterData.def,
- hp: monsterData.hp,
- sp: monsterData.sp,
- water: 0,
- fire: 0,
- wind: 0,
- thunder: 0,
- earth: 0,
- sd: 500,
- weaponSkill: 0,
- suitId: 0,
- suitCount: 0,
- attrs: [],
- zdl: 1,
- skin: '30000',
- weapon: null,
- bullet: null
- };
- return fd1;
- }
- public getGoodById(id: string) {
- return this.goodMap.get(parseInt(id));
- }
- public getGoodById1(id: number) {
- return this.goodMap.get(id);
- }
- public getEquipById(id): __EquipData {
- return this.equipMap.get(id);
- }
- public getEquipAttrById(id) {
- return this.attrMap.get(id);
- }
- public getSkillById(id: number) {
- return this.skillMap.get(id);
- }
- public getRoleById(id: number) {
- return this.roleDataMap.get(id);
- }
- public getRoleIcon() {
- return this.roleIcons
- }
- /**
- * 获取某个类型的强化数据
- * @param type
- */
- public getEquipQHByType(equipData: __EquipData): Array<__EquipQHData> {
- return this.equipQHMap.get(equipData.occ + '@' + equipData.type)
- }
- /**
- * 从接收的数据中分离出奖励数据
- * @param reve
- */
- public getRewards(reveData: ReveData): Array<RewardData> {
- let list = [];
- let data = reveData.data;
- if (data._role != undefined) {
- if (data._role._money != undefined) {
- if (data._role._money > 0) {
- let rewardData = {
- type: 0,
- icon: 'icon/good/3001',
- count: data._role._money,
- id: 0,
- pz: 4,
- star: 0,
- name: i18n.t('金币')
- }
- list.push(rewardData);
- }
- }
- if (data._role._gold != undefined) {
- if (data._role._gold > 0) {
- let rewardData = {
- type: 1,
- icon: 'icon/good/3002',
- count: data._role._gold,
- id: 0,
- pz: 5,
- star: 0,
- name: i18n.t('钻石')
- }
- list.push(rewardData);
- }
- }
- if (data._role._power != undefined) {
- if (data._role._power > 0) {
- let rewardData = {
- type: 1,
- icon: 'icon/good/3003',
- count: data._role._power,
- id: 0,
- pz: 5,
- star: 0,
- name: i18n.t('体力')
- }
- list.push(rewardData);
- }
- }
- }
- //道具
- if (data._pack != undefined) {
- for (let i = 0; i < data._pack.length; i++) {
- const element = data._pack[i];
- if (element.count > 0) {
- let good = this.getGoodById1(element.id);
- let rewardData = {
- type: 2,
- icon: 'icon/good/' + good.icon,
- count: element.count,
- id: element.id,
- pz: good.pz,
- star: 0,
- name: i18n.t(good.name)
- }
- list.push(rewardData);
- }
- }
- }
- //装备
- if (data._equip != undefined) {
- for (let i = 0; i < data._equip.length; i++) {
- const element = data._equip[i];
- let equip = this.getEquipById(element.id);
- let rewardData = {
- type: 3,
- icon: 'icon/equip/' + equip.icon,
- count: 0,
- id: element.id,
- pz: equip.pz,
- PI: element.PI,
- star: element.star,
- _data: equip,
- name: i18n.t(equip.name)
- }
- list.push(rewardData);
- }
- }
- if (data._godCard != undefined) {
- for (let i = 0; i < data._godCard.length; i++) {
- const element = data._godCard[i];
- let rewardData = {
- type: 4,
- data: element,
- name: i18n.t('神卡')
- }
- list.push(rewardData);
- }
- }
- return list;
- }
- /**
- * 从接收的数据中分离出奖励数据
- * @param reve
- */
- public getRewardViews(rewards: Array<__MagicBoxReward>): Array<RewardData> {
- let list = [];
- for (let i = 0; i < rewards.length; i++) {
- const element = rewards[i];
- if (element.type == 1) {
- let rewardData = {
- type: 0,
- icon: 'icon/good/3001',
- count: element.value1,
- id: 0,
- pz: 3,
- star: 0,
- PR: element.PR
- }
- list.push(rewardData);
- } else if (element.type == 2) {
- let rewardData = {
- type: 1,
- icon: 'icon/good/3002',
- count: element.value1,
- id: 0,
- pz: 5,
- star: 0,
- PR: element.PR
- }
- list.push(rewardData);
- } else if (element.type == 3) {
- let good = this.getGoodById1(element.value1);
- let rewardData = {
- type: 2,
- icon: 'icon/good/' + good.icon,
- count: element.value2,
- id: element.id,
- pz: good.pz,
- star: 0,
- PR: element.PR
- }
- list.push(rewardData);
- } else if (element.type == 4) {
- let equip = this.getEquipById(element.value1);
- let rewardData = {
- type: 3,
- icon: 'icon/equip/' + equip.icon,
- count: 0,
- id: element.id,
- pz: equip.pz,
- PI: element.value3,
- star: 0,
- _data: equip,
- PR: element.PR
- }
- list.push(rewardData);
- }
- }
- return list;
- }
- }
|