伤害计算展示createdBy

This commit is contained in:
Kokomi 2023-10-29 15:51:31 +08:00
parent 64b880036b
commit 6badfb97a7
6 changed files with 58 additions and 16 deletions

View File

@ -5,7 +5,7 @@ import { Character } from './index.js'
import DmgBuffs from './dmg/DmgBuffs.js'
import DmgAttr from './dmg/DmgAttr.js'
import DmgCalc from './dmg/DmgCalc.js'
import { MiaoError, Meta } from '#miao'
import { MiaoError, Meta, Common } from '#miao'
export default class ProfileDmg extends Base {
constructor (profile = {}, game = 'gs') {
@ -20,10 +20,18 @@ export default class ProfileDmg extends Base {
static dmgRulePath (name, game = 'gs') {
const _path = process.cwd()
for (let file of ['calc_user', 'calc_auto', 'calc']) {
let path = `${_path}/plugins/miao-plugin/resources/meta-${game}/character/${name}/${file}.js`
let dmgFile = [
{ file: 'calc_user', name: '自定义伤害' },
{ file: 'calc_auto', name: '组团伤害', test: () => Common.cfg('teamCalc') },
{ file: 'calc', name: '喵喵' }
]
for (let ds of dmgFile) {
let path = `${_path}/plugins/miao-plugin/resources/meta-${game}/character/${name}/${ds.file}.js`
if (ds.test && !ds.test()) {
continue
}
if (fs.existsSync(path)) {
return path
return { path, createdBy: ds.name }
}
}
return false
@ -79,8 +87,12 @@ export default class ProfileDmg extends Base {
const cfgPath = ProfileDmg.dmgRulePath(this.char?.name, this.char?.game)
let cfg = {}
if (cfgPath) {
cfg = await import(`file://${cfgPath}`)
cfg = await import(`file://${cfgPath.path}`)
// 文件中定义了createBy的话优先进行展示
let createdBy = cfg.createdBy || cfgPath.createdBy || '喵喵'
createdBy = createdBy.slice(0, 15)
return {
createdBy,
details: cfg.details || false, // 计算详情
buffs: cfg.buffs || [], // 角色buff
defParams: cfg.defParams || {}, // 默认参数,一般为空
@ -105,7 +117,7 @@ export default class ProfileDmg extends Base {
if (!charCalcData) {
return false
}
let { buffs, details, defParams, mainAttr, defDmgIdx, defDmgKey, enemyName } = charCalcData
let { createdBy, buffs, details, defParams, mainAttr, defDmgIdx, defDmgKey, enemyName } = charCalcData
let talent = this.talent()
@ -260,7 +272,8 @@ export default class ProfileDmg extends Base {
dmgRet,
enemyName,
dmgCfg: dmgDetail,
enemyLv
enemyLv,
createdBy
}
}
}

View File

@ -19,7 +19,7 @@ body {
}
.basic {
position: relative;
margin: 0 -15px 10px -10px;
margin: 0 -15px 15px -10px;
}
.basic:after {
content: "";
@ -324,7 +324,11 @@ body {
margin: 10px 0;
width: 100%;
}
.dmg-mode .dmg-list .cont-footer {
.dmg-created-by {
padding-left: 5px;
float: right;
}
.dmg-mode .not-dmg-mode {
display: none;
}
.cont-title {
@ -383,10 +387,12 @@ body {
.dmg-cont .tr .th {
color: #d3bc8e;
padding-right: 15px;
padding-left: 5px;
text-align: right;
background: rgba(0, 0, 0, 0.4);
min-width: 100px;
font-size: 15px;
white-space: nowrap;
}
.profile-mode .dmg-idx {
display: none !important;

View File

@ -236,7 +236,7 @@
{{/if}}
{{each ad.artis ds idx}}
<div class="item arti">
<div class="item arti arti-class-{{ds.markClass}}">
{{if ds && ds.name && ds.main && ds.main.key && ds.main.key!="undefined"}}
<div class="arti-icon">
<div class="img" style="background-image:url({{_res_path}}{{ds.img}})"></div>
@ -268,12 +268,13 @@
<!-- 【 伤害表格 】 -->
{{ set {dmgRet, dmgCfg, enemyLv, enemyName, dmgMsg, dmgData} = dmgCalc }}
{{ set {dmgRet, dmgCfg, enemyLv, enemyName, dmgMsg, dmgData, createdBy} = dmgCalc }}
<div>
{{if dmgData?.length > 0}}
<div class="dmg-cont dmg-list cont">
<div class="cont-title">
伤害计算<span>目标为{{enemyLv}}级{{enemyName||'小宝'}}{{if game==='gs'}},如需调整等级可使用 #敌人等级{{enemyLv}} 来进行设置{{/if}}</span>
伤害计算
<span class="not-dmg-mode dmg-desc">使用<strong>{{gameHash}}{{data.abbr}}伤害</strong>命令可以查看伤害详情</span>
</div>
<div class="cont-table">
<div class="tr thead">
@ -297,7 +298,11 @@
{{/each}}
</div>
<div class="cont-footer dmg-desc">
使用命令<strong>{{gameHash}}{{data.abbr}}伤害</strong>可以查看伤害详情,使用命令<strong>#角色面板帮助</strong>可查看帮助说明
<span>目标为{{enemyLv}}级{{enemyName||'小宝'}}{{if game==='gs'}},使用<strong>#敌人等级{{enemyLv}}</strong>命令可指定等级{{/if}}</span>
{{if createdBy}}
<!-- 优先展示calc.js中 返回的createdBy字段用于展示伤害计算作者-->
<span class="dmg-created-by">伤害计算来源:<strong>{{createdBy}}</strong></span>
{{/if}}
</div>
</div>
{{/if}}

View File

@ -18,7 +18,7 @@ body {
.basic {
position: relative;
margin: 0 -15px 10px -10px;
margin: 0 -15px 15px -10px;
}
.basic:after {
@ -388,7 +388,12 @@ body {
width: 100%;
}
.dmg-mode .dmg-list .cont-footer {
.dmg-created-by {
padding-left: 5px;
float: right;
}
.dmg-mode .not-dmg-mode {
display: none;
}
@ -461,10 +466,12 @@ body {
.th {
color: #d3bc8e;
padding-right: 15px;
padding-left: 5px;
text-align: right;
background: rgba(0, 0, 0, .4);
min-width: 100px;
font-size: 15px;
white-space: nowrap;
}
}
@ -533,6 +540,15 @@ body {
box-shadow: 0 0 1px 0 #ccc, 2px 2px 4px 0 rgba(50, 50, 50, .8);
overflow: hidden;
&.item {
&.arti-class-ACE,
&.arti-class-MAX {
.head {
}
}
}
.arti-icon {
width: 60px;

View File

@ -75,5 +75,6 @@ export const usefulAttr = {
琳妮特: { hp: 0, atk: 75, def: 0, cpct: 100, cdmg: 100, mastery: 0, dmg: 100, phy: 0, recharge: 55, heal: 0 },
菲米尼: { hp: 0, atk: 75, def: 0, cpct: 100, cdmg: 100, mastery: 0, dmg: 100, phy: 100, recharge: 55, heal: 0 },
那维莱特: { hp: 100, atk: 0, def: 0, cpct: 100, cdmg: 100, mastery: 75, dmg: 100, phy: 0, recharge: 75, heal: 0 },
莱欧斯利: { hp: 0, atk: 75, def: 0, cpct: 100, cdmg: 100, mastery: 75, dmg: 100, phy: 0, recharge: 55, heal: 0 }
莱欧斯利: { hp: 0, atk: 75, def: 0, cpct: 100, cdmg: 100, mastery: 75, dmg: 100, phy: 0, recharge: 55, heal: 0 },
芙宁娜: { hp: 100, atk: 0, def: 0, cpct: 100, cdmg: 100, mastery: 75, dmg: 100, phy: 0, recharge: 75, heal: 100 },
}

View File

@ -39,6 +39,7 @@ export const descFix = {
贯月矢: '触发草元素反应后每20秒产生至多存在10秒的种识之叶后台也能触发。拾取提升攻击力<nobr>32%</nobr>持续12秒。',
护摩之杖: '生命值提升$[0]。<br />获得$[1]生命值上限的攻击力提升生命值低于50%时,进一步获得$[2]生命值上限的攻击力提升。',
薙草之稻光: '攻击力获得提升提升程度相当于充能效率超出100%部分的$[0],至多提升$[1]。<br/>施放爆发后的12秒内充能效率提升$[2]。',
"「渔获」":'元素爆发的伤害提升$[0]<br />元素爆发的暴击率提升$[1]',
// 弓
终末嗟叹之诗: '精通提高$[0]点战技或爆发命中敌人时获得追思之符后台也能触发。4枚时消耗所有追思之符精通提高$[1]点,攻击力提升$[2]持续12秒。',