mirror of
https://github.com/yoimiya-kokomi/miao-plugin.git
synced 2024-11-16 04:35:42 +00:00
初版调整,功能暂不可用
This commit is contained in:
parent
5e3995e082
commit
da903e4418
@ -27,7 +27,7 @@ export async function profileArtis (e) {
|
||||
let { attrMap } = Artifact.getMeta()
|
||||
|
||||
let artisDetail = profile.getArtisMark()
|
||||
let artisKeyTitle = ProfileArtis.getArtisKeyTitle()
|
||||
let artisKeyTitle = Artifact.getArtisKeyTitle()
|
||||
|
||||
// 渲染图像
|
||||
return await Common.render('character/artis-mark', {
|
||||
@ -84,7 +84,7 @@ export async function profileArtisList (e) {
|
||||
artis = artis.reverse()
|
||||
let number = Cfg.get('artisNumber', 28)
|
||||
artis = artis.slice(0, `${number}`)
|
||||
let artisKeyTitle = ProfileArtis.getArtisKeyTitle()
|
||||
let artisKeyTitle = Artifact.getArtisKeyTitle()
|
||||
|
||||
// 渲染图像
|
||||
return await Common.render('character/artis-list', {
|
||||
|
@ -186,7 +186,7 @@ let ProfileDetail = {
|
||||
}
|
||||
|
||||
let artisDetail = profile.getArtisMark()
|
||||
let artisKeyTitle = ProfileArtis.getArtisKeyTitle(game)
|
||||
let artisKeyTitle = Artifact.getArtisKeyTitle(game)
|
||||
let data = profile.getData('name,abbr,cons,level,talent,dataSource,updateTime,imgs,costumeSplash')
|
||||
if (isSr) {
|
||||
let treeData = []
|
||||
|
@ -7,6 +7,7 @@ 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, abbr as abbrSR } from '../resources/meta-sr/artifact/index.js'
|
||||
import lodash from 'lodash'
|
||||
import ArtisMark from './artis/ArtisMark.js'
|
||||
|
||||
class Artifact extends Base {
|
||||
static getAttrs
|
||||
@ -123,6 +124,11 @@ class Artifact extends Base {
|
||||
}
|
||||
}
|
||||
|
||||
static getArtisKeyTitle (game = 'gs') {
|
||||
return ArtisMark.getKeyTitleMap(game)
|
||||
}
|
||||
|
||||
// 获取圣遗物属性数据
|
||||
getAttrData (mainId, attrData, level = 1, star = 5, idx = 1) {
|
||||
let mainKey = metaDataSR.mainIdx[idx][mainId]
|
||||
let starCfg = metaDataSR.starData[star]
|
||||
|
@ -91,6 +91,19 @@ class ArtifactSet extends Base {
|
||||
static getAliasMap (game = 'gs') {
|
||||
return game === 'gs' ? aliasMap : aliasMapSR
|
||||
}
|
||||
|
||||
// 循环圣遗物套装
|
||||
static eachSet (sets, fn, game = 'gs') {
|
||||
lodash.forEach(sets || [], (v, k) => {
|
||||
let artisSet = ArtifactSet.get(k, game)
|
||||
if (artisSet) {
|
||||
if (v >= 4) {
|
||||
fn(artisSet, 2)
|
||||
}
|
||||
fn(artisSet, v)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export default ArtifactSet
|
||||
|
@ -1,313 +0,0 @@
|
||||
/**
|
||||
* 面板圣遗物
|
||||
*/
|
||||
import lodash from 'lodash'
|
||||
import Base from './Base.js'
|
||||
import { Artifact, ArtifactSet } from './index.js'
|
||||
import { Format, Data } from '#miao'
|
||||
import ArtisMark from './profile/ArtisMark.js'
|
||||
|
||||
export default class AvatarArtis extends Base {
|
||||
constructor (charid = 0, game = 'gs') {
|
||||
super()
|
||||
this.game = game
|
||||
this.charid = charid
|
||||
this.artis = {}
|
||||
}
|
||||
|
||||
get sets () {
|
||||
return this.getSetData().sets || {}
|
||||
}
|
||||
|
||||
get names () {
|
||||
return this.getSetData().names || []
|
||||
}
|
||||
|
||||
get hasArtis () {
|
||||
return !lodash.isEmpty(this.artis)
|
||||
}
|
||||
|
||||
get hasAttr () {
|
||||
if (this.isSr) {
|
||||
return true
|
||||
}
|
||||
return ArtisMark.hasAttr(this.artis)
|
||||
}
|
||||
|
||||
static _eachArtisSet (sets, fn, game = 'gs') {
|
||||
lodash.forEach(sets || [], (v, k) => {
|
||||
let artisSet = ArtifactSet.get(k, game)
|
||||
if (artisSet) {
|
||||
if (v >= 4) {
|
||||
fn(artisSet, 2)
|
||||
}
|
||||
fn(artisSet, v)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
static getArtisKeyTitle (game = 'gs') {
|
||||
return ArtisMark.getKeyTitleMap(game)
|
||||
}
|
||||
|
||||
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}`], isProfile)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setArtis (idx = 1, ds = {}, isProfile = false) {
|
||||
idx = idx.toString().replace('arti', '')
|
||||
this.artis[idx] = this.artis[idx] || {}
|
||||
let arti = this.artis[idx]
|
||||
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
|
||||
let attrIds = ds.attrIds || ds.attrs
|
||||
if (ds.mainId && attrIds) {
|
||||
let attr = artiObj.getAttrData(ds.mainId, attrIds, arti.level, arti.star, idx)
|
||||
if (attr) {
|
||||
arti.mainId = ds.mainId
|
||||
arti.attrIds = attrIds
|
||||
arti.main = attr.main || arti.main || {}
|
||||
arti.attrs = attr.attrs || arti.attrs || {}
|
||||
} else {
|
||||
console.log('attr id error', ds.main, ds.mainId, idx, arti.level, arti.star)
|
||||
}
|
||||
} else {
|
||||
arti.attrs = []
|
||||
}
|
||||
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
|
||||
} else {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
// 存在面板数据,更新面板数据
|
||||
if (ds.mainId && ds.attrIds) {
|
||||
arti.mainId = ds.mainId
|
||||
arti.attrIds = ds.attrIds
|
||||
arti.main = Artifact.getMainById(ds.mainId, arti._level, arti._star)
|
||||
arti.attrs = Artifact.getAttrsByIds(ds.attrIds, arti._star)
|
||||
} else if (ds.main && ds.attrs) {
|
||||
arti.main = ArtisMark.formatAttr(ds.main || {})
|
||||
arti.attrs = []
|
||||
for (let attrIdx in ds.attrs || []) {
|
||||
if (ds.attrs[attrIdx]) {
|
||||
arti.attrs.push(ArtisMark.formatAttr(ds.attrs[attrIdx]))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
forEach (fn) {
|
||||
lodash.forEach(this.artis, (ds, idx) => {
|
||||
if (ds.name) {
|
||||
fn(ds, idx)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
_get (key) {
|
||||
let artis = this.artis
|
||||
switch (key) {
|
||||
case 'length':
|
||||
return lodash.keys(artis).length
|
||||
}
|
||||
if (artis[key]) {
|
||||
return artis[key]
|
||||
}
|
||||
}
|
||||
|
||||
toJSON () {
|
||||
let ret = {}
|
||||
for (let idx = 1; idx <= (this.isGs ? 5 : 6); idx++) {
|
||||
let ds = this.artis[idx]
|
||||
if (!ds) {
|
||||
continue
|
||||
}
|
||||
let tmp = {
|
||||
level: ds.level || 1,
|
||||
star: ds.star || 5
|
||||
}
|
||||
|
||||
if (this.isSr) {
|
||||
tmp.id = ds.id
|
||||
tmp.mainId = ds.main?.id
|
||||
tmp.attrIds = []
|
||||
lodash.forEach(ds.attrs, (as) => {
|
||||
tmp.attrIds.push([
|
||||
as?.id || '',
|
||||
as?.count || 1,
|
||||
as?.step || 0
|
||||
].join(','))
|
||||
})
|
||||
} 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
|
||||
tmp._level = ds._level || null
|
||||
tmp._star = ds._star || null
|
||||
}
|
||||
}
|
||||
if (ds.mainId && ds.attrIds) {
|
||||
tmp.mainId = ds.mainId || null
|
||||
tmp.attrIds = ds.attrIds
|
||||
} else if (ds.main && ds.attrs) {
|
||||
tmp.main = ds.main || null
|
||||
tmp.attrs = []
|
||||
for (let attrIdx in ds.attrs || []) {
|
||||
if (ds.attrs[attrIdx]) {
|
||||
tmp.attrs.push(ArtisMark.formatAttr(ds.attrs[attrIdx]))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ret[idx] = tmp
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
getDetail (profile = false) {
|
||||
let ret = {}
|
||||
for (let idx = 1; idx <= 5; idx++) {
|
||||
let ds = this.artis[idx]
|
||||
if (ds) {
|
||||
let artis = Artifact.get(profile ? ds._name : ds.name)
|
||||
let tmp = {
|
||||
...artis?.getData('img,name,set'),
|
||||
level: (profile ? ds._level : ds.level) || 1
|
||||
}
|
||||
if (ds.main && ds.attrs) {
|
||||
tmp.main = ds.main || null
|
||||
tmp.attrs = []
|
||||
for (let attrIdx in ds.attrs || []) {
|
||||
if (ds.attrs[attrIdx]) {
|
||||
tmp.attrs.push(ArtisMark.formatAttr(ds.attrs[attrIdx]))
|
||||
}
|
||||
}
|
||||
}
|
||||
ret[idx] = tmp
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
mainAttr (idx = '') {
|
||||
if (!idx) {
|
||||
let ret = {}
|
||||
for (let i = 1; i <= 5; i++) {
|
||||
ret[i] = this.mainAttr(i)
|
||||
}
|
||||
return ret
|
||||
}
|
||||
let main = this.artis[idx]?.main
|
||||
if (!main) {
|
||||
return ''
|
||||
}
|
||||
return main.key || ''
|
||||
}
|
||||
|
||||
is (check, pos = '') {
|
||||
if (pos) {
|
||||
return this.isAttr(check, pos)
|
||||
}
|
||||
let sets = this.getSetData()?.abbrs || []
|
||||
let ret = false
|
||||
Data.eachStr(check, (s) => {
|
||||
if (sets.includes(s)) {
|
||||
ret = true
|
||||
return false
|
||||
}
|
||||
})
|
||||
return ret
|
||||
}
|
||||
|
||||
isAttr (attr, pos = '3,4,5') {
|
||||
let mainAttr = this.mainAttr()
|
||||
let check = true
|
||||
Data.eachStr(pos.toString(), (p) => {
|
||||
let attrs = attr.split(',')
|
||||
if (!attrs.includes(mainAttr[p]) && (p === '4' && !attrs.includes('dmg') && Format.isElem(mainAttr[p]))) {
|
||||
check = false
|
||||
return false
|
||||
}
|
||||
})
|
||||
return check
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取圣遗物套装数据
|
||||
* @returns {*|{imgs: *[], names: *[], sets: {}, abbrs: *[], sName: string, name: (string|*)}}
|
||||
* sets: 套装名:2/4
|
||||
* names: [套装名]
|
||||
* imgs: [img]
|
||||
* abbrs:[别名]
|
||||
* name: '组合名字', 若为4件套会使用套装完整名
|
||||
* sName: '简写名字',若为4件套也会使用简写
|
||||
*/
|
||||
getSetData (profile = false) {
|
||||
let setCount = {}
|
||||
this.forEach((arti, idx) => {
|
||||
setCount[profile ? arti._set : arti.set] = (setCount[profile ? arti._set : arti.set] || 0) + 1
|
||||
})
|
||||
let sets = {}
|
||||
let names = []
|
||||
let imgs = []
|
||||
let abbrs = []
|
||||
let abbrs2 = []
|
||||
for (let set in setCount) {
|
||||
if (setCount[set] >= 2) {
|
||||
let count = setCount[set] >= 4 ? 4 : 2
|
||||
sets[set] = count
|
||||
let artiSet = ArtifactSet.get(set)
|
||||
names.push(artiSet.name)
|
||||
imgs.push(artiSet.img)
|
||||
abbrs.push(artiSet.abbr + count)
|
||||
abbrs2.push(artiSet.name + count)
|
||||
}
|
||||
}
|
||||
return {
|
||||
sets,
|
||||
names,
|
||||
imgs,
|
||||
abbrs: [...abbrs, ...abbrs2],
|
||||
name: (abbrs.length > 1 || abbrs2[0]?.length > 7) ? abbrs.slice(0, 2).join('+') : abbrs2[0],
|
||||
sName: abbrs.slice(0, 2).join('+')
|
||||
}
|
||||
}
|
||||
|
||||
eachArtisSet (fn) {
|
||||
AvatarArtis._eachArtisSet(this.sets, fn, this.game)
|
||||
}
|
||||
}
|
@ -18,7 +18,7 @@ export default class AvatarData extends Base {
|
||||
this.id = char.id
|
||||
this.char = char
|
||||
this.game = char.game || game
|
||||
this.initArtis()
|
||||
this._mysArtis = new AvatarArtis(this.id, this.game)
|
||||
this.setAvatar(ds)
|
||||
}
|
||||
|
||||
@ -51,6 +51,13 @@ export default class AvatarData extends Base {
|
||||
return lodash.mapValues(this.talent, (ds) => ds.original)
|
||||
}
|
||||
|
||||
// 已经到达当前等级的最大天赋
|
||||
get isMaxTalent () {
|
||||
let maxLv = [1, 2, 4, 6, 8, 10]?.[this.promote - 1] || 10
|
||||
let minTalent = lodash.min(lodash.map(this.talent, (ds) => ds.original))
|
||||
return minTalent >= maxLv
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取圣遗物套装属性
|
||||
* @returns {boolean|*|{imgs: *[], names: *[], sets: {}, abbrs: *[], sName: string, name: (string|*)}|{}}
|
||||
@ -84,6 +91,14 @@ export default class AvatarData extends Base {
|
||||
return ''
|
||||
}
|
||||
|
||||
get mysArtis () {
|
||||
return this._mysArtis
|
||||
}
|
||||
|
||||
get artis () {
|
||||
return this._mysArtis
|
||||
}
|
||||
|
||||
static create (ds, game = 'gs') {
|
||||
let avatar = new AvatarData(ds, game)
|
||||
if (!avatar) {
|
||||
@ -92,10 +107,6 @@ export default class AvatarData extends Base {
|
||||
return avatar
|
||||
}
|
||||
|
||||
initArtis () {
|
||||
this.artis = new AvatarArtis(this.id, this.game)
|
||||
}
|
||||
|
||||
_get (key) {
|
||||
if (charKey.includes(key)) {
|
||||
return this.char[key]
|
||||
@ -107,7 +118,7 @@ export default class AvatarData extends Base {
|
||||
this.setBasic(ds, source)
|
||||
ds.weapon && this.setWeapon(ds.weapon)
|
||||
ds.talent && this.setTalent(ds.talent, 'original', source)
|
||||
ds.artis && this.setArtis(ds)
|
||||
this.setArtis(ds)
|
||||
delete this._now
|
||||
}
|
||||
|
||||
@ -125,10 +136,10 @@ export default class AvatarData extends Base {
|
||||
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 = this.trees || []
|
||||
this._source = ds._source || 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
|
||||
this._source = ds._source || this._source || '' // 数据源
|
||||
this._time = ds._time || this._time || now // 面板最后更新时间
|
||||
this._update = ds._update || this._update || ds._time || now //最后更新时间,包括mys
|
||||
this._talent = ds._talent || this._talent || ds._time || now // 最后天赋更新时间,包括mys
|
||||
|
||||
if (ds.trees) {
|
||||
this.setTrees(ds.trees)
|
||||
@ -147,6 +158,7 @@ export default class AvatarData extends Base {
|
||||
}
|
||||
}
|
||||
|
||||
// 星铁的行迹数据
|
||||
setTrees (ds) {
|
||||
this.trees = []
|
||||
let prefix = ''
|
||||
@ -169,6 +181,7 @@ export default class AvatarData extends Base {
|
||||
})
|
||||
}
|
||||
|
||||
// 设置武器
|
||||
setWeapon (ds = {}) {
|
||||
let w = Weapon.get(ds.name || ds.id, this.game)
|
||||
if (!w) {
|
||||
@ -187,6 +200,7 @@ export default class AvatarData extends Base {
|
||||
}
|
||||
}
|
||||
|
||||
// 获取武器详情信息
|
||||
getWeaponDetail () {
|
||||
let ret = {
|
||||
...this.weapon
|
||||
@ -216,6 +230,7 @@ export default class AvatarData extends Base {
|
||||
return ret
|
||||
}
|
||||
|
||||
// 设置天赋
|
||||
setTalent (ds = false, mode = 'original', updateTime = '') {
|
||||
const now = this._now || (new Date()) * 1
|
||||
if (ds) {
|
||||
@ -232,7 +247,7 @@ export default class AvatarData extends Base {
|
||||
}
|
||||
|
||||
setArtis (ds, source) {
|
||||
this.artis.setArtisData(ds.artis, source)
|
||||
this.mysArtis.setArtisData(ds.mysArtis || ds.artis, source)
|
||||
}
|
||||
|
||||
getProfile () {
|
||||
|
@ -45,13 +45,10 @@ export default class Player extends Base {
|
||||
}
|
||||
|
||||
get _file () {
|
||||
if (this.isSr) {
|
||||
return `/data/PlayerData/sr/${this.uid}.json`
|
||||
} else {
|
||||
return `/data/UserData/${this.uid}.json`
|
||||
}
|
||||
return `/data/PlayerData/${this.game}/${this.uid}.json`
|
||||
}
|
||||
|
||||
// 玩家头像
|
||||
get faceImgs () {
|
||||
let char
|
||||
if (this.isGs && this.face) {
|
||||
@ -98,12 +95,8 @@ export default class Player extends Base {
|
||||
* 重新加载json文件
|
||||
*/
|
||||
reload () {
|
||||
let data
|
||||
data = Data.readJSON(this._file, 'root')
|
||||
let data = Data.readJSON(this._file, 'root')
|
||||
this.setBasicData(data)
|
||||
if (data.chars) {
|
||||
this.setAvatars(data.chars)
|
||||
}
|
||||
this.setAvatars(data.avatars || [])
|
||||
if (data._ck) {
|
||||
this._ck = data._ck
|
||||
@ -133,11 +126,7 @@ export default class Player extends Base {
|
||||
if (this._ck) {
|
||||
ret._ck = this._ck
|
||||
}
|
||||
if (this.isSr) {
|
||||
Data.writeJSON(`/data/PlayerData/sr/${this.uid}.json`, ret, 'root')
|
||||
} else {
|
||||
Data.writeJSON(`/data/UserData/${this.uid}.json`, ret, 'root')
|
||||
}
|
||||
Data.writeJSON(this._file, ret, 'root')
|
||||
}
|
||||
|
||||
del () {
|
||||
@ -281,7 +270,7 @@ export default class Player extends Base {
|
||||
// 更新米游社数据
|
||||
/**
|
||||
* 更新米游社数据
|
||||
* @param force: 0:不强制,长超时时间 1:短超时时间 2:无视缓存,强制刷新
|
||||
* @param force 0:不强制,长超时时间 1:短超时时间 2:无视缓存,强制刷新
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
async refreshMysDetail (force = 0) {
|
||||
|
@ -1,134 +0,0 @@
|
||||
/**
|
||||
* 面板圣遗物
|
||||
*/
|
||||
import lodash from 'lodash'
|
||||
import AvatarArtis from './AvatarArtis.js'
|
||||
import { Artifact, ArtifactSet, Character } from './index.js'
|
||||
import { Format } from '../components/index.js'
|
||||
import ArtisMark from './profile/ArtisMark.js'
|
||||
import { attrMap as attrMapGS } from '../resources/meta/artifact/index.js'
|
||||
import { attrMap as attrMapSR } from '../resources/meta-sr/artifact/index.js'
|
||||
import CharArtis from './profile/CharArtis.js'
|
||||
|
||||
export default class ProfileArtis extends AvatarArtis {
|
||||
constructor (charid = 0, elem = '', game = 'gs') {
|
||||
super(charid, game)
|
||||
this.elem = elem
|
||||
}
|
||||
|
||||
setProfile (profile, artis) {
|
||||
this.profile = profile
|
||||
this.elem = profile.elem || profile.char?.elem
|
||||
if (artis) {
|
||||
this.setArtisData(artis, true)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取角色配置
|
||||
* @returns {{classTitle: *, weight: *, posMaxMark: {}, mark: {}, attrs: {}}}
|
||||
*/
|
||||
getCharCfg () {
|
||||
let char = Character.get(this.charid)
|
||||
let { game, isGs } = char
|
||||
let { attrWeight, title } = CharArtis.getCharArtisCfg(char, this.profile, this)
|
||||
let attrs = {}
|
||||
let baseAttr = char.baseAttr || { hp: 14000, atk: 230, def: 700 }
|
||||
let attrMap = isGs ? attrMapGS : attrMapSR
|
||||
lodash.forEach(attrMap, (attr, key) => {
|
||||
let k = attr.base || ''
|
||||
let weight = attrWeight[k || key]
|
||||
if (!weight || weight * 1 === 0) {
|
||||
return true
|
||||
}
|
||||
let ret = {
|
||||
...attr,
|
||||
weight,
|
||||
fixWeight: weight,
|
||||
mark: weight / attr.value
|
||||
}
|
||||
if (!k) {
|
||||
ret.mark = weight / attr.value
|
||||
} else {
|
||||
let plus = k === 'atk' ? 520 : 0
|
||||
ret.mark = weight / attrMap[k].value / (baseAttr[k] + plus) * 100
|
||||
ret.fixWeight = weight * attr.value / attrMap[k].value / (baseAttr[k] + plus) * 100
|
||||
}
|
||||
attrs[key] = ret
|
||||
})
|
||||
let posMaxMark = ArtisMark.getMaxMark(attrs, game)
|
||||
// 返回内容待梳理简化
|
||||
return {
|
||||
attrs,
|
||||
classTitle: title,
|
||||
posMaxMark
|
||||
}
|
||||
}
|
||||
|
||||
getMarkDetail (withDetail = true) {
|
||||
let charCfg = this.getCharCfg()
|
||||
let artis = {}
|
||||
let setCount = {}
|
||||
let totalMark = 0
|
||||
let self = this
|
||||
this.forEach((arti, idx) => {
|
||||
let mark = ArtisMark.getMark({
|
||||
charCfg,
|
||||
idx,
|
||||
arti,
|
||||
elem: this.elem,
|
||||
game: self.game
|
||||
})
|
||||
totalMark += mark
|
||||
setCount[arti.set] = (setCount[arti.set] || 0) + 1
|
||||
if (!withDetail) {
|
||||
artis[idx] = {
|
||||
_mark: mark,
|
||||
mark: Format.comma(mark, 1),
|
||||
markClass: ArtisMark.getMarkClass(mark)
|
||||
}
|
||||
} else {
|
||||
let artifact = Artifact.get(arti.name, this.game)
|
||||
artis[idx] = {
|
||||
name: artifact.name,
|
||||
abbr: artifact.abbr,
|
||||
set: artifact.setName,
|
||||
img: artifact.img,
|
||||
level: arti.level,
|
||||
_mark: mark,
|
||||
mark: Format.comma(mark, 1),
|
||||
markClass: ArtisMark.getMarkClass(mark),
|
||||
main: ArtisMark.formatArti(arti.main, charCfg.attrs, true, this.game),
|
||||
attrs: ArtisMark.formatArti(arti.attrs, charCfg.attrs, false, this.game)
|
||||
}
|
||||
}
|
||||
})
|
||||
let sets = {}
|
||||
let names = []
|
||||
let imgs = []
|
||||
for (let set in setCount) {
|
||||
if (setCount[set] >= 2) {
|
||||
sets[set] = setCount[set] >= 4 ? 4 : 2
|
||||
let artiSet = ArtifactSet.get(set)
|
||||
imgs.push(artiSet.img)
|
||||
names.push(artiSet.name)
|
||||
}
|
||||
}
|
||||
this.mark = totalMark
|
||||
this.markClass = ArtisMark.getMarkClass(totalMark / 5)
|
||||
let ret = {
|
||||
mark: Format.comma(totalMark, 1),
|
||||
_mark: totalMark,
|
||||
markClass: ArtisMark.getMarkClass(totalMark / 5),
|
||||
artis,
|
||||
sets,
|
||||
names,
|
||||
imgs,
|
||||
classTitle: charCfg.classTitle
|
||||
}
|
||||
if (withDetail) {
|
||||
ret.charWeight = lodash.mapValues(charCfg.attrs, ds => ds.weight)
|
||||
}
|
||||
return ret
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
import lodash from 'lodash'
|
||||
import AvatarData from './AvatarData.js'
|
||||
import { Data, Cfg } from '#miao'
|
||||
import { ProfileArtis, ProfileDmg } from './index.js'
|
||||
import { ProfileArtis, AvatarArtis, ProfileDmg } from './index.js'
|
||||
import AttrCalc from './profile/AttrCalc.js'
|
||||
import CharImg from './character/CharImg.js'
|
||||
|
||||
@ -53,8 +53,16 @@ export default class ProfileData extends AvatarData {
|
||||
return this.hasData && !!ProfileDmg.dmgRulePath(this.name, this.game)
|
||||
}
|
||||
|
||||
static create (ds, game = 'gs') {
|
||||
let profile = new ProfileData(ds, game)
|
||||
get mysArtis(){
|
||||
return this._mysArtis
|
||||
}
|
||||
|
||||
get artis () {
|
||||
return this._artis
|
||||
}
|
||||
|
||||
static create (ds, game = 'gs', calc = true) {
|
||||
let profile = new ProfileData(ds, game, calc)
|
||||
if (!profile) {
|
||||
return false
|
||||
}
|
||||
@ -62,17 +70,8 @@ export default class ProfileData extends AvatarData {
|
||||
}
|
||||
|
||||
initArtis () {
|
||||
this.artis = new ProfileArtis(this.id, this.elem, this.game)
|
||||
}
|
||||
|
||||
setAttr (ds) {
|
||||
this.attr = lodash.extend(Data.getData(ds, 'atk,atkBase,def,defBase,hp,hpBase,mastery,recharge'), {
|
||||
heal: ds.heal || ds.hInc || 0,
|
||||
cpct: ds.cpct || ds.cRate,
|
||||
cdmg: ds.cdmg || ds.cDmg,
|
||||
dmg: ds.dmg || ds.dmgBonus || 0,
|
||||
phy: ds.phy || ds.phyBonus || 0
|
||||
})
|
||||
this._artis = new ProfileArtis(this.id, this.elem, this.game)
|
||||
this._mysArtis = new AvatarArtis(this.id, this.game)
|
||||
}
|
||||
|
||||
calcAttr () {
|
||||
@ -81,8 +80,12 @@ export default class ProfileData extends AvatarData {
|
||||
this.base = this._attr.getBase()
|
||||
}
|
||||
|
||||
setArtis (ds = false) {
|
||||
this.artis?.setProfile(this, ds.artis?.artis || ds.artis || ds)
|
||||
setArtis (ds = false, isMysArtis = false) {
|
||||
if (isMysArtis) {
|
||||
this.mysArtis.setArtis(ds.artis?.artis || ds.artis || ds)
|
||||
} else {
|
||||
this.artis?.setProfile(this, ds.artis?.artis || ds.artis || ds)
|
||||
}
|
||||
}
|
||||
|
||||
// 获取当前profileData的圣遗物评分,withDetail=false仅返回简略信息
|
||||
|
216
models/artis/Artis.js
Normal file
216
models/artis/Artis.js
Normal file
@ -0,0 +1,216 @@
|
||||
/**
|
||||
* 面板圣遗物
|
||||
*/
|
||||
import lodash from 'lodash'
|
||||
import { Artifact, ArtifactSet, Character } from '#miao.models'
|
||||
import { Data, Format } from '#miao'
|
||||
import ArtisMark from './ArtisMark.js'
|
||||
import { attrMap as attrMapGS } from '../../resources/meta/artifact/index.js'
|
||||
import { attrMap as attrMapSR } from '../../resources/meta-sr/artifact/index.js'
|
||||
import CharArtis from '../profile/CharArtis.js'
|
||||
import ArtisBase from './ArtisBase.js'
|
||||
|
||||
export default class Artis extends ArtisBase {
|
||||
constructor (isProfile = false, game = 'gs') {
|
||||
super(game)
|
||||
this.isProfile = !!isProfile
|
||||
}
|
||||
|
||||
// 有圣遗物词条
|
||||
get hasAttr () {
|
||||
if (this.isSr) {
|
||||
return true
|
||||
}
|
||||
return ArtisMark.hasAttr(this.artis)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取角色配置
|
||||
* @returns {{classTitle: *, weight: *, posMaxMark: {}, mark: {}, attrs: {}}}
|
||||
*/
|
||||
getCharCfg () {
|
||||
let char = Character.get(this.charid)
|
||||
let { game, isGs } = char
|
||||
let { attrWeight, title } = CharArtis.getCharArtisCfg(char, this.profile, this)
|
||||
let attrs = {}
|
||||
let baseAttr = char.baseAttr || { hp: 14000, atk: 230, def: 700 }
|
||||
let attrMap = isGs ? attrMapGS : attrMapSR
|
||||
lodash.forEach(attrMap, (attr, key) => {
|
||||
let k = attr.base || ''
|
||||
let weight = attrWeight[k || key]
|
||||
if (!weight || weight * 1 === 0) {
|
||||
return true
|
||||
}
|
||||
let ret = {
|
||||
...attr, weight, fixWeight: weight, mark: weight / attr.value
|
||||
}
|
||||
if (!k) {
|
||||
ret.mark = weight / attr.value
|
||||
} else {
|
||||
let plus = k === 'atk' ? 520 : 0
|
||||
ret.mark = weight / attrMap[k].value / (baseAttr[k] + plus) * 100
|
||||
ret.fixWeight = weight * attr.value / attrMap[k].value / (baseAttr[k] + plus) * 100
|
||||
}
|
||||
attrs[key] = ret
|
||||
})
|
||||
let posMaxMark = ArtisMark.getMaxMark(attrs, game)
|
||||
// 返回内容待梳理简化
|
||||
return {
|
||||
attrs, classTitle: title, posMaxMark
|
||||
}
|
||||
}
|
||||
|
||||
getMarkDetail (withDetail = true) {
|
||||
let charCfg = this.getCharCfg()
|
||||
let artis = {}
|
||||
let setCount = {}
|
||||
let totalMark = 0
|
||||
let self = this
|
||||
this.forEach((arti, idx) => {
|
||||
let mark = ArtisMark.getMark({
|
||||
charCfg, idx, arti, elem: this.elem, game: self.game
|
||||
})
|
||||
totalMark += mark
|
||||
setCount[arti.set] = (setCount[arti.set] || 0) + 1
|
||||
if (!withDetail) {
|
||||
artis[idx] = {
|
||||
_mark: mark, mark: Format.comma(mark, 1), markClass: ArtisMark.getMarkClass(mark)
|
||||
}
|
||||
} else {
|
||||
let artifact = Artifact.get(arti.name, this.game)
|
||||
artis[idx] = {
|
||||
name: artifact.name,
|
||||
abbr: artifact.abbr,
|
||||
set: artifact.setName,
|
||||
img: artifact.img,
|
||||
level: arti.level,
|
||||
_mark: mark,
|
||||
mark: Format.comma(mark, 1),
|
||||
markClass: ArtisMark.getMarkClass(mark),
|
||||
main: ArtisMark.formatArti(arti.main, charCfg.attrs, true, this.game),
|
||||
attrs: ArtisMark.formatArti(arti.attrs, charCfg.attrs, false, this.game)
|
||||
}
|
||||
}
|
||||
})
|
||||
let sets = {}
|
||||
let names = []
|
||||
let imgs = []
|
||||
for (let set in setCount) {
|
||||
if (setCount[set] >= 2) {
|
||||
sets[set] = setCount[set] >= 4 ? 4 : 2
|
||||
let artiSet = ArtifactSet.get(set)
|
||||
imgs.push(artiSet.img)
|
||||
names.push(artiSet.name)
|
||||
}
|
||||
}
|
||||
this.mark = totalMark
|
||||
this.markClass = ArtisMark.getMarkClass(totalMark / 5)
|
||||
let ret = {
|
||||
mark: Format.comma(totalMark, 1),
|
||||
_mark: totalMark,
|
||||
markClass: ArtisMark.getMarkClass(totalMark / 5),
|
||||
artis,
|
||||
sets,
|
||||
names,
|
||||
imgs,
|
||||
classTitle: charCfg.classTitle
|
||||
}
|
||||
if (withDetail) {
|
||||
ret.charWeight = lodash.mapValues(charCfg.attrs, ds => ds.weight)
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
setArtis (idx = 1, ds = {}) {
|
||||
idx = idx.toString().replace('arti', '')
|
||||
parent.setArtis(idx, ds)
|
||||
let arti = this.artis[idx]
|
||||
if (!ds.attrIds || !ds.mainId) {
|
||||
return false
|
||||
}
|
||||
arti.mainId = ds.mainId
|
||||
arti.attrIds = ds.attrIds
|
||||
arti.main = {}
|
||||
arti.attrs = {}
|
||||
let artiObj = Artifact.get(ds.id, this.game)
|
||||
if (!artiObj) {
|
||||
return false
|
||||
}
|
||||
let attr = artiObj.getAttrData(ds.mainId, attrIds, arti.level, arti.star, idx)
|
||||
if (!attr) {
|
||||
console.log('attr id error', ds.main, ds.mainId, idx, arti.level, arti.star)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// 获取保存数据
|
||||
toJSON () {
|
||||
let ret = {}
|
||||
this.eachIdx((ds, idx) => {
|
||||
let tmp = this.isGs ? { name: ds.name } : { id: ds.id }
|
||||
tmp.level = ds.level || 1
|
||||
tmp.star = ds.star || 5
|
||||
ret[idx] = tmp
|
||||
// 如果不为面板数据,则不保存mainId和attrIds
|
||||
if (!this.isProfile) {
|
||||
return true
|
||||
}
|
||||
tmp.mainId = ds.main?.id
|
||||
if (this.isSr) {
|
||||
tmp.attrIds = []
|
||||
lodash.forEach(ds.attrs, (as) => {
|
||||
tmp.attrIds.push([as?.id || '', as?.count || 1, as?.step || 0].join(','))
|
||||
})
|
||||
} else {
|
||||
tmp.attrIds = ds.attrIds
|
||||
}
|
||||
})
|
||||
return ret
|
||||
}
|
||||
|
||||
// 获取指定idx的主词条
|
||||
getMainAttr (idx = '') {
|
||||
if (!idx) {
|
||||
let ret = {}
|
||||
this.eachIdx((arti, idx) => {
|
||||
ret[idx] = this.getMainAttr(idx)
|
||||
})
|
||||
return ret
|
||||
}
|
||||
let main = this.artis[idx]?.main
|
||||
if (!main) {
|
||||
return ''
|
||||
}
|
||||
return main.key || ''
|
||||
}
|
||||
|
||||
is (check, pos = '') {
|
||||
if (pos) {
|
||||
return this.isAttr(check, pos)
|
||||
}
|
||||
let sets = this.getSetData()?.abbrs || []
|
||||
let ret = false
|
||||
Data.eachStr(check, (s) => {
|
||||
if (sets.includes(s)) {
|
||||
ret = true
|
||||
return false
|
||||
}
|
||||
})
|
||||
return ret
|
||||
}
|
||||
|
||||
isAttr (attr, pos = '') {
|
||||
let mainAttr = this.getMainAttr()
|
||||
let check = true
|
||||
pos = pos || this.isGs ? '3,4,5' : '3,4,5,6'
|
||||
let dmgIdx = this.isGs ? 4 : 5
|
||||
Data.eachStr(pos.toString(), (p) => {
|
||||
let attrs = attr.split(',')
|
||||
if (!attrs.includes(mainAttr[p]) && (p === dmgIdx && !attrs.includes('dmg') && Format.isElem(mainAttr[p]))) {
|
||||
check = false
|
||||
return false
|
||||
}
|
||||
})
|
||||
return check
|
||||
}
|
||||
}
|
117
models/artis/ArtisBase.js
Normal file
117
models/artis/ArtisBase.js
Normal file
@ -0,0 +1,117 @@
|
||||
/**
|
||||
* 面板圣遗物
|
||||
*/
|
||||
import lodash from 'lodash'
|
||||
import Base from '../Base.js'
|
||||
import { Artifact, ArtifactSet } from '#miao.models'
|
||||
import ArtisMark from './ArtisMark.js'
|
||||
import ArtisSet from './ArtisSet.js'
|
||||
|
||||
export default class ArtisBase extends Base {
|
||||
constructor (game = 'gs') {
|
||||
super()
|
||||
this.game = game
|
||||
this.artis = {}
|
||||
}
|
||||
|
||||
// 获取圣遗物套装数据
|
||||
getSetData () {
|
||||
return ArtisSet.getSetData(this)
|
||||
}
|
||||
|
||||
get sets () {
|
||||
return this.getSetData().sets || {}
|
||||
}
|
||||
|
||||
get names () {
|
||||
return this.getSetData().names || []
|
||||
}
|
||||
|
||||
// 有圣遗物数据
|
||||
get hasArtis () {
|
||||
return !lodash.isEmpty(this.artis)
|
||||
}
|
||||
|
||||
_get (key) {
|
||||
let artis = this.artis
|
||||
switch (key) {
|
||||
case 'length':
|
||||
return lodash.keys(artis).length
|
||||
}
|
||||
if (artis[key]) {
|
||||
return artis[key]
|
||||
}
|
||||
}
|
||||
|
||||
forEach (fn) {
|
||||
lodash.forEach(this.artis, (ds, idx) => {
|
||||
if (ds.name) {
|
||||
fn(ds, idx)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
eachIdx (fn) {
|
||||
for (let idx = 1; idx <= (this.isGs ? 5 : 6); idx++) {
|
||||
this.artis[idx] = this.artis[idx] || {}
|
||||
fn(this.artis[idx], idx)
|
||||
}
|
||||
}
|
||||
|
||||
setArtisData (ds = {}) {
|
||||
this.eachIdx((arti, idx) => {
|
||||
this.setArtis(idx, ds[idx] || ds[`arti${idx}`] || {})
|
||||
})
|
||||
}
|
||||
|
||||
setArtis (idx = 1, ds = {}) {
|
||||
this.artis[idx] = this.artis[idx] || {}
|
||||
let arti = this.artis[idx]
|
||||
|
||||
if (this.isSr) {
|
||||
let 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
|
||||
} else {
|
||||
arti.name = ds.name || arti.name || ''
|
||||
arti.set = ds.set || Artifact.getSetNameByArti(arti.name) || ''
|
||||
arti.level = ds.level || 1
|
||||
arti.star = ds.star || 5
|
||||
}
|
||||
}
|
||||
|
||||
getDetail () {
|
||||
let ret = {}
|
||||
for (let idx = 1; idx <= 5; idx++) {
|
||||
let ds = this.artis[idx]
|
||||
if (ds) {
|
||||
let artis = Artifact.get(ds.name)
|
||||
let tmp = {
|
||||
...artis?.getData('img,name,set'),
|
||||
level: ds.level || 1
|
||||
}
|
||||
if (ds.main && ds.attrs) {
|
||||
tmp.main = ds.main || null
|
||||
tmp.attrs = []
|
||||
for (let attrIdx in ds.attrs || []) {
|
||||
if (ds.attrs[attrIdx]) {
|
||||
tmp.attrs.push(ArtisMark.formatAttr(ds.attrs[attrIdx]))
|
||||
}
|
||||
}
|
||||
}
|
||||
ret[idx] = tmp
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
eachArtisSet (fn) {
|
||||
ArtifactSet.eachSet(this.sets, fn, this.game)
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@ import { usefulAttr as usefulAttrGS } from '../../resources/meta/artifact/artis-
|
||||
import { usefulAttr as usefulAttrSR } from '../../resources/meta-sr/artifact/artis-mark.js'
|
||||
import lodash from 'lodash'
|
||||
|
||||
const CharArtis = {
|
||||
const ArtisMarkCfg = {
|
||||
|
||||
getCharArtisCfg (char, profile, artis) {
|
||||
let { attr, weapon, elem } = profile
|
||||
@ -93,4 +93,4 @@ const CharArtis = {
|
||||
}
|
||||
}
|
||||
}
|
||||
export default CharArtis
|
||||
export default ArtisMarkCfg
|
49
models/artis/ArtisSet.js
Normal file
49
models/artis/ArtisSet.js
Normal file
@ -0,0 +1,49 @@
|
||||
// 处理套装相关
|
||||
import { ArtifactSet } from '#miao.models'
|
||||
|
||||
const ArtisSet = {
|
||||
/**
|
||||
* 获取套装统计
|
||||
* @param artis
|
||||
* @returns {{imgs: *[], names: *[], sets: {}, abbrs: *[], sName: string, name: (string|*)}}
|
||||
* @returns sets 套装个数, {套装名:2/4}
|
||||
* @returns names 套装名数组
|
||||
* @returns imgs 套装图像
|
||||
* @returns abbrs 套装组合
|
||||
* @returns name 套装展示名
|
||||
* @returns sName 套装精简名
|
||||
*/
|
||||
getSetData (artis) {
|
||||
let setCount = {}
|
||||
artis.forEach((arti, idx) => {
|
||||
setCount[arti.set] = (setCount[arti.set] || 0) + 1
|
||||
})
|
||||
|
||||
let sets = {}
|
||||
let names = []
|
||||
let imgs = []
|
||||
let abbrs = []
|
||||
let abbrs2 = []
|
||||
for (let set in setCount) {
|
||||
if (setCount[set] >= 2) {
|
||||
let count = setCount[set] >= 4 ? 4 : 2
|
||||
sets[set] = count
|
||||
let artiSet = ArtifactSet.get(set)
|
||||
names.push(artiSet.name)
|
||||
imgs.push(artiSet.img)
|
||||
abbrs.push(artiSet.abbr + count)
|
||||
abbrs2.push(artiSet.name + count)
|
||||
}
|
||||
}
|
||||
return {
|
||||
sets,
|
||||
names,
|
||||
imgs,
|
||||
abbrs: [...abbrs, ...abbrs2],
|
||||
name: (abbrs.length > 1 || abbrs2[0]?.length > 7) ? abbrs.slice(0, 2).join('+') : abbrs2[0],
|
||||
sName: abbrs.slice(0, 2).join('+')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default ArtisSet
|
@ -3,13 +3,11 @@ import Character from './Character.js'
|
||||
import Artifact from './Artifact.js'
|
||||
import ArtifactSet from './ArtifactSet.js'
|
||||
import AvatarData from './AvatarData.js'
|
||||
import AvatarArtis from './AvatarArtis.js'
|
||||
import Abyss from './Abyss.js'
|
||||
import Player from './Player.js'
|
||||
import ProfileServ from './ProfileServ.js'
|
||||
import ProfileReq from './ProfileReq.js'
|
||||
import ProfileData from './ProfileData.js'
|
||||
import ProfileArtis from './ProfileArtis.js'
|
||||
import ProfileAttr from './ProfileAttr.js'
|
||||
import ProfileDmg from './ProfileDmg.js'
|
||||
import ProfileRank from './ProfileRank.js'
|
||||
@ -25,11 +23,9 @@ export {
|
||||
Artifact,
|
||||
ArtifactSet,
|
||||
AvatarData,
|
||||
AvatarArtis,
|
||||
ProfileServ,
|
||||
ProfileReq,
|
||||
ProfileData,
|
||||
ProfileArtis,
|
||||
ProfileAttr,
|
||||
ProfileDmg,
|
||||
ProfileRank,
|
||||
|
@ -152,7 +152,9 @@ const MysAvatar = {
|
||||
stats[lodash.camelCase(key)] = num
|
||||
}
|
||||
})
|
||||
|
||||
if (stats?.fieldExtMap) {
|
||||
delete stats.fieldExtMap
|
||||
}
|
||||
let exploration = {}
|
||||
lodash.forEach(infoData?.world_explorations || [], (ds) => {
|
||||
let { name } = ds
|
||||
@ -166,6 +168,7 @@ const MysAvatar = {
|
||||
stats,
|
||||
exploration
|
||||
}
|
||||
|
||||
player._info = new Date() * 1
|
||||
player.save()
|
||||
},
|
||||
@ -220,7 +223,7 @@ const MysAvatar = {
|
||||
// 并发5,请求天赋数据
|
||||
await Data.asyncPool(5, needReqIds, async (id) => {
|
||||
let avatar = player.getAvatar(id)
|
||||
if (!avatar) {
|
||||
if (!avatar || avatar.isMaxTalent) {
|
||||
return false
|
||||
}
|
||||
if (failCount > 5) {
|
||||
@ -246,7 +249,6 @@ const MysAvatar = {
|
||||
let id = char.id
|
||||
let talent = {}
|
||||
let talentRes = await mys.getDetail(id)
|
||||
// { data: null, message: '请先登录', retcode: -100, api: 'detail' }
|
||||
if (talentRes && talentRes.skill_list) {
|
||||
let talentList = lodash.orderBy(talentRes.skill_list, ['id'], ['asc'])
|
||||
for (let val of talentList) {
|
||||
|
@ -70,7 +70,7 @@ let DmgBuffs = {
|
||||
// 圣遗物Buff
|
||||
getArtisBuffs (artis = {}, game = 'gs') {
|
||||
let retBuffs = []
|
||||
ProfileArtis._eachArtisSet(artis, (sets, num) => {
|
||||
ArtifactSet.eachSet(artis, (sets, num) => {
|
||||
let buffs = ArtifactSet.getArtisSetBuff(sets.name, num, game)
|
||||
if (lodash.isPlainObject(buffs)) {
|
||||
buffs = [buffs]
|
||||
|
@ -1,2 +0,0 @@
|
||||
let ProfileInput = {}
|
||||
export default ProfileInput
|
132
tools/profile-trans.js
Normal file
132
tools/profile-trans.js
Normal file
@ -0,0 +1,132 @@
|
||||
import { Data } from '#miao'
|
||||
import lodash from 'lodash'
|
||||
import fs from 'node:fs'
|
||||
|
||||
let Trans = {
|
||||
init () {
|
||||
Data.createDir('temp/UserData_BAK')
|
||||
let uids = fs.readdirSync('./data/UserData')
|
||||
uids = uids.filter((uid) => /\.(json)/i.test(uid))
|
||||
let success = 0
|
||||
let count = 0
|
||||
if (uids.length === 0) {
|
||||
return
|
||||
}
|
||||
console.log('准备将面板数据迁移至data/PlayerData/gs...')
|
||||
lodash.forEach(uids, (uid) => {
|
||||
uid = uid.replace('.json', '')
|
||||
let ret = Trans.trans(uid)
|
||||
count++
|
||||
if (ret) {
|
||||
success++
|
||||
}
|
||||
|
||||
if (count % 100 === 0) {
|
||||
console.log(`迁移成功: ${success}...`)
|
||||
}
|
||||
|
||||
try {
|
||||
let src = `./data/UserData/${uid}.json`
|
||||
let dst = `./temp/UserData_BAK/${uid}.json`
|
||||
fs.existsSync(dst) && fs.unlinkSync(dst)
|
||||
fs.copyFileSync(src, dst)
|
||||
fs.unlinkSync(src)
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
|
||||
})
|
||||
console.log('Trans UID', success)
|
||||
},
|
||||
trans (uid) {
|
||||
let data = Trans.getData(uid)
|
||||
if (data) {
|
||||
Data.writeJSON(`data/PlayerData/gs/${uid}.json`, data, 'root', 0)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
},
|
||||
getData (uid) {
|
||||
let ds = Data.readJSON(`data/UserData/${uid}.json`)
|
||||
let dst = Data.readJSON(`data/PlayerData/gs/${uid}.json`)
|
||||
if (!ds.uid || (lodash.isEmpty(ds.avatars) && lodash.isEmpty(ds.chars))) {
|
||||
return false
|
||||
}
|
||||
let ret = Data.getData(ds, 'uid,name,level,word,face,card,sign,_profile')
|
||||
ret.game = 'gs'
|
||||
let info = ds.info || dst.info
|
||||
if (info) {
|
||||
if (info?.stats?.fieldExtMap) {
|
||||
delete info.stats.fieldExtMap
|
||||
}
|
||||
ret.info = info
|
||||
}
|
||||
ret.avatars = {
|
||||
...(dst.avatars || {}),
|
||||
...Trans.getAvatars({ ...ds.chars, ...ds.avatars })
|
||||
}
|
||||
return ret
|
||||
},
|
||||
getAvatars (ds) {
|
||||
let ret = {}
|
||||
lodash.forEach(ds || {}, (avatar, id) => {
|
||||
avatar = Trans.getAvatar(avatar)
|
||||
if (avatar) {
|
||||
ret[id] = avatar
|
||||
}
|
||||
})
|
||||
return ret
|
||||
},
|
||||
getAvatar (ds) {
|
||||
if (!ds.id || !ds.name || !ds.level || !ds.weapon || !ds.promote) {
|
||||
return false
|
||||
}
|
||||
return {
|
||||
...Data.getData(ds, 'id,name,elem,level,promote,fetter,costume,cons,talent,weapon'),
|
||||
...Trans.getArtis(ds.artis),
|
||||
...Data.getData(ds, '_source,_time,_talent')
|
||||
}
|
||||
},
|
||||
getArtis (artis) {
|
||||
let profile = {}
|
||||
let mys = {}
|
||||
lodash.forEach(artis, (ds, idx) => {
|
||||
if (ds.mainId && ds.attrIds) {
|
||||
profile[idx] = {
|
||||
level: ds._level || ds.level || 1,
|
||||
star: ds._star || ds.star || 1,
|
||||
name: ds._name || ds.name || '',
|
||||
mainId: ds.mainId,
|
||||
attrIds: ds.attrIds
|
||||
}
|
||||
}
|
||||
mys[idx] = {
|
||||
level: ds.level || 1,
|
||||
star: ds.star || 1,
|
||||
name: ds.name || '',
|
||||
}
|
||||
})
|
||||
let ret = {}
|
||||
if (lodash.isEmpty(profile)) {
|
||||
if (!lodash.isEmpty(mys)) {
|
||||
ret.mysArtis = mys
|
||||
}
|
||||
} else {
|
||||
ret.artis = profile
|
||||
let hasDiff = false
|
||||
let getKey = (d) => {
|
||||
return [d?.name || '', d?.level || '', d?.star || ''].join('|')
|
||||
}
|
||||
for (let idx = 1; idx <= 5; idx++) {
|
||||
if (getKey(profile[idx]) !== getKey(mys[idx])) {
|
||||
hasDiff = true
|
||||
}
|
||||
}
|
||||
if (hasDiff) {
|
||||
ret.mysArtis = mys
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
}
|
||||
export default Trans
|
Loading…
Reference in New Issue
Block a user