2023-02-08 20:55:54 +00:00
|
|
|
import { Character, Artifact } from '../index.js'
|
2022-08-20 23:40:32 +00:00
|
|
|
import lodash from 'lodash'
|
2023-02-08 20:55:54 +00:00
|
|
|
|
|
|
|
const attrMap = {
|
|
|
|
HP: 'hpPlus',
|
|
|
|
HP_PERCENT: 'hp',
|
|
|
|
ATTACK: 'atkPlus',
|
|
|
|
ATTACK_PERCENT: 'atk',
|
|
|
|
DEFENSE: 'defPlus',
|
|
|
|
DEFENSE_PERCENT: 'def',
|
|
|
|
FIRE_ADD_HURT: '',
|
|
|
|
ICE_ADD_HURT: 'cryo',
|
|
|
|
ROCK_ADD_HURT: 'geo',
|
|
|
|
ELEC_ADD_HURT: 'electro',
|
|
|
|
WIND_ADD_HURT: 'anemo',
|
|
|
|
WATER_ADD_HURT: 'hydro',
|
|
|
|
PHYSICAL_ADD_HURT: 'phy',
|
|
|
|
GRASS_ADD_HURT: 'dendro',
|
|
|
|
HEAL_ADD: 'heal',
|
|
|
|
ELEMENT_MASTERY: 'mastery',
|
|
|
|
CRITICAL: 'cpct',
|
|
|
|
CRITICAL_HURT: 'cdmg',
|
|
|
|
CHARGE_EFFICIENCY: 'recharge'
|
|
|
|
}
|
|
|
|
|
2022-08-20 23:40:32 +00:00
|
|
|
|
|
|
|
let MiaoData = {
|
|
|
|
key: 'miao',
|
2022-10-21 14:48:19 +00:00
|
|
|
name: '喵喵Api',
|
2022-08-20 23:40:32 +00:00
|
|
|
|
|
|
|
getData (uid, data) {
|
|
|
|
let ret = {
|
|
|
|
uid,
|
|
|
|
chars: {}
|
|
|
|
}
|
|
|
|
if (data.cacheExpireAt) {
|
|
|
|
let exp = Math.max(0, Math.round(data.cacheExpireAt - (new Date() / 1000)))
|
|
|
|
ret.ttl = Math.max(60, exp)
|
|
|
|
}
|
|
|
|
return ret
|
|
|
|
},
|
|
|
|
|
|
|
|
getAvatar (ds) {
|
|
|
|
let char = Character.get(ds.id)
|
|
|
|
return {
|
|
|
|
id: ds.id,
|
|
|
|
name: char ? char.name : '',
|
|
|
|
dataSource: 'miao',
|
|
|
|
level: ds.level
|
|
|
|
}
|
|
|
|
},
|
2023-02-08 20:55:54 +00:00
|
|
|
setAvatar (player, ds) {
|
2022-08-20 23:40:32 +00:00
|
|
|
let char = Character.get(ds.id)
|
2023-02-08 20:55:54 +00:00
|
|
|
let avatar = player.getAvatar(ds.id)
|
|
|
|
let talentRet = MiaoData.getTalent(char.id, ds.skill)
|
|
|
|
avatar.setAvatar({
|
2022-08-20 23:40:32 +00:00
|
|
|
level: ds.level,
|
|
|
|
cons: ds.constellationNum || 0,
|
|
|
|
fetter: ds.fetterLevel,
|
2022-08-31 18:26:36 +00:00
|
|
|
costume: char.checkCostume(ds.costumeID) ? ds.costumeID : 0,
|
2023-02-08 20:55:54 +00:00
|
|
|
elem: talentRet.elem,
|
|
|
|
weapon: MiaoData.getWeapon(ds.weapon),
|
|
|
|
talent: talentRet.talent,
|
|
|
|
artis: MiaoData.getArtifact(ds.reliquary)
|
|
|
|
}, 'miao')
|
|
|
|
return avatar
|
2022-08-20 23:40:32 +00:00
|
|
|
},
|
|
|
|
getWeapon (weapon) {
|
|
|
|
return {
|
|
|
|
name: weapon.name,
|
|
|
|
star: weapon.rank,
|
|
|
|
level: weapon.level,
|
|
|
|
promote: weapon.promoteLevel,
|
|
|
|
affix: (weapon.affixLevel || 0) + 1
|
|
|
|
}
|
|
|
|
},
|
|
|
|
getArtifact (data) {
|
|
|
|
let ret = {}
|
|
|
|
let get = function (d) {
|
|
|
|
if (!d) {
|
|
|
|
return []
|
|
|
|
}
|
|
|
|
let name = d.name
|
|
|
|
name = name.replace('FIGHT_PROP_', '')
|
|
|
|
if (!attrMap[name]) {
|
|
|
|
return []
|
|
|
|
}
|
|
|
|
let value = d.value
|
|
|
|
if (value && value < 1) {
|
|
|
|
value = value * 100
|
|
|
|
}
|
2023-02-08 20:55:54 +00:00
|
|
|
return { key: attrMap[name], value }
|
2022-08-20 23:40:32 +00:00
|
|
|
}
|
|
|
|
lodash.forEach(data, (ds) => {
|
|
|
|
let sub = ds.appendAffix || []
|
2023-02-08 20:55:54 +00:00
|
|
|
let idx = {
|
|
|
|
生之花: 1,
|
|
|
|
死之羽: 2,
|
|
|
|
时之沙: 3,
|
|
|
|
空之杯: 4,
|
|
|
|
理之冠: 5
|
|
|
|
}[ds.type]
|
2022-08-20 23:40:32 +00:00
|
|
|
if (!idx) {
|
|
|
|
return
|
|
|
|
}
|
2023-02-08 20:55:54 +00:00
|
|
|
ret[idx] = {
|
2022-08-20 23:40:32 +00:00
|
|
|
name: ds.name,
|
2023-02-08 20:55:54 +00:00
|
|
|
set: Artifact.getSetNameByArti(ds.name) || '',
|
2022-08-20 23:40:32 +00:00
|
|
|
level: ds.level,
|
|
|
|
main: get(ds.mainAffix),
|
|
|
|
attrs: [
|
|
|
|
get(sub[0]),
|
|
|
|
get(sub[1]),
|
|
|
|
get(sub[2]),
|
|
|
|
get(sub[3])
|
|
|
|
]
|
|
|
|
}
|
|
|
|
})
|
|
|
|
return ret
|
|
|
|
},
|
2022-09-03 21:08:57 +00:00
|
|
|
getTalent (charid, data = {}) {
|
|
|
|
let char = Character.get(charid)
|
|
|
|
let { talentId = {}, talentElem = {}, talentKey = {} } = char.meta
|
|
|
|
let elem = ''
|
|
|
|
let idx = 0
|
2022-08-20 23:40:32 +00:00
|
|
|
let ret = {}
|
2022-09-03 21:08:57 +00:00
|
|
|
lodash.forEach(data, (ds) => {
|
|
|
|
let key
|
|
|
|
if (talentId[ds.id]) {
|
|
|
|
let tid = talentId[ds.id]
|
|
|
|
key = talentKey[tid]
|
|
|
|
elem = elem || talentElem[tid]
|
2022-11-23 20:26:07 +00:00
|
|
|
ret[key] = {
|
|
|
|
level: ds.level
|
|
|
|
}
|
2022-09-03 21:08:57 +00:00
|
|
|
} else {
|
|
|
|
key = ['a', 'e', 'q'][idx++]
|
2022-11-23 20:26:07 +00:00
|
|
|
ret[key] = ret[key] || {
|
|
|
|
level: ds.level
|
|
|
|
}
|
2022-08-20 23:40:32 +00:00
|
|
|
}
|
|
|
|
})
|
2022-09-03 21:08:57 +00:00
|
|
|
return {
|
|
|
|
talent: ret,
|
|
|
|
elem
|
|
|
|
}
|
2022-08-20 23:40:32 +00:00
|
|
|
}
|
|
|
|
}
|
2022-08-18 10:13:42 +00:00
|
|
|
export default MiaoData
|