面板更换功能支持武器别名

This commit is contained in:
Kokomi 2022-11-27 05:51:36 +08:00
parent 7d9f068d28
commit 93666108ca
8 changed files with 185 additions and 19 deletions

View File

@ -14,9 +14,13 @@ let app = App.init({
name: '角色面板'
})
app.reg('profile-detail', profileDetail, {
rule: /^#*([^#]+)(详细|详情|面板|面版|圣遗物|伤害[1-7]?)\s*(\d{9})*(.*[换变改].*)?$/,
rule: /^#*([^#]+)\s*(详细|详情|面板|面版|圣遗物|伤害[1-7]?)\s*(\d{9})*(.*[换变改].*)?$/,
name: '角色面板'
})
app.reg('profile-change', profileDetail, {
rule: /^#.+换.+$/,
name: '角色面板计算'
})
app.reg('group-profile', groupRank, {
rule: /^#(群|群内)?(排名|排行)?(最强|最高|最高分|最牛|第一)+.+/,
@ -77,7 +81,7 @@ export async function profileDetail (e) {
if (!msg) {
return false
}
if (!/详细|详情|面板|面版|圣遗物|伤害/.test(msg)) {
if (!/详细|详情|面板|面版|圣遗物|伤害|换/.test(msg)) {
return false
}
let mode = 'profile'

View File

@ -38,7 +38,7 @@ const ProfileChange = {
return false
}
msg = msg.toLowerCase().replace(/uid ?:? ?/, '')
let regRet = /^#*(\d{9})?(.+?)(详细|详情|面板|面版|圣遗物|伤害[1-7]?)\s*(\d{9})?(.+)/.exec(msg)
let regRet = /^#*(\d{9})?(.+?)(详细|详情|面板|面版|圣遗物|伤害[1-7]?|换)\s*(\d{9})?(.+)/.exec(msg)
if (!regRet || !regRet[2]) {
return false
}
@ -50,7 +50,7 @@ const ProfileChange = {
return false
}
ret.char = char.id
ret.mode = regRet[3]
ret.mode = regRet[3] === '换' ? '面板' : regRet[3]
ret.uid = regRet[1] || regRet[4] || ''
msg = regRet[5]
@ -84,11 +84,11 @@ const ProfileChange = {
if (wRet && wRet[4]) {
let weaponName = lodash.trim(wRet[4])
let weapon = Weapon.get(weaponName)
if (weapon || weaponName === '武器') {
if (weapon || weaponName === '武器' || Weapon.isWeaponSet(weaponName)) {
let affix = wRet[1] || wRet[3]
affix = { : 1, : 2, : 3, : 4, : 5 }[affix] || affix * 1
let tmp = {
weapon: weaponName === '武器' ? '' : weaponName,
weapon: (Weapon.isWeaponSet(weaponName) ? weaponName : weapon?.name) || '',
affix: affix || '',
level: wRet[2] * 1 || ''
}
@ -182,7 +182,7 @@ const ProfileChange = {
level,
cons: Data.def(dc.cons, source.cons, 0),
fetter: source.fetter || 10,
elem: source.elem || char.elem,
elem: char.elem,
dataSource: 'change',
promote
}, uid, false)
@ -190,7 +190,7 @@ const ProfileChange = {
// 设置武器
let wCfg = ds.weapon || {}
let wSource = getSource(wCfg).weapon || {}
let weapon = Weapon.get(wCfg?.weapon || wSource?.name || defWeapon[char.weaponType])
let weapon = Weapon.get(wCfg?.weapon || wSource?.name || defWeapon[char.weaponType], char.weaponType)
if (!weapon || weapon.type !== char.weaponType) {
weapon = Weapon.get(defWeapon[char.weaponType])
}

View File

@ -1,6 +1,7 @@
import Base from './Base.js'
import { Data } from '../components/index.js'
import { data as weaponData, abbr } from '../resources/meta/weapon/index.js'
import { weaponData, weaponAbbr, weaponAlias, weaponType, weaponSet } from '../resources/meta/weapon/index.js'
import lodash from 'lodash'
class Weapon extends Base {
constructor (name) {
@ -21,7 +22,7 @@ class Weapon extends Base {
}
get abbr () {
return abbr[this.name] || this.name
return weaponAbbr[this.name] || this.name
}
get title () {
@ -53,9 +54,20 @@ class Weapon extends Base {
return this._detail
}
static get (name) {
if (weaponData[name]) {
return new Weapon(name)
static isWeaponSet (name) {
return weaponSet.includes(name)
}
static get (name, type = '') {
name = lodash.trim(name)
if (weaponAlias[name]) {
return new Weapon(weaponAlias[name])
}
if (type) {
let name2 = name + (weaponType[type] || type)
if (weaponAlias[name2]) {
return new Weapon(weaponAlias[name2])
}
}
return false
}

View File

@ -6,7 +6,7 @@
import { Weapon, ProfileAttr } from '../index.js'
import { Format } from '../../components/index.js'
import { calc as artisBuffs } from '../../resources/meta/artifact/index.js'
import { calc as weaponBuffs } from '../../resources/meta/weapon/index.js'
import { weaponBuffs } from '../../resources/meta/weapon/index.js'
import lodash from 'lodash'
class AttrCalc {

View File

@ -10,7 +10,7 @@ let artisBuffs = {}
// lazy load
setTimeout(async function init () {
weaponBuffs = (await Data.importModule('resources/meta/weapon/index.js')).calc || {}
weaponBuffs = (await Data.importModule('resources/meta/weapon/index.js')).weaponBuffs || {}
artisBuffs = (await Data.importModule('resources/meta/artifact/index.js')).calc || {}
})

Binary file not shown.

Before

Width:  |  Height:  |  Size: 763 KiB

After

Width:  |  Height:  |  Size: 151 KiB

View File

@ -1,6 +1,6 @@
import { Data } from '../../../components/index.js'
import lodash from 'lodash'
import { weaponType, abbr } from './meta.js'
import { weaponType, abbr, alias, weaponSet } from './meta.js'
let calc = {}
let data = {}
@ -43,4 +43,25 @@ for (let type in weaponType) {
})
}
export { abbr, weaponType, calc, data }
let aliasMap = {}
lodash.forEach(alias, (txt, name) => {
Data.eachStr(txt, (t) => {
aliasMap[t] = name
aliasMap[name] = name
})
})
lodash.forEach(abbr, (a, name) => {
aliasMap[a] = name
})
lodash.forEach(data, (ds, name) => {
if (!aliasMap[name]) {
console.log(name)
}
aliasMap[name] = name
})
export const weaponBuffs = calc
export const weaponData = data
export const weaponAbbr = abbr
export const weaponAlias = aliasMap
export { weaponType, weaponSet }

View File

@ -1,5 +1,5 @@
export const weaponType = {
polearm: '长柄',
polearm: '',
catalyst: '法器',
sword: '剑',
bow: '弓',
@ -31,7 +31,7 @@ export const abbr = {
讨龙英杰谭: '讨龙',
神射手之誓: '神射手',
'「渔获」': '渔获',
暗巷的酒与诗: '暗巷酒诗',
暗巷的酒与诗: '暗巷',
飞天大御剑: '飞天大剑',
口袋魔导书: '魔导书',
历练的猎弓: '历练猎弓',
@ -41,3 +41,132 @@ export const abbr = {
西福斯的月光: '西福斯',
玛海菈的水色: '玛海菈'
}
export const alias = {
// 剑
天空之刃: '天空剑',
风鹰剑: '风鹰,风影',
波乱月白经津: '波乱,月白,波乱月白,经津,波波津,啵啵剑,月经剑',
磐岩结绿: '绿箭,绿剑',
斫峰之刃: '斫峰,盾剑',
苍古自由之誓: '苍古,乐团剑',
雾切之回光: '雾切',
西风剑: '剑',
暗巷闪光: '暗巷剑,暗巷单手剑',
宗室长剑: '宗室剑,宗室单手剑',
祭礼剑: '祭礼单手剑',
黑岩长剑: '黑岩剑',
匣里龙吟: '匣里剑,龙吟,匣里单手剑',
试作斩岩: '试作剑,试做剑,斩岩,试做斩岩,试做单手剑,试作单手剑',
铁蜂刺: '铁封刺,铁锋刺',
天目影打刀: '天目刀,天目,稻妻锻造单手剑,稻妻锻造剑',
原木刀: '原木刀,木刀,须弥锻造剑,须弥锻造单手剑',
西福斯的月光: '西福斯的月光,月光剑,月光,西福斯',
辰砂之纺锤: '辰砂,辰砂纺锤,纺锤',
降临之剑: '降临剑,降临',
腐殖之剑: '腐殖,腐殖剑',
笼钓瓶一心: '妖刀,红刀,笼钓瓶,一心传名刀,一心传',
东花坊时雨: '雨伞,伞剑',
黑剑: '月卡剑',
// 大剑
天空之傲: '天空大剑',
狼的末路: '狼末',
无工之剑: '蜈蚣,蜈蚣大剑,无工大剑,盾大剑,无工',
赤角石溃杵: '赤角,石溃杵',
松籁响起之时: '松籁,乐团大剑,松剑',
西风大剑: '西风大剑',
祭礼大剑: '祭礼双手剑',
黑岩斩刀: '黑岩刀,黑岩大剑',
宗室大剑: '宗室双手剑',
千岩古剑: '千岩剑,千岩大剑',
试作古华: '古华,试做古华,试作大剑,试做大剑',
白影剑: '白影大剑',
雪葬的星银: '雪葬,星银,雪葬星银,雪山大剑',
桂木斩长正: '桂木,斩长正,稻妻锻造大剑',
森林王器: '森林王器,王器,须弥锻造大剑',
玛海菈的水色: '玛海菈的水色,水色,玛海菈',
衔珠海皇: '海皇,咸鱼剑,咸鱼大剑',
螭骨剑: '螭骨,丈育剑,离骨剑,月卡大剑',
沐浴龙血的剑: '龙血剑,龙血大剑',
// 枪
天空之脊: '天空枪,薄荷枪',
护摩之杖: '护摩,护摩枪,护膜',
圣显之钥: '圣显之钥,板砖',
赤沙之杖: '赤沙之杖,船桨',
和璞鸢: '鸟枪,绿枪,绿叉',
贯虹之槊: '贯虹,岩枪,盾枪',
薙草之稻光: '薙草,稻光,薙草稻光,马尾枪,马尾,薙刀',
千岩长枪: '千岩枪',
黑岩刺枪: '黑岩枪',
断浪长鳍: '断浪,断浪长枪,断浪枪',
恶王丸: '恶丸,恶王',
西风长枪: '西风枪',
宗室猎枪: '宗室枪,宗室长枪',
匣里灭辰: '灭辰,匣里长枪,匣里枪',
试作星镰: '星镰,试做星镰,试做长枪,试作长枪,试做枪,试作枪,试做枪',
流月针: '针,留月针',
龙脊长枪: '雪山枪,雪山长枪',
喜多院十文字: '喜多院,十文字,稻妻锻造枪',
贯月矢: '贯月矢,月矢,须弥锻造枪',
'「渔获」': '鱼叉,渔叉,鱼获',
风信之锋: '风信之锋,风信',
黑缨枪: '史莱姆枪',
决斗之枪: '决斗枪,决斗,月卡枪',
// 法器
四风原典: '四风,四风书,四风法器',
天空之卷: '天空书,厕纸,天空法器',
尘世之锁: '尘世锁,尘世,盾书,锁',
神乐之真意: '神乐,真意,果盘',
不灭月华: '月华',
千夜浮梦: '千夜,夜壶,神灯,乐神壶',
流浪乐章: '赌狗书,赌狗乐章,赌狗',
昭心: '糟心',
西风秘典: '西风法器,西风书',
祭礼残章: '祭礼法器,祭礼书',
匣里日月: '日月,匣里法器,月卡法器',
图莱杜拉的回忆: '图莱杜拉的回忆,图莱杜拉,铃铛',
黑岩绯玉: '黑岩法器,黑岩书,黑岩法器',
宗室秘法录: '宗室法器,宗室书',
暗巷的酒与诗: '暗巷书,酒与诗,暗巷法器',
讨龙英杰谭: '讨龙',
试作金珀: '金珀,试做金珀,试做金箔,试作星镰,试作法器,试做法器',
万国诸海图谱: '万国,万国诸海',
忍冬之果: '雪山法器,忍冬',
白辰之环: '白辰,白辰环,稻妻锻造法器',
盈满之实: '盈满之实,盈满,须弥锻造法器',
流浪的晚星: '流浪的晚星,晚星',
证誓之明瞳: '证誓,明瞳,证誓明瞳',
嘟嘟可故事集: '嘟嘟可,故事集,故事书',
// 弓
天空之翼: '天空弓',
阿莫斯之弓: '阿莫斯,ams,痛苦弓',
冬极白星: '冬极,冬季',
若水: '麒麟弓,aqua',
终末嗟叹之诗: '终末,终末弓,叹气弓,乐团弓',
飞雷之弦振: '飞雷,飞雷弓,弦振',
猎人之径: '猎人',
曚云之月: '曚云弓',
祭礼弓: '祭礼弓箭',
黑岩战弓: '黑岩弓',
西风猎弓: '西风弓',
宗室长弓: '宗室弓',
幽夜华尔兹: '幽夜,幽夜弓,华尔兹',
暗巷猎手: '暗巷弓',
神射手之誓: '脚气弓,神射手',
苍翠猎弓: '绿弓,月卡弓',
试作澹月: '澹月,试做澹月,试做弓,试作弓',
钢轮弓: '钢轮,钢弓',
破魔之弓: '破魔弓,稻妻锻造弓',
王下近侍: '王下近侍,近侍,须弥锻造弓',
落霞: '落下',
掠食者: '掠食',
风花之颂: '风花弓',
竭泽: '竭泽,咸鱼弓,鱼弓,渔弓',
弓藏: '弓藏'
}
export const weaponSet = ['西风', '天空', '试做', '试作', '祭礼', '黑岩', '宗室', '暗巷', '匣里', '千岩']