From 5ba52ad2c829da0cf1f7fb59961156f46c9fa78a Mon Sep 17 00:00:00 2001 From: xichaoyin Date: Fri, 5 Jan 2024 20:46:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=9B=AE=E5=BD=95=E7=BB=93=E6=9E=84?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api_s2c/heroskin/ApiUplv.ts | 2 +- src/api_s2c/heroskin/ApiWear.ts | 2 +- src/public/heroskin.ts | 19 +------------------ src/public/player.ts | 1 - src/shared/public/hero.ts | 4 ++-- src/shared/public/heroskin.ts | 21 +++++++++++++++++++++ 6 files changed, 26 insertions(+), 23 deletions(-) create mode 100644 src/shared/public/heroskin.ts diff --git a/src/api_s2c/heroskin/ApiUplv.ts b/src/api_s2c/heroskin/ApiUplv.ts index d8ed43b..b07f8c1 100644 --- a/src/api_s2c/heroskin/ApiUplv.ts +++ b/src/api_s2c/heroskin/ApiUplv.ts @@ -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) { diff --git a/src/api_s2c/heroskin/ApiWear.ts b/src/api_s2c/heroskin/ApiWear.ts index 3a43ef7..5c68082 100644 --- a/src/api_s2c/heroskin/ApiWear.ts +++ b/src/api_s2c/heroskin/ApiWear.ts @@ -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) { let hero = await HeroFun.getHero(call, call.req.heroOid); diff --git a/src/public/heroskin.ts b/src/public/heroskin.ts index f0e0504..a769476 100644 --- a/src/public/heroskin.ts +++ b/src/public/heroskin.ts @@ -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 { - 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; - } } \ No newline at end of file diff --git a/src/public/player.ts b/src/public/player.ts index 5c6e168..dfbe3ff 100644 --- a/src/public/player.ts +++ b/src/public/player.ts @@ -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; diff --git a/src/shared/public/hero.ts b/src/shared/public/hero.ts index d4ad2ff..52531a2 100644 --- a/src/shared/public/hero.ts +++ b/src/shared/public/hero.ts @@ -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'; @@ -284,7 +284,7 @@ export class HeroShared { for (let skinId in otherBuff.heroskin) { let skinConf = G.gc.heroSkin[skinId]; if (skinConf.heroId != hero.heroId) console; - PublicShared.mergeProperty(buff, HeroSkinFun.calcBuff( + PublicShared.mergeProperty(buff, HeroSkinShared.calcBuff( skinId, otherBuff.heroskin[skinId] )); } diff --git a/src/shared/public/heroskin.ts b/src/shared/public/heroskin.ts new file mode 100644 index 0000000..b0cb955 --- /dev/null +++ b/src/shared/public/heroskin.ts @@ -0,0 +1,21 @@ + +export default class HeroSkinShared { + + + /** + * 计算皮肤buff + * @param skid + * @param lv + * @returns {[string]: number} + * */ + static calcBuff(skid: string, lv: number): k_v { + 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; + } +} \ No newline at end of file