Merge branch 'dev' of http://git.legu.cc/qixin/HJ_Server into dev
This commit is contained in:
commit
6cb6d8f60d
20
src/api_s2c/heroskin/ApiTakeOff.ts
Normal file
20
src/api_s2c/heroskin/ApiTakeOff.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import { ApiCall } from "tsrpc";
|
||||
import { ReqTakeOff, ResTakeOff } from "../../shared/protocols/heroskin/PtlTakeOff";
|
||||
import { HeroFun } from "../../public/hero";
|
||||
|
||||
export default async function (call: ApiCall<ReqTakeOff, ResTakeOff>) {
|
||||
let hero = await HeroFun.getHero(call, call.req.heroOid);
|
||||
if (!hero) { // 英雄不存在
|
||||
call.error(lng.hero_1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!hero.skin) { // 没有穿戴皮肤
|
||||
call.error(lng.hero_22);
|
||||
return;
|
||||
}
|
||||
|
||||
HeroFun.changeHeroAttr(call, hero, { skin: "" });
|
||||
|
||||
call.succ({});
|
||||
}
|
36
src/api_s2c/heroskin/ApiUplv.ts
Normal file
36
src/api_s2c/heroskin/ApiUplv.ts
Normal file
@ -0,0 +1,36 @@
|
||||
import { ApiCall } from "tsrpc";
|
||||
import HeroSkinFun from "../../public/heroskin";
|
||||
import { PlayerFun } from "../../public/player";
|
||||
import { ReqUplv, ResUplv } from "../../shared/protocols/heroskin/PtlUplv";
|
||||
|
||||
|
||||
export default async function (call: ApiCall<ReqUplv, ResUplv>) {
|
||||
let skin = HeroSkinFun.getHeroSkin(call);
|
||||
if (!skin[call.req.skid]) {// 皮肤未获得
|
||||
call.error(lng.hero_20);
|
||||
}
|
||||
|
||||
let cur_lv = skin[call.req.skid];
|
||||
let skinconf = G.gc.heroSkin[skin.skid];
|
||||
|
||||
let need = [];
|
||||
for (let i = 0; i < call.req.lv; i++) {
|
||||
need.concat(
|
||||
G.gc.heroSkinLv[skinconf.colour][cur_lv + i].need
|
||||
)
|
||||
}
|
||||
|
||||
// 检测消耗
|
||||
await PlayerFun.checkNeedIsMeet(call, need);
|
||||
|
||||
// 扣除消耗
|
||||
await PlayerFun.cutNeed(call, need);
|
||||
|
||||
// 更新等级
|
||||
skin[call.req.skid] = cur_lv + call.req.lv;
|
||||
|
||||
// 更新skinlv
|
||||
HeroSkinFun.updateHeroSkinLv(call, { [call.req.skid]: cur_lv + call.req.lv });
|
||||
|
||||
call.succ({});
|
||||
}
|
28
src/api_s2c/heroskin/ApiWear.ts
Normal file
28
src/api_s2c/heroskin/ApiWear.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import { ApiCall } from "tsrpc";
|
||||
import { HeroFun } from "../../public/hero";
|
||||
import HeroSkinFun from "../../public/heroskin";
|
||||
import { ReqWear, ResWear } from "../../shared/protocols/heroskin/PtlWear";
|
||||
|
||||
export default async function (call: ApiCall<ReqWear, ResWear>) {
|
||||
let hero = await HeroFun.getHero(call, call.req.heroOid);
|
||||
if (!hero) { // 英雄不存在
|
||||
call.error(lng.hero_1);
|
||||
return;
|
||||
}
|
||||
|
||||
let skin = HeroSkinFun.getHeroSkin(call);
|
||||
if (!skin || !skin[call.req.skid]) { // 皮肤不存在
|
||||
call.error(lng.hero_20);
|
||||
return;
|
||||
}
|
||||
|
||||
let skinconf = G.gc.heroSkin[skin.skid];
|
||||
if (skinconf.heroid != hero.heroId) { // 皮肤不属于该英雄
|
||||
call.error(lng.hero_21);
|
||||
return;
|
||||
}
|
||||
|
||||
HeroFun.changeHeroAttr(call, hero, { skin: call.req.skid });
|
||||
|
||||
call.succ({});
|
||||
}
|
@ -1330,6 +1330,20 @@ export const serviceProto: ServiceProto<ServiceType> = {
|
||||
}
|
||||
},
|
||||
"optional": true
|
||||
},
|
||||
{
|
||||
"id": 39,
|
||||
"name": "heroskin",
|
||||
"type": {
|
||||
"type": "Interface",
|
||||
"indexSignature": {
|
||||
"keyType": "String",
|
||||
"type": {
|
||||
"type": "Number"
|
||||
}
|
||||
}
|
||||
},
|
||||
"optional": true
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -1721,6 +1735,13 @@ export const serviceProto: ServiceProto<ServiceType> = {
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 8,
|
||||
"name": "skin",
|
||||
"type": {
|
||||
"type": "String"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -136,9 +136,9 @@ type gc_clsl_dan = k_v<{
|
||||
/** 机器人 */
|
||||
'npc': number,
|
||||
/** 随机机器人概率*/
|
||||
'pro':number
|
||||
'pro': number
|
||||
/** 对手范围 */
|
||||
'fighter':number[]
|
||||
'fighter': number[]
|
||||
}>;
|
||||
|
||||
type gc_com = k_v<{
|
||||
@ -1809,6 +1809,28 @@ type gc_push_gift = {
|
||||
}
|
||||
}
|
||||
|
||||
type gc_hero_skin = {
|
||||
[k: string]: {
|
||||
/**皮肤id*/
|
||||
id: number
|
||||
/**干部id*/
|
||||
heroid: number
|
||||
/**皮肤品质*/
|
||||
colour: number
|
||||
/**摸到重复时转换*/
|
||||
zhuanhuan: atn[]
|
||||
}
|
||||
}
|
||||
|
||||
type gc_hero_skin_lv = {
|
||||
[colour: string]: {
|
||||
[lv: string]: {
|
||||
buff: { [k: string]: number }
|
||||
need: { a: string, t: string, n: number }[];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type gcType = {
|
||||
[key: string]: any
|
||||
armyattr: gc_armyattr
|
||||
@ -1959,6 +1981,8 @@ type gcType = {
|
||||
yuyuemail: gc_yuyuemail
|
||||
tuisonglibao: gc_push_gift
|
||||
renown_level: gc_renown_level
|
||||
heroSkin: gc_hero_skin
|
||||
heroSkinLv: gc_hero_skin_lv
|
||||
}
|
||||
|
||||
|
||||
|
@ -239,6 +239,9 @@ class Lng {
|
||||
hero_17 = "hero_17";
|
||||
hero_18 = "hero_18";
|
||||
hero_19 = "hero_19";
|
||||
hero_20 = "hero_20";
|
||||
hero_21 = "hero_21";
|
||||
hero_22 = "hero_22";
|
||||
|
||||
item_1 = "item_1";
|
||||
item_2 = "item_2";
|
||||
|
@ -1,25 +1,25 @@
|
||||
import {ResSyncBtn} from '../shared/protocols/PtlSyncBtn';
|
||||
import {payLog} from '../shared/protocols/pay/PtlGetList';
|
||||
import {rankType} from '../shared/protocols/rank/PtlOpen';
|
||||
import {CollectionChatLog} from './collection_chatlog';
|
||||
import {CollectionActionLog} from './collection_actionLog';
|
||||
import {CollectionCardlog} from './collection_cardlog';
|
||||
import {CollectionCllsCrossGroup, CollectionCllsCrossUser} from './collection_clsl';
|
||||
import {CollectionCrosskv} from './collection_crosskv';
|
||||
import {CollectionDayPay} from './collection_dayPay';
|
||||
import {CollectionDxlt} from './collection_dxlt';
|
||||
import {CollectionEmail} from './collection_email';
|
||||
import {CollectionEquip} from './collection_equip';
|
||||
import {CollectionEvent} from './collection_event';
|
||||
import {CollectionFriend} from './collection_friend';
|
||||
import {CollectionGanHai} from './collection_ganhai';
|
||||
import {CollectionGBTX} from './collection_gbtx';
|
||||
import {CollectionGongHui, CollectionGongHuiFb, CollectionGongHuiUser} from './collection_gonghui';
|
||||
import {CollectionHbzbUserCross, CollectionHbzbUserZbs} from './collection_hbzb_user_cross';
|
||||
import {CollectionHero} from './collection_hero';
|
||||
import {CollectionItem} from './collection_item';
|
||||
import {CollectionJJC} from './collection_jjc';
|
||||
import {CollectionApiWeiXiuChang} from './collection_weixiuchang';
|
||||
import { ResSyncBtn } from '../shared/protocols/PtlSyncBtn';
|
||||
import { payLog } from '../shared/protocols/pay/PtlGetList';
|
||||
import { rankType } from '../shared/protocols/rank/PtlOpen';
|
||||
import { CollectionChatLog } from './collection_chatlog';
|
||||
import { CollectionActionLog } from './collection_actionLog';
|
||||
import { CollectionCardlog } from './collection_cardlog';
|
||||
import { CollectionCllsCrossGroup, CollectionCllsCrossUser } from './collection_clsl';
|
||||
import { CollectionCrosskv } from './collection_crosskv';
|
||||
import { CollectionDayPay } from './collection_dayPay';
|
||||
import { CollectionDxlt } from './collection_dxlt';
|
||||
import { CollectionEmail } from './collection_email';
|
||||
import { CollectionEquip } from './collection_equip';
|
||||
import { CollectionEvent } from './collection_event';
|
||||
import { CollectionFriend } from './collection_friend';
|
||||
import { CollectionGanHai } from './collection_ganhai';
|
||||
import { CollectionGBTX } from './collection_gbtx';
|
||||
import { CollectionGongHui, CollectionGongHuiFb, CollectionGongHuiUser } from './collection_gonghui';
|
||||
import { CollectionHbzbUserCross, CollectionHbzbUserZbs } from './collection_hbzb_user_cross';
|
||||
import { CollectionHero } from './collection_hero';
|
||||
import { CollectionItem } from './collection_item';
|
||||
import { CollectionJJC } from './collection_jjc';
|
||||
import { CollectionApiWeiXiuChang } from './collection_weixiuchang';
|
||||
|
||||
import {
|
||||
CollectionKbzzApplyUser,
|
||||
@ -134,7 +134,7 @@ export type MongodbCollections = {
|
||||
rmbuse: CollectionRmbuse
|
||||
fightLog: CollectionFightLog
|
||||
shop: CollectionShop
|
||||
pushgift:CollectionPushGift
|
||||
pushgift: CollectionPushGift
|
||||
|
||||
huodong_user: CollectionUser;
|
||||
weiwang: CollectionWeiwang;
|
||||
|
@ -2651,6 +2651,20 @@ export const serviceProto: ServiceProto<ServiceType> = {
|
||||
}
|
||||
},
|
||||
"optional": true
|
||||
},
|
||||
{
|
||||
"id": 39,
|
||||
"name": "heroskin",
|
||||
"type": {
|
||||
"type": "Interface",
|
||||
"indexSignature": {
|
||||
"keyType": "String",
|
||||
"type": {
|
||||
"type": "Number"
|
||||
}
|
||||
}
|
||||
},
|
||||
"optional": true
|
||||
}
|
||||
]
|
||||
},
|
||||
|
49
src/public/heroskin.ts
Normal file
49
src/public/heroskin.ts
Normal file
@ -0,0 +1,49 @@
|
||||
import { ApiCall } from "tsrpc";
|
||||
import { call } from "../public/player";
|
||||
import { PlayerFun } from "./player";
|
||||
|
||||
|
||||
export default class HeroSkinFun {
|
||||
|
||||
/**
|
||||
* 获取英雄皮肤列表
|
||||
* @param uid
|
||||
* @returns
|
||||
*/
|
||||
static getHeroSkin(call: call, oids: string | string[] = '') {
|
||||
return call.conn.gud.heroskin || {};
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新英雄皮肤数据
|
||||
*
|
||||
* 说明 addAttr 会推送msg_s2c/PlayerChange
|
||||
* addEventMsg 会检测 PlayerChange 如果change的key在player中则触发重算战力操作
|
||||
* 所以这个地放更新heroskin数据不需要主动重算战力
|
||||
* @param oid
|
||||
* @param data
|
||||
* @returns
|
||||
* */
|
||||
static async updateHeroSkinLv(call: ApiCall, change: k_v<number>) {
|
||||
let skin = this.getHeroSkin(call);
|
||||
skin = Object.assign(skin, change);
|
||||
await PlayerFun.addAttr(call, { heroskin: skin });
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算皮肤buff
|
||||
* @param skid
|
||||
* @param lv
|
||||
* @returns {[string]: number}
|
||||
* */
|
||||
static calcBuff(skid: string, lv: number): k_v<number> {
|
||||
let buff = {};
|
||||
let skin = G.gc.heroSkin[skid];
|
||||
for (let i = 1; i <= lv; i++) {
|
||||
for (let k in G.gc.heroSkinLv[skin.colour][i].buff) {
|
||||
buff[k] = (buff[k] || 0) + G.gc.heroSkinLv[skin.colour][i].buff[k];
|
||||
}
|
||||
}
|
||||
return buff;
|
||||
}
|
||||
}
|
@ -1,24 +1,25 @@
|
||||
import {ObjectId, OptionalId} from 'mongodb';
|
||||
import {ApiCall, BaseConnection, TsrpcError} from 'tsrpc';
|
||||
import {checkPlayerGift} from '../api_s2c/event/xianshilibao/fun';
|
||||
import {md_redPoint_check} from '../api_s2c/gongyu/mingdao/ApiOpen';
|
||||
import {CollectionPeiJian} from '../module/collection_peijian';
|
||||
import {Wjjl} from '../module/collection_wjjl';
|
||||
import {MongodbCollections} from '../module/mongodb';
|
||||
import {G123} from '../sdk/G123';
|
||||
import {ResGetList} from '../shared/protocols/item/PtlGetList';
|
||||
import {ResLogin} from '../shared/protocols/user/PtlLogin';
|
||||
import {player} from '../shared/protocols/user/type';
|
||||
import {HeroShared, otherBuff} from '../shared/public/hero';
|
||||
import {PublicShared} from '../shared/public/public';
|
||||
import {HeroFun} from './hero';
|
||||
import {ShiwuFun} from './shiwu';
|
||||
import {UserFun} from './user';
|
||||
import {getItemByItemId, getItemNum} from './item';
|
||||
import {getGud, setGud} from './gud';
|
||||
import {addGameLog} from "../gameLog";
|
||||
import {PushGiftFun} from "./pushgift";
|
||||
import { ObjectId, OptionalId } from 'mongodb';
|
||||
import { ApiCall, BaseConnection, TsrpcError } from 'tsrpc';
|
||||
import { checkPlayerGift } from '../api_s2c/event/xianshilibao/fun';
|
||||
import { md_redPoint_check } from '../api_s2c/gongyu/mingdao/ApiOpen';
|
||||
import { CollectionPeiJian } from '../module/collection_peijian';
|
||||
import { Wjjl } from '../module/collection_wjjl';
|
||||
import { MongodbCollections } from '../module/mongodb';
|
||||
import { G123 } from '../sdk/G123';
|
||||
import { ResGetList } from '../shared/protocols/item/PtlGetList';
|
||||
import { ResLogin } from '../shared/protocols/user/PtlLogin';
|
||||
import { player } from '../shared/protocols/user/type';
|
||||
import { HeroShared, otherBuff } from '../shared/public/hero';
|
||||
import { PublicShared } from '../shared/public/public';
|
||||
import { HeroFun } from './hero';
|
||||
import { ShiwuFun } from './shiwu';
|
||||
import { UserFun } from './user';
|
||||
import { getItemByItemId, getItemNum } from './item';
|
||||
import { getGud, setGud } from './gud';
|
||||
import { addGameLog } from "../gameLog";
|
||||
import { PushGiftFun } from "./pushgift";
|
||||
import { ActionLog } from './actionLog/actionLog';
|
||||
import HeroSkinFun from './heroskin';
|
||||
|
||||
|
||||
export type call = {
|
||||
@ -70,13 +71,13 @@ export class PlayerFun {
|
||||
if (err) {
|
||||
// 消耗不足 触发推送礼包
|
||||
PushGiftFun.chkItemGift(call.uid, atn)
|
||||
throw new TsrpcError('', {code: -104, atn: atn});
|
||||
throw new TsrpcError('', { code: -104, atn: atn });
|
||||
} else {
|
||||
return {isOk: false, atn: atn};
|
||||
return { isOk: false, atn: atn };
|
||||
}
|
||||
}
|
||||
}
|
||||
return {isOk: true, atn: null};
|
||||
return { isOk: true, atn: null };
|
||||
}
|
||||
|
||||
/**
|
||||
@ -94,7 +95,7 @@ export class PlayerFun {
|
||||
atn: need
|
||||
};
|
||||
if (args.length < 1) {
|
||||
throw new TsrpcError('', {code: -104, atn: meet.atn});
|
||||
throw new TsrpcError('', { code: -104, atn: meet.atn });
|
||||
}
|
||||
return await this.checkNeedByArgs(call, ...args);
|
||||
}
|
||||
@ -117,10 +118,10 @@ export class PlayerFun {
|
||||
all.push(this.addItem(call, item));
|
||||
}
|
||||
// 记录消耗
|
||||
addGameLog(call.uid, call.service.name, call.req, {need: val})
|
||||
addGameLog(call.uid, call.service.name, call.req, { need: val })
|
||||
await Promise.all(all);
|
||||
G.emit('USE_ITEM', call.conn.gud, needArr.map(need => {
|
||||
return {...need, n: Math.abs(need.n)};
|
||||
return { ...need, n: Math.abs(need.n) };
|
||||
}));
|
||||
}
|
||||
|
||||
@ -136,16 +137,18 @@ export class PlayerFun {
|
||||
let equip = prizeList.filter(atn => atn.a == 'equip' && atn.n != 0);
|
||||
let shiwu = prizeList.filter(atn => atn.a == 'shiwu' && atn.n != 0);
|
||||
let peijian = prizeList.filter(atn => atn.a == 'peijian' && atn.n != 0);
|
||||
let heroskin = prizeList.filter(atn => atn.a == 'heroskin' && atn.n != 0);
|
||||
|
||||
// 记录获得
|
||||
addGameLog(call.uid, call.service.name, call.req, {prize: prizeList})
|
||||
addGameLog(call.uid, call.service.name, call.req, { prize: prizeList })
|
||||
await Promise.all([
|
||||
attr.length > 0 && this.addAttr(call, attr),
|
||||
item.length > 0 && this.addItem(call, item),
|
||||
hero.length > 0 && this.addHero(call, hero),
|
||||
equip.length > 0 && this.addEquip(call, equip),
|
||||
shiwu.length > 0 && this.addShiwu(call, shiwu),
|
||||
peijian.length > 0 && this.addPeijian(call, peijian)
|
||||
peijian.length > 0 && this.addPeijian(call, peijian),
|
||||
heroskin.length > 0 && this.addHeroskin(call, heroskin),
|
||||
]);
|
||||
|
||||
return prizeList;
|
||||
@ -180,9 +183,9 @@ export class PlayerFun {
|
||||
}
|
||||
}
|
||||
|
||||
if( (atn.t == 'rmbmoney' || atn.t == 'jinbi') && atn.n > 0 ){
|
||||
if ((atn.t == 'rmbmoney' || atn.t == 'jinbi') && atn.n > 0) {
|
||||
//统计今日获取的金币和钻石
|
||||
ActionLog.addDayLog(call.conn.uid, { key: 'got_'+atn.t, val: atn.n });
|
||||
ActionLog.addDayLog(call.conn.uid, { key: 'got_' + atn.t, val: atn.n });
|
||||
}
|
||||
|
||||
// 增加vip经验的任务监听
|
||||
@ -190,7 +193,7 @@ export class PlayerFun {
|
||||
G.emit("Class_task_157", 'Class_task_157', call, atn.n, 0);
|
||||
}
|
||||
all.push(this.changeAttr(call.conn.uid, change));
|
||||
all.push(this.upAttr(call, {...atn, n: change[atn.t]}));
|
||||
all.push(this.upAttr(call, { ...atn, n: change[atn.t] }));
|
||||
//await this.changeAttr(call.conn.uid, change);
|
||||
//await this.upAttr(call, {...atn, n: change[atn.t]});
|
||||
}
|
||||
@ -233,17 +236,17 @@ export class PlayerFun {
|
||||
G.mongodb.collection('rmbuse').insertOne(data);
|
||||
// 消费竞赛开启时写入跨服数据库
|
||||
if (G.huodong.xfjs && !data.isAdd && typeof data.change == 'number') {
|
||||
G.crossmongodb.collection('rmbuse').updateOne({uid: data.uid, type: `xfjs_${G.huodong.xfjsId}`}, {
|
||||
$set: {time: G.time},
|
||||
$inc: {change: data.change}
|
||||
}, {upsert: true});
|
||||
G.crossmongodb.collection('rmbuse').updateOne({ uid: data.uid, type: `xfjs_${G.huodong.xfjsId}` }, {
|
||||
$set: { time: G.time },
|
||||
$inc: { change: data.change }
|
||||
}, { upsert: true });
|
||||
}
|
||||
}
|
||||
|
||||
static async changeAttr(uid: string, change: Partial<player>) {
|
||||
setGud(uid, change);
|
||||
|
||||
G.mongodb.collection('user').updateOne({uid: uid}, {$set: change});
|
||||
G.mongodb.collection('user').updateOne({ uid: uid }, { $set: change });
|
||||
|
||||
if (G.server.uid_connections[uid]) {
|
||||
checkPlayerGift(G.server.uid_connections[uid].gud, change);
|
||||
@ -265,9 +268,9 @@ export class PlayerFun {
|
||||
const curLv = call.conn.gud.lv;
|
||||
while (conf[curLv + addLv + 1] && atn.n >= conf[curLv + addLv + 1].need) {
|
||||
addLv++;
|
||||
G123.sendUserLevelUp({...call.conn.gud, lv: curLv + addLv, nexp: atn.n});
|
||||
G123.sendUserLevelUp({ ...call.conn.gud, lv: curLv + addLv, nexp: atn.n });
|
||||
}
|
||||
addLv && await this.addAttr(call, {lv: curLv + addLv});
|
||||
addLv && await this.addAttr(call, { lv: curLv + addLv });
|
||||
break;
|
||||
case 'payExp':
|
||||
let addVip = 0;
|
||||
@ -276,7 +279,7 @@ export class PlayerFun {
|
||||
while (vipConf[curVip + addVip + 1] && atn.n >= vipConf[curVip + addVip + 1].exp) {
|
||||
addVip++;
|
||||
}
|
||||
addVip && await this.addAttr(call, {vip: curVip + addVip});
|
||||
addVip && await this.addAttr(call, { vip: curVip + addVip });
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -287,7 +290,7 @@ export class PlayerFun {
|
||||
static async addItem(call: call, val: atn[]) {
|
||||
for (let atn of val) {
|
||||
let upObj = {
|
||||
filter: {uid: call.uid, itemId: atn.t},
|
||||
filter: { uid: call.uid, itemId: atn.t },
|
||||
update: {
|
||||
$setOnInsert: {
|
||||
firstTime: G.time,
|
||||
@ -319,7 +322,7 @@ export class PlayerFun {
|
||||
};
|
||||
G.mongodb.collection('item').updateOne(upObj.filter, upObj.update, upObj.options);
|
||||
call.addEventMsg('msg_s2c/ItemChange', atn.t, data);
|
||||
addGameLog(call.uid, "_itemChange", {"additem": 1}, {
|
||||
addGameLog(call.uid, "_itemChange", { "additem": 1 }, {
|
||||
"filter": upObj.filter,
|
||||
"update": upObj.update,
|
||||
"options": upObj.options
|
||||
@ -327,10 +330,10 @@ export class PlayerFun {
|
||||
} else {
|
||||
if (item.num + atn.n <= 0) {
|
||||
await Promise.all([
|
||||
G.mongodb.collection('item').deleteOne({uid: call.uid, itemId: atn.t})
|
||||
G.mongodb.collection('item').deleteOne({ uid: call.uid, itemId: atn.t })
|
||||
]);
|
||||
call.addEventMsg('msg_s2c/ItemChange', atn.t, {num: 0});
|
||||
addGameLog(call.uid, "_itemChange", {"delitem": 1}, {"itemId": atn.t})
|
||||
call.addEventMsg('msg_s2c/ItemChange', atn.t, { num: 0 });
|
||||
addGameLog(call.uid, "_itemChange", { "delitem": 1 }, { "itemId": atn.t })
|
||||
} else {
|
||||
await Promise.all([
|
||||
G.mongodb.collection('item').updateOne(upObj.filter, upObj.update, upObj.options)
|
||||
@ -339,7 +342,7 @@ export class PlayerFun {
|
||||
num: item.num + atn.n,
|
||||
lastTime: upObj.update.$set.lastTime
|
||||
});
|
||||
addGameLog(call.uid, "_itemChange", {"attritem": 1}, {
|
||||
addGameLog(call.uid, "_itemChange", { "attritem": 1 }, {
|
||||
"filter": upObj.filter,
|
||||
"update": upObj.update,
|
||||
"options": upObj.options,
|
||||
@ -374,7 +377,7 @@ export class PlayerFun {
|
||||
|
||||
insertData.forEach((v, key) => {
|
||||
let id = result.insertedIds[key].toHexString();
|
||||
let {_id, ...ops} = v;
|
||||
let { _id, ...ops } = v;
|
||||
|
||||
Wjjl.setVal(call.uid, `has_equip_color_${G.gc.equip[ops.equipId].colour}`, 1, false);
|
||||
|
||||
@ -408,10 +411,10 @@ export class PlayerFun {
|
||||
*/
|
||||
static async cutEquip(call: call, _idArr: string[]) {
|
||||
for (let _id of _idArr) {
|
||||
G.mongodb.collection('equip').deleteOne({uid: call.uid, _id: new ObjectId(_id)});
|
||||
call.addEventMsg('msg_s2c/EquipChange', _id, {num: 0});
|
||||
G.mongodb.collection('equip').deleteOne({ uid: call.uid, _id: new ObjectId(_id) });
|
||||
call.addEventMsg('msg_s2c/EquipChange', _id, { num: 0 });
|
||||
|
||||
addGameLog(call.uid, "_cutEquip", {}, {_id: _id})
|
||||
addGameLog(call.uid, "_cutEquip", {}, { _id: _id })
|
||||
}
|
||||
}
|
||||
|
||||
@ -445,7 +448,7 @@ export class PlayerFun {
|
||||
let v = insertData[key]
|
||||
|
||||
let id = result.insertedIds[key].toHexString();
|
||||
let {_id, ...ops} = v;
|
||||
let { _id, ...ops } = v;
|
||||
|
||||
call.addEventMsg('msg_s2c/HeroChange', id, {
|
||||
_id: id,
|
||||
@ -478,9 +481,9 @@ export class PlayerFun {
|
||||
static async cutHero(call: call, _idArr: string[]) {
|
||||
for (let _id of _idArr) {
|
||||
await HeroFun.delHero(call, _id);
|
||||
G.mongodb.collection('hero').deleteOne({uid: call.uid, _id: new ObjectId(_id)});
|
||||
call.addEventMsg('msg_s2c/HeroChange', _id, {num: 0});
|
||||
addGameLog(call.uid, "_cutHero", {}, {_id: _id})
|
||||
G.mongodb.collection('hero').deleteOne({ uid: call.uid, _id: new ObjectId(_id) });
|
||||
call.addEventMsg('msg_s2c/HeroChange', _id, { num: 0 });
|
||||
addGameLog(call.uid, "_cutHero", {}, { _id: _id })
|
||||
}
|
||||
}
|
||||
|
||||
@ -495,7 +498,7 @@ export class PlayerFun {
|
||||
colour: v.colour,
|
||||
wearId: '',
|
||||
shiwuId: v.t,
|
||||
jichu: ShiwuFun.randomJichu({colour: v.colour, shiwuId: v.t}),
|
||||
jichu: ShiwuFun.randomJichu({ colour: v.colour, shiwuId: v.t }),
|
||||
fujia: []
|
||||
};
|
||||
if (v.shiwuBuff) {
|
||||
@ -515,7 +518,7 @@ export class PlayerFun {
|
||||
|
||||
insertData.forEach((v, key) => {
|
||||
let id = result.insertedIds[key].toHexString();
|
||||
let {_id, ...ops} = v;
|
||||
let { _id, ...ops } = v;
|
||||
call.addEventMsg('msg_s2c/ShiwuChange', id, {
|
||||
_id: id,
|
||||
...ops
|
||||
@ -534,9 +537,9 @@ export class PlayerFun {
|
||||
*/
|
||||
static async cutShiwu(call: call, _idArr: string[]) {
|
||||
for (let _id of _idArr) {
|
||||
G.mongodb.collection('shiwu').deleteOne({uid: call.uid, _id: new ObjectId(_id)});
|
||||
call.addEventMsg('msg_s2c/ShiwuChange', _id, {num: 0});
|
||||
addGameLog(call.uid, "_cutShiwu", {}, {_id: _id})
|
||||
G.mongodb.collection('shiwu').deleteOne({ uid: call.uid, _id: new ObjectId(_id) });
|
||||
call.addEventMsg('msg_s2c/ShiwuChange', _id, { num: 0 });
|
||||
addGameLog(call.uid, "_cutShiwu", {}, { _id: _id })
|
||||
}
|
||||
}
|
||||
|
||||
@ -561,7 +564,7 @@ export class PlayerFun {
|
||||
addGameLog(call.uid, "_addPeiJian", {}, insertData)
|
||||
|
||||
insertData.forEach((v, key) => {
|
||||
let {_id, uid, ...ops} = v;
|
||||
let { _id, uid, ...ops } = v;
|
||||
let id = _id.toHexString();
|
||||
|
||||
if (G.gc.peijian[v.peijianId].colour != 5) {
|
||||
@ -569,8 +572,8 @@ export class PlayerFun {
|
||||
lshd[v.peijianId]++;
|
||||
}
|
||||
|
||||
G.redis.set('peijian', call.uid, id, {_id: id, ...ops});
|
||||
call.addEventMsg('msg_s2c/PeijianChange', id, {_id: id, ...ops});
|
||||
G.redis.set('peijian', call.uid, id, { _id: id, ...ops });
|
||||
call.addEventMsg('msg_s2c/PeijianChange', id, { _id: id, ...ops });
|
||||
});
|
||||
|
||||
G.mongodb.collection('playerInfo', 'lshd_peijian').updateOne(
|
||||
@ -591,15 +594,39 @@ export class PlayerFun {
|
||||
return Object.values(result.insertedIds).map(v => G.mongodb.conversionId(v));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加皮肤
|
||||
* */
|
||||
static async addHeroskin(call: call, val: atn[]) {
|
||||
let prize = [];
|
||||
let upskin = {};
|
||||
let heroskin = HeroSkinFun.getHeroSkin(call);
|
||||
for (let p of val) {
|
||||
if (!heroskin[p.t]) {
|
||||
upskin[p.t] = 1;
|
||||
} else {
|
||||
prize.concat(G.gc.heroSkin[p.t].zhuanhuan);
|
||||
}
|
||||
}
|
||||
if (Object.keys(upskin).length > 0) {
|
||||
this.addAttr(call, Object.assign(heroskin, upskin));
|
||||
}
|
||||
|
||||
// 皮肤存在转换为其他奖励
|
||||
if (prize.length > 0) {
|
||||
this.sendPrize(call, prize);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除配件
|
||||
*/
|
||||
static async cutPeijian(call: call, _idArr: string[]) {
|
||||
for (let _id of _idArr) {
|
||||
G.redis.del('peijian', call.uid, _id);
|
||||
G.mongodb.collection('peijian').deleteOne({uid: call.uid, _id: new ObjectId(_id)});
|
||||
call.addEventMsg('msg_s2c/PeijianChange', _id, {num: 0});
|
||||
addGameLog(call.uid, "_cutPeijian", {}, {_id: _id})
|
||||
G.mongodb.collection('peijian').deleteOne({ uid: call.uid, _id: new ObjectId(_id) });
|
||||
call.addEventMsg('msg_s2c/PeijianChange', _id, { num: 0 });
|
||||
addGameLog(call.uid, "_cutPeijian", {}, { _id: _id })
|
||||
}
|
||||
}
|
||||
|
||||
@ -608,7 +635,7 @@ export class PlayerFun {
|
||||
*/
|
||||
static async getAttr(uid: string, where: { ctype: string; }) {
|
||||
let _w = where;
|
||||
Object.assign(_w, {uid: uid});
|
||||
Object.assign(_w, { uid: uid });
|
||||
const _res = await G.mongodb.collection('playattr').find(_w).toArray();
|
||||
_res.forEach(v => {
|
||||
if (v._id) {
|
||||
@ -623,7 +650,7 @@ export class PlayerFun {
|
||||
*/
|
||||
static async getAttrOne(uid: string, where: { ctype: string; }) {
|
||||
let _w = where;
|
||||
Object.assign(_w, {uid: uid});
|
||||
Object.assign(_w, { uid: uid });
|
||||
const _res = await G.mongodb.collection('playattr').findOne(_w);
|
||||
if (_res) {
|
||||
delete _res['_id'];
|
||||
@ -639,10 +666,10 @@ export class PlayerFun {
|
||||
time = G.time;
|
||||
}
|
||||
let _zeroTime = PublicShared.getToDayZeroTime(time);
|
||||
let _tmp = {lasttime: {$gte: _zeroTime, $lte: _zeroTime + 24 * 60 * 60 - 1}};
|
||||
let _tmp = { lasttime: { $gte: _zeroTime, $lte: _zeroTime + 24 * 60 * 60 - 1 } };
|
||||
|
||||
let _w = where;
|
||||
Object.assign(_w, {uid: uid, ..._tmp});
|
||||
Object.assign(_w, { uid: uid, ..._tmp });
|
||||
const _res = await G.mongodb.collection('playattr').find(_w).toArray();
|
||||
_res.forEach(v => {
|
||||
if (v._id) {
|
||||
@ -657,7 +684,7 @@ export class PlayerFun {
|
||||
*/
|
||||
static async setAttr(uid: string, where: { ctype: string; }, data: {}, islasttime = 1) {
|
||||
let _w = where;
|
||||
Object.assign(_w, {uid: uid});
|
||||
Object.assign(_w, { uid: uid });
|
||||
|
||||
if (islasttime == 1) {
|
||||
data["lasttime"] = G.time;
|
||||
@ -668,7 +695,7 @@ export class PlayerFun {
|
||||
// 加入创建数据时间
|
||||
data["ctime"] = G.time;
|
||||
}
|
||||
let _res = await G.mongodb.collection('playattr').updateMany(_w, {$set: data}, {upsert: true});
|
||||
let _res = await G.mongodb.collection('playattr').updateMany(_w, { $set: data }, { upsert: true });
|
||||
return _res;
|
||||
}
|
||||
}
|
@ -71,4 +71,6 @@ type heroAddKey = {
|
||||
peijian: {
|
||||
[pos: string]: string;
|
||||
};
|
||||
/**皮肤*/
|
||||
skin: string;
|
||||
};
|
7
src/shared/protocols/heroskin/PtlTakeOff.ts
Normal file
7
src/shared/protocols/heroskin/PtlTakeOff.ts
Normal file
@ -0,0 +1,7 @@
|
||||
export interface ReqTakeOff {
|
||||
heroOid: string
|
||||
}
|
||||
|
||||
export interface ResTakeOff {
|
||||
|
||||
}
|
6
src/shared/protocols/heroskin/PtlUplv.ts
Normal file
6
src/shared/protocols/heroskin/PtlUplv.ts
Normal file
@ -0,0 +1,6 @@
|
||||
export interface ReqUplv {
|
||||
lv: 1;
|
||||
skid: string;
|
||||
}
|
||||
|
||||
export interface ResUplv { }
|
6
src/shared/protocols/heroskin/PtlWear.ts
Normal file
6
src/shared/protocols/heroskin/PtlWear.ts
Normal file
@ -0,0 +1,6 @@
|
||||
export interface ReqWear {
|
||||
skid: string,
|
||||
heroOid: string,
|
||||
}
|
||||
|
||||
export interface ResWear { }
|
File diff suppressed because it is too large
Load Diff
@ -195,4 +195,9 @@ export type playerAppend = {
|
||||
};
|
||||
/**威望额外属性*/
|
||||
weiwangbuff?: { [k: string]: number };
|
||||
|
||||
/**获得的皮肤*/
|
||||
heroskin?: {
|
||||
[skid: string]: number;
|
||||
}
|
||||
};
|
@ -1,3 +1,4 @@
|
||||
import HeroSkinFun from '../../public/heroskin';
|
||||
import { ResGetList } from '../protocols/hero/PtlGetList';
|
||||
import { player } from '../protocols/user/type';
|
||||
import { EquipShared } from './equip';
|
||||
@ -279,8 +280,19 @@ export class HeroShared {
|
||||
}
|
||||
|
||||
// 威望加成计算
|
||||
if (otherBuff?.weiwang) {
|
||||
PublicShared.mergeProperty(buff, otherBuff?.weiwang || {});
|
||||
if (otherBuff?.weiwangbuff) {
|
||||
PublicShared.mergeProperty(buff, otherBuff?.weiwangbuff || {});
|
||||
}
|
||||
|
||||
// 计算皮肤buff
|
||||
if (otherBuff?.heroskin) {
|
||||
for (let skinId in otherBuff.heroskin) {
|
||||
let skinConf = G.gc.heroSkin[skinId];
|
||||
if (skinConf.heroid != hero.heroId) console;
|
||||
PublicShared.mergeProperty(buff, HeroSkinFun.calcBuff(
|
||||
skinId, otherBuff.heroskin[skinId]
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
//最后进行加成属性计算
|
||||
|
Loading…
Reference in New Issue
Block a user