调整avatars获取天赋的部分逻辑

This commit is contained in:
yoimiya-kokomi 2022-09-18 06:19:26 +08:00
parent 54011f9310
commit 1794a12456
7 changed files with 26 additions and 70 deletions

View File

@ -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 { renderAvatar } from './character/avatar-card.js'
// 角色图像上传
import { uploadCharacterImg } from './character/character-img-upload.js'
// 老婆
import { wife, wifeReg } from './character/avatar-wife.js'
import { getOriginalPicture } from './character/utils.js'
let app = App.init({

View File

@ -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 lodash from 'lodash'
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 crownNum = 0;
let crownNum = 0
let talent = {}
if (!char.isCustom) {
talent = await getTalent(e, avatar)
// 计算皇冠个数
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))
} else {
// 渲染图像
// let talent =
let msgRes = await Common.render('character/character-card', {
save_id: uid,
uid,
@ -93,17 +95,14 @@ async function renderCard (e, avatar, renderType = 'card') {
// 获取角色技能数据
async function getTalent (e, avatars) {
let talent = {};
let cons = 0;
let char = Character.get(avatars.id);
let mode = 'level'
let char = Character.get(avatars.id)
if (char.isCustom) {
return {}
}
let uid = e.uid
if (avatars.dataSource && avatars.talent) {
// profile模式
talent = avatars.talent || {}
cons = avatars.cons || 0
return avatars.talent
} else {
let MysApi = await e.getMysApi({
auth: 'all',
@ -112,28 +111,9 @@ async function getTalent (e, avatars) {
actionName: '查询信息'
})
if (!MysApi && !MysApi.isSelfCookie) return {}
let skillRes = await MysApi.getAvatar(avatars.id)
cons = avatars.actived_constellation_num
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
let avatar = new Avatars(uid, [avatars])
return await avatar.getAvatarTalent(avatars.id, MysApi)
}
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)
}
/*

View File

@ -3,13 +3,8 @@ import { Character } from '../models/index.js'
import { getTargetUid, getProfile, profileHelp, inputProfile } from './character/profile-common.js'
import { profileArtis, profileArtisList } from './character/profile-artis.js'
import { renderProfile } from './character/profile-detail.js'
// 面板练度统计
import { profileStat } from './character/profile-stat.js'
// 面板角色列表
import { profileList } from './character/profile-list.js'
import { enemyLv } from './character/utils.js'
let app = App.init({

View File

@ -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>`
}
}
if (global.debugView === 'web-debug') {
if (process.argv.includes('web-debug')) {
// debug下保存当前页面的渲染数据方便模板编写与调试
// 由于只用于调试开发者只关注自己当时开发的文件即可暂不考虑app及plugin的命名冲突
let saveDir = _path + '/data/ViewData/'

View File

@ -99,50 +99,35 @@ export default class Avatars extends Base {
}
async getAvatarTalent (id, MysApi) {
let talent = { id, a: {}, e: {}, q: {} }
let talent = {}
let talentRes = await MysApi.getDetail(id)
let char = Character.get(id)
let avatar = this.avatars[id]
if (!char || !avatar) {
return talent
}
let consTalent = char.talentCons
if (talentRes && talentRes.skill_list) {
talent.id = id
let talentList = lodash.orderBy(talentRes.skill_list, ['id'], ['asc'])
for (let val of talentList) {
let { max_level: maxLv, level_current: lv } = val
let ds = {
current: lv,
original: lv,
crown: lv === maxLv
}
if (val.name.includes('普通攻击')) {
talent.a = ds
talent.a = lv
continue
}
if (maxLv >= 10 && !talent.e?.current) {
talent.e = ds
if (maxLv >= 10 && !talent.e) {
talent.e = lv
continue
}
if (maxLv >= 10 && !talent.q?.current) {
talent.q = ds
if (maxLv >= 10 && !talent.q) {
talent.q = lv
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
}
}
})
}
return talent
let ret = char.getAvatarTalent(talent, avatar.cons, 'original')
ret.id = id
return ret
}
}

View File

@ -47,9 +47,9 @@
</div>
{{each tk talentKey}}
{{set curr = (avatar.talent||{})[talentKey] || {original:1,current:'-'} }}
<div class="td-talent lv{{talentLvMap[curr.original]}} {{curr.current>curr.original?'talent-plus':''}}">
{{curr.current}}
{{set curr = (avatar.talent||{})[talentKey] || {original:1,level:'-'} }}
<div class="td-talent lv{{talentLvMap[curr.original]}} {{curr.level>curr.original?'talent-plus':''}}">
{{curr.level}}
</div>
{{/each}}

View File

@ -13,11 +13,11 @@
<div class="avatar-level">Lv{{avatar.level}}</div>
</div>
{{set talent = avatar.talent || {} }}
{{if talent.a && talent.a.current }}
{{if talent.a && talent.a.level }}
<div class="avatar-talent">
{{each talentMap 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}}
</div>
{{else}}