diff --git a/apps/profile/ProfileChange.js b/apps/profile/ProfileChange.js index 66b3b8d7..fe17403e 100644 --- a/apps/profile/ProfileChange.js +++ b/apps/profile/ProfileChange.js @@ -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, diff --git a/apps/profile/ProfileDetail.js b/apps/profile/ProfileDetail.js index 7a5bc1d3..b152cd29 100644 --- a/apps/profile/ProfileDetail.js +++ b/apps/profile/ProfileDetail.js @@ -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') { diff --git a/apps/profile/ProfileList.js b/apps/profile/ProfileList.js index 8c4f1596..a413968a 100644 --- a/apps/profile/ProfileList.js +++ b/apps/profile/ProfileList.js @@ -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 }) } diff --git a/apps/profile/ProfileWeapon.js b/apps/profile/ProfileWeapon.js index b5451fbd..c874fe9c 100644 --- a/apps/profile/ProfileWeapon.js +++ b/apps/profile/ProfileWeapon.js @@ -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, diff --git a/models/Artifact.js b/models/Artifact.js index 69be3221..f57521b8 100644 --- a/models/Artifact.js +++ b/models/Artifact.js @@ -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 diff --git a/models/AvatarArtis.js b/models/AvatarArtis.js index f663a2d1..84c5c028 100644 --- a/models/AvatarArtis.js +++ b/models/AvatarArtis.js @@ -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 } diff --git a/models/AvatarData.js b/models/AvatarData.js index 00b500e3..549a5c21 100644 --- a/models/AvatarData.js +++ b/models/AvatarData.js @@ -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') } } diff --git a/models/Base.js b/models/Base.js index 4557fbfe..5630aaa9 100644 --- a/models/Base.js +++ b/models/Base.js @@ -94,11 +94,11 @@ export default class Base { delete metaMap[id] } - isSr () { + get isSr () { return this.game === 'sr' } - isGs () { + get isGs () { return !this.isSr } } diff --git a/models/Character.js b/models/Character.js index 2fc6c52f..57af1114 100644 --- a/models/Character.js +++ b/models/Character.js @@ -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 } // 检查老婆类型 diff --git a/models/Player.js b/models/Player.js index 2e5d68c5..eecefca7 100644 --- a/models/Player.js +++ b/models/Player.js @@ -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 } diff --git a/models/ProfileArtis.js b/models/ProfileArtis.js index 9042218e..24b2efbb 100644 --- a/models/ProfileArtis.js +++ b/models/ProfileArtis.js @@ -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, diff --git a/models/ProfileData.js b/models/ProfileData.js index 7e9dce20..eeab336c 100644 --- a/models/ProfileData.js +++ b/models/ProfileData.js @@ -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 {} diff --git a/models/Weapon.js b/models/Weapon.js index b947bdfd..728ce62e 100644 --- a/models/Weapon.js +++ b/models/Weapon.js @@ -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) { diff --git a/models/character/CharTalent.js b/models/character/CharTalent.js index 215c67e5..6695089d 100644 --- a/models/character/CharTalent.js +++ b/models/character/CharTalent.js @@ -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 } diff --git a/models/player/LuluApi.js b/models/player/LuluApi.js index 464c62a2..278fa33b 100644 --- a/models/player/LuluApi.js +++ b/models/player/LuluApi.js @@ -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 } } diff --git a/models/profile/AttrCalc.js b/models/profile/AttrCalc.js index ad377057..6998f8ee 100644 --- a/models/profile/AttrCalc.js +++ b/models/profile/AttrCalc.js @@ -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) { diff --git a/resources/character/character-card.html b/resources/character/character-card.html index dc3f11cc..1e0a3a83 100644 --- a/resources/character/character-card.html +++ b/resources/character/character-card.html @@ -78,7 +78,8 @@