fix 合成装备bug

This commit is contained in:
luying
2020-12-21 11:45:16 +08:00
parent e05577bae8
commit dc527cae2e
11 changed files with 759 additions and 713 deletions

View File

@@ -48,7 +48,7 @@ export class EquipHandler {
let cost = new Array<ItemInter>();
if(targetGood.suitId > 0) { // 套装
cost.concat(targetGood.composeMaterial);
cost = cost.concat(targetGood.composeMaterial);
let specialMaterial = targetGood.specialMaterial;
let costCount = 0;
let equips = await EquipModel.getEquips(originalEquip);
@@ -83,7 +83,7 @@ export class EquipHandler {
let sid: string = session.get('sid');
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);
let { ePlace, lv: playerLv } = hero; // 装备栏
@@ -135,7 +135,7 @@ export class EquipHandler {
hero.ePlace = ePlace;
await calPlayerCeAndSave(sid, roleId, [hero], HERO_SYSTEM_TYPE.EPLACE_STRENGTHEN);
await calPlayerCeAndSave(sid, roleId, [hero], HERO_SYSTEM_TYPE.EQUIP);
const curHero = {
hid,
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) {
let roleId: string = session.get('roleId');
// let roleName: string = session.get('roleName');
@@ -152,7 +152,7 @@ export class EquipHandler {
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);
let { ePlace } = hero; // 装备栏
@@ -169,7 +169,7 @@ export class EquipHandler {
return resResult(STATUS.ROLE_EQUIP_REACH_MAX);
}
// TODO 是否成功精炼
// 是否成功精炼
let dicRefine = gameData.refine.get(refineLv + 1);
if(!dicRefine) {
return resResult(STATUS.ROLE_INFO_NOT_FOUND)
@@ -188,7 +188,6 @@ export class EquipHandler {
let ran = Math.floor(Math.random() * 100);
let isSuccess = ran <= successRate;
console.log(successRate, ran, isSuccess)
// 消耗道具提升成功率 每个道具提升10%成功率
// 精炼
@@ -201,7 +200,7 @@ export class EquipHandler {
let result = await handleCost(roleId, sid, cost);
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 = {
hid,

View File

@@ -20,11 +20,12 @@ import { PvpDefenseModel } from '@db/PvpDefense';
import { Service } from 'egg';
import Counter from '@db/Counter';
import { STATUS } from '@consts';
import { STATUS, HERO_SYSTEM_TYPE } from '@consts';
import { ITID, COUNTER } from '@consts';
import Actor from '@pubUtils/actor';
import { ItemModel } from '@db/Item';
import { gameData } from '@pubUtils/data';
import { calPlayerCeAndSave, getAllAttrStage } from '@pubUtils/playerCe';
/**
* Test Service
@@ -210,7 +211,8 @@ export default class GMUsers extends Service {
try {
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 });
} catch(e) {

View File

@@ -6,7 +6,7 @@ export const HERO_SYSTEM_TYPE = {
SKIN:7,
FAVOUR:8,
CONNECT:9,
EPLACE_STRENGTHEN: 10
EQUIP: 10
};
// 武将上限

View File

@@ -91,6 +91,7 @@ const itid_array = [
{ id: 34, name: '代币', table: 'item', type: CONSUME_TYPE.POINT },
{ id: 39, name: '时装', table: 'hero', type: CONSUME_TYPE.SKIN },
{ 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 }
];

View File

@@ -3,6 +3,7 @@ import { index, getModelForClass, prop, DocumentType, modelOptions } from '@type
import { COUNTER } from '../consts';
import { CounterModel } from './Counter';
import { HeroModel } from './Hero';
import { CeAttrNumber } from './generalField';
export class RandSe {
@prop({ required: true })
@@ -69,6 +70,9 @@ export default class Equip extends BaseModel {
@prop({ required: true, type: Holes, default: [] })
holes: Holes[];
@prop({required: true, default: new CeAttrNumber() })
ceAttr: CeAttrNumber; // 影响战力的属性
public static async findbyRole(roleId: string, lean = true) {
const equips: EquipType[] = await EquipModel.find({ roleId }).lean(lean);
return equips;

View File

@@ -144,6 +144,11 @@ export default class Hero extends BaseModel {
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) {
const hero: HeroType = await HeroModel.findOneAndUpdate(
{ roleId, hid, 'ePlace.id': ePlaceId },

View File

@@ -168,7 +168,7 @@ function parseSpecialMaterial(str: string) {
let decodeArr = decodeArrayStr(str);
if(decodeArr.length >= 2) {
let ids = parseNumberList(decodeArr[0]);
let count = parseInt(decodeArr[0]);
let count = parseInt(decodeArr[1]);
if(isNaN(count)) return specialAttr;
specialAttr.ids = ids;
specialAttr.count = count;

View File

@@ -26,7 +26,7 @@ export const dicRefine = new Map<number, DicRefine>();
arr.forEach(o => {
o.material = parseReward(o.material)
dicRefine.set(o.id, o);
dicRefine.set(o.level, o);
});
arr = undefined;

View File

@@ -2,7 +2,7 @@
* 体力系统
*/
import { HERO_SYSTEM_TYPE } from '../consts';
import { HERO_SYSTEM_TYPE, ABI_TYPE } from '../consts';
import { deepCopy } from './util';
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 { Attributes } from './interface';
import { DicSe } from './dictionary/DicSe';
import { EquipType } from '../db/Equip';
const HERO_CE_RATIO = 100;
const _ = require('underscore');
//战力计算TODO
@@ -35,6 +37,8 @@ export function calPlayerCe(hero: HeroType, type: number, args: Array<number>) {
reIncAttr = calHeroFavourUpIncAttr(hero, args);
} else if (type == HERO_SYSTEM_TYPE.CONNECT) {
reIncAttr = calHeroConectIncAttr(hero, args);
} else if (type == HERO_SYSTEM_TYPE.EQUIP) {
reIncAttr = calHeroEquipIncAttr(hero, args);
}
addSeidEffect(reIncAttr, addSeidList, removeSeidList); // 处理加值
@@ -225,6 +229,36 @@ export function calHeroFavourUpIncAttr(hero: HeroType, args: Array<number>) {
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
function getFieldByStage(stage: number, jobid: number) {
let targetAttrId = ABI_TYPE_TO_STAGE.get(stage);

File diff suppressed because it is too large Load Diff

View File

@@ -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 { HeroModel } from '@db/Hero';
import { RoleModel } from '@db/Role';
@@ -8,6 +8,7 @@ import { smsModel } from '@db/Sms';
import { Service } from 'egg';
import Counter from '@db/Counter';
import { getHeroInfoById } from 'app/pubUtils/gamedata';
import { calPlayerCeAndSave, getAllAttrStage } from 'app/pubUtils/playerCe';
const _ = require('underscore');
/**
@@ -147,7 +148,7 @@ export default class Auth extends Service {
hero = await HeroModel.createHero({
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 });
}