diff --git a/apps/profile.js b/apps/profile.js index 09914753..34f290a4 100644 --- a/apps/profile.js +++ b/apps/profile.js @@ -72,7 +72,7 @@ app.reg({ profileStat: { name: '面板练度统计', fn: ProfileStat.stat, - rule: /^#(面板|喵喵)练度统计$/, + rule: /^#(星铁|原神)?(面板|喵喵)?练度统计$/, yzRule: /^#*(我的)*(武器|角色|练度|五|四|5|4|星)+(汇总|统计|列表)(force|五|四|5|4|星)*[ |0-9]*$/, yzCheck: () => Cfg.get('profileStat', false) }, @@ -94,7 +94,7 @@ app.reg({ refreshTalent: { name: '强制刷新天赋', fn: ProfileStat.refreshTalent, - rule: /^#(强制)?(刷新|更新)(所有|角色)*(天赋|技能)$/ + rule: /^#(星铁|原神)?(强制)?(刷新|更新)(所有|角色)*(天赋|技能)$/ }, profileHelp: { diff --git a/apps/profile/ProfileStat.js b/apps/profile/ProfileStat.js index f947e909..cd839572 100644 --- a/apps/profile/ProfileStat.js +++ b/apps/profile/ProfileStat.js @@ -13,23 +13,32 @@ const ProfileStat = { }, async refreshTalent (e) { + let game = /星铁/.test(e.msg) ? 'sr' : 'gs' + e.isSr = game === 'sr' + let mys = await MysApi.init(e) if (!mys || !mys.uid) return false - let player = Player.create(e) + let player = Player.create(e, game) let refreshCount = await player.refreshTalent('', 2) - if (refreshCount) { + if (refreshCount && !e.isSr) { e.reply(`角色天赋更新成功,共${refreshCount}个角色\n你现在可以通过【#练度统计】【#天赋统计】来查看角色信息了...`) + } else if (e.isSr) { + e.reply(`角色天赋更新成功,共${refreshCount}个角色\n你现在可以通过【*练度统计】来查看角色信息了...`) } else { e.reply('角色天赋未能更新...') } }, // 渲染 - // isAvatarList true:角色列表 false练度统计 + // mode stat:练度统计 avatar:角色列表 talent:天赋统计 async render (e, mode = 'stat') { + let game = /星铁/.test(e.msg) ? 'sr' : 'gs' + e.isSr = game === 'sr' + e.game = game + // 缓存时间,单位小时 - let msg = e.msg.replace('#', '').trim() + let msg = e.msg.replace(/#星铁|#/, '').trim() if (msg === '角色统计' || msg === '武器统计') { // 暂时避让一下抽卡分析的关键词 return false @@ -39,13 +48,12 @@ const ProfileStat = { mode = 'talent' } - let mys = await MysApi.init(e) if (!mys || !mys.uid) return false const uid = mys.uid - let player = Player.create(e) + let player = Player.create(e, game) let avatarRet = await player.refreshAndGetAvatarData({ index: 2, @@ -112,7 +120,6 @@ const ProfileStat = { goldCount: '金卡总数' } - let tpl = mode === 'avatar' ? 'character/avatar-list' : 'character/profile-stat' return await Common.render(tpl, { save_id: uid, @@ -123,7 +130,8 @@ const ProfileStat = { face, mode, week, - avatars: avatarRet + avatars: avatarRet, + game }, { e, scale: 1.4 }) } } diff --git a/models/Avatar.js b/models/Avatar.js index 18d14a2e..23453adc 100644 --- a/models/Avatar.js +++ b/models/Avatar.js @@ -206,7 +206,7 @@ export default class Avatar extends Base { level: ds.level || ds.lv || 1, promote: lodash.isUndefined(ds.promote) ? Attr.calcPromote(ds.level || ds.lv || 1) : (ds.promote || 0), affix: ds.affix, - ...w.getData('star,abbr,type,img') + ...w.getData('star,abbr,type,img,imgs') } if (this.weapon.level < 20) { this.weapon.promote = 0 diff --git a/models/MysApi.js b/models/MysApi.js index 62d71cf6..05491759 100644 --- a/models/MysApi.js +++ b/models/MysApi.js @@ -3,7 +3,7 @@ import { Version } from '#miao' import { Button } from '#miao.models' export default class MysApi { - constructor (e, uid, mysInfo) { + constructor(e, uid, mysInfo) { this.e = e this.mysInfo = mysInfo this.ckInfo = mysInfo.ckInfo @@ -82,7 +82,7 @@ export default class MysApi { if (this.mys) { return this.mys } - this.mys = await e.runtime.getMysApi(targetType, option) + this.mys = await e.runtime.getMysApi(targetType, option, e.isSr) return this.mys } @@ -146,6 +146,7 @@ export default class MysApi { } async getDetail (id) { + if (this.e.isSr) { return await this.getData('detail', { avatar_id: id, tab_from: 'TabOwned' }) } return await this.getData('detail', { avatar_id: id }) } diff --git a/models/Player.js b/models/Player.js index 2520b242..e3c41a8f 100644 --- a/models/Player.js +++ b/models/Player.js @@ -17,7 +17,7 @@ Data.createDir('/data/PlayerData/gs', 'root') Data.createDir('/data/PlayerData/sr', 'root') export default class Player extends Base { - constructor (uid, game = 'gs') { + constructor(uid, game = 'gs') { super() uid = uid?._mys?.uid || uid?.uid || uid if (!uid) { @@ -381,6 +381,9 @@ export default class Player extends Base { let { talent } = avatar let ds = avatar.getDetail() ds.aeq = talent?.a?.original + talent?.e?.original + talent?.q?.original || 3 + if (avatar.game === 'sr') { + ds.aeq = talent?.a?.original + talent?.e?.original + talent?.q?.original + talent?.t?.original || 4 + } avatarRet[ds.id] = ds let profile = avatar.getProfile() @@ -407,6 +410,4 @@ export default class Player extends Base { } return avatarRet } - - } diff --git a/models/Weapon.js b/models/Weapon.js index 6ed3711f..0f5d72ee 100644 --- a/models/Weapon.js +++ b/models/Weapon.js @@ -1,12 +1,11 @@ import Base from './Base.js' import { Data, Format, Meta } from '#miao' +import lodash from 'lodash' let weaponSet -import lodash from 'lodash' - class Weapon extends Base { - constructor (meta, game = 'gs') { + constructor(meta, game = 'gs') { if (!meta || !meta.name) { return false } @@ -309,7 +308,6 @@ class Weapon extends Base { if (!tables[ds.idx]) return true ds.data[ds.key] = tables[ds.idx] } else if (ds.refine) { - lodash.forEach(ds.refine, (r, key) => { ds.data[key] = ({ refine }) => r[refine] * (ds.buffCount || 1) }) diff --git a/models/avatar/MysAvatar.js b/models/avatar/MysAvatar.js index ee60630b..844cc239 100644 --- a/models/avatar/MysAvatar.js +++ b/models/avatar/MysAvatar.js @@ -17,13 +17,6 @@ const MysAvatar = { return force } return force - // 暂时不处理ck变更 - player._info = 0 - player._mys = 0 - player.forEachAvatar((avatar) => { - avatar._talent = 0 - }) - return 2 }, /** * 更新米游社角色信息 @@ -241,7 +234,8 @@ const MysAvatar = { let id = char.id let talent = {} let talentRes = await mys.getDetail(id) - if (talentRes && talentRes.skill_list) { + let game = avatar.game + if (game === 'gs' && talentRes && talentRes.skill_list) { let talentList = lodash.orderBy(talentRes.skill_list, ['id'], ['asc']) for (let val of talentList) { let { max_level: maxLv, level_current: lv } = val @@ -257,6 +251,27 @@ const MysAvatar = { talent.q = lv } } + } else if (game === 'sr' && talentRes && talentRes.skills) { + let talentList = lodash.orderBy(talentRes.skills, ['point_id'], ['asc']) + for (let val of talentList) { + let { cur_level: lv, anchor } = val + if (anchor.includes('Point01')) { + talent.a = lv + continue + } + if (anchor.includes('Point02')) { + talent.e = lv + continue + } + if (anchor.includes('Point03')) { + talent.q = lv + continue + } + if (anchor.includes('Point04')) { + talent.t = lv + continue + } + } } let ret = char.getAvatarTalent(talent, avatar.cons, 'original') avatar.setTalent(ret, 'original', true) diff --git a/resources/character/imgs/bg-02.jpg b/resources/character/imgs/bg-02.jpg new file mode 100644 index 00000000..7ddfa5eb Binary files /dev/null and b/resources/character/imgs/bg-02.jpg differ diff --git a/resources/character/imgs/main-02.png b/resources/character/imgs/main-02.png new file mode 100644 index 00000000..e902e863 Binary files /dev/null and b/resources/character/imgs/main-02.png differ diff --git a/resources/character/profile-stat.css b/resources/character/profile-stat.css index 9417735e..d901b6e6 100644 --- a/resources/character/profile-stat.css +++ b/resources/character/profile-stat.css @@ -1,11 +1,3 @@ -body { - background: url('./imgs/bg-01.jpg') left center; - background-size: 100% auto; -} -.container { - background: url('./imgs/main-01.png') center -25px no-repeat; - background-size: 100% auto; -} .head-box { margin-top: 0; } @@ -266,6 +258,10 @@ body { .cont .tr .lv5.talent-plus { color: #b70000; } +.cont .tr .lv5.crown-sr { + background: url("../common/item/crown-sr-o.png") center center no-repeat rgba(255, 36, 26, 0.55); + background-size: contain; +} .cont .td-artis { width: 115px; text-align: left; @@ -392,4 +388,3 @@ body { .cont-notice span { margin-left: 5px; } -/*# sourceMappingURL=profile-stat.css.map */ \ No newline at end of file diff --git a/resources/character/profile-stat.html b/resources/character/profile-stat.html index ec084c5d..c903782b 100644 --- a/resources/character/profile-stat.html +++ b/resources/character/profile-stat.html @@ -1,14 +1,41 @@ {{extend defaultLayout}} +{{set isSr = game === 'sr'}} + {{block 'css'}} - +{{if isSr}} + +{{else}} + +{{/if}} + {{/block}} - {{block 'main'}} +