This commit is contained in:
xichaoyin 2024-01-06 14:59:50 +08:00
commit 5e50e29f0a
8 changed files with 50 additions and 44 deletions

View File

@ -1,10 +1,10 @@
import {ApiCall} from "tsrpc";
import {HeroFun} from '../public/hero';
import {PlayerFun} from '../public/player';
import {defaultUserAppend, UserFun} from '../public/user';
import {ReqBingo, ResBingo} from "../shared/protocols/PtlBingo";
import {ReqEmail} from "../monopoly/protocols/PtlEmail";
import {EmailFun} from "../public/email";
import { ApiCall } from "tsrpc";
import { HeroFun } from '../public/hero';
import { PlayerFun } from '../public/player';
import { defaultUserAppend, UserFun } from '../public/user';
import { ReqBingo, ResBingo } from "../shared/protocols/PtlBingo";
import { ReqEmail } from "../monopoly/protocols/PtlEmail";
import { EmailFun } from "../public/email";
export default async function (call: ApiCall<ReqBingo, ResBingo>) {
// TODO
@ -72,37 +72,37 @@ export default async function (call: ApiCall<ReqBingo, ResBingo>) {
if (!G.gc.item[shell[1]]) return call.error(`道具id不存在${shell[1]}`);
if (isNaN(parseInt(shell[2]))) return call.error(`请输入正确的数量`);
await PlayerFun.addItem(call, [{a: 'item', t: shell[1], n: parseInt(shell[2])}]);
await PlayerFun.addItem(call, [{ a: 'item', t: shell[1], n: parseInt(shell[2]) }]);
} else if (shell[0] == 'hero') {
if (!G.gc.hero[shell[1]]) return call.error(`英雄id不存在${shell[1]}`);
if (isNaN(parseInt(shell[2]))) return call.error(`请输入正确的数量`);
await PlayerFun.addHero(call, [{a: 'item', t: shell[1], n: parseInt(shell[2])}]);
await PlayerFun.addHero(call, [{ a: 'item', t: shell[1], n: parseInt(shell[2]) }]);
} else if (shell[0] == 'equip') {
if (!G.gc.equip[shell[1]]) return call.error(`装备id不存在${shell[1]}`);
if (isNaN(parseInt(shell[2]))) return call.error(`请输入正确的数量`);
await PlayerFun.addEquip(call, [{a: 'equip', t: shell[1], n: parseInt(shell[2])}]);
await PlayerFun.addEquip(call, [{ a: 'equip', t: shell[1], n: parseInt(shell[2]) }]);
} else if (shell[0] == 'shiwu') {
if (!G.gc.shiwu[shell[1]]) return call.error(`饰物id不存在${shell[1]}`);
if (isNaN(parseInt(shell[2]))) return call.error(`请输入正确的数量`);
if (isNaN(parseInt(shell[3]))) return call.error(`请输入正确的品质`);
await PlayerFun.addShiwu(call, [{a: 'shiwu', t: shell[1], n: parseInt(shell[2]), colour: parseInt(shell[3])}]);
await PlayerFun.addShiwu(call, [{ a: 'shiwu', t: shell[1], n: parseInt(shell[2]), colour: parseInt(shell[3]) }]);
} else if (shell[0] == 'peijian') {
if (!G.gc.peijian[shell[1]]) return call.error(`配件id不存在${shell[1]}`);
if (isNaN(parseInt(shell[2]))) return call.error(`请输入正确的数量`);
await PlayerFun.addPeijian(call, [{a: 'peijian', t: shell[1], n: parseInt(shell[2])}]);
await PlayerFun.addPeijian(call, [{ a: 'peijian', t: shell[1], n: parseInt(shell[2]) }]);
} else if (shell[0] == 'attr') {
if (G.gc.attr[shell[1]] == undefined) return call.error(`道具id不存在${shell[1]}`);
if (isNaN(parseInt(shell[2]))) return call.error(`请输入正确的数量`);
await PlayerFun.addAttr(call, [{a: 'attr', t: shell[1], n: parseInt(shell[2])}]);
await PlayerFun.addAttr(call, [{ a: 'attr', t: shell[1], n: parseInt(shell[2]) }]);
} else if (shell.length == 2) {
@ -141,6 +141,9 @@ export default async function (call: ApiCall<ReqBingo, ResBingo>) {
}
if (shell[3]) emailMsg.prize = JSON.parse(shell[3])
EmailFun.addEmail(emailMsg);
} else if (shell[0] == "heroskin") {
await PlayerFun.sendPrize(call, [{ a: "heroskin", "t": shell[1], n: 1 }]);
}
call.succ('succ');
}

View File

@ -1,7 +1,7 @@
import { ApiCall } from "tsrpc";
import HeroSkinFun from "../../public/heroskin";
import { PlayerFun } from "../../public/player";
import { ReqUplv, ResUplv } from "../../shared/protocols/heroskin/PtlUplv";
import HeroSkinFun from "../../public/heroskin";
export default async function (call: ApiCall<ReqUplv, ResUplv>) {
@ -11,7 +11,7 @@ export default async function (call: ApiCall<ReqUplv, ResUplv>) {
}
let cur_lv = skin[call.req.skid];
let skinconf = G.gc.heroSkin[skin.skid];
let skinconf = G.gc.heroSkin[call.req.skid];
let need = [];
for (let i = 0; i < call.req.lv; i++) {
@ -30,7 +30,7 @@ export default async function (call: ApiCall<ReqUplv, ResUplv>) {
skin[call.req.skid] = cur_lv + call.req.lv;
// 更新skinlv
HeroSkinFun.updateHeroSkinLv(call, { [call.req.skid]: cur_lv + call.req.lv });
await HeroSkinFun.updateHeroSkinLv(call, { [call.req.skid]: cur_lv + call.req.lv });
call.succ({});
}

View File

@ -1,7 +1,7 @@
import { ApiCall } from "tsrpc";
import { HeroFun } from "../../public/hero";
import HeroSkinFun from "../../public/heroskin";
import { ReqWear, ResWear } from "../../shared/protocols/heroskin/PtlWear";
import HeroSkinFun from "../../public/heroskin";
export default async function (call: ApiCall<ReqWear, ResWear>) {
let hero = await HeroFun.getHero(call, call.req.heroOid);
@ -16,8 +16,8 @@ export default async function (call: ApiCall<ReqWear, ResWear>) {
return;
}
let skinconf = G.gc.heroSkin[skin.skid];
if (skinconf.heroid != hero.heroId) { // 皮肤不属于该英雄
let skinconf = G.gc.heroSkin[call.req.skid];
if (skinconf.heroId != hero.heroId) { // 皮肤不属于该英雄
call.error(lng.hero_21);
return;
}

View File

@ -1814,7 +1814,7 @@ type gc_hero_skin = {
/**皮肤id*/
id: number
/**干部id*/
heroid: number
heroId: number
/**皮肤品质*/
colour: number
/**摸到重复时转换*/

View File

@ -1,6 +1,6 @@
import { ApiCall } from "tsrpc";
import { call } from "../public/player";
import { PlayerFun } from "./player";
import { PlayerFun } from "../public/player";
export default class HeroSkinFun {
@ -29,21 +29,4 @@ export default class HeroSkinFun {
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;
}
}

View File

@ -21,7 +21,6 @@ import { PushGiftFun } from "./pushgift";
import { ActionLog } from './actionLog/actionLog';
import HeroSkinFun from './heroskin';
export type call = {
get otherBuff(): otherBuff;
uid: string;
@ -609,9 +608,9 @@ export class PlayerFun {
}
}
if (Object.keys(upskin).length > 0) {
this.addAttr(call, Object.assign(heroskin, upskin));
this.addAttr(call, { heroskin: Object.assign(heroskin, upskin) });
}
// 皮肤存在转换为其他奖励
if (prize.length > 0) {
this.sendPrize(call, prize);

View File

@ -1,7 +1,7 @@
import HeroSkinFun from '../../public/heroskin';
import { ResGetList } from '../protocols/hero/PtlGetList';
import { player } from '../protocols/user/type';
import { EquipShared } from './equip';
import HeroSkinShared from './heroskin';
import { PeijianShared } from './peijian';
import { PlayerShared } from './player';
import { PublicShared } from './public';
@ -288,8 +288,8 @@ export class HeroShared {
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(
if (skinConf.heroId != hero.heroId) console;
PublicShared.mergeProperty(buff, HeroSkinShared.calcBuff(
skinId, otherBuff.heroskin[skinId]
));
}

View File

@ -0,0 +1,21 @@
export default class HeroSkinShared {
/**
* 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;
}
}