装备精炼,洗炼,缺少消耗

This commit is contained in:
luying
2020-12-18 13:56:12 +08:00
parent 329d59b6cc
commit b39c9bdc8b
14 changed files with 490 additions and 51 deletions

View File

@@ -1,5 +1,5 @@
import { Application, BackendSession } from "pinus";
import { STATUS, EQUIP_STRENGTHEN_TYPE, CURRENCY_BY_TYPE, CURRENCY_TYPE, HERO_SYSTEM_TYPE, CONSUME_TYPE, GOOD_TYPE } from "../../../consts";
import { STATUS, EQUIP_STRENGTHEN_TYPE, CURRENCY_BY_TYPE, CURRENCY_TYPE, HERO_SYSTEM_TYPE, CONSUME_TYPE, GOOD_TYPE, HERO_GROW_MAX } from "../../../consts";
import { ItemInter } from "../../../pubUtils/interface";
import { resResult, parseReward, getRandomByLen } from "../../../pubUtils/util";
import { addItems, handleCost } from "../../../services/rewardService";
@@ -73,7 +73,7 @@ export class EquipHandler {
let hero = await HeroModel.findByHidAndRole(hid, roleId);
if(!hero) return resResult(STATUS.HERO_NOT_FIND);
let { ePlace = new Array<EPlace>() } = hero; // 装备栏
let { ePlace } = hero; // 装备栏
let strengthenArr = new Array<EPlace>();
if(type == EQUIP_STRENGTHEN_TYPE.SINGLE || type == EQUIP_STRENGTHEN_TYPE.SINGLE_QUICK) { // 单装备强化
strengthenArr = ePlace.filter(cur => cur.id == ePlaceId && cur.equip);
@@ -90,6 +90,9 @@ export class EquipHandler {
let {coin, lv: playerLv} = await Role.findByRoleId(roleId);
let maxLv = type == EQUIP_STRENGTHEN_TYPE.SINGLE?minLv + 1:playerLv;
if(minLv == maxLv) {
return resResult(STATUS.ROLE_EQUIP_REACH_MAX);
}
let costCoin = 0; // 消耗铜币
let flag = false; // 铜币不足
for(let i = minLv; i < maxLv; i++) {
@@ -128,11 +131,62 @@ export class EquipHandler {
}
// TODO 装备栏精炼
public async refine(msg: { }, session: BackendSession) {
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');
let sid: string = session.get('sid');
let {hid, ePlaceId, material} = msg;
let hero = await HeroModel.findByHidAndRole(hid, roleId);
if(!hero) return resResult(STATUS.HERO_NOT_FIND);
let { ePlace } = hero; // 装备栏
let curEplace = ePlace.find(cur => cur.id == ePlaceId);
if(!curEplace) {
return resResult(STATUS.ROLE_EQUIP_PLACE_NOT_ENOUGH);
}
let {lv, refineLv } = curEplace; // 强化等级,精炼等级,精炼次数
if(lv < HERO_GROW_MAX.EQUIP_STRENGTHEN) {
return resResult(STATUS.ROLE_EQUIP_NOT_REACH_MAX);
}
if(refineLv >= HERO_GROW_MAX.EQUIP_REFINE) {
return resResult(STATUS.ROLE_EQUIP_REACH_MAX);
}
// TODO 是否成功精炼
let dicRefine = gameData.refine.get(refineLv + 1);
if(!dicRefine) {
return resResult(STATUS.ROLE_INFO_NOT_FOUND)
}
let ran = Math.floor(Math.random() * 100)
let isSuccess = ran <= dicRefine.successRate;
// 消耗道具提升成功率 每个道具提升10%成功率
// 精炼
if(isSuccess) {
curEplace.refineLv++;
} else {
curEplace.refineCount++;
}
// TODO 消耗
let cost = [];
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);
const curHero = {
hid,
ePlace: curEplace
}
return resResult(STATUS.SUCCESS, { isSuccess, curHero});
}
// TODO 装备洗炼锁定
// 装备洗炼锁定消耗TODO
public async lockRandSe(msg: { eid: number, id: number, lock: boolean }, session: BackendSession) {
let roleId: string = session.get('roleId');
// let roleName: string = session.get('roleName');
@@ -147,6 +201,7 @@ export class EquipHandler {
return resResult(STATUS.EQUIP_HAVE_NO_RANDSE);
}
// TODO 锁
// let lock = 0;
// let result = await handleCost(roleId, sid, [{id: lock, count: 1}]);
// if(!result) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
@@ -159,7 +214,7 @@ export class EquipHandler {
}
// TODO 装备洗炼
// TODO 装备洗炼消耗TODO
public async reStrengthen(msg: { eid: number }, session: BackendSession) {
let roleId: string = session.get('roleId');
// let roleName: string = session.get('roleName');
@@ -179,37 +234,40 @@ export class EquipHandler {
let {randomEffect} = dicGoods;
let pool = randomEffect.map(cur => gameData.randomEffectPool.get(cur));
let chosen = randSe.map(cur => cur.seid);
let newRandSe = new Array<RandSe>();
let chosen = randSe.map(cur => cur.seid); // 上一轮和这一轮随机出来的
let newTurnChosen = new Array<number>(); // 这一轮随机出来的
let hasReset = false;
for(let i = 0; i < randSe.length; i++) {
if(!randSe[i].locked) {
pool = pool.filter(cur => !chosen.includes(cur.id));
let random = getRandomByLen(pool);
if(!random) break;
let newPool = pool.filter(cur => !chosen.includes(cur.id));
if(newPool.length <= 0) newPool = pool.filter(cur => !newTurnChosen.includes(cur.id));
let random = getRandomByLen(newPool);
if(!random) {break};
chosen.push(random.id);
newTurnChosen.push(random.id);
let rand = 0;
if(random.id > 0) rand = Math.floor(Math.random() * (random.max - random.min) + random.min);
newRandSe.push({
id: i + 1,
seid: random.id,
rand,
locked: false
});
} else {
newRandSe.push({
id: i + 1,
seid: randSe[i].seid,
rand: randSe[i].rand,
locked: randSe[i].locked
});
console.log(Math.random(), random.Max, random.Min)
if(random.id > 0) rand = Math.floor(Math.random() * (random.Max - random.Min) + random.Min);
randSe[i].seid = random.id;
randSe[i].rand = rand;
hasReset = true;
}
}
if(!hasReset) {
return resResult(STATUS.ROLE_EQUIP_CANNOT_RESTRENGTHEN);
}
// TODO 消耗
let cost = [];
let result = await handleCost(roleId, sid, cost);
if(!result) return resResult(STATUS.ROLE_MATERIAL_NOT_ENOUGH);
let curEquip = await EquipModel.updateEquipInfo(eid, {randSe: newRandSe})
let equipResult = await EquipModel.updateEquipInfo(eid, { randSe })
let curEquip = {
seqId: equipResult.seqId,
id: equipResult.id,
randSe: equipResult.randSe
}
return resResult(STATUS.SUCCESS,{curEquip});
}

View File

@@ -8,7 +8,7 @@
"declarations": true
},
"scripts": {
"start": "egg-scripts start --daemon --title=egg-server-gm-server",
"start": "egg-scripts start --daemon --title=egg-server-gm-server --ignore-stderr",
"stop": "egg-scripts stop --title=egg-server-gm-server",
"dev": "egg-bin dev",
"debug": "egg-bin debug",

View File

@@ -13,7 +13,9 @@ export const HERO_SYSTEM_TYPE = {
export const HERO_GROW_MAX = {
STAR: 6,
COLORSTAR: 6,
QUALITY: 3
QUALITY: 3,
EQUIP_STRENGTHEN: 100,
EQUIP_REFINE: 15
}
export const JOB_TYPE = {

View File

@@ -83,8 +83,9 @@ export const FILENAME = {
DIC_TOWER: 'dic_zyz_tower',
DIC_XUNBAO: 'dic_zyz_xunbao',
DIC_QUESTION: 'Questions',
DIC_RANDOM_EFFECT_POOL: 'dic_random_effect_pool',
DIC_STRENGTHEN_COST: 'dic_zyz_enhancementCost'
DIC_RANDOM_EFFECT_POOL: 'dic_zyz_randomEffectPool',
DIC_STRENGTHEN_COST: 'dic_zyz_enhancementCost',
DIC_REFINE: 'dic_zyz_jinglian'
}
export const WAR_RELATE_TABLES = [

View File

@@ -148,6 +148,9 @@ export const STATUS = {
ROLE_EQUIP_PLACE_NOT_ENOUGH: {code: 30400, simStr: '装备栏未装备或无可强化'},
ROLE_COIN_NOT_ENOUGH: {code: 30401, simStr: '铜币不足'},
EQUIP_HAVE_NO_RANDSE: { code: 30403, simStr: '装备无随机属性' },
ROLE_EQUIP_REACH_MAX: { code: 30404, simStr: '强化已达上限' },
ROLE_EQUIP_NOT_REACH_MAX: { code: 30405, simStr: '强化未达到上限' },
ROLE_EQUIP_CANNOT_RESTRENGTHEN: { code: 30406, simStr: '无属性可以洗炼' },
EQUIP_NOT_FIND: {code: 30500, simStr: '装备不存在'},
EQUIP_IS_EQUIPED: {code: 30501, simStr: '装备已经穿戴'},

View File

@@ -11,33 +11,33 @@ export class CeAttrData {
export class CeAttr {
@prop({ required: false })
hp?: CeAttrData;
hp?: CeAttrData = new CeAttrData();
@prop({ required: false })
atk?: CeAttrData;
atk?: CeAttrData = new CeAttrData();
@prop({ required: false })
matk?: CeAttrData;
matk?: CeAttrData = new CeAttrData();
@prop({ required: false })
def?: CeAttrData;
def?: CeAttrData = new CeAttrData();
@prop({ required: false })
mdef?: CeAttrData;
mdef?: CeAttrData = new CeAttrData();
@prop({ required: false })
agi?: CeAttrData;
agi?: CeAttrData = new CeAttrData();
@prop({ required: false })
luk?: CeAttrData;
luk?: CeAttrData = new CeAttrData();
@prop({ required: false })
hit?: CeAttrData;
hit?: CeAttrData = new CeAttrData();
@prop({ required: false })
cri?: CeAttrData;
cri?: CeAttrData = new CeAttrData();
@prop({ required: false })
flee?: CeAttrData;
flee?: CeAttrData = new CeAttrData();
@prop({ required: false })
antCri?: CeAttrData;
antCri?: CeAttrData = new CeAttrData();
@prop({ required: false })
damageIncrease?: CeAttrData;
damageIncrease?: CeAttrData = new CeAttrData();
@prop({ required: false })
damageDecrease?: CeAttrData;
damageDecrease?: CeAttrData = new CeAttrData();
@prop({ required: false })
defIngnore?: CeAttrData;
defIngnore?: CeAttrData = new CeAttrData();
@prop({ required: false })
bloodSuck?: CeAttrData;
bloodSuck?: CeAttrData = new CeAttrData();
}

View File

@@ -27,6 +27,7 @@ import { dicHeroStar } from "./dictionary/DicHeroStar";
import { dicHeroWake } from "./dictionary/DicHeroWake";
import { dicRandomEffectPool } from './dictionary/DicRandomEffectPool';
import { dicStrengthenCost } from './dictionary/DicStrengthenCost';
import { dicRefine } from './dictionary/DicRefine';
export const gameData = {
blurprtCompose: dicBlueprtCompose,
@@ -64,7 +65,8 @@ export const gameData = {
friendShipLevel: dicFriendShipLevel,
friendShipLevelMap: dicFriendShipLevelMap,
randomEffectPool: dicRandomEffectPool,
strengthenCost: dicStrengthenCost
strengthenCost: dicStrengthenCost,
refine: dicRefine
};
// 在此提供一些原先在gamedata中提供的方法以便更方便获取gameData数据

View File

@@ -2,4 +2,8 @@ export const EQUIP = {
EQUIP_ONE_HOLE: '1&1', // 装备孔1号位消耗
EQUIP_TWO_HOLE: '1&2', // 装备孔2号位消耗
EQUIP_THREE_HOLE: '1&4', // 装备孔3号位消耗
XILIAN_ZERO_LOCK: '1&1', // 洗炼0个锁
XILIAN_ONE_LOCK: '1&2', // 洗炼1个锁
XILIAN_TWO_LOCK: '1&3', // 洗炼2个锁
XILIAN_THREE_LOCK: '1&4', // 洗炼3个锁
};

View File

@@ -13,9 +13,9 @@ export interface DicRandomEffectPool {
// 随机值位置
readonly index: number;
// 随机最小值
readonly min: number;
readonly Min: number;
// 随机最大值
readonly max: number;
readonly Max: number;
}

View File

@@ -0,0 +1,30 @@
// 武将特技表
import { readJsonFile, parseReward } from '../util'
import { FILENAME } from '../../consts'
import { RewardInter } from '../interface';
export interface DicRefine {
// 精炼id
readonly id: number;
// 精炼等级
readonly level: number;
// 提高属性百分比
readonly upPercent: number;
// 材料
readonly material: Array<RewardInter>;
// 成功率
readonly successRate: number;
}
const str = readJsonFile(FILENAME.DIC_REFINE);
let arr = JSON.parse(str);
export const dicRefine = new Map<number, DicRefine>();
arr.forEach(o => {
o.material = parseReward(o.gainvalue)
dicRefine.set(o.id, o);
});

View File

@@ -40,11 +40,11 @@ export async function addEquips(roleId: string, roleName: string, weapon: EquipI
let randSe = new Array<RandSe>();
for(let i = 0; i < randomNum; i++) {
pool = pool.filter(cur => !chosen.includes(cur.id));
console.log(JSON.stringify(pool))
let random = getRandomByLen(pool);
if(!random) break;
chosen.push(random.id);
let rand = 0;
if(random.id > 0) rand = Math.floor(Math.random() * (random.max - random.min) + random.min);
if(random.id > 0) rand = Math.floor(Math.random() * (random.Max - random.Min) + random.Min);
randSe.push({
id: i + 1,
seid: random.id,

View File

@@ -483,7 +483,7 @@ export function parseReward(str: string) {
export function parseNumberList(str: string) {
let res = new Array<number>();
if(!str) return res;
let arr = decodeArrayStr(str);
let arr = decodeArrayStr(str, '&');
for(let g of arr) {
if(g === "") continue;
res.push(parseInt(g));

View File

@@ -0,0 +1,340 @@
[
{
"id": 1,
"type": 102,
"gainValue": "2&0",
"index": 2,
"Min": 5,
"Max": 10,
"info": "物攻提高",
"__EMPTY": 0,
"__EMPTY_1": 0,
"__EMPTY_2": 0,
"__EMPTY_3": 0
},
{
"id": 2,
"type": 102,
"gainValue": "1&0",
"index": 2,
"Min": 5,
"Max": 10,
"info": "生命值提高",
"__EMPTY": 0,
"__EMPTY_1": 0,
"__EMPTY_2": 0,
"__EMPTY_3": 0
},
{
"id": 3,
"type": 102,
"gainValue": "3&0",
"index": 2,
"Min": 5,
"Max": 10,
"info": "策攻提高",
"__EMPTY": 0,
"__EMPTY_1": 0,
"__EMPTY_2": 0,
"__EMPTY_3": 0
},
{
"id": 4,
"type": 102,
"gainValue": "4&0",
"index": 2,
"Min": 5,
"Max": 10,
"info": "物防提高",
"__EMPTY": 0,
"__EMPTY_1": 0,
"__EMPTY_2": 0,
"__EMPTY_3": 0
},
{
"id": 5,
"type": 102,
"gainValue": "5&0",
"index": 2,
"Min": 5,
"Max": 10,
"info": "策防提高",
"__EMPTY": 0,
"__EMPTY_1": 0,
"__EMPTY_2": 0,
"__EMPTY_3": 0
},
{
"id": 6,
"type": 102,
"gainValue": "6&0",
"index": 2,
"Min": 5,
"Max": 10,
"info": "敏捷提高",
"__EMPTY": 0,
"__EMPTY_1": 0,
"__EMPTY_2": 0,
"__EMPTY_3": 0
},
{
"id": 7,
"type": 102,
"gainValue": "7&0",
"index": 2,
"Min": 5,
"Max": 10,
"info": "幸运提高",
"__EMPTY": 0,
"__EMPTY_1": 0,
"__EMPTY_2": 0,
"__EMPTY_3": 0
},
{
"id": 8,
"type": 101,
"gainValue": "2&0",
"index": 2,
"Min": 200,
"Max": 400,
"info": "物攻提高",
"__EMPTY": 0,
"__EMPTY_1": 0,
"__EMPTY_2": 0,
"__EMPTY_3": 0
},
{
"id": 9,
"type": 101,
"gainValue": "1&0",
"index": 2,
"Min": 200,
"Max": 400,
"info": "生命值提高",
"__EMPTY": 0,
"__EMPTY_1": 0,
"__EMPTY_2": 0,
"__EMPTY_3": 0
},
{
"id": 10,
"type": 101,
"gainValue": "3&0",
"index": 2,
"Min": 200,
"Max": 400,
"info": "策攻提高",
"__EMPTY": 0,
"__EMPTY_1": 0,
"__EMPTY_2": 0,
"__EMPTY_3": 0
},
{
"id": 11,
"type": 101,
"gainValue": "4&0",
"index": 2,
"Min": 200,
"Max": 400,
"info": "物防提高",
"__EMPTY": 0,
"__EMPTY_1": 0,
"__EMPTY_2": 0,
"__EMPTY_3": 0
},
{
"id": 12,
"type": 101,
"gainValue": "5&0",
"index": 2,
"Min": 200,
"Max": 400,
"info": "策防提高",
"__EMPTY": 0,
"__EMPTY_1": 0,
"__EMPTY_2": 0,
"__EMPTY_3": 0
},
{
"id": 13,
"type": 101,
"gainValue": "6&0",
"index": 2,
"Min": 200,
"Max": 400,
"info": "敏捷提高",
"__EMPTY": 0,
"__EMPTY_1": 0,
"__EMPTY_2": 0,
"__EMPTY_3": 0
},
{
"id": 14,
"type": 101,
"gainValue": "7&0",
"index": 2,
"Min": 5000,
"Max": 10000,
"info": "幸运提高",
"__EMPTY": 0,
"__EMPTY_1": 0,
"__EMPTY_2": 0,
"__EMPTY_3": 0
},
{
"id": 15,
"type": 101,
"gainValue": "8&0",
"index": 2,
"Min": 1,
"Max": 3,
"info": "移动提高",
"__EMPTY": 0,
"__EMPTY_1": 0,
"__EMPTY_2": 0,
"__EMPTY_3": 0
},
{
"id": 16,
"type": 101,
"gainValue": "9&0",
"index": 2,
"Min": 5000,
"Max": 10000,
"info": "命中提高",
"__EMPTY": 0,
"__EMPTY_1": 0,
"__EMPTY_2": 0,
"__EMPTY_3": 0
},
{
"id": 17,
"type": 101,
"gainValue": "10&0",
"index": 2,
"Min": 5000,
"Max": 10000,
"info": "暴击提高",
"__EMPTY": 0,
"__EMPTY_1": 0,
"__EMPTY_2": 0,
"__EMPTY_3": 0
},
{
"id": 18,
"type": 101,
"gainValue": "11&0",
"index": 2,
"Min": 5000,
"Max": 10000,
"info": "格挡提高",
"__EMPTY": 0,
"__EMPTY_1": 0,
"__EMPTY_2": 0,
"__EMPTY_3": 0
},
{
"id": 19,
"type": 101,
"gainValue": "12&0",
"index": 2,
"Min": 5000,
"Max": 10000,
"info": "暴击等级提高",
"__EMPTY": 0,
"__EMPTY_1": 0,
"__EMPTY_2": 0,
"__EMPTY_3": 0
},
{
"id": 20,
"type": 101,
"gainValue": "13&0",
"index": 2,
"Min": 5000,
"Max": 10000,
"info": "伤害加深提高",
"__EMPTY": 0,
"__EMPTY_1": 0,
"__EMPTY_2": 0,
"__EMPTY_3": 0
},
{
"id": 21,
"type": 101,
"gainValue": "14&0",
"index": 2,
"Min": 5000,
"Max": 10000,
"info": "伤害减免提高",
"__EMPTY": 0,
"__EMPTY_1": 0,
"__EMPTY_2": 0,
"__EMPTY_3": 0
},
{
"id": 22,
"type": 101,
"gainValue": "15&0",
"index": 2,
"Min": 5000,
"Max": 10000,
"info": "忽视防御提高",
"__EMPTY": 0,
"__EMPTY_1": 0,
"__EMPTY_2": 0,
"__EMPTY_3": 0
},
{
"id": 23,
"type": 101,
"gainValue": "16&0",
"index": 2,
"Min": 5000,
"Max": 10000,
"info": "吸血提高",
"__EMPTY": 0,
"__EMPTY_1": 0,
"__EMPTY_2": 0,
"__EMPTY_3": 0
},
{
"id": 24,
"type": 101,
"gainValue": "1&10",
"index": 0,
"Min": 0,
"Max": 0,
"info": "生命值提高",
"__EMPTY": 0,
"__EMPTY_1": 0,
"__EMPTY_2": 0,
"__EMPTY_3": 0
},
{
"id": 25,
"type": 101,
"gainValue": "2&20",
"index": 0,
"Min": 0,
"Max": 0,
"info": "物攻提高",
"__EMPTY": 0,
"__EMPTY_1": 0,
"__EMPTY_2": 0,
"__EMPTY_3": 0
},
{
"id": 26,
"type": 101,
"gainValue": "10&50000",
"index": 0,
"Min": 0,
"Max": 0,
"info": "暴击提高",
"__EMPTY": 0,
"__EMPTY_1": 0,
"__EMPTY_2": 0,
"__EMPTY_3": 0
}
]