军团捐献,许愿池,装备,养成 注释

This commit is contained in:
mamengke01
2021-02-24 18:34:54 +08:00
parent 87d7bf6a8e
commit 88d5e26753
9 changed files with 152 additions and 73 deletions
@@ -20,7 +20,11 @@ export class DonationHandler {
constructor(private app: Application) { constructor(private app: Application) {
} }
/**
* 捐献所的等级,捐献的次数,战报,捐献达到的基金,领取宝箱记录
* @param msg
* @param session
*/
async getDonation(msg: {}, session: BackendSession) { async getDonation(msg: {}, session: BackendSession) {
const roleId: string = session.get('roleId'); const roleId: string = session.get('roleId');
const serverId: number = parseInt(session.get('serverId')); const serverId: number = parseInt(session.get('serverId'));
@@ -32,7 +36,11 @@ export class DonationHandler {
let { donateFund, reports, donationLv } = await getDonation(code, serverId); let { donateFund, reports, donationLv } = await getDonation(code, serverId);
return resResult(STATUS.SUCCESS, { receiveBoxs, donateFund, reports, donateCnt:donateCnt||0, donationLv}); return resResult(STATUS.SUCCESS, { receiveBoxs, donateFund, reports, donateCnt:donateCnt||0, donationLv});
} }
/**
* 捐献
* @param msg
* @param session
*/
async donate(msg: {id: number}, session: BackendSession) { async donate(msg: {id: number}, session: BackendSession) {
const { id } = msg; const { id } = msg;
const roleId: string = session.get('roleId'); const roleId: string = session.get('roleId');
@@ -64,7 +72,11 @@ export class DonationHandler {
return resResult(STATUS.SUCCESS, { donateFund, reports, donateCnt, goods }); return resResult(STATUS.SUCCESS, { donateFund, reports, donateCnt, goods });
} }
/**
* 领取宝箱
* @param msg
* @param session
*/
async receiveBox(msg: {id: number}, session: BackendSession) { async receiveBox(msg: {id: number}, session: BackendSession) {
const { id } = msg; const { id } = msg;
const roleId: string = session.get('roleId'); const roleId: string = session.get('roleId');
@@ -528,8 +528,7 @@ export class EquipHandler {
let good = ITID.get(goodInfo.itid); let good = ITID.get(goodInfo.itid);
if (good.type != CONSUME_TYPE.JEWEL) if (good.type != CONSUME_TYPE.JEWEL)
return resResult(STATUS.WRONG_PARMS); return resResult(STATUS.WRONG_PARMS);
//检查宝石消耗是否合法TODO let needConsumes = checkMaterialEnough(consumes, jewel, count);//检查是否可以合成,并返回最终需要消耗的材料
let needConsumes = checkMaterialEnough(consumes, jewel, count);
if (!needConsumes) if (!needConsumes)
return resResult(STATUS.WRONG_PARMS); return resResult(STATUS.WRONG_PARMS);
let res = await handleCost(roleId, sid, needConsumes); let res = await handleCost(roleId, sid, needConsumes);
@@ -576,26 +575,29 @@ export class EquipHandler {
let good = ITID.get(goodInfo.itid); let good = ITID.get(goodInfo.itid);
if (good.type != CONSUME_TYPE.JEWEL) if (good.type != CONSUME_TYPE.JEWEL)
return resResult(STATUS.WRONG_PARMS); return resResult(STATUS.WRONG_PARMS);
//检查宝石消耗是否合法TODO if (!purchaseGoods) //需要购买才可进行合成的物品
if (!purchaseGoods)
purchaseGoods = []; purchaseGoods = [];
if (!consumes) if (!consumes)
consumes = []; consumes = [];
let needConsumes = checkMaterialEnough(consumes.concat(purchaseGoods), jewel, count); let needConsumes = checkMaterialEnough(consumes.concat(purchaseGoods), jewel, count);//检查是否可以合成,并返回最终需要消耗的材料
if (!needConsumes) if (!needConsumes)
return resResult(STATUS.WRONG_PARMS); return resResult(STATUS.WRONG_PARMS);
let items:Array<{id: number, count: number, ratio?:number}> = []; let items:Array<{id: number, count: number, ratio?:number}> = [];
for (let item of purchaseGoods) { for (let item of purchaseGoods) {
items.push({id: item.id, count: item.count, ratio: 1}) items.push({id: item.id, count: item.count, ratio: 1})//加上购买的数量
} }
items = items.concat(needConsumes); items = items.concat(needConsumes);
let hasError = await decreaseItems(roleId, sid, items); let hasError = await decreaseItems(roleId, sid, items);//合并消耗是否足够
if (!!hasError) if (!!hasError)
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH); return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
await addItems(roleId, roleName, sid, [{ id: jewel, count: count }]); await addItems(roleId, roleName, sid, [{ id: jewel, count: count }]);
return resResult(STATUS.SUCCESS); return resResult(STATUS.SUCCESS);
} }
/**
* 临时使用的购买物品,后应该在商店中购买
* @param msg
* @param session
*/
public async purchaseGoods(msg: { purchaseGoods: Array<{ id: number, count: number }>}, session: BackendSession) { public async purchaseGoods(msg: { purchaseGoods: Array<{ id: number, count: number }>}, session: BackendSession) {
let { purchaseGoods } = msg; let { purchaseGoods } = msg;
let roleId: string = session.get('roleId'); let roleId: string = session.get('roleId');
@@ -607,7 +609,11 @@ export class EquipHandler {
} }
return resResult(STATUS.SUCCESS); return resResult(STATUS.SUCCESS);
} }
//合成下一级宝石并穿戴(装备镶嵌界面) /**
* 合成下一级宝石并穿戴(装备镶嵌界面)
* @param msg
* @param session
*/
public async composeNextLevelJewel(msg: { jewel: number, count: number, eid: number, id: number }, session: BackendSession) { public async composeNextLevelJewel(msg: { jewel: number, count: number, eid: number, id: number }, session: BackendSession) {
let { count, jewel, eid, id } = msg; let { count, jewel, eid, id } = msg;
let roleId: string = session.get('roleId'); let roleId: string = session.get('roleId');
@@ -621,25 +627,27 @@ export class EquipHandler {
if (good.type != CONSUME_TYPE.JEWEL) if (good.type != CONSUME_TYPE.JEWEL)
return resResult(STATUS.WRONG_PARMS); return resResult(STATUS.WRONG_PARMS);
let equip; let equip;
if (!!eid) { if (!!eid) {//合成并穿戴
equip = await EquipModel.getEquip(eid); equip = await EquipModel.getEquip(eid);
let index = findIndex(equip.holes,{id}); let index = findIndex(equip.holes,{id});
//装备上该位置有穿戴该宝石,且在合成的材料中
if (!!equip.holes[index] && equip.holes[index].jewel == goodInfo.composeMaterial[0].id) { if (!!equip.holes[index] && equip.holes[index].jewel == goodInfo.composeMaterial[0].id) {
oldJewel = equip.holes[index].jewel; oldJewel = equip.holes[index].jewel;
equip.holes[index].jewel = jewel; equip.holes[index].jewel = jewel;//合成后的新宝石穿戴到装备上
needUpdate = true; needUpdate = true;
consumes.push({id: goodInfo.composeMaterial[0].id, count: 1, ratio: 1}); consumes.push({id: goodInfo.composeMaterial[0].id, count: 1, ratio: 1});//ratio:1表示可以释放掉一颗宝石
} }
} }
consumes = consumes.concat(goodInfo.composeMaterial); consumes = consumes.concat(goodInfo.composeMaterial);
if (goodInfo.specialMaterial.count) { if (goodInfo.specialMaterial.count) {
consumes.push({id: goodInfo.specialMaterial.ids[0], count: goodInfo.specialMaterial.count}) consumes.push({id: goodInfo.specialMaterial.ids[0], count: goodInfo.specialMaterial.count})
} }
let hasError = await decreaseItems(roleId, sid, consumes); let hasError = await decreaseItems(roleId, sid, consumes);//检查是消耗是否足够
if (!!hasError) if (!!hasError)
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH); return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
let result = {}; let result = {};
if (needUpdate) { if (needUpdate) {
//穿戴宝石
await EquipModel.updateEquipInfo(eid, { holes: equip.holes }); await EquipModel.updateEquipInfo(eid, { holes: equip.holes });
if (!!equip.hid) { if (!!equip.hid) {
let hero = await HeroModel.findByHidAndRole(equip.hid, roleId); let hero = await HeroModel.findByHidAndRole(equip.hid, roleId);
@@ -10,7 +10,7 @@ import { getTeraphAttr, getAtrrNameById } from '../../../consts/constModules/abi
import { findIndex } from 'underscore'; import { findIndex } from 'underscore';
import { SclResultInter, SclPosInter } from '../../../pubUtils/interface'; import { SclResultInter, SclPosInter } from '../../../pubUtils/interface';
import { SchoolModel } from '../../../db/School'; import { SchoolModel } from '../../../db/School';
import { checkMaterialEnough } from '../../../services/roleService' import { checkTeraphMaterialEnough } from '../../../services/roleService'
import { calPlayerCeAndSave, calAllHeroCe } from '../../../services/playerCeService'; import { calPlayerCeAndSave, calAllHeroCe } from '../../../services/playerCeService';
import { HERO_SYSTEM_TYPE } from '../../../consts'; import { HERO_SYSTEM_TYPE } from '../../../consts';
@@ -94,7 +94,7 @@ export class RoleHandler {
return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH); return resResult(STATUS.BATTLE_CONSUMES_NOT_ENOUGH);
await RoleModel.updateRoleInfo(roleId, { title }); await RoleModel.updateRoleInfo(roleId, { title });
let {ce} = await calAllHeroCe( sid, roleId, HERO_SYSTEM_TYPE.TITLE, [title]); let {ce} = await calAllHeroCe( sid, roleId, HERO_SYSTEM_TYPE.TITLE, [title]);
return resResult(STATUS.SUCCESS, { roleId, title, oldCe: reduceCe(oldCe), incRoleCe: ce - reduceCe(oldCe)}); return resResult(STATUS.SUCCESS, { roleId, title });
} }
//神像强化 //神像强化
@@ -120,7 +120,7 @@ export class RoleHandler {
if (!attrs.length) if (!attrs.length)
return resResult(STATUS.ROLE_TERAPH_NOT_STRENGTHEN); return resResult(STATUS.ROLE_TERAPH_NOT_STRENGTHEN);
// 随机神像中的一条属性并检查道具是否足够 // 随机神像中的一条属性并检查道具是否足够
let {attr, consumes} = checkMaterialEnough(count, attrs, teraphInfo, teraph); let {attr, consumes} = checkTeraphMaterialEnough(count, attrs, teraphInfo, teraph);
for (let key in attr) { for (let key in attr) {
teraph[key] += attr[key]; teraph[key] += attr[key];
role.globalCeAttr[key].fixUp += attr[key]; role.globalCeAttr[key].fixUp += attr[key];
+10 -1
View File
@@ -4,6 +4,11 @@ import { getTodayZeroPoint, nowSeconds } from '../pubUtils/timeUtil';
import { GuildModel } from '../db/Guild'; import { GuildModel } from '../db/Guild';
import { findWhere } from 'underscore'; import { findWhere } from 'underscore';
import { GUILD_STRUCTURE } from '../consts/constModules/guildConst'; import { GUILD_STRUCTURE } from '../consts/constModules/guildConst';
/**
* 获得军团捐献,并检查是否刷新捐献数据
* @param code
* @param serverId
*/
export async function getDonation(code: string, serverId: number) { export async function getDonation(code: string, serverId: number) {
let donation = await DonationModel.getDonation(code); let donation = await DonationModel.getDonation(code);
if (!donation) { if (!donation) {
@@ -17,7 +22,11 @@ export async function getDonation(code: string, serverId: number) {
return donation; return donation;
} }
/**
* 创建军团捐献信息
* @param code
* @param serverId
*/
export async function createDonation(code: string, serverId: number) { export async function createDonation(code: string, serverId: number) {
let { structure } = await GuildModel.findGuild(code, serverId, 'structure'); let { structure } = await GuildModel.findGuild(code, serverId, 'structure');
let { lv } = findWhere(structure, {id: GUILD_STRUCTURE.DONATE}); let { lv } = findWhere(structure, {id: GUILD_STRUCTURE.DONATE});
+61 -26
View File
@@ -1,67 +1,93 @@
import { mergeSameGoods } from '../pubUtils/util'; import { mergeSameGoods } from '../pubUtils/util';
import { EquipModel } from "../db/Equip"; import { EquipModel } from "../db/Equip";
import { HeroModel, EPlace, HeroType } from "../db/Hero"; import { HeroModel, EPlace, HeroType } from "../db/Hero";
import { ITID } from "../consts/constModules/itemConst";
import { getHeroJob, getGoodById, gameData, getJewelById, getHeroEquipByClassId } from "../pubUtils/data"; import { getHeroJob, getGoodById, gameData, getJewelById, getHeroEquipByClassId } from "../pubUtils/data";
import { calPlayerCeAndSave } from "./playerCeService"; import { calPlayerCeAndSave } from "./playerCeService";
import { HERO_SYSTEM_TYPE } from "../consts"; import { HERO_SYSTEM_TYPE } from "../consts";
import { EquipType } from "../db/Equip"; import { EquipType } from "../db/Equip";
import { calEquipSeids } from '../pubUtils/playerCe'; import { calEquipSeids } from '../pubUtils/playerCe';
import { indexOf, findIndex } from 'underscore'; import { indexOf, findIndex } from 'underscore';
/**
* 校验前端传入的消耗数量是否准确,并返回消耗的道具并加上特殊材料needConsumes
* @param consumes
* @param jewel
* @param jewelCount
*/
export function checkMaterialEnough(consumes:Array<{id: number, count: number}>, jewel: number, jewelCount: number) { export function checkMaterialEnough(consumes:Array<{id: number, count: number}>, jewel: number, jewelCount: number) {
let comJewelMap = {}; let comJewelMap = {};
consumes = mergeSameGoods(consumes); consumes = mergeSameGoods(consumes);
let needConsumes: Array<{id: number, count: number}> = []; let needConsumes: Array<{id: number, count: number}> = [];
let gidJewelInfo = getGoodById(jewel); let gidJewelInfo = getGoodById(jewel);//目标宝石信息
for (let { id, count } of consumes) { for (let { id, count } of consumes) {
let jewelInfo = getJewelById(id); let jewelInfo = getJewelById(id);
if (!jewelInfo || !jewelInfo.count) if (!jewelInfo || !jewelInfo.count) //筛选出特殊材料,特殊材料没有合成下一级需要的count数量
continue; continue;
needConsumes.push({ id, count}); needConsumes.push({ id, count});//将该宝石加入消耗中
comJewelMap[jewelInfo.good_id] = count + (comJewelMap[jewelInfo.good_id] || 0); comJewelMap[id] = count + (comJewelMap[id] || 0);
for (let i = jewelInfo.lvLimited; i < gidJewelInfo.lvLimited; i++) { for (let i = jewelInfo.lvLimited; i < gidJewelInfo.lvLimited; i++) {//当前消耗的宝石升级到目标宝石的消耗
if (((comJewelMap[jewelInfo.good_id] || 0) % jewelInfo.count != 0)) { if (((comJewelMap[id] || 0) % jewelInfo.count != 0)) {//jewelInfo的count,表示宝石id合成下一级需要的数量
break; break;//数量有余,跳出循环,等待下次合成
} }
let comcount = Math.floor(((comJewelMap[jewelInfo.good_id] || 0)) / jewelInfo.count); let comcount = Math.floor(((comJewelMap[id] || 0)) / jewelInfo.count);
if (comcount < 1) { if (comcount < 1) {
break; break;//不能合成,跳出循环,等待下次合成
} }
comJewelMap[jewelInfo.nextJewelId] = comcount + (comJewelMap[jewelInfo.nextJewelId] || 0); comJewelMap[jewelInfo.nextJewelId] = comcount + (comJewelMap[jewelInfo.nextJewelId] || 0);//jewelInfo的nextJewelId,表示宝石id合成下一级的宝石good_id
delete comJewelMap[jewelInfo.good_id]; delete comJewelMap[id];
if (!!jewelInfo.specialCount) if (!!jewelInfo.specialCount)
needConsumes.push({ count: jewelInfo.specialCount * comcount, id: jewelInfo.nextSpecialId}); needConsumes.push({ count: jewelInfo.specialCount * comcount, id: jewelInfo.nextSpecialId});//消耗中曾加合成下一级需要的特殊消耗物品的数量
jewelInfo = getJewelById(jewelInfo.nextJewelId); jewelInfo = getJewelById(jewelInfo.nextJewelId);
} }
} }
if (comJewelMap[jewel] != jewelCount || Object.keys(comJewelMap).length != 1) if (comJewelMap[jewel] != jewelCount || Object.keys(comJewelMap).length != 1)//检查最终是否可以合成目标宝石jewel,以及对应的数量jewelCount
return false; return false;
return needConsumes; return needConsumes;
} }
/**
* 将装备卸载下来,并坚持是否有替换装备的武将,若有则替换
* @param roleId
* @param sid
* @param equip
* @param hid
* @param id
* @param seqId
*/
export async function changeEquip(roleId: string, sid: string, equip: EquipType, hid: number, id: number, seqId: number) { export async function changeEquip(roleId: string, sid: string, equip: EquipType, hid: number, id: number, seqId: number) {
let hero; let hero;
if (!!hid) //需要卸下或者替换的武将 if (!!hid) //需要卸下或者替换的武将
hero = await HeroModel.findByHidAndRoleWithEquip(hid, roleId); hero = await HeroModel.findByHidAndRoleWithEquip(hid, roleId);//需要替换的武将
if (!!equip) {//需要卸下的装备 if (!!equip) {//需要卸下的装备
if (!!hero) {//判断是否替换装备 if (!!hero) {
let goodInfo = getGoodById(equip.id); let goodInfo = getGoodById(equip.id);
if (goodInfo.lvLimited > hero.lv) if (goodInfo.lvLimited > hero.lv) {
return takeOffEquip(equip.seqId); let res = await takeOffEquip(equip.seqId);//不能替换,卸载装备不算战力
return res;
}
let { jobid } = gameData.hero.get(hid); let { jobid } = gameData.hero.get(hid);
let { job_class } = getHeroJob(jobid); let { job_class } = getHeroJob(jobid);
let { classId } = getHeroEquipByClassId(goodInfo.itid); let { classId } = getHeroEquipByClassId(goodInfo.itid);
if (indexOf(classId, job_class) < 0) if (indexOf(classId, job_class) < 0) {
return takeOffEquip(equip.seqId); let res = await takeOffEquip(equip.seqId);//不能替换,卸载装备不算战力
return dressEquip(roleId, sid, hero, equip); return res;
}
let res = await dressEquip(roleId, sid, hero, equip);//替换给武将,并计算战力
return res;
} else { } else {
return takeOffEquip(equip.seqId); let res = await takeOffEquip(equip.seqId);//不能替换,卸载装备不算战力
return res;
} }
} else if (!!hero) {//从穿戴装备的武将上卸下装备 } else if (!!hero) {//从穿戴装备的武将上卸下装备
await takeOffEquipAndCalPlayerCe(roleId, sid, seqId, hero, id);//卸下装备并重算战力 await takeOffEquipAndCalPlayerCe(roleId, sid, seqId, hero, id);//卸下装备并重算战力
} }
} }
/**
* 从穿戴装备的武将上卸下装备,并重算战力
* @param roleId
* @param sid
* @param seqId
* @param hero
* @param id
*/
export async function takeOffEquipAndCalPlayerCe(roleId: string, sid: string, seqId: number, hero:HeroType, id: number ) { export async function takeOffEquipAndCalPlayerCe(roleId: string, sid: string, seqId: number, hero:HeroType, id: number ) {
let index = findIndex(hero.ePlace, { id }); let index = findIndex(hero.ePlace, { id });
if (index < 0) if (index < 0)
@@ -72,14 +98,23 @@ export async function takeOffEquipAndCalPlayerCe(roleId: string, sid: string, se
await calPlayerCeAndSave(sid, roleId, [hero], HERO_SYSTEM_TYPE.EQUIP, args); await calPlayerCeAndSave(sid, roleId, [hero], HERO_SYSTEM_TYPE.EQUIP, args);
return { seqId, hid: 0}; return { seqId, hid: 0};
} }
/**
* 穿戴装备并重算战力
* @param roleId
* @param sid
* @param hero
* @param equip
*/
export async function dressEquip(roleId: string, sid: string, hero:HeroType, equip: EquipType) { export async function dressEquip(roleId: string, sid: string, hero:HeroType, equip: EquipType) {
hero = await HeroModel.addEquip(roleId, hero.hid, equip.ePlaceId, equip._id); hero = await HeroModel.addEquip(roleId, hero.hid, equip.ePlaceId, equip._id);
let args = calEquipSeids(hero); let args = calEquipSeids(hero);
await calPlayerCeAndSave(sid, roleId, [hero], HERO_SYSTEM_TYPE.EQUIP, args); await calPlayerCeAndSave(sid, roleId, [hero], HERO_SYSTEM_TYPE.EQUIP, args);
return { seqId: equip.seqId, hid: hero.hid }; return { seqId: equip.seqId, hid: hero.hid };
} }
/**
* 修改装备未穿戴状态,不计算战力
* @param seqId
*/
async function takeOffEquip(seqId: number) { async function takeOffEquip(seqId: number) {
await EquipModel.updateEquipInfo(seqId, { hid: 0 }); await EquipModel.updateEquipInfo(seqId, { hid: 0 });
return { seqId, hid: 0}; return { seqId, hid: 0};
+26 -14
View File
@@ -4,18 +4,25 @@ import { getRandNum, getRandomArr } from '../pubUtils/util';
import { TERAPH_RANDOM } from "../consts/consts"; import { TERAPH_RANDOM } from "../consts/consts";
import { indexOf } from 'underscore'; import { indexOf } from 'underscore';
const TERAPH_STRENGTHEN = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; const TERAPH_STRENGTHEN = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
export function checkMaterialEnough(count: number, attrs:Array<any>, teraphInfo: any, teraph: any) { /**
* 计算强化次数和消耗
* @param count 强化次数
* @param attrNames 可以强化的属性名字
* @param teraphInfo 字典表对应的神像信息
* @param teraph
*/
export function checkTeraphMaterialEnough(count: number, attrNames:Array<any>, teraphInfo: any, teraph: any) {
let res = {}; let res = {};
let consumes = []; let consumes = [];
let times = 0; let times = 0;
if (count < 10) { if (count < 10) {
for (let i = 0; i < count; i++) { for (let i = 0; i < count; i++) {
if (!attrs.length) { if (!attrNames.length) {
break; break;
} }
let num = getRandNum(TERAPH_RANDOM.MIN, TERAPH_RANDOM.MAX); let num = getRandNum(TERAPH_RANDOM.MIN, TERAPH_RANDOM.MAX);
let arr = getRandomArr(attrs, num) let arr = getRandomArr(attrNames, num)
let critical = getRandNum(0, 100); let critical = getRandNum(0, 100);//属性暴击率
let criEffect = 1; let criEffect = 1;
if (critical <= teraphInfo.criRate) if (critical <= teraphInfo.criRate)
criEffect = teraphInfo.criEffect; criEffect = teraphInfo.criEffect;
@@ -24,43 +31,48 @@ export function checkMaterialEnough(count: number, attrs:Array<any>, teraphInfo:
res[attrName] = teraphInfo[attrName] * criEffect; res[attrName] = teraphInfo[attrName] * criEffect;
if (teraph[attrName] + res[attrName] > teraphInfo[attrNameMax]) { if (teraph[attrName] + res[attrName] > teraphInfo[attrNameMax]) {
res[attrName] = teraphInfo[attrNameMax] - teraph[attrName]; res[attrName] = teraphInfo[attrNameMax] - teraph[attrName];
let attrIndex = indexOf(attrs, attrName); let attrIndex = indexOf(attrNames, attrName);
attrs.splice(attrIndex, 1); attrNames.splice(attrIndex, 1);
} }
} }
times++; times++;
} }
} else if (count == 10){ } else if (count == 10){
let criticalArr = getRandomArr(TERAPH_STRENGTHEN, 2); let criticalArrTimes = getRandomArr(TERAPH_STRENGTHEN, 2);//10次中随机2次发生暴击
for (let item of TERAPH_STRENGTHEN) { for (let item of TERAPH_STRENGTHEN) {
if (!attrs.length) { if (!attrNames.length) {
break; break;
} }
let criEffect = 1; let criEffect = 1;
let index = indexOf(criticalArr, {item}); let index = indexOf(criticalArrTimes, {item});
if (index > 0) { if (index > 0) {
criEffect = teraphInfo.criEffect; criEffect = teraphInfo.criEffect;//本次是暴击 item 在 criticalArrTimes 中
} }
let num = getRandNum(TERAPH_RANDOM.MIN, TERAPH_RANDOM.MAX); let num = getRandNum(TERAPH_RANDOM.MIN, TERAPH_RANDOM.MAX);
let arr = getRandomArr(attrs, num); let arr = getRandomArr(attrNames, num);
for (let attrName of arr) { for (let attrName of arr) {
res[attrName] = (res[attrName]||0) + teraphInfo[attrName] * criEffect; res[attrName] = (res[attrName]||0) + teraphInfo[attrName] * criEffect;
let attrNameMax = attrName+'Max'; let attrNameMax = attrName+'Max';
if (teraph[attrName] + res[attrName] > teraphInfo[attrNameMax]) { if (teraph[attrName] + res[attrName] > teraphInfo[attrNameMax]) {
res[attrName] = teraphInfo[attrNameMax] - teraph[attrName]; res[attrName] = teraphInfo[attrNameMax] - teraph[attrName];
let attrIndex = indexOf(attrs, attrName); let attrIndex = indexOf(attrNames, attrName);
attrs.splice(attrIndex, 1); attrNames.splice(attrIndex, 1);
} }
} }
times++; times++;
} }
} }
//计算消耗
for (let {id, count} of teraphInfo.upMaterial) { for (let {id, count} of teraphInfo.upMaterial) {
consumes.push({ id, count: count*times}); consumes.push({ id, count: count*times});
} }
return {attr: res, consumes}; return {attr: res, consumes};
} }
/**
*
* @param channel
* @param user
*/
export function addUserToChannel(channel: Channel, user: ChannelUser) { export function addUserToChannel(channel: Channel, user: ChannelUser) {
const users = channel.getMembers(); const users = channel.getMembers();
const { uid, sid } = user; const { uid, sid } = user;
@@ -152,6 +152,7 @@ export async function checkResult(pvpDefense: PvpDefenseType, seasonNum: number,
score += heroScore.score; score += heroScore.score;
} }
let pLv = getLvByScore(pvpDefense.heroScores); let pLv = getLvByScore(pvpDefense.heroScores);
//pvp锁定的信息存入赛季结算表中
await PvpSeasonResultModel.updatePvpSeasonResult(pvpDefense.roleId, { await PvpSeasonResultModel.updatePvpSeasonResult(pvpDefense.roleId, {
oldSeasonData:{refOppCnt: pvpDefense.refOppCnt, rankLv, score: pvpDefense.score, pLv: oldPLv, heroScores: oldHeroScores, oldSeasonData:{refOppCnt: pvpDefense.refOppCnt, rankLv, score: pvpDefense.score, pLv: oldPLv, heroScores: oldHeroScores,
seasonNum: pvpDefense.seasonNum, challengeCnt, challengeRefTime, seasonEndTime: oldSeasonEndTime seasonNum: pvpDefense.seasonNum, challengeCnt, challengeRefTime, seasonEndTime: oldSeasonEndTime
+11 -9
View File
@@ -66,7 +66,7 @@ export default class UserGuild extends BaseModel {
@prop({ required: true, default: new Date(), select: false }) @prop({ required: true, default: new Date(), select: false })
refTimeDaily: Date; refTimeDaily: Date;
//练兵场
@prop({ required: true, default: 0 }) @prop({ required: true, default: 0 })
trainCount: number;//每日挑战训练场的次数 trainCount: number;//每日挑战训练场的次数
@@ -78,18 +78,20 @@ export default class UserGuild extends BaseModel {
@prop({ required: true, default: [] }) @prop({ required: true, default: [] })
trainRewards: Array<number>;//领取过的进阶等级 trainRewards: Array<number>;//领取过的进阶等级
//捐献所
@prop({ required: true, default: [], type: WishGood, _id: false })
wishGoods: Array<WishGood>;
@prop({ required: true, default: [], type: Number }) @prop({ required: true, default: [], type: Number })
receiveBoxs: Array<number>; receiveBoxs: Array<number>; //今天捐献所领取宝箱id记录,
@prop({ required: true, default: 0 })
wishDntCnt: number;//今天许愿池捐献次数
@prop({ required: true, default: 0 }) @prop({ required: true, default: 0 })
donateCnt: number;//今天捐献所次数 donateCnt: number;//今天捐献所次数
//许愿池
@prop({ required: true, default: [], type: WishGood, _id: false })
wishGoods: Array<WishGood>;
@prop({ required: true, default: 0 })
wishDntCnt: number;//今天许愿池捐献次数
public static async getMyAuth(roleId: string, guildCode?: string, userGuild?: UserGuildType) { public static async getMyAuth(roleId: string, guildCode?: string, userGuild?: UserGuildType) {
let myGuild: UserGuildType; let myGuild: UserGuildType;
+4 -4
View File
@@ -6,16 +6,16 @@ import { nowSeconds, getTodayZeroPoint } from '../pubUtils/timeUtil';
export default class WishPoolReport extends BaseModel { export default class WishPoolReport extends BaseModel {
@prop({ required: true }) @prop({ required: true })
guildCode: string; // 角色 id guildCode: string; // 军团code
@prop({ required: true }) @prop({ required: true })
dntTime: number; //捐献时间 dntTime: number; //捐献时间
@prop({ required: true }) @prop({ required: true })
wishRoleId: string; //被捐献人 wishRoleId: string; //许愿者
@prop({ required: true }) @prop({ required: true })
wishRoleName: string; //捐赠人 wishRoleName: string; //许愿者name
@prop({ required: true }) @prop({ required: true })
goodId: number; //捐献物品 goodId: number; //捐献物品
@@ -27,7 +27,7 @@ export default class WishPoolReport extends BaseModel {
dntRoleId: string; //捐赠人 dntRoleId: string; //捐赠人
@prop({ required: true }) @prop({ required: true })
dntRoleName: string; //捐赠人 dntRoleName: string; //捐赠人name
public static async addReport(guildCode: string, wishRoleId: string, wishRoleName: string, dntRoleId: string, dntRoleName: string, goodId: number, count: number) { public static async addReport(guildCode: string, wishRoleId: string, wishRoleName: string, dntRoleId: string, dntRoleName: string, goodId: number, count: number) {
const doc = new WishPoolReportModel(); const doc = new WishPoolReportModel();