fix 合成装备bug
This commit is contained in:
@@ -48,7 +48,7 @@ export class EquipHandler {
|
|||||||
|
|
||||||
let cost = new Array<ItemInter>();
|
let cost = new Array<ItemInter>();
|
||||||
if(targetGood.suitId > 0) { // 套装
|
if(targetGood.suitId > 0) { // 套装
|
||||||
cost.concat(targetGood.composeMaterial);
|
cost = cost.concat(targetGood.composeMaterial);
|
||||||
let specialMaterial = targetGood.specialMaterial;
|
let specialMaterial = targetGood.specialMaterial;
|
||||||
let costCount = 0;
|
let costCount = 0;
|
||||||
let equips = await EquipModel.getEquips(originalEquip);
|
let equips = await EquipModel.getEquips(originalEquip);
|
||||||
@@ -83,7 +83,7 @@ export class EquipHandler {
|
|||||||
let sid: string = session.get('sid');
|
let sid: string = session.get('sid');
|
||||||
|
|
||||||
let {hid, ePlaceId, type} = msg;
|
let {hid, ePlaceId, type} = msg;
|
||||||
let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
let hero = await HeroModel.findByHidAndRoleWithEquip(hid, roleId);
|
||||||
if(!hero) return resResult(STATUS.HERO_NOT_FIND);
|
if(!hero) return resResult(STATUS.HERO_NOT_FIND);
|
||||||
|
|
||||||
let { ePlace, lv: playerLv } = hero; // 装备栏
|
let { ePlace, lv: playerLv } = hero; // 装备栏
|
||||||
@@ -135,7 +135,7 @@ export class EquipHandler {
|
|||||||
|
|
||||||
hero.ePlace = ePlace;
|
hero.ePlace = ePlace;
|
||||||
|
|
||||||
await calPlayerCeAndSave(sid, roleId, [hero], HERO_SYSTEM_TYPE.EPLACE_STRENGTHEN);
|
await calPlayerCeAndSave(sid, roleId, [hero], HERO_SYSTEM_TYPE.EQUIP);
|
||||||
const curHero = {
|
const curHero = {
|
||||||
hid,
|
hid,
|
||||||
ePlace: strengthenArr
|
ePlace: strengthenArr
|
||||||
@@ -144,7 +144,7 @@ export class EquipHandler {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO 装备栏精炼
|
// 装备栏精炼
|
||||||
public async refine(msg: { hid: number, ePlaceId: number, material: {id: number, count: number}[] }, session: BackendSession) {
|
public async refine(msg: { hid: number, ePlaceId: number, material: {id: number, count: number}[] }, session: BackendSession) {
|
||||||
let roleId: string = session.get('roleId');
|
let roleId: string = session.get('roleId');
|
||||||
// let roleName: string = session.get('roleName');
|
// let roleName: string = session.get('roleName');
|
||||||
@@ -152,7 +152,7 @@ export class EquipHandler {
|
|||||||
|
|
||||||
let {hid, ePlaceId, material} = msg;
|
let {hid, ePlaceId, material} = msg;
|
||||||
|
|
||||||
let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
let hero = await HeroModel.findByHidAndRoleWithEquip(hid, roleId);
|
||||||
if(!hero) return resResult(STATUS.HERO_NOT_FIND);
|
if(!hero) return resResult(STATUS.HERO_NOT_FIND);
|
||||||
let { ePlace } = hero; // 装备栏
|
let { ePlace } = hero; // 装备栏
|
||||||
|
|
||||||
@@ -169,7 +169,7 @@ export class EquipHandler {
|
|||||||
return resResult(STATUS.ROLE_EQUIP_REACH_MAX);
|
return resResult(STATUS.ROLE_EQUIP_REACH_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO 是否成功精炼
|
// 是否成功精炼
|
||||||
let dicRefine = gameData.refine.get(refineLv + 1);
|
let dicRefine = gameData.refine.get(refineLv + 1);
|
||||||
if(!dicRefine) {
|
if(!dicRefine) {
|
||||||
return resResult(STATUS.ROLE_INFO_NOT_FOUND)
|
return resResult(STATUS.ROLE_INFO_NOT_FOUND)
|
||||||
@@ -188,7 +188,6 @@ export class EquipHandler {
|
|||||||
|
|
||||||
let ran = Math.floor(Math.random() * 100);
|
let ran = Math.floor(Math.random() * 100);
|
||||||
let isSuccess = ran <= successRate;
|
let isSuccess = ran <= successRate;
|
||||||
console.log(successRate, ran, isSuccess)
|
|
||||||
// 消耗道具提升成功率 每个道具提升10%成功率
|
// 消耗道具提升成功率 每个道具提升10%成功率
|
||||||
|
|
||||||
// 精炼
|
// 精炼
|
||||||
@@ -201,7 +200,7 @@ export class EquipHandler {
|
|||||||
let result = await handleCost(roleId, sid, cost);
|
let result = await handleCost(roleId, sid, cost);
|
||||||
if(!result) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
if(!result) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
|
||||||
|
|
||||||
await calPlayerCeAndSave(sid, roleId, [hero], HERO_SYSTEM_TYPE.EPLACE_STRENGTHEN);
|
await calPlayerCeAndSave(sid, roleId, [hero], HERO_SYSTEM_TYPE.EQUIP);
|
||||||
|
|
||||||
const curHero = {
|
const curHero = {
|
||||||
hid,
|
hid,
|
||||||
|
|||||||
@@ -20,11 +20,12 @@ import { PvpDefenseModel } from '@db/PvpDefense';
|
|||||||
|
|
||||||
import { Service } from 'egg';
|
import { Service } from 'egg';
|
||||||
import Counter from '@db/Counter';
|
import Counter from '@db/Counter';
|
||||||
import { STATUS } from '@consts';
|
import { STATUS, HERO_SYSTEM_TYPE } from '@consts';
|
||||||
import { ITID, COUNTER } from '@consts';
|
import { ITID, COUNTER } from '@consts';
|
||||||
import Actor from '@pubUtils/actor';
|
import Actor from '@pubUtils/actor';
|
||||||
import { ItemModel } from '@db/Item';
|
import { ItemModel } from '@db/Item';
|
||||||
import { gameData } from '@pubUtils/data';
|
import { gameData } from '@pubUtils/data';
|
||||||
|
import { calPlayerCeAndSave, getAllAttrStage } from '@pubUtils/playerCe';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test Service
|
* Test Service
|
||||||
@@ -210,7 +211,8 @@ export default class GMUsers extends Service {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
for(let heroInfo of heroInfos) {
|
for(let heroInfo of heroInfos) {
|
||||||
await HeroModel.createHero(heroInfo);
|
let hero = await HeroModel.createHero(heroInfo);
|
||||||
|
await calPlayerCeAndSave(hero.roleId, [hero], HERO_SYSTEM_TYPE.STAR, getAllAttrStage());
|
||||||
}
|
}
|
||||||
return ctx.service.utils.resResult(STATUS.SUCCESS, { uids });
|
return ctx.service.utils.resResult(STATUS.SUCCESS, { uids });
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ export const HERO_SYSTEM_TYPE = {
|
|||||||
SKIN:7,
|
SKIN:7,
|
||||||
FAVOUR:8,
|
FAVOUR:8,
|
||||||
CONNECT:9,
|
CONNECT:9,
|
||||||
EPLACE_STRENGTHEN: 10
|
EQUIP: 10
|
||||||
};
|
};
|
||||||
|
|
||||||
// 武将上限
|
// 武将上限
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export const CONSUME_TYPE = {
|
|||||||
FAVOUR: 6, // 好感度道具
|
FAVOUR: 6, // 好感度道具
|
||||||
SKIN: 7, // 时装
|
SKIN: 7, // 时装
|
||||||
PIECE: 8, // 装备碎片
|
PIECE: 8, // 装备碎片
|
||||||
JEWEL: 9,//宝石
|
JEWEL: 9, //宝石
|
||||||
};
|
};
|
||||||
|
|
||||||
export enum EQUIP_TYPE {
|
export enum EQUIP_TYPE {
|
||||||
@@ -91,6 +91,7 @@ const itid_array = [
|
|||||||
{ id: 34, name: '代币', table: 'item', type: CONSUME_TYPE.POINT },
|
{ id: 34, name: '代币', table: 'item', type: CONSUME_TYPE.POINT },
|
||||||
{ id: 39, name: '时装', table: 'hero', type: CONSUME_TYPE.SKIN },
|
{ id: 39, name: '时装', table: 'hero', type: CONSUME_TYPE.SKIN },
|
||||||
{ id: 40, name: '装备碎片', table: 'item', type: CONSUME_TYPE.PIECE },
|
{ id: 40, name: '装备碎片', table: 'item', type: CONSUME_TYPE.PIECE },
|
||||||
|
{ id: 41, name: '图纸', table: 'item', type: CONSUME_TYPE.CONSUME },
|
||||||
{ id: 42, name: '宝石', table: 'item', type: CONSUME_TYPE.JEWEL }
|
{ id: 42, name: '宝石', table: 'item', type: CONSUME_TYPE.JEWEL }
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { index, getModelForClass, prop, DocumentType, modelOptions } from '@type
|
|||||||
import { COUNTER } from '../consts';
|
import { COUNTER } from '../consts';
|
||||||
import { CounterModel } from './Counter';
|
import { CounterModel } from './Counter';
|
||||||
import { HeroModel } from './Hero';
|
import { HeroModel } from './Hero';
|
||||||
|
import { CeAttrNumber } from './generalField';
|
||||||
|
|
||||||
export class RandSe {
|
export class RandSe {
|
||||||
@prop({ required: true })
|
@prop({ required: true })
|
||||||
@@ -69,6 +70,9 @@ export default class Equip extends BaseModel {
|
|||||||
@prop({ required: true, type: Holes, default: [] })
|
@prop({ required: true, type: Holes, default: [] })
|
||||||
holes: Holes[];
|
holes: Holes[];
|
||||||
|
|
||||||
|
@prop({required: true, default: new CeAttrNumber() })
|
||||||
|
ceAttr: CeAttrNumber; // 影响战力的属性
|
||||||
|
|
||||||
public static async findbyRole(roleId: string, lean = true) {
|
public static async findbyRole(roleId: string, lean = true) {
|
||||||
const equips: EquipType[] = await EquipModel.find({ roleId }).lean(lean);
|
const equips: EquipType[] = await EquipModel.find({ roleId }).lean(lean);
|
||||||
return equips;
|
return equips;
|
||||||
|
|||||||
@@ -144,6 +144,11 @@ export default class Hero extends BaseModel {
|
|||||||
return hero;
|
return hero;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static async findByHidAndRoleWithEquip(hid: number, roleId: string, lean = true) {
|
||||||
|
const hero: HeroType = await HeroModel.findOne({ hid, roleId }).populate('ePlace.equip').lean(lean);
|
||||||
|
return hero;
|
||||||
|
}
|
||||||
|
|
||||||
public static async addEquip(roleId: string, hid: number, ePlaceId: number, equipId: string, lean = true) {
|
public static async addEquip(roleId: string, hid: number, ePlaceId: number, equipId: string, lean = true) {
|
||||||
const hero: HeroType = await HeroModel.findOneAndUpdate(
|
const hero: HeroType = await HeroModel.findOneAndUpdate(
|
||||||
{ roleId, hid, 'ePlace.id': ePlaceId },
|
{ roleId, hid, 'ePlace.id': ePlaceId },
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ function parseSpecialMaterial(str: string) {
|
|||||||
let decodeArr = decodeArrayStr(str);
|
let decodeArr = decodeArrayStr(str);
|
||||||
if(decodeArr.length >= 2) {
|
if(decodeArr.length >= 2) {
|
||||||
let ids = parseNumberList(decodeArr[0]);
|
let ids = parseNumberList(decodeArr[0]);
|
||||||
let count = parseInt(decodeArr[0]);
|
let count = parseInt(decodeArr[1]);
|
||||||
if(isNaN(count)) return specialAttr;
|
if(isNaN(count)) return specialAttr;
|
||||||
specialAttr.ids = ids;
|
specialAttr.ids = ids;
|
||||||
specialAttr.count = count;
|
specialAttr.count = count;
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ export const dicRefine = new Map<number, DicRefine>();
|
|||||||
|
|
||||||
arr.forEach(o => {
|
arr.forEach(o => {
|
||||||
o.material = parseReward(o.material)
|
o.material = parseReward(o.material)
|
||||||
dicRefine.set(o.id, o);
|
dicRefine.set(o.level, o);
|
||||||
});
|
});
|
||||||
|
|
||||||
arr = undefined;
|
arr = undefined;
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
* 体力系统
|
* 体力系统
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { HERO_SYSTEM_TYPE } from '../consts';
|
import { HERO_SYSTEM_TYPE, ABI_TYPE } from '../consts';
|
||||||
|
|
||||||
import { deepCopy } from './util';
|
import { deepCopy } from './util';
|
||||||
import { HeroModel, HeroType } from '../db/Hero';
|
import { HeroModel, HeroType } from '../db/Hero';
|
||||||
@@ -12,6 +12,8 @@ import { getAttrNameByJobStage, getAttrCeRatio, getAtrrNameById, ABI_TYPE_TO_STA
|
|||||||
import { gameData, getJobByGradeAndClass, getHeroWakeByQuality, getHeroStarByQuality, getFriendShipById } from './data';
|
import { gameData, getJobByGradeAndClass, getHeroWakeByQuality, getHeroStarByQuality, getFriendShipById } from './data';
|
||||||
import { Attributes } from './interface';
|
import { Attributes } from './interface';
|
||||||
import { DicSe } from './dictionary/DicSe';
|
import { DicSe } from './dictionary/DicSe';
|
||||||
|
import { EquipType } from '../db/Equip';
|
||||||
|
|
||||||
const HERO_CE_RATIO = 100;
|
const HERO_CE_RATIO = 100;
|
||||||
const _ = require('underscore');
|
const _ = require('underscore');
|
||||||
//战力计算TODO
|
//战力计算TODO
|
||||||
@@ -35,6 +37,8 @@ export function calPlayerCe(hero: HeroType, type: number, args: Array<number>) {
|
|||||||
reIncAttr = calHeroFavourUpIncAttr(hero, args);
|
reIncAttr = calHeroFavourUpIncAttr(hero, args);
|
||||||
} else if (type == HERO_SYSTEM_TYPE.CONNECT) {
|
} else if (type == HERO_SYSTEM_TYPE.CONNECT) {
|
||||||
reIncAttr = calHeroConectIncAttr(hero, args);
|
reIncAttr = calHeroConectIncAttr(hero, args);
|
||||||
|
} else if (type == HERO_SYSTEM_TYPE.EQUIP) {
|
||||||
|
reIncAttr = calHeroEquipIncAttr(hero, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
addSeidEffect(reIncAttr, addSeidList, removeSeidList); // 处理加值
|
addSeidEffect(reIncAttr, addSeidList, removeSeidList); // 处理加值
|
||||||
@@ -225,6 +229,36 @@ export function calHeroFavourUpIncAttr(hero: HeroType, args: Array<number>) {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function calHeroEquipIncAttr(hero: HeroType, args: Array<number>) {
|
||||||
|
let res: CeAttr = {};
|
||||||
|
let {ePlace} = hero;
|
||||||
|
|
||||||
|
for(let {equip, lv, refineLv} of ePlace) {
|
||||||
|
if(equip) {
|
||||||
|
let e = <EquipType>equip;
|
||||||
|
console.log(e.id, e._id);
|
||||||
|
let dicGoods = gameData.goods.get(e.id);
|
||||||
|
let {goodsAbility, goodsAbilityUp} = dicGoods;
|
||||||
|
let dicRefine = gameData.refine.get(refineLv);
|
||||||
|
|
||||||
|
for(let i = ABI_TYPE.ABI_HP; i < ABI_TYPE.ABI_MAX; i++) {
|
||||||
|
let jewel = 0;
|
||||||
|
for(let j = 0; j < e.holes.length; i++) {
|
||||||
|
|
||||||
|
}
|
||||||
|
let attr = (goodsAbility.get(i) + lv * goodsAbilityUp.get(i)) * ( 1 + dicRefine.upPercent);
|
||||||
|
|
||||||
|
console.log(jewel, attr, args);
|
||||||
|
}
|
||||||
|
// 基础属性
|
||||||
|
// 装备栏强化
|
||||||
|
// 精炼
|
||||||
|
// 宝石
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
// 根据存在升星表等的stage字段的id对应17维id
|
// 根据存在升星表等的stage字段的id对应17维id
|
||||||
function getFieldByStage(stage: number, jobid: number) {
|
function getFieldByStage(stage: number, jobid: number) {
|
||||||
let targetAttrId = ABI_TYPE_TO_STAGE.get(stage);
|
let targetAttrId = ABI_TYPE_TO_STAGE.get(stage);
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
|||||||
import { FIX_SMS_CODE_TELS, COUNTER } from '@consts';
|
import { FIX_SMS_CODE_TELS, COUNTER, HERO_SYSTEM_TYPE } from '@consts';
|
||||||
import { DEFAULT_HEROES } from '@consts';
|
import { DEFAULT_HEROES } from '@consts';
|
||||||
import { HeroModel } from '@db/Hero';
|
import { HeroModel } from '@db/Hero';
|
||||||
import { RoleModel } from '@db/Role';
|
import { RoleModel } from '@db/Role';
|
||||||
@@ -8,6 +8,7 @@ import { smsModel } from '@db/Sms';
|
|||||||
import { Service } from 'egg';
|
import { Service } from 'egg';
|
||||||
import Counter from '@db/Counter';
|
import Counter from '@db/Counter';
|
||||||
import { getHeroInfoById } from 'app/pubUtils/gamedata';
|
import { getHeroInfoById } from 'app/pubUtils/gamedata';
|
||||||
|
import { calPlayerCeAndSave, getAllAttrStage } from 'app/pubUtils/playerCe';
|
||||||
const _ = require('underscore');
|
const _ = require('underscore');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -147,7 +148,7 @@ export default class Auth extends Service {
|
|||||||
hero = await HeroModel.createHero({
|
hero = await HeroModel.createHero({
|
||||||
roleId, roleName: role.roleName, hid, hName, star, quality, job, serverId: role.serverId
|
roleId, roleName: role.roleName, hid, hName, star, quality, job, serverId: role.serverId
|
||||||
});
|
});
|
||||||
|
await calPlayerCeAndSave(roleId, [hero], HERO_SYSTEM_TYPE.STAR, getAllAttrStage());
|
||||||
}
|
}
|
||||||
return ctx.service.utils.resResult(STATUS.SUCCESS, { roleId: role.roleId });
|
return ctx.service.utils.resResult(STATUS.SUCCESS, { roleId: role.roleId });
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user