diff --git a/apps/admin.js b/apps/admin.js index fe395e40..8cfa3429 100644 --- a/apps/admin.js +++ b/apps/admin.js @@ -71,6 +71,8 @@ async function sysCfg (e) { let cfgSchema = cfgSchemaMap[regRet[1]] if (cfgSchema.input) { val = cfgSchema.input(val) + } else if (cfgSchema.type === 'str') { + val = (val || cfgSchema.def) + '' } else { val = cfgSchema.type === 'num' ? (val * 1 || cfgSchema.def) : !/关闭/.test(val) } diff --git a/apps/wiki/Calendar.js b/apps/wiki/Calendar.js index c9b84cb3..abc3e758 100644 --- a/apps/wiki/Calendar.js +++ b/apps/wiki/Calendar.js @@ -218,11 +218,11 @@ let Cal = { // 遍历角色数据 Character.forEach((char) => { if (charBirth[char.birth] && (char.isRelease || char.birth !== '1-1')) { - charBirth[char.birth].push(char.getData('id,name:sName,star,face')) + charBirth[char.birth].push(char.getData('id,name:abbr,star,face')) } let t = char.materials?.talent if (t && charTalent[t] && !char.isTraveler) { - let data = char.getData('id,name:sName,star,face') + let data = char.getData('id,name:abbr,star,face') data.weekly = char.getMaterials('weekly')?.icon charTalent[t].chars.push(data) } diff --git a/components/cfg/CfgData.js b/components/cfg/CfgData.js index a5dbd2e6..41ce9eab 100644 --- a/components/cfg/CfgData.js +++ b/components/cfg/CfgData.js @@ -14,7 +14,11 @@ let cfgData = { if (cfgItem.input) { val = cfgItem.input(val) } - ret.push(`export const ${cfgKey} = ${val.toString()}`, '') + if (cfgItem.type === 'str') { + ret.push(`export const ${cfgKey} = '${val.toString()}'`, '') + } else { + ret.push(`export const ${cfgKey} = ${val.toString()}`, '') + } }) }) fs.writeFileSync(`${process.cwd()}/plugins/miao-plugin/config/cfg.js`, ret.join('\n'), 'utf8') diff --git a/config/system/cfg_system.js b/config/system/cfg_system.js index b9250a8a..c28769b7 100644 --- a/config/system/cfg_system.js +++ b/config/system/cfg_system.js @@ -82,17 +82,17 @@ export const cfgSchema = { profileServer: { title: '面板服务', key: '面板服务', - type: 'num', - def: 0, - input: (n) => /[0-4]{1,3}/.test(n) ? n : 0, + def: '0', + type: 'str', + input: (n) => /[0-4]{1,3}/.test(n) ? n : '0', desc: '面板服务选择:0:自动,1:喵Api(需具备Token), 2:Enka-API, 3:MiniGG-Api, 4:Hutao-Enka代理。如设置三位数字则为分服务器设置,按顺序分别为 国服/B服/外服,例如112代表国服B服Miao,国外Enka' }, srProfileServer: { title: '星铁面板服务', key: '星铁面板服务', - type: 'num', - def: 0, - input: (n) => /[0-4]{1,3}/.test(n) ? n : 0, + def: '0', + type: 'str', + input: (n) => /[0-4]{1,3}/.test(n) ? n : '0', desc: '星铁面板服务选择:0:自动,1:喵Api(需具备Token), 2:Mihomo, 3:Avocado(鳄梨), 4:EnkaHSR。如设置三位数字则为分服务器设置,按顺序分别为 国服/B服/外服,例如114代表国服B服Miao,国外Enka' }, costumeSplash: { diff --git a/models/Character.js b/models/Character.js index e3457984..b8095864 100644 --- a/models/Character.js +++ b/models/Character.js @@ -69,7 +69,6 @@ class Character extends Base { } _get (key) { - if (metaKey.includes(key)) { return this.meta[key] } @@ -181,6 +180,11 @@ class Character extends Base { return new Character(id) } + static sample (game = 'gs') { + let id = CharId.getRandomId(game) + return Character.get(id) + } + static forEach (fn, type = 'all', game = 'gs') { let ids = Meta.getIds(game, 'char') lodash.forEach(ids, (id) => { diff --git a/models/ProfileDmg.js b/models/ProfileDmg.js index ce2916b4..4fa85e51 100644 --- a/models/ProfileDmg.js +++ b/models/ProfileDmg.js @@ -134,7 +134,7 @@ export default class ProfileDmg extends Base { trees: this.trees() } - let { id, weapon, attr } = profile + let { id, weapon, attr, artis } = profile defParams = defParams || {} @@ -142,7 +142,7 @@ export default class ProfileDmg extends Base { buffs = this.getBuffs(buffs) - let { msg } = DmgAttr.calcAttr({ originalAttr, buffs, meta, params: defParams || {}, game }) + let { msg } = DmgAttr.calcAttr({ originalAttr, buffs, artis, meta, params: defParams || {}, game }) let msgList = [] let ret = [] @@ -172,22 +172,24 @@ export default class ProfileDmg extends Base { } if (lodash.isFunction(detail)) { - let { attr } = DmgAttr.calcAttr({ originalAttr, buffs, meta }) + let { attr } = DmgAttr.calcAttr({ originalAttr, artis, buffs, meta }) let ds = lodash.merge({ talent }, DmgAttr.getDs(attr, meta)) detail = detail({ ...ds, attr, profile }) } let params = lodash.merge({}, defParams, detail?.params || {}) - let { attr, msg } = DmgAttr.calcAttr({ originalAttr, buffs, meta, params, talent: detail.talent || '', game }) + let { attr, msg } = DmgAttr.calcAttr({ originalAttr, buffs, artis, meta, params, talent: detail.talent || '', game }) if (detail.isStatic) { return } - if (detail.check && !detail.check(DmgAttr.getDs(attr, meta, params))) { + + let ds = lodash.merge({ talent }, DmgAttr.getDs(attr, meta, params)) + ds.artis = artis + if (detail.check && !detail.check(ds)) { return } if (detail.cons && meta.cons < detail.cons * 1) { return } - let ds = lodash.merge({ talent }, DmgAttr.getDs(attr, meta, params)) let dmg = DmgCalc.getDmgFn({ ds, attr, level: profile.level, enemyLv, showDetail: detail.showDetail, game }) let basicDmgRet @@ -218,7 +220,7 @@ export default class ProfileDmg extends Base { } if (lodash.isFunction(detail)) { - let { attr } = DmgAttr.calcAttr({ originalAttr, buffs, meta }) + let { attr } = DmgAttr.calcAttr({ originalAttr, buffs, artis, meta }) let ds = lodash.merge({ talent }, DmgAttr.getDs(attr, meta)) detail = detail({ ...ds, attr, profile }) } @@ -246,6 +248,7 @@ export default class ProfileDmg extends Base { let { attr } = DmgAttr.calcAttr({ originalAttr, buffs, + artis, meta, params, incAttr, diff --git a/models/character/CharId.js b/models/character/CharId.js index 384423fa..842fc56e 100644 --- a/models/character/CharId.js +++ b/models/character/CharId.js @@ -64,6 +64,15 @@ const CharId = { return false }, + getRandomId (game = 'gs') { + let meta = Meta.create(game, 'char') + let ids = meta.getIds() + if (game === 'gs') { + ids = lodash.filter(ids, (id) => /^\d+$/.test(id)) + } + return lodash.sample(ids) + }, + isTraveler (id) { if (id) { return [10000007, 10000005, 20000000].includes(id * 1) diff --git a/models/dmg/DmgAttr.js b/models/dmg/DmgAttr.js index 70b9366c..c4bb24d6 100644 --- a/models/dmg/DmgAttr.js +++ b/models/dmg/DmgAttr.js @@ -117,7 +117,7 @@ let DmgAttr = { }, // 计算属性 - calcAttr ({ originalAttr, buffs, meta, params = {}, incAttr = '', reduceAttr = '', talent = '', game = 'gs' }) { + calcAttr ({ originalAttr, buffs, meta, artis, params = {}, incAttr = '', reduceAttr = '', talent = '', game = 'gs' }) { let attr = DmgAttr.getAttr({ originalAttr, game }) let msg = [] let { attrMap } = Meta.getMeta(game, 'arti') @@ -135,6 +135,7 @@ let DmgAttr = { let ds = DmgAttr.getDs(attr, meta, params) ds.currentTalent = talent + ds.artis = artis if (buff.isStatic) { return diff --git a/resources/admin/index.html b/resources/admin/index.html index 21cfa456..cc0d931e 100644 --- a/resources/admin/index.html +++ b/resources/admin/index.html @@ -23,7 +23,7 @@ {{if cfgItem.type==='num'}} {{cfgItem.def}}{{else}} 开启/关闭{{/if}} {{/if}} - {{if cfgItem.type === 'num'}} + {{if cfgItem.type === 'num' || cfgItem.type === 'str'}}