mirror of
https://github.com/yoimiya-kokomi/miao-plugin.git
synced 2024-11-25 17:35:34 +00:00
调整avatars获取天赋的部分逻辑
This commit is contained in:
parent
54011f9310
commit
1794a12456
@ -1,12 +1,8 @@
|
|||||||
import { Common, Cfg, App } from '../components/index.js'
|
import { Common, App } from '../components/index.js'
|
||||||
import { Character } from '../models/index.js'
|
import { Character } from '../models/index.js'
|
||||||
import { renderAvatar } from './character/avatar-card.js'
|
import { renderAvatar } from './character/avatar-card.js'
|
||||||
// 角色图像上传
|
|
||||||
import { uploadCharacterImg } from './character/character-img-upload.js'
|
import { uploadCharacterImg } from './character/character-img-upload.js'
|
||||||
|
|
||||||
// 老婆
|
|
||||||
import { wife, wifeReg } from './character/avatar-wife.js'
|
import { wife, wifeReg } from './character/avatar-wife.js'
|
||||||
|
|
||||||
import { getOriginalPicture } from './character/utils.js'
|
import { getOriginalPicture } from './character/utils.js'
|
||||||
|
|
||||||
let app = App.init({
|
let app = App.init({
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Artifact, Character } from '../../models/index.js'
|
import { Artifact, Character, Avatars } from '../../models/index.js'
|
||||||
import { Cfg, Data, Common, Profile } from '../../components/index.js'
|
import { Cfg, Data, Common, Profile } from '../../components/index.js'
|
||||||
import lodash from 'lodash'
|
import lodash from 'lodash'
|
||||||
import { segment } from 'oicq'
|
import { segment } from 'oicq'
|
||||||
@ -59,9 +59,10 @@ async function renderCard (e, avatar, renderType = 'card') {
|
|||||||
}
|
}
|
||||||
let uid = e.uid || (e.targetUser && e.targetUser.uid)
|
let uid = e.uid || (e.targetUser && e.targetUser.uid)
|
||||||
|
|
||||||
let crownNum = 0;
|
let crownNum = 0
|
||||||
let talent = {}
|
let talent = {}
|
||||||
if (!char.isCustom) {
|
if (!char.isCustom) {
|
||||||
|
|
||||||
talent = await getTalent(e, avatar)
|
talent = await getTalent(e, avatar)
|
||||||
// 计算皇冠个数
|
// 计算皇冠个数
|
||||||
crownNum = lodash.filter(lodash.map(talent, (d) => d.original), (d) => d >= 10).length
|
crownNum = lodash.filter(lodash.map(talent, (d) => d.original), (d) => d >= 10).length
|
||||||
@ -71,6 +72,7 @@ async function renderCard (e, avatar, renderType = 'card') {
|
|||||||
e.reply(segment.image(process.cwd() + '/plugins/miao-plugin/resources/' + bg.img))
|
e.reply(segment.image(process.cwd() + '/plugins/miao-plugin/resources/' + bg.img))
|
||||||
} else {
|
} else {
|
||||||
// 渲染图像
|
// 渲染图像
|
||||||
|
// let talent =
|
||||||
let msgRes = await Common.render('character/character-card', {
|
let msgRes = await Common.render('character/character-card', {
|
||||||
save_id: uid,
|
save_id: uid,
|
||||||
uid,
|
uid,
|
||||||
@ -93,17 +95,14 @@ async function renderCard (e, avatar, renderType = 'card') {
|
|||||||
|
|
||||||
// 获取角色技能数据
|
// 获取角色技能数据
|
||||||
async function getTalent (e, avatars) {
|
async function getTalent (e, avatars) {
|
||||||
let talent = {};
|
let char = Character.get(avatars.id)
|
||||||
let cons = 0;
|
|
||||||
let char = Character.get(avatars.id);
|
|
||||||
let mode = 'level'
|
|
||||||
if (char.isCustom) {
|
if (char.isCustom) {
|
||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
|
let uid = e.uid
|
||||||
if (avatars.dataSource && avatars.talent) {
|
if (avatars.dataSource && avatars.talent) {
|
||||||
// profile模式
|
// profile模式
|
||||||
talent = avatars.talent || {}
|
return avatars.talent
|
||||||
cons = avatars.cons || 0
|
|
||||||
} else {
|
} else {
|
||||||
let MysApi = await e.getMysApi({
|
let MysApi = await e.getMysApi({
|
||||||
auth: 'all',
|
auth: 'all',
|
||||||
@ -112,28 +111,9 @@ async function getTalent (e, avatars) {
|
|||||||
actionName: '查询信息'
|
actionName: '查询信息'
|
||||||
})
|
})
|
||||||
if (!MysApi && !MysApi.isSelfCookie) return {}
|
if (!MysApi && !MysApi.isSelfCookie) return {}
|
||||||
let skillRes = await MysApi.getAvatar(avatars.id)
|
let avatar = new Avatars(uid, [avatars])
|
||||||
cons = avatars.actived_constellation_num
|
return await avatar.getAvatarTalent(avatars.id, MysApi)
|
||||||
mode = 'original'
|
|
||||||
if (skillRes && skillRes.skill_list) {
|
|
||||||
let skillList = lodash.orderBy(skillRes.skill_list, ['id'], ['asc'])
|
|
||||||
for (let val of skillList) {
|
|
||||||
if (val.name.includes('普通攻击')) {
|
|
||||||
talent.a = val
|
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
if (val.max_level >= 10 && !talent.e) {
|
|
||||||
talent.e = val
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if (val.max_level >= 10 && !talent.q) {
|
|
||||||
talent.q = val
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return char.getAvatarTalent(talent, cons, mode)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -3,13 +3,8 @@ import { Character } from '../models/index.js'
|
|||||||
import { getTargetUid, getProfile, profileHelp, inputProfile } from './character/profile-common.js'
|
import { getTargetUid, getProfile, profileHelp, inputProfile } from './character/profile-common.js'
|
||||||
import { profileArtis, profileArtisList } from './character/profile-artis.js'
|
import { profileArtis, profileArtisList } from './character/profile-artis.js'
|
||||||
import { renderProfile } from './character/profile-detail.js'
|
import { renderProfile } from './character/profile-detail.js'
|
||||||
|
|
||||||
// 面板练度统计
|
|
||||||
import { profileStat } from './character/profile-stat.js'
|
import { profileStat } from './character/profile-stat.js'
|
||||||
|
|
||||||
// 面板角色列表
|
|
||||||
import { profileList } from './character/profile-list.js'
|
import { profileList } from './character/profile-list.js'
|
||||||
|
|
||||||
import { enemyLv } from './character/utils.js'
|
import { enemyLv } from './character/utils.js'
|
||||||
|
|
||||||
let app = App.init({
|
let app = App.init({
|
||||||
|
@ -28,7 +28,7 @@ export default async function (path, params, cfg) {
|
|||||||
copyright: `Created By Yunzai-Bot<span class="version">${Version.yunzai}</span> & Miao-Plugin<span class="version">${Version.version}</span>`
|
copyright: `Created By Yunzai-Bot<span class="version">${Version.yunzai}</span> & Miao-Plugin<span class="version">${Version.version}</span>`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (global.debugView === 'web-debug') {
|
if (process.argv.includes('web-debug')) {
|
||||||
// debug下保存当前页面的渲染数据,方便模板编写与调试
|
// debug下保存当前页面的渲染数据,方便模板编写与调试
|
||||||
// 由于只用于调试,开发者只关注自己当时开发的文件即可,暂不考虑app及plugin的命名冲突
|
// 由于只用于调试,开发者只关注自己当时开发的文件即可,暂不考虑app及plugin的命名冲突
|
||||||
let saveDir = _path + '/data/ViewData/'
|
let saveDir = _path + '/data/ViewData/'
|
||||||
|
@ -99,50 +99,35 @@ export default class Avatars extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getAvatarTalent (id, MysApi) {
|
async getAvatarTalent (id, MysApi) {
|
||||||
let talent = { id, a: {}, e: {}, q: {} }
|
let talent = {}
|
||||||
let talentRes = await MysApi.getDetail(id)
|
let talentRes = await MysApi.getDetail(id)
|
||||||
let char = Character.get(id)
|
let char = Character.get(id)
|
||||||
let avatar = this.avatars[id]
|
let avatar = this.avatars[id]
|
||||||
if (!char || !avatar) {
|
if (!char || !avatar) {
|
||||||
return talent
|
return talent
|
||||||
}
|
}
|
||||||
let consTalent = char.talentCons
|
|
||||||
if (talentRes && talentRes.skill_list) {
|
if (talentRes && talentRes.skill_list) {
|
||||||
talent.id = id
|
talent.id = id
|
||||||
let talentList = lodash.orderBy(talentRes.skill_list, ['id'], ['asc'])
|
let talentList = lodash.orderBy(talentRes.skill_list, ['id'], ['asc'])
|
||||||
for (let val of talentList) {
|
for (let val of talentList) {
|
||||||
let { max_level: maxLv, level_current: lv } = val
|
let { max_level: maxLv, level_current: lv } = val
|
||||||
let ds = {
|
|
||||||
current: lv,
|
|
||||||
original: lv,
|
|
||||||
crown: lv === maxLv
|
|
||||||
}
|
|
||||||
if (val.name.includes('普通攻击')) {
|
if (val.name.includes('普通攻击')) {
|
||||||
talent.a = ds
|
talent.a = lv
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if (maxLv >= 10 && !talent.e?.current) {
|
if (maxLv >= 10 && !talent.e) {
|
||||||
talent.e = ds
|
talent.e = lv
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if (maxLv >= 10 && !talent.q?.current) {
|
if (maxLv >= 10 && !talent.q) {
|
||||||
talent.q = ds
|
talent.q = lv
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lodash.forEach([3, 5], (c) => {
|
|
||||||
if (avatar.cons >= c) {
|
|
||||||
if (consTalent.e === c) {
|
|
||||||
talent.e.current += 3
|
|
||||||
talent.e.plus = true
|
|
||||||
} else if (consTalent.q === c) {
|
|
||||||
talent.q.current += 3
|
|
||||||
talent.q.plus = true
|
|
||||||
}
|
}
|
||||||
}
|
let ret = char.getAvatarTalent(talent, avatar.cons, 'original')
|
||||||
})
|
ret.id = id
|
||||||
}
|
return ret
|
||||||
return talent
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,9 +47,9 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{each tk talentKey}}
|
{{each tk talentKey}}
|
||||||
{{set curr = (avatar.talent||{})[talentKey] || {original:1,current:'-'} }}
|
{{set curr = (avatar.talent||{})[talentKey] || {original:1,level:'-'} }}
|
||||||
<div class="td-talent lv{{talentLvMap[curr.original]}} {{curr.current>curr.original?'talent-plus':''}}">
|
<div class="td-talent lv{{talentLvMap[curr.original]}} {{curr.level>curr.original?'talent-plus':''}}">
|
||||||
{{curr.current}}
|
{{curr.level}}
|
||||||
</div>
|
</div>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
|
||||||
|
@ -13,11 +13,11 @@
|
|||||||
<div class="avatar-level">Lv{{avatar.level}}</div>
|
<div class="avatar-level">Lv{{avatar.level}}</div>
|
||||||
</div>
|
</div>
|
||||||
{{set talent = avatar.talent || {} }}
|
{{set talent = avatar.talent || {} }}
|
||||||
{{if talent.a && talent.a.current }}
|
{{if talent.a && talent.a.level }}
|
||||||
<div class="avatar-talent">
|
<div class="avatar-talent">
|
||||||
{{each talentMap k}}
|
{{each talentMap k}}
|
||||||
{{set t = talent[k] || {} }}
|
{{set t = talent[k] || {} }}
|
||||||
<span class="talent-item talent-{{k}} talent-{{t.crown?'crown':'none'}} talent-{{t.plus?'plus':'none'}}">{{t.current}}</span>
|
<span class="talent-item talent-{{k}} talent-{{t.original===10?'crown':'none'}} talent-{{t.level>t.original?'plus':'none'}}">{{t.level}}</span>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</div>
|
</div>
|
||||||
{{else}}
|
{{else}}
|
||||||
|
Loading…
Reference in New Issue
Block a user