调整星铁面板更新时的保存逻辑

This commit is contained in:
Kokomi 2023-05-16 13:04:43 +08:00
parent 838f102996
commit fddcfeef60
21 changed files with 747 additions and 571 deletions

View File

@ -86,7 +86,7 @@ const ProfileChange = {
let wRet = /^(?:等?级?([1-9][0-9])?级?)?\s*(?:([1-5一二三四五满])?精炼?([1-5一二三四五])?)?\s*(?:等?级?([1-9][0-9])?级?)?\s*(.*)$/.exec(txt)
if (wRet && wRet[5]) {
let weaponName = lodash.trim(wRet[5])
let weapon = Weapon.get(weaponName)
let weapon = Weapon.get(weaponName, ret.char.game)
if (weapon || weaponName === '武器' || Weapon.isWeaponSet(weaponName)) {
let affix = wRet[2] || wRet[3]
affix = { : 1, : 2, : 3, : 4, : 5, : 5 }[affix] || affix * 1
@ -195,14 +195,14 @@ const ProfileChange = {
elem: char.elem,
dataSource: 'change',
promote
}, false)
}, char.game, false)
// 设置武器
let wCfg = ds.weapon || {}
let wSource = getSource(wCfg).weapon || {}
let weapon = Weapon.get(wCfg?.weapon || wSource?.name || defWeapon[char.weaponType], char.weaponType)
let weapon = Weapon.get(wCfg?.weapon || wSource?.name || defWeapon[char.weaponType], char.game, char.weaponType)
if (!weapon || weapon.type !== char.weaponType) {
weapon = Weapon.get(defWeapon[char.weaponType])
weapon = Weapon.get(defWeapon[char.weaponType], char.game)
}
let wDs = {
name: weapon.name,

View File

@ -40,7 +40,10 @@ let ProfileDetail = {
msg = msg.replace(uidRet[0], '')
}
let name = msg.replace(/#|老婆|老公/g, '').trim()
if (/星铁/.test(msg)) {
e.isSr = true
}
let name = msg.replace(/#|老婆|老公|星铁|原神/g, '').trim()
msg = msg.replace('面版', '面板')
let dmgRet = /(?:伤害|武器)(\d?)$/.exec(name)
let dmgIdx = 0
@ -145,7 +148,7 @@ let ProfileDetail = {
attr[`${key}Plus`] = fn(a[key2] - base[key2])
})
let weapon = Weapon.get(profile.weapon.name)
let weapon = Weapon.get(profile.weapon.name, char.game)
let w = profile.weapon
let wCfg = {}
if (mode === 'weapon') {

View File

@ -61,7 +61,7 @@ const ProfileList = {
isSelfUid = uids.join(',').split(',').includes(uid + '')
}
let rank = false
let servName = Player.getProfileServName(uid)
let hasNew = false
let newCount = 0
@ -75,6 +75,7 @@ const ProfileList = {
const cfg = await Data.importCfg('cfg')
// 获取面板数据
let player = Player.create(e)
let servName = Player.getProfileServName(uid, player.game)
if (!player.hasProfile) {
await player.refresh({ profile: true })
}

View File

@ -1,7 +1,7 @@
import { ProfileData, Weapon } from '#miao.models'
export const ProfileWeapon = {
async calc (profile) {
async calc (profile, game = 'gs') {
let ret = []
await Weapon.forEach(async (w) => {
let weaponRet = w.getData('name,star,abbr,icon')
@ -13,7 +13,7 @@ export const ProfileWeapon = {
let tempProfile = new ProfileData({
...profile.getData('uid,id,level,cons,fetter,elem,promote,talent,artis'),
dataSource: 'change'
}, false)
}, game, false)
tempProfile.setWeapon({
name: w.name,

View File

@ -5,28 +5,31 @@ import Base from './Base.js'
import { Format } from '#miao'
import { ArtifactSet } from './index.js'
import { artiMap, attrMap, mainIdMap, attrIdMap } from '../resources/meta/artifact/index.js'
import { idMap as idMapSR, artiMap as artiMapSR, metaData as metaDataSR } from '../resources/meta-sr/artifact/index.js'
import lodash from 'lodash'
class Artifact extends Base {
static getAttrs
constructor (name) {
constructor (name, game = 'gs') {
super()
let cache = this._getCache(`arti:${name}`)
let cache = this._getCache(`arti:${game}:${name}`)
if (cache) {
return cache
}
let data = artiMap[name]
this.game = game
let data = (this.isGs ? artiMap : artiMapSR)[name]
if (!data) {
return false
}
this.name = name
this.id = data.id || ''
this.name = data.name
this.meta = data
return this._cache()
}
get artiSet () {
return ArtifactSet.get(this.set)
return ArtifactSet.get(this.set, this.game)
}
get setName () {
@ -34,12 +37,18 @@ class Artifact extends Base {
}
get img () {
return `meta/artifact/imgs/${this.setName}/${this.idx}.webp`
return this.isGs ? `meta/artifact/imgs/${this.setName}/${this.idx}.webp` : `meta-sr/artifact/imgs/${this.setName}/arti-${this.idx}.webp`
}
static get (name) {
if (artiMap[name]) {
return new Artifact(name)
static get (name, game = 'gs') {
if (!name) {
return false
}
if (game === 'sr') {
name = idMapSR[name]?.name || name
}
if ((game === 'gs' ? artiMap : artiMapSR)[name]) {
return new Artifact(name, game)
}
return false
}
@ -96,6 +105,37 @@ class Artifact extends Base {
})
return ret
}
getStarById (id) {
return this.meta.ids[id] || ''
}
getAttrData (mainId, attrData, level = 1, star = 5) {
let starCfg = metaDataSR.starData[star]
let mainCfg = starCfg.main[mainId]
if (!mainId || !mainCfg) {
return false
}
let main = {
id: mainId,
key: mainCfg.key,
value: mainCfg.base + mainCfg.step * level
}
let attrs = []
lodash.forEach(attrData, (ds) => {
let attrCfg = starCfg.sub[ds.id]
attrs.push({
...ds,
key: attrCfg.key,
value: attrCfg.base * ds.count + attrCfg.step * ds.step
})
})
return {
main,
attrs
}
}
}
export default Artifact

View File

@ -8,8 +8,9 @@ import { Format, Data } from '#miao'
import ArtisMark from './profile/ArtisMark.js'
export default class AvatarArtis extends Base {
constructor (charid = 0) {
constructor (charid = 0, game = 'gs') {
super()
this.game = game
this.charid = charid
this.artis = {}
}
@ -49,40 +50,64 @@ export default class AvatarArtis extends Base {
return ArtisMark.getKeyTitleMap()
}
setArtisData (ds = {}, profile = false) {
// let force = !this.hasArtis || ArtisMark.hasAttr(ds) || !ArtisMark.hasAttr(this.artis)
if (!profile || (profile && ArtisMark.hasAttr(ds))) {
for (let idx = 1; idx <= 5; idx++) {
setArtisData (ds = {}, isProfile = false) {
if (!isProfile || (isProfile && ArtisMark.hasAttr(ds))) {
for (let idx = 1; idx <= (this.isGs ? 5 : 6); idx++) {
if (ds[idx] || ds[`arti${idx}`]) {
this.setArtis(idx, ds[idx] || ds[`arti${idx}`], profile)
this.setArtis(idx, ds[idx] || ds[`arti${idx}`], isProfile)
}
}
}
}
setArtis (idx = 1, ds = {}, profile = false) {
setArtis (idx = 1, ds = {}, isProfile = false) {
idx = idx.toString().replace('arti', '')
this.artis[idx] = this.artis[idx] || {}
let arti = this.artis[idx]
if (profile) {
arti.name = ds._name || ds.name || arti.name || ''
arti.set = ds._set || Artifact.getSetNameByArti(arti._name) || ds.set || ''
arti.level = ds._level || ds.level || 1
arti.star = ds._star || ds.star || 5
arti.main = ds.main
arti.attrs = ds.attrs
return true
}
arti.name = ds.name || arti.name || ''
arti.set = ds.set || Artifact.getSetNameByArti(arti.name) || ''
arti.level = ds.level || 1
arti.star = ds.star || 5
let artiObj
if (this.isSr) {
artiObj = Artifact.get(ds.id, this.game)
if (!artiObj) {
return false
}
arti.id = artiObj.id || ds.id || arti.id || ''
arti.name = artiObj.name || arti.name || ''
arti.set = artiObj.setName || arti.set || ''
arti.level = ds.level || arti.level || 1
arti.star = artiObj.getStarById(ds.id) || arti.star || 5
if (ds.mainId || ds.main) {
arti._name = ds._name || ds.name || arti._name || arti.name
arti._set = ds._set || Artifact.getSetNameByArti(arti._name) || arti._set || ''
arti._level = ds._level || ds.level || arti._level || arti.level
arti._star = ds._star || ds.star || arti._star || arti.star || 5
if (ds.mainId && ds.attrs) {
let attr = artiObj.getAttrData(ds.mainId, ds.attrs, arti.level, arti.star)
if (attr) {
arti.mainId = ds.mainId
arti.main = attr.main || arti.main || {}
arti.attrs = attr.attrs || arti.attrs || {}
} else {
console.log('attr id error', ds.main, arti.level, arti.star)
}
}
return
} else {
if (isProfile) {
arti.name = ds._name || ds.name || arti.name || ''
arti.set = ds._set || Artifact.getSetNameByArti(arti._name) || ds.set || ''
arti.level = ds._level || ds.level || 1
arti.star = ds._star || ds.star || 5
arti.main = ds.main
arti.attrs = ds.attrs
return true
}
arti.name = ds.name || arti.name || ''
arti.set = ds.set || Artifact.getSetNameByArti(arti.name) || ''
arti.level = ds.level || 1
arti.star = ds.star || 5
if (ds.mainId || ds.main) {
arti._name = ds._name || ds.name || arti._name || arti.name
arti._set = ds._set || Artifact.getSetNameByArti(arti._name) || arti._set || ''
arti._level = ds._level || ds.level || arti._level || arti.level
arti._star = ds._star || ds.star || arti._star || arti.star || 5
}
}
// 存在面板数据,更新面板数据
@ -104,6 +129,7 @@ export default class AvatarArtis extends Base {
forEach (fn) {
lodash.forEach(this.artis, (ds, idx) => {
console.log(ds, this.game, ds.mainId, ds.main)
if (ds.name) {
fn(ds, idx)
}
@ -123,14 +149,29 @@ export default class AvatarArtis extends Base {
toJSON () {
let ret = {}
for (let idx = 1; idx <= 5; idx++) {
for (let idx = 1; idx <= (this.isGs ? 5 : 6); idx++) {
let ds = this.artis[idx]
if (ds) {
let tmp = {
name: ds.name || '',
level: ds.level || 1,
star: ds.star || 5
}
if (!ds) {
continue
}
let tmp = {
level: ds.level || 1,
star: ds.star || 5
}
console.log('tojson', 'isSr')
if (this.isSr) {
tmp.id = ds.id
tmp.mainId = ds.main?.id
tmp.attrs = []
lodash.forEach(ds.attrs, (as) => {
tmp.attrs.push({
id: as?.id,
count: as?.count,
step: as?.step
})
})
} else {
tmp.name = ds.name || ''
if ((ds.mainId && ds.attrIds) || (ds.main && ds.attrs)) {
if ((ds._name && ds._name !== ds.name) || (ds._level && ds._level !== ds.level) || (ds._star && ds._star !== ds.star)) {
tmp._name = ds._name || null
@ -150,8 +191,8 @@ export default class AvatarArtis extends Base {
}
}
}
ret[idx] = tmp
}
ret[idx] = tmp
}
return ret
}

View File

@ -63,9 +63,10 @@ export default class AvatarData extends Base {
return {
enka: 'Enka.Network',
miao: '喵喵Api',
mgg: 'MiniGG-API',
mgg: 'MiniGG-Api',
hutao: 'Hutao-Enka',
mys: '米游社'
mys: '米游社',
lulu: '路路Api'
}[this._source] || this._source
}
@ -92,7 +93,7 @@ export default class AvatarData extends Base {
}
initArtis () {
this.artis = new AvatarArtis(this.id)
this.artis = new AvatarArtis(this.id, this.game)
}
_get (key) {
@ -123,11 +124,12 @@ export default class AvatarData extends Base {
this._costume = ds.costume || this._costume || 0
this.elem = ds.elem || this.elem || this.char.elem || ''
this.promote = lodash.isUndefined(ds.promote) ? (this.promote || AttrCalc.calcPromote(this.level)) : (ds.promote || 0)
this.trees = ds.trees || this.trees || []
this._source = ds._source || ds.dataSource || this._source || ''
this._time = ds._time || this._time || now
this._update = ds._update || this._update || ds._time || now
this._talent = ds._talent || this._talent || ds._time || now
// 存在数据源时更新时间
if (source) {
this._update = now
@ -142,13 +144,13 @@ export default class AvatarData extends Base {
}
setWeapon (ds = {}) {
let w = Weapon.get(ds.name)
let w = Weapon.get(ds.name || ds.id, this.game)
if (!w) {
return false
}
this.weapon = {
name: ds.name,
id: ds.id || w.id,
name: ds.name || w.name,
level: ds.level || ds.lv || 1,
promote: lodash.isUndefined(ds.promote) ? AttrCalc.calcPromote(ds.level || ds.lv || 1) : (ds.promote || 0),
affix: ds.affix,
@ -182,7 +184,7 @@ export default class AvatarData extends Base {
if (!this.isProfile) {
return false
}
return ProfileData.create(this)
return ProfileData.create(this, this.game)
}
// 判断当前profileData是否具备有效圣遗物信息
@ -192,9 +194,12 @@ export default class AvatarData extends Base {
// toJSON 供保存使用
toJSON () {
let keys = this.isGs ?
'name,id,elem,level,promote,fetter,costume,cons,talent:originalTalent' :
'name,id,elem,level,promote,cons,talent:originalTalent,trees'
return {
...this.getData('name,id,elem,level,promote,fetter,costume,cons,talent:originalTalent'),
weapon: Data.getData(this.weapon, 'name,level,promote,affix'),
...this.getData(keys),
weapon: Data.getData(this.weapon, this.isGs ? 'name,level,promote,affix' : 'id,level,promote,affix'),
...this.getData('artis,_source,_time,_update,_talent')
}
}
@ -208,7 +213,7 @@ export default class AvatarData extends Base {
}
} else {
return {
...(this.getData(keys || 'id,name,level,star,cons,fetter,elem,abbr,weapon,talent,artisSet') || {}),
...(this.getData(keys || 'id,name,level,star,cons,elem,abbr,weapon,talent,artisSet,trees') || {}),
...Data.getData(imgs, 'face,qFace,gacha,preview')
}
}

View File

@ -94,11 +94,11 @@ export default class Base {
delete metaMap[id]
}
isSr () {
get isSr () {
return this.game === 'sr'
}
isGs () {
get isGs () {
return !this.isSr
}
}

View File

@ -226,9 +226,26 @@ class Character extends Base {
return CharImg.getCardImg(this.name, se, def)
}
// 设置旅行者数据
// 设置天赋数据
getAvatarTalent (talent = {}, cons = 0, mode = 'original') {
return CharTalent.getAvatarTalent(this.id, talent, cons, mode, this.talentCons)
return CharTalent.getAvatarTalent(this, talent, cons, mode)
}
getTalentKey (id) {
if (this.talentId[id]) {
return this.talentId[id]
}
if (this.isSr) {
id = (id + '').replace(this.id, '')
return {
'001': 'a',
'002': 'e',
'003': 'q',
'004': 't',
'007': 'z'
}[id]
}
return false
}
// 检查老婆类型

View File

@ -169,7 +169,6 @@ export default class Player extends Base {
// 获取Avatar角色
getAvatar (id, create = false) {
let char = Character.get(id)
console.log('getAvatar', char.id)
let avatars = this._avatars
if (this.isGs) {
// 兼容处理旅行者的情况
@ -178,7 +177,7 @@ export default class Player extends Base {
}
}
if (!avatars[id] && create) {
avatars[id] = AvatarData.create({ id })
avatars[id] = AvatarData.create({ id }, '', this.game)
}
return avatars[id] || false
}

View File

@ -10,8 +10,8 @@ import { attrMap } from '../resources/meta/artifact/index.js'
import CharArtis from './profile/CharArtis.js'
export default class ProfileArtis extends AvatarArtis {
constructor (charid = 0, elem = '') {
super(charid)
constructor (charid = 0, elem = '', game = 'gs') {
super(charid, game)
this.elem = elem
}
@ -85,6 +85,7 @@ export default class ProfileArtis extends AvatarArtis {
}
} else {
let artifact = Artifact.get(arti.name)
console.log(arti.main, arti.mainId, arti)
artis[idx] = {
name: artifact.name,
set: artifact.setName,

View File

@ -6,9 +6,9 @@ import AttrCalc from './profile/AttrCalc.js'
import CharImg from './character/CharImg.js'
export default class ProfileData extends AvatarData {
constructor (ds = {}, calc = true) {
super(ds)
if (calc && !this.isSr) {
constructor (ds = {}, game = 'gs', calc = true) {
super(ds, game)
if (calc) {
this.calcAttr()
}
}
@ -53,8 +53,8 @@ export default class ProfileData extends AvatarData {
return this.hasData && !!ProfileDmg.dmgRulePath(this.name)
}
static create (ds) {
let profile = new ProfileData(ds)
static create (ds, game = 'gs') {
let profile = new ProfileData(ds, game)
if (!profile) {
return false
}
@ -62,7 +62,7 @@ export default class ProfileData extends AvatarData {
}
initArtis () {
this.artis = new ProfileArtis(this.id, this.elem)
this.artis = new ProfileArtis(this.id, this.elem, this.game)
}
setAttr (ds) {
@ -76,7 +76,7 @@ export default class ProfileData extends AvatarData {
}
calcAttr () {
this._attr = AttrCalc.create(this)
this._attr = AttrCalc.create(this, this.game)
this.attr = this._attr.calc()
this.base = this._attr.getBase()
}
@ -88,6 +88,7 @@ export default class ProfileData extends AvatarData {
// 获取当前profileData的圣遗物评分withDetail=false仅返回简略信息
getArtisMark (withDetail = true) {
if (this.hasData) {
console.log(this.game)
return this.artis.getMarkDetail(withDetail)
}
return {}

View File

@ -1,16 +1,18 @@
import Base from './Base.js'
import { Data } from '#miao'
import { weaponData, weaponAbbr, weaponAlias, weaponType, weaponSet } from '../resources/meta/weapon/index.js'
import { weaponData as weaponDataSR, weaponAlias as weaponAliasSR } from '../resources/meta-sr/weapon/index.js'
import lodash from 'lodash'
class Weapon extends Base {
constructor (name) {
constructor (name, game = 'gs') {
super(name)
let meta = weaponData[name]
let meta = game === 'gs' ? weaponData[name] : weaponDataSR[name]
if (!meta) {
return false
}
let cache = this._getCache(`weapon:${name}`)
let cache = this._getCache(`weapon:${game}:${name}`)
if (cache) {
return cache
}
@ -19,6 +21,7 @@ class Weapon extends Base {
this.meta = meta
this.type = meta.type
this.star = meta.star
this.game = game
return this._cache()
}
@ -31,14 +34,22 @@ class Weapon extends Base {
}
get img () {
return `meta/weapon/${this.type}/${this.name}/icon.webp`
return `meta/${this.isGs ? 'meta' : 'meta-sr'}/${this.type}/${this.name}/icon.webp`
}
get imgs () {
return {
icon: `meta/weapon/${this.type}/${this.name}/icon.webp`,
icon2: `meta/weapon/${this.type}/${this.name}/awaken.webp`,
gacha: `meta/weapon/${this.type}/${this.name}/gacha.webp`
if (this.isGs) {
return {
icon: `meta/weapon/${this.type}/${this.name}/icon.webp`,
icon2: `meta/weapon/${this.type}/${this.name}/awaken.webp`,
gacha: `meta/weapon/${this.type}/${this.name}/gacha.webp`
}
} else {
return {
icon: `meta/weapon-sr/${this.type}/${this.name}/icon.webp`,
icon2: `meta/weapon-sr/${this.type}/${this.name}/icon-s.webp`,
gacha: `meta/weapon-sr/${this.type}/${this.name}/splash.webp`
}
}
}
@ -67,12 +78,13 @@ class Weapon extends Base {
return weaponSet.includes(name)
}
static get (name, type = '') {
static get (name, game = 'gs', type = '') {
name = lodash.trim(name)
if (weaponAlias[name]) {
return new Weapon(weaponAlias[name])
let alias = game === 'gs' ? weaponAlias : weaponAliasSR
if (alias[name]) {
return new Weapon(alias[name], game)
}
if (type) {
if (type && game === 'gs') {
let name2 = name + (weaponType[type] || type)
if (weaponAlias[name2]) {
return new Weapon(weaponAlias[name2])
@ -96,7 +108,7 @@ class Weapon extends Base {
if (this._detail) {
return this._detail
}
const path = 'resources/meta/weapon'
const path = this.isGs ? 'resources/meta/weapon' : 'resources/meta/weapon-sr'
try {
this._detail = Data.readJSON(`${path}/${this.type}/${this.name}/data.json`, 'miao')
} catch (e) {

View File

@ -5,9 +5,10 @@ import lodash from 'lodash'
const CharTalent = {
// 处理获取天赋数据
getAvatarTalent (id, talent, cons, mode, consTalent = {}) {
getAvatarTalent (char, talent, cons, mode) {
let { id, talentCons, game } = char
let ret = {}
lodash.forEach(['a', 'e', 'q'], (key) => {
lodash.forEach(game === 'gs' ? ['a', 'e', 'q'] : ['a', 'e', 'q', 't'], (key) => {
let ds = talent[key]
if (!ds) {
return false
@ -26,10 +27,10 @@ const CharTalent = {
mode = 'level'
} else {
original = value
if (key === 'a') {
if (key === 'a' && char.isGs) {
level = aPlus ? value + 1 : value
} else {
level = cons >= consTalent[key] ? (value + 3) : value
level = cons >= talentCons[key] ? (value + 3) : value
}
}
}
@ -37,10 +38,10 @@ const CharTalent = {
// 基于level计算original
value = value || ds.level || ds.level_current || ds.original || ds.level_original
level = value
if (key === 'a') {
if (key === 'a' && char.isGs) {
original = aPlus ? value - 1 : value
} else {
original = cons >= consTalent[key] ? (value - 3) : value
original = cons >= talentCons[key] ? (value - 3) : value
}
}
ret[key] = { level, original }

View File

@ -38,17 +38,17 @@ export default {
},
updatePlayer (player, data) {
player.setBasicData(Data.getData(data, 'name:NickName,face:HeadIconID,level:Level,word:WorldLevel,sign:Signature'))
console.log('avatars', data.avatars)
lodash.forEach(data.avatars, (ds, id) => {
console.log('ret1', ds)
let ret = LuluData.setAvatar(player, ds)
console.log('ret2', ret, ds)
if (ret) {
console.log('done', id)
player._update.push(id)
}
})
try {
player.setBasicData(Data.getData(data, 'name:NickName,face:HeadIconID,level:Level,word:WorldLevel,sign:Signature'))
lodash.forEach(data.avatars, (ds, id) => {
let ret = LuluData.setAvatar(player, ds)
if (ret) {
player._update.push(ds.AvatarID)
}
})
} catch (e) {
console.log(e)
}
},
// 获取冷却时间
@ -59,51 +59,58 @@ export default {
const LuluData = {
setAvatar (player, data) {
console.log('data', data.AvatarID, data)
console.log('data.ID', data.AvatarID)
let char = Character.get(data.AvatarID)
console.log('char.id', char.id, char.name)
if (!char) {
return false
}
let avatar = player.getAvatar(char.id, true)
console.log('setAvatar', avatar)
let setData = {
level: data.Level,
promote: data.Promotion,
cons: data.Rank || 0,
weapon: Data.getData(data.EquipmentID, 'id:ID,promote:Promotion,level:Level'),
...LuluData.getTalent(data.BehaviorList, char.talentId),
weapon: Data.getData(data.EquipmentID, 'id:ID,promote:Promotion,level:Level,affix:Rank'),
...LuluData.getTalent(data.BehaviorList, char),
artis: LuluData.getArtis(data.RelicList)
}
console.log('char.setData', setData)
avatar.setAvatar(setData, 'lulu')
return avatar
},
getTalent (ds, talentId = {}) {
getTalent (ds, char) {
let talent = {}
let behaviors = []
let trees = []
let talentId = char.talentId
lodash.forEach(ds, (d) => {
let key = talentId[d.BehaviorID]
let key = char.getTalentKey(d.BehaviorID)
if (key || d.Level > 1) {
talent[key || d.BehaviorID] = d.Level
} else {
behaviors.push(d.BehaviorID)
trees.push(d.BehaviorID)
}
})
return { talent, behaviors }
return { talent, trees }
},
getArtis (artis) {
let ret = {}
lodash.forEach(artis, (ds) => {
let tmp = Data.getData('id:ID,main:MainAffixID,level:Level')
tmp.attrs = []
let tmp = {
id: ds.ID,
level: ds.Level || 1,
mainId: ds.MainAffixID,
attrs: []
}
lodash.forEach(ds.RelicSubAffix, (s) => {
tmp.attrs.push(Data.getData(s, 'id:SubAffixID,count:Cnt,step:Step'))
if (!s.SubAffixID) {
return true
}
tmp.attrs.push({
id: s.SubAffixID,
count: s.Cnt,
step: s.Step || 0
})
})
ret[ds.Type] = tmp
})
console.log(lodash.keys(ret))
return ret
}
}

View File

@ -13,6 +13,7 @@ class AttrCalc {
constructor (profile) {
this.profile = profile
this.char = profile.char
this.game = profile.game
}
/**
@ -48,9 +49,11 @@ class AttrCalc {
*/
calc () {
this.attr = ProfileAttr.create({})
this.addAttr('recharge', 100, true)
this.addAttr('cpct', 5, true)
this.addAttr('cdmg', 50, true)
if (this.profile.isGs) {
this.addAttr('recharge', 100, true)
this.addAttr('cpct', 5, true)
this.addAttr('cdmg', 50, true)
}
this.setCharAttr()
this.setWeaponAttr()
this.setArtisAttr()
@ -123,7 +126,7 @@ class AttrCalc {
*/
setWeaponAttr () {
let wData = this.profile?.weapon || {}
let weapon = Weapon.get(wData?.name)
let weapon = Weapon.get(wData?.name || wData?.id, this.game)
let wCalcRet = weapon.calcAttr(wData.level, wData.promote)
if (wCalcRet) {

View File

@ -78,7 +78,8 @@
</div>
<div class="copyright data-source">
数据源:{{ {miao:'喵喵API', 'enka':'Enka.Network', 'mgg':'MiniGG-API', mys:'米游社', 'hutao':'Hutao-Enka' }[data.source]||data.source }} {{data.updateTime}}
数据源:{{ {miao:'喵喵API', 'enka':'Enka.Network', 'mgg':'MiniGG-API', mys:'米游社', 'hutao':'Hutao-Enka', 'lulu':'路路Api'
}[data.source]||data.source }} {{data.updateTime}}
</div>
{{else}}
{{if custom}}

View File

@ -0,0 +1,24 @@
import { Data } from '#miao'
import lodash from 'lodash'
let data = Data.readJSON('/resources/meta-sr/artifact/data.json', 'miao')
let meta = Data.readJSON('/resources/meta-sr/artifact/meta.json', 'miao')
let artiMap = {}
let idMap = {}
lodash.forEach(data, (setData) => {
lodash.forEach(setData.idxs, (ds, idx) => {
artiMap[ds.name] = {
...ds,
set: setData.name,
setId: setData.id,
idx
}
idMap[ds.name] = artiMap[ds.name]
lodash.forEach(ds.ids, (star, id) => {
idMap[id] = artiMap[ds.name]
})
})
})
export const metaData = meta
export { artiMap, idMap }

View File

@ -41,463 +41,469 @@
"defPct"
]
},
"mainAttr": {
"starData": {
"2": {
"1": {
"key": "stance",
"base": 0.04147200011757768,
"step": 0.014514999934858639
"main": {
"1": {
"key": "stance",
"base": 0.04147200076840818,
"step": 0.014515000162646174
},
"2": {
"key": "recharge",
"base": 0.01244200044311583,
"step": 0.004355000331997871
},
"3": {
"key": "hpPct",
"base": 0.027648000279441476,
"step": 0.009677000343799591
},
"4": {
"key": "atkPct",
"base": 0.027648000279441476,
"step": 0.009677000343799591
},
"5": {
"key": "defPct",
"base": 0.03456000052392483,
"step": 0.012096000602468848
},
"6": {
"key": "ice",
"base": 0.024883000878617167,
"step": 0.008708999957889318
},
"7": {
"key": "elec",
"base": 0.024883000878617167,
"step": 0.008708999957889318
},
"8": {
"key": "wind",
"base": 0.024883000878617167,
"step": 0.008708999957889318
},
"9": {
"key": "quantum",
"base": 0.024883000878617167,
"step": 0.008708999957889318
},
"10": {
"key": "imaginary",
"base": 0.024883000878617167,
"step": 0.008708999957889318
}
},
"2": {
"key": "recharge",
"base": 0.012442000247860399,
"step": 0.00435500026365376
},
"3": {
"key": "hpPct",
"base": 0.02764799984555448,
"step": 0.009677000191936
},
"4": {
"key": "atkPct",
"base": 0.02764799984555448,
"step": 0.009677000191936
},
"5": {
"key": "defPct",
"base": 0.03455999998156608,
"step": 0.01209600041264328
},
"6": {
"key": "ice",
"base": 0.024883000488122,
"step": 0.0087089998212168
},
"7": {
"key": "elec",
"base": 0.024883000488122,
"step": 0.0087089998212168
},
"8": {
"key": "wind",
"base": 0.024883000488122,
"step": 0.0087089998212168
},
"9": {
"key": "quantum",
"base": 0.024883000488122,
"step": 0.0087089998212168
},
"10": {
"key": "imaginary",
"base": 0.024883000488122,
"step": 0.0087089998212168
"sub": {
"1": {
"key": "hp",
"base": 13.548016000073403,
"step": 1.693502000765875
},
"2": {
"key": "atk",
"base": 6.774008000502363,
"step": 0.8467510011978447
},
"3": {
"key": "def",
"base": 6.774008000502363,
"step": 0.8467510011978447
},
"4": {
"key": "hpPct",
"base": 0.013824000488966703,
"step": 0.0017280005849897861
},
"5": {
"key": "atkPct",
"base": 0.013824000488966703,
"step": 0.0017280005849897861
},
"6": {
"key": "defPct",
"base": 0.017280000261962414,
"step": 0.002160000381991267
},
"7": {
"key": "speed",
"base": 1,
"step": 0.10000000009313226
},
"8": {
"key": "cpct",
"base": 0.010368000715970993,
"step": 0.001296000787988305
},
"9": {
"key": "cdmg",
"base": 0.020736000733450055,
"step": 0.0025920008774846792
},
"10": {
"key": "effPct",
"base": 0.013824000488966703,
"step": 0.0017280005849897861
},
"11": {
"key": "effDef",
"base": 0.013824000488966703,
"step": 0.0017280005849897861
},
"12": {
"key": "stance",
"base": 0.020736000733450055,
"step": 0.0025920008774846792
}
}
},
"3": {
"1": {
"key": "stance",
"base": 0.062207999128628635,
"step": 0.02177300060457928
"main": {
"1": {
"key": "stance",
"base": 0.06220800010487437,
"step": 0.02177300094626844
},
"2": {
"key": "recharge",
"base": 0.018662000307813287,
"step": 0.006532000144943595
},
"3": {
"key": "hpPct",
"base": 0.04147200076840818,
"step": 0.014515000162646174
},
"4": {
"key": "atkPct",
"base": 0.04147200076840818,
"step": 0.014515000162646174
},
"5": {
"key": "defPct",
"base": 0.05184000078588724,
"step": 0.018143999855965376
},
"6": {
"key": "ice",
"base": 0.037324999924749136,
"step": 0.01306400028988719
},
"7": {
"key": "elec",
"base": 0.037324999924749136,
"step": 0.01306400028988719
},
"8": {
"key": "wind",
"base": 0.037324999924749136,
"step": 0.01306400028988719
},
"9": {
"key": "quantum",
"base": 0.037324999924749136,
"step": 0.01306400028988719
},
"10": {
"key": "imaginary",
"base": 0.037324999924749136,
"step": 0.01306400028988719
}
},
"2": {
"key": "recharge",
"base": 0.01866200001494584,
"step": 0.00653200004243528
},
"3": {
"key": "hpPct",
"base": 0.04147200011757768,
"step": 0.014514999934858639
},
"4": {
"key": "atkPct",
"base": 0.04147200011757768,
"step": 0.014514999934858639
},
"5": {
"key": "defPct",
"base": 0.051839999972349116,
"step": 0.01814399957122704
},
"6": {
"key": "ice",
"base": 0.037324999338998556,
"step": 0.01306400008487056
},
"7": {
"key": "elec",
"base": 0.037324999338998556,
"step": 0.01306400008487056
},
"8": {
"key": "wind",
"base": 0.037324999338998556,
"step": 0.01306400008487056
},
"9": {
"key": "quantum",
"base": 0.037324999338998556,
"step": 0.01306400008487056
},
"10": {
"key": "imaginary",
"base": 0.037324999338998556,
"step": 0.01306400008487056
"sub": {
"1": {
"key": "hp",
"base": 20.32202300033532,
"step": 2.540253001032397
},
"2": {
"key": "atk",
"base": 10.161012000171468,
"step": 1.2701260005123913
},
"3": {
"key": "def",
"base": 10.161012000171468,
"step": 1.2701260005123913
},
"4": {
"key": "hpPct",
"base": 0.020736000733450055,
"step": 0.0025920008774846792
},
"5": {
"key": "atkPct",
"base": 0.020736000733450055,
"step": 0.0025920008774846792
},
"6": {
"key": "defPct",
"base": 0.02592000039294362,
"step": 0.0032400002237409353
},
"7": {
"key": "speed",
"base": 1.2000000001862645,
"step": 0.10000000009313226
},
"8": {
"key": "cpct",
"base": 0.015552000375464559,
"step": 0.0019440008327364922
},
"9": {
"key": "cdmg",
"base": 0.031104000052437186,
"step": 0.0038880009669810534
},
"10": {
"key": "effPct",
"base": 0.020736000733450055,
"step": 0.0025920008774846792
},
"11": {
"key": "effDef",
"base": 0.020736000733450055,
"step": 0.0025920008774846792
},
"12": {
"key": "stance",
"base": 0.031104000052437186,
"step": 0.0038880009669810534
}
}
},
"4": {
"1": {
"key": "stance",
"base": 0.08294399953666344,
"step": 0.029029999171225358
"main": {
"1": {
"key": "stance",
"base": 0.08294400083832443,
"step": 0.029029999626800418
},
"2": {
"key": "recharge",
"base": 0.024883000878617167,
"step": 0.008708999957889318
},
"3": {
"key": "hpPct",
"base": 0.05529600055888295,
"step": 0.01935399998910725
},
"4": {
"key": "atkPct",
"base": 0.05529600055888295,
"step": 0.01935399998910725
},
"5": {
"key": "defPct",
"base": 0.0691199996508658,
"step": 0.024192000506445765
},
"6": {
"key": "ice",
"base": 0.04976600036025047,
"step": 0.017417999915778637
},
"7": {
"key": "elec",
"base": 0.04976600036025047,
"step": 0.017417999915778637
},
"8": {
"key": "wind",
"base": 0.04976600036025047,
"step": 0.017417999915778637
},
"9": {
"key": "quantum",
"base": 0.04976600036025047,
"step": 0.017417999915778637
},
"10": {
"key": "imaginary",
"base": 0.04976600036025047,
"step": 0.017417999915778637
}
},
"2": {
"key": "recharge",
"base": 0.024883000488122,
"step": 0.0087089998212168
},
"3": {
"key": "hpPct",
"base": 0.05529599969110896,
"step": 0.01935399968538008
},
"4": {
"key": "atkPct",
"base": 0.05529599969110896,
"step": 0.01935399968538008
},
"5": {
"key": "defPct",
"base": 0.06911999856614832,
"step": 0.02419200012679464
},
"6": {
"key": "ice",
"base": 0.04976599957926016,
"step": 0.0174179996424336
},
"7": {
"key": "elec",
"base": 0.04976599957926016,
"step": 0.0174179996424336
},
"8": {
"key": "wind",
"base": 0.04976599957926016,
"step": 0.0174179996424336
},
"9": {
"key": "quantum",
"base": 0.04976599957926016,
"step": 0.0174179996424336
},
"10": {
"key": "imaginary",
"base": 0.04976599957926016,
"step": 0.0174179996424336
"sub": {
"1": {
"key": "hp",
"base": 27.09603099990636,
"step": 3.3870039999019355
},
"2": {
"key": "atk",
"base": 13.548016000073403,
"step": 1.693502000765875
},
"3": {
"key": "def",
"base": 13.548016000073403,
"step": 1.693502000765875
},
"4": {
"key": "hpPct",
"base": 0.027648000279441476,
"step": 0.0034560004714876413
},
"5": {
"key": "atkPct",
"base": 0.027648000279441476,
"step": 0.0034560004714876413
},
"6": {
"key": "defPct",
"base": 0.03456000052392483,
"step": 0.0043200000654906034
},
"7": {
"key": "speed",
"base": 1.6000000005587935,
"step": 0.20000000018626451
},
"8": {
"key": "cpct",
"base": 0.020736000733450055,
"step": 0.0025920008774846792
},
"9": {
"key": "cdmg",
"base": 0.04147200076840818,
"step": 0.0051840003579854965
},
"10": {
"key": "effPct",
"base": 0.027648000279441476,
"step": 0.0034560004714876413
},
"11": {
"key": "effDef",
"base": 0.027648000279441476,
"step": 0.0034560004714876413
},
"12": {
"key": "stance",
"base": 0.04147200076840818,
"step": 0.0051840003579854965
}
}
},
"5": {
"1": {
"key": "stance",
"base": 0.10367999924620631,
"step": 0.036287999840946
"main": {
"1": {
"key": "stance",
"base": 0.10368000087328255,
"step": 0.03628800041042268
},
"2": {
"key": "recharge",
"base": 0.031104000052437186,
"step": 0.010886001167818904
},
"3": {
"key": "hpPct",
"base": 0.0691199996508658,
"step": 0.024192000506445765
},
"4": {
"key": "atkPct",
"base": 0.0691199996508658,
"step": 0.024192000506445765
},
"5": {
"key": "defPct",
"base": 0.08639999991282821,
"step": 0.030240000458434224
},
"6": {
"key": "ice",
"base": 0.06220800010487437,
"step": 0.02177300094626844
},
"7": {
"key": "elec",
"base": 0.06220800010487437,
"step": 0.02177300094626844
},
"8": {
"key": "wind",
"base": 0.06220800010487437,
"step": 0.02177300094626844
},
"9": {
"key": "quantum",
"base": 0.06220800010487437,
"step": 0.02177300094626844
},
"10": {
"key": "imaginary",
"base": 0.06220800010487437,
"step": 0.02177300094626844
}
},
"2": {
"key": "recharge",
"base": 0.031103999564314318,
"step": 0.01088600099698216
},
"3": {
"key": "hpPct",
"base": 0.06911999856614832,
"step": 0.02419200012679464
},
"4": {
"key": "atkPct",
"base": 0.06911999856614832,
"step": 0.02419200012679464
},
"5": {
"key": "defPct",
"base": 0.08639999855693135,
"step": 0.03023999998387032
},
"6": {
"key": "ice",
"base": 0.062207999128628635,
"step": 0.02177300060457928
},
"7": {
"key": "elec",
"base": 0.062207999128628635,
"step": 0.02177300060457928
},
"8": {
"key": "wind",
"base": 0.062207999128628635,
"step": 0.02177300060457928
},
"9": {
"key": "quantum",
"base": 0.062207999128628635,
"step": 0.02177300060457928
},
"10": {
"key": "imaginary",
"base": 0.062207999128628635,
"step": 0.02177300060457928
}
}
},
"subAttr": {
"2": {
"1": {
"key": "hp",
"base": 13.548015787460994,
"step": 1.6935019741893238
},
"2": {
"key": "atk",
"base": 6.774007894196158,
"step": 0.846750987909569
},
"3": {
"key": "def",
"base": 6.774007894196158,
"step": 0.846750987909569
},
"4": {
"key": "hpPct",
"base": 0.0138240002720232,
"step": 0.00172800055787184
},
"5": {
"key": "atkPct",
"base": 0.0138240002720232,
"step": 0.00172800055787184
},
"6": {
"key": "defPct",
"base": 0.01727999999078304,
"step": 0.00216000034809384
},
"7": {
"key": "speed",
"base": 0.9999999843067494,
"step": 0.0999999985238072
},
"8": {
"key": "cpct",
"base": 0.01036800055326336,
"step": 0.00129600076764984
},
"9": {
"key": "cdmg",
"base": 0.020736000408034798,
"step": 0.00259200083680776
},
"10": {
"key": "effPct",
"base": 0.0138240002720232,
"step": 0.00172800055787184
},
"11": {
"key": "effDef",
"base": 0.0138240002720232,
"step": 0.00172800055787184
},
"12": {
"key": "stance",
"base": 0.020736000408034798,
"step": 0.00259200083680776
}
},
"3": {
"1": {
"key": "hp",
"base": 20.322022681416723,
"step": 2.54025296116757
},
"2": {
"key": "atk",
"base": 10.16101184071216,
"step": 1.2701259805799858
},
"3": {
"key": "def",
"base": 10.16101184071216,
"step": 1.2701259805799858
},
"4": {
"key": "hpPct",
"base": 0.020736000408034798,
"step": 0.00259200083680776
},
"5": {
"key": "atkPct",
"base": 0.020736000408034798,
"step": 0.00259200083680776
},
"6": {
"key": "defPct",
"base": 0.025919999986174558,
"step": 0.0032400001728948
},
"7": {
"key": "speed",
"base": 1.1999999813543638,
"step": 0.0999999985238072
},
"8": {
"key": "cpct",
"base": 0.01555200013140312,
"step": 0.0019440008022287999
},
"9": {
"key": "cdmg",
"base": 0.031103999564314318,
"step": 0.00388800090596568
},
"10": {
"key": "effPct",
"base": 0.020736000408034798,
"step": 0.00259200083680776
},
"11": {
"key": "effDef",
"base": 0.020736000408034798,
"step": 0.00259200083680776
},
"12": {
"key": "stance",
"base": 0.031103999564314318,
"step": 0.00388800090596568
}
},
"4": {
"1": {
"key": "hp",
"base": 27.096030574681556,
"step": 3.387003946748833
},
"2": {
"key": "atk",
"base": 13.548015787460994,
"step": 1.6935019741893238
},
"3": {
"key": "def",
"base": 13.548015787460994,
"step": 1.6935019741893238
},
"4": {
"key": "hpPct",
"base": 0.02764799984555448,
"step": 0.00345600041725176
},
"5": {
"key": "atkPct",
"base": 0.02764799984555448,
"step": 0.00345600041725176
},
"6": {
"key": "defPct",
"base": 0.03455999998156608,
"step": 0.00431999999769576
},
"7": {
"key": "speed",
"base": 1.5999999754495926,
"step": 0.1999999970476144
},
"8": {
"key": "cpct",
"base": 0.020736000408034798,
"step": 0.00259200083680776
},
"9": {
"key": "cdmg",
"base": 0.04147200011757768,
"step": 0.00518400027663168
},
"10": {
"key": "effPct",
"base": 0.02764799984555448,
"step": 0.00345600041725176
},
"11": {
"key": "effDef",
"base": 0.02764799984555448,
"step": 0.00345600041725176
},
"12": {
"key": "stance",
"base": 0.04147200011757768,
"step": 0.00518400027663168
}
},
"5": {
"1": {
"key": "hp",
"base": 33.87003846957621,
"step": 4.233754934425572
},
"2": {
"key": "atk",
"base": 16.93501873490072,
"step": 2.116876967558232
},
"3": {
"key": "def",
"base": 16.93501873490072,
"step": 2.116876967558232
},
"4": {
"key": "hpPct",
"base": 0.03455999998156608,
"step": 0.00431999999769576
},
"5": {
"key": "atkPct",
"base": 0.03455999998156608,
"step": 0.00431999999769576
},
"6": {
"key": "defPct",
"base": 0.04319999927846568,
"step": 0.00539999982249672
},
"7": {
"key": "speed",
"base": 1.9999999686134988,
"step": 0.2999999955714216
},
"8": {
"key": "cpct",
"base": 0.025919999986174558,
"step": 0.0032400001728948
},
"9": {
"key": "cdmg",
"base": 0.051839999972349116,
"step": 0.0064800003457896
},
"10": {
"key": "effPct",
"base": 0.03455999998156608,
"step": 0.00431999999769576
},
"11": {
"key": "effDef",
"base": 0.03455999998156608,
"step": 0.00431999999769576
},
"12": {
"key": "stance",
"base": 0.051839999972349116,
"step": 0.0064800003457896
"sub": {
"1": {
"key": "hp",
"base": 33.870039001107216,
"step": 4.23375500086695
},
"2": {
"key": "atk",
"base": 16.935019000666216,
"step": 2.1168770007789135
},
"3": {
"key": "def",
"base": 16.935019000666216,
"step": 2.1168770007789135
},
"4": {
"key": "hpPct",
"base": 0.03456000052392483,
"step": 0.0043200000654906034
},
"5": {
"key": "atkPct",
"base": 0.03456000052392483,
"step": 0.0043200000654906034
},
"6": {
"key": "defPct",
"base": 0.043199999956414104,
"step": 0.005399999907240272
},
"7": {
"key": "speed",
"base": 2,
"step": 0.3000000002793968
},
"8": {
"key": "cpct",
"base": 0.02592000039294362,
"step": 0.0032400002237409353
},
"9": {
"key": "cdmg",
"base": 0.05184000078588724,
"step": 0.006480000447481871
},
"10": {
"key": "effPct",
"base": 0.03456000052392483,
"step": 0.0043200000654906034
},
"11": {
"key": "effDef",
"base": 0.03456000052392483,
"step": 0.0043200000654906034
},
"12": {
"key": "stance",
"base": 0.05184000078588724,
"step": 0.006480000447481871
}
}
}
}

View File

@ -0,0 +1,13 @@
import { Data } from '#miao'
import lodash from 'lodash'
let data = Data.readJSON('/resources/meta-sr/weapon/data.json', 'miao')
let aliasMap = {}
lodash.forEach(data, (ds) => {
aliasMap[ds.id] = ds.id
aliasMap[ds.name] = ds.id
})
export const weaponAlias = aliasMap
export const weaponData = data

View File

@ -18,6 +18,7 @@ lodash.forEach(artis, (ds) => {
if (as.name) {
artiMap[as.name] = {
set: ds.name,
name: as.name,
idx
}
artiSet.sets[idx] = as.name