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"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -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";
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -19,6 +19,7 @@ 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 = {
|
||||
@ -136,6 +137,7 @@ 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 })
|
||||
@ -145,7 +147,8 @@ export class PlayerFun {
|
||||
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;
|
||||
@ -591,6 +594,30 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除配件
|
||||
*/
|
||||
|
@ -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