mirror of
https://github.com/yoimiya-kokomi/miao-plugin.git
synced 2025-02-01 16:05:53 +00:00
一些Bugfix
This commit is contained in:
parent
a56e1cd81d
commit
7272da906d
@ -177,10 +177,10 @@ const ProfileChange = {
|
||||
return source
|
||||
}
|
||||
let cuid = cfg.uid || uid
|
||||
let cPlayer = Player.create(uid)
|
||||
let id = cfg.char || source.id
|
||||
let key = cuid + ':' + id
|
||||
if (!profiles[key]) {
|
||||
let cPlayer = Player.create(cuid)
|
||||
profiles[key] = cPlayer.getProfile(id) || {}
|
||||
}
|
||||
return profiles[key]?.id ? profiles[key] : source
|
||||
|
@ -199,7 +199,7 @@ export async function renderProfile (e, char, mode = 'profile', params = {}) {
|
||||
let msgRes = await Common.render('character/profile-detail', {
|
||||
save_id: uid,
|
||||
uid,
|
||||
data: avatar.getData('name,abbr,cons,level,weapon,talent,dataSource,updateTime'),
|
||||
data: profile.getData('name,abbr,cons,level,weapon,talent,dataSource,updateTime'),
|
||||
attr,
|
||||
elem: char.elem,
|
||||
dmgData,
|
||||
|
@ -9,7 +9,7 @@ import Profile from './player-lib/Profile.js'
|
||||
const charKey = 'name,abbr,sName,star,imgs,face,side,gacha,weaponTypeName'.split(',')
|
||||
|
||||
export default class AvatarData extends Base {
|
||||
constructor (ds = {}, source) {
|
||||
constructor(ds = {}, source) {
|
||||
super()
|
||||
let char = Character.get({ id: ds.id, elem: ds.elem })
|
||||
if (!char) {
|
||||
@ -21,11 +21,75 @@ export default class AvatarData extends Base {
|
||||
this.setAvatar(ds, source)
|
||||
}
|
||||
|
||||
initArtis () {
|
||||
this.artis = new AvatarArtis(this.id)
|
||||
/**
|
||||
* 当前数据是否需要更新天赋
|
||||
* @returns {boolean}
|
||||
*/
|
||||
get needRefreshTalent() {
|
||||
// 不存在天赋数据
|
||||
if (!this.hasTalent) {
|
||||
return true
|
||||
}
|
||||
// 超过2个小时的天赋数据进行请求
|
||||
return (new Date() * 1) - this._talent > 3600 * 2 * 1000
|
||||
}
|
||||
|
||||
static create (ds, source) {
|
||||
get hasTalent() {
|
||||
return this.talent && !lodash.isEmpty(this.talent) && !!this._talent
|
||||
}
|
||||
|
||||
get name() {
|
||||
return this.char?.name || ''
|
||||
}
|
||||
|
||||
// 是否是合法面板数据
|
||||
get isProfile() {
|
||||
return Profile.isProfile(this)
|
||||
}
|
||||
|
||||
get costume() {
|
||||
let costume = this._costume
|
||||
if (lodash.isArray(costume)) {
|
||||
costume = costume[0]
|
||||
}
|
||||
return costume
|
||||
}
|
||||
|
||||
get originalTalent() {
|
||||
return lodash.mapValues(this.talent, (ds) => ds.original)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取圣遗物套装属性
|
||||
* @returns {boolean|*|{imgs: *[], names: *[], sets: {}, abbrs: *[], sName: string, name: (string|*)}|{}}
|
||||
*/
|
||||
get artisSet() {
|
||||
return this.artis.getSetData()
|
||||
}
|
||||
|
||||
get dataSource() {
|
||||
return {
|
||||
enka: 'Enka.Network',
|
||||
miao: '喵喵Api',
|
||||
mys: '米游社'
|
||||
}[this._source] || this._source
|
||||
}
|
||||
|
||||
get updateTime() {
|
||||
let time = this._time
|
||||
if (!time) {
|
||||
return ''
|
||||
}
|
||||
if (lodash.isString(time)) {
|
||||
return moment(time).format('MM-DD HH:mm')
|
||||
}
|
||||
if (lodash.isNumber(time)) {
|
||||
return moment(new Date(time)).format('MM-DD HH:mm')
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
static create(ds, source) {
|
||||
let avatar = new AvatarData(ds)
|
||||
if (!avatar) {
|
||||
return false
|
||||
@ -33,13 +97,17 @@ export default class AvatarData extends Base {
|
||||
return avatar
|
||||
}
|
||||
|
||||
_get (key) {
|
||||
initArtis() {
|
||||
this.artis = new AvatarArtis(this.id)
|
||||
}
|
||||
|
||||
_get(key) {
|
||||
if (charKey.includes(key)) {
|
||||
return this.char[key]
|
||||
}
|
||||
}
|
||||
|
||||
setAvatar (ds, source = '') {
|
||||
setAvatar(ds, source = '') {
|
||||
this._now = new Date() * 1
|
||||
this.setBasic(ds, source)
|
||||
ds.weapon && this.setWeapon(ds.weapon)
|
||||
@ -53,7 +121,7 @@ export default class AvatarData extends Base {
|
||||
* @param ds
|
||||
* @param source
|
||||
*/
|
||||
setBasic (ds = {}, source = '') {
|
||||
setBasic(ds = {}, source = '') {
|
||||
const now = this._now || (new Date()) * 1
|
||||
this.level = ds.lv || ds.level || this.level || 1
|
||||
this.cons = ds.cons || this.cons || 0
|
||||
@ -79,21 +147,24 @@ export default class AvatarData extends Base {
|
||||
}
|
||||
}
|
||||
|
||||
setWeapon (ds = {}) {
|
||||
let w = Weapon.get(ds.name) || {}
|
||||
setWeapon(ds = {}) {
|
||||
let w = Weapon.get(ds.name)
|
||||
if (!w) {
|
||||
return false
|
||||
}
|
||||
this.weapon = {
|
||||
name: ds.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,
|
||||
...w?.getData('star,abbr,type,img')
|
||||
...w.getData('star,abbr,type,img')
|
||||
}
|
||||
if (this.weapon.level < 20) {
|
||||
this.weapon.promote = 0
|
||||
}
|
||||
}
|
||||
|
||||
setTalent (ds = {}, mode = 'original', source = '') {
|
||||
setTalent(ds = {}, mode = 'original', source = '') {
|
||||
const now = this._now || (new Date()) * 1
|
||||
let ret = this.char.getAvatarTalent(ds, this.cons, mode)
|
||||
this.talent = ret || this.talent
|
||||
@ -104,37 +175,11 @@ export default class AvatarData extends Base {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前数据是否需要更新天赋
|
||||
* @returns {boolean}
|
||||
*/
|
||||
get needRefreshTalent () {
|
||||
// 不存在天赋数据
|
||||
if (!this.hasTalent) {
|
||||
return true
|
||||
}
|
||||
// 超过2个小时的天赋数据进行请求
|
||||
return (new Date() * 1) - this._talent > 3600 * 2 * 1000
|
||||
}
|
||||
|
||||
setArtis (ds, source) {
|
||||
setArtis(ds, source) {
|
||||
this.artis.setArtisData(ds.artis, source)
|
||||
}
|
||||
|
||||
get hasTalent () {
|
||||
return this.talent && !lodash.isEmpty(this.talent) && !!this._talent
|
||||
}
|
||||
|
||||
get name () {
|
||||
return this.char?.name || ''
|
||||
}
|
||||
|
||||
// 是否是合法面板数据
|
||||
get isProfile () {
|
||||
return Profile.isProfile(this)
|
||||
}
|
||||
|
||||
getProfile () {
|
||||
getProfile() {
|
||||
if (!this.isProfile) {
|
||||
return false
|
||||
}
|
||||
@ -142,24 +187,12 @@ export default class AvatarData extends Base {
|
||||
}
|
||||
|
||||
// 判断当前profileData是否具备有效圣遗物信息
|
||||
hasArtis () {
|
||||
hasArtis() {
|
||||
return this.isProfile && this.artis.length > 0
|
||||
}
|
||||
|
||||
get costume () {
|
||||
let costume = this._costume
|
||||
if (lodash.isArray(costume)) {
|
||||
costume = costume[0]
|
||||
}
|
||||
return costume
|
||||
}
|
||||
|
||||
get originalTalent () {
|
||||
return lodash.mapValues(this.talent, (ds) => ds.original)
|
||||
}
|
||||
|
||||
// toJSON 供保存使用
|
||||
toJSON () {
|
||||
toJSON() {
|
||||
return {
|
||||
...this.getData('name,id,elem,level,promote,fetter,costume,cons,talent:originalTalent'),
|
||||
weapon: Data.getData(this.weapon, 'name,level,promote,affix'),
|
||||
@ -167,41 +200,11 @@ export default class AvatarData extends Base {
|
||||
}
|
||||
}
|
||||
|
||||
getDetail (keys = '') {
|
||||
getDetail(keys = '') {
|
||||
return this.getData(keys || 'id,name,level,star,cons,fetter,elem,face,side,gacha,abbr,weapon,talent,artisSet') || {}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取圣遗物套装属性
|
||||
* @returns {boolean|*|{imgs: *[], names: *[], sets: {}, abbrs: *[], sName: string, name: (string|*)}|{}}
|
||||
*/
|
||||
get artisSet () {
|
||||
return this.artis.getSetData()
|
||||
}
|
||||
|
||||
getArtisDetail () {
|
||||
getArtisDetail() {
|
||||
return this.artis.getDetail()
|
||||
}
|
||||
|
||||
get dataSource () {
|
||||
return {
|
||||
enka: 'Enka.Network',
|
||||
miao: '喵喵Api',
|
||||
mys: '米游社'
|
||||
}[this._source] || this._source
|
||||
}
|
||||
|
||||
get updateTime () {
|
||||
let time = this._time
|
||||
if (!time) {
|
||||
return ''
|
||||
}
|
||||
if (lodash.isString(time)) {
|
||||
return moment(time).format('MM-DD HH:mm')
|
||||
}
|
||||
if (lodash.isNumber(time)) {
|
||||
return moment(new Date(time)).format('MM-DD HH:mm')
|
||||
}
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
@ -482,7 +482,7 @@ export const attrMap = {
|
||||
ATTACK_PERCENT: 'atk',
|
||||
DEFENSE: 'defPlus',
|
||||
DEFENSE_PERCENT: 'def',
|
||||
FIRE_ADD_HURT: '',
|
||||
FIRE_ADD_HURT: 'pyro',
|
||||
ICE_ADD_HURT: 'cryo',
|
||||
ROCK_ADD_HURT: 'geo',
|
||||
ELEC_ADD_HURT: 'electro',
|
||||
|
Loading…
Reference in New Issue
Block a user