日历中会展示角色生日

This commit is contained in:
yoimiya-kokomi 2022-10-07 06:20:46 +08:00
parent 5ee98eed54
commit 9054bdc50f
31 changed files with 261 additions and 73 deletions

View File

@ -1,15 +1,18 @@
# 2.0.2
# 2.0.3
* `#日历` 页面样式微调,功能升级
* 日历中会展示角色生日
* 日历会展示本日可刷天赋角色列表(暂未完成)
* 一些已知问题修复
# 2.0.1~2.0.2
* 添加 纳西妲、莱依拉 的天赋及命座数据
* 可通过 `#草神天赋``#草神命座``#草神图鉴`查看
* 优化character的进入判定逻辑防止一些额外的log触发
* 角色相关命令在V3下会联合V3的角色别名一同查询
# 2.0.1
* 支持Enka获取3.1新角色及新武器的数据
* 新角色及新武器暂未支持伤害计算,稍晚会升级
* 补充坎蒂丝、赛诺的角色图像
* 优化character的进入判定逻辑防止一些额外的log触发
* 角色相关命令在V3下会联合V3的角色别名一同查询
# 2.0.0

View File

@ -1,9 +1,9 @@
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'
import { renderAvatar } from './character/AvatarCard.js'
import { uploadCharacterImg } from './character/ImgUpload.js'
import { wife, wifeReg } from './character/AvatarWife.js'
import { getOriginalPicture } from './character/ProfileUtils.js'
let app = App.init({
id: 'character',

View File

@ -14,7 +14,7 @@ export async function renderAvatar (e, avatar, renderType = 'card') {
let mys = await MysApi.init(e)
if (!mys) return true
uid = mys.uid
if (!char.isArrive) {
if (!char.isRelease) {
avatar = { id: char.id, name: char.name, detail: false }
} else {
let profile = Profile.get(uid, char.id, true)
@ -52,8 +52,8 @@ async function renderCard (e, ds, renderType = 'card') {
let uid = e.uid || (e.targetUser && e.targetUser.uid)
let data = {}
let custom = char.isCustom
let arrive = char.isArrive
if (arrive) {
let isRelease = char.isRelease
if (isRelease) {
let mys = await MysApi.init(e)
let avatar = new Avatar(ds, uid, mys.isSelfCookie)
data = avatar.getData('id,name,sName,level,fetter,cons,weapon,elem,artis,artisSet,imgs,dataSourceName,updateTime')
@ -83,7 +83,7 @@ async function renderCard (e, ds, renderType = 'card') {
widthStyle: `<style>html,body,#container{width:${width}px} ${imgCss}</style>`,
mode: bg.mode,
custom,
arrive,
isRelease,
data
}, { e, scale, retMsgId: true })
if (msgRes && msgRes.message_id) {

View File

@ -2,7 +2,7 @@
import lodash from 'lodash'
import { Cfg } from '../../components/index.js'
import { Character, MysApi } from '../../models/index.js'
import { getAvatarList, renderAvatar } from './avatar-card.js'
import { getAvatarList, renderAvatar } from './AvatarCard.js'
const relationMap = {
wife: {

View File

@ -4,7 +4,7 @@
* */
import lodash from 'lodash'
import { Profile, Common } from '../../components/index.js'
import { getTargetUid, profileHelp, autoGetProfile } from './profile-common.js'
import { getTargetUid, profileHelp, autoGetProfile } from './ProfileCommon.js'
import { Artifact, Character } from '../../models/index.js'
/*

View File

@ -3,7 +3,7 @@
* */
import lodash from 'lodash'
import { segment } from 'oicq'
import { profileList } from './profile-list.js'
import { profileList } from './ProfileList.js'
import { Profile, Version } from '../../components/index.js'
import { Character, MysApi } from '../../models/index.js'

View File

@ -1,5 +1,5 @@
import lodash from 'lodash'
import { autoRefresh } from './profile-common.js'
import { autoRefresh } from './ProfileCommon.js'
import { Common, Format, Profile } from '../../components/index.js'
import { MysApi, Avatar } from '../../models/index.js'

View File

@ -1,5 +1,5 @@
import lodash from 'lodash'
import { autoRefresh, getTargetUid } from './profile-common.js'
import { autoRefresh, getTargetUid } from './ProfileCommon.js'
import { Common, Profile } from '../../components/index.js'
export async function profileList (e) {

View File

@ -1,7 +1,7 @@
import lodash from 'lodash'
import fs from 'fs'
import { Cfg, Version, Common, Data, App } from '../components/index.js'
import Theme from './help/theme.js'
import HelpTheme from './help/HelpTheme.js'
let app = App.init({
id: 'help',
@ -74,7 +74,7 @@ async function help (e) {
helpGroup.push(group)
})
let themeData = await Theme.getThemeData(diyCfg.helpCfg || {}, sysCfg.helpCfg || {})
let themeData = await HelpTheme.getThemeData(diyCfg.helpCfg || {}, sysCfg.helpCfg || {})
return await Common.render('help/index', {
helpCfg: helpConfig,
helpGroup,

View File

@ -2,7 +2,7 @@ import lodash from 'lodash'
import fs from 'fs'
import { Data } from '../../components/index.js'
let Theme = {
let HelpTheme = {
async getThemeCfg (theme, exclude) {
let dirPath = './plugins/miao-plugin/resources/help/theme/'
let ret = []
@ -37,7 +37,7 @@ let Theme = {
let colCount = Math.min(5, Math.max(parseInt(helpConfig?.colCount) || 3, 2))
let colWidth = Math.min(500, Math.max(100, parseInt(helpConfig?.colWidth) || 265))
let width = Math.min(2500, Math.max(800, colCount * colWidth + 30))
let theme = await Theme.getThemeCfg(diyStyle.theme || sysStyle.theme, diyStyle.themeExclude || sysStyle.themeExclude)
let theme = await HelpTheme.getThemeCfg(diyStyle.theme || sysStyle.theme, diyStyle.themeExclude || sysStyle.themeExclude)
let themeStyle = theme.style || {}
let ret = [`
body{background-image:url(${theme.bg});width:${width}px;}
@ -65,4 +65,4 @@ let Theme = {
}
}
}
export default Theme
export default HelpTheme

View File

@ -1,5 +1,5 @@
import { App } from '../components/index.js'
import { pokeWife } from './character/avatar-wife.js'
import { pokeWife } from './character/AvatarWife.js'
let app = App.init({
id: 'poke',

View File

@ -1,11 +1,11 @@
import { Common, Cfg, App } from '../components/index.js'
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'
import { getTargetUid, getProfile, profileHelp, inputProfile } from './character/ProfileCommon.js'
import { profileArtis, profileArtisList } from './character/ProfileArtis.js'
import { renderProfile } from './character/ProfileDetail.js'
import { profileStat } from './character/ProfileStat.js'
import { profileList } from './character/ProfileList.js'
import { enemyLv } from './character/ProfileUtils.js'
let app = App.init({
id: 'profile',
@ -126,7 +126,7 @@ export async function profileDetail (e) {
e.reply('自定义角色暂不支持此功能')
return true
}
if (!char.isArrive) {
if (!char.isRelease) {
e.reply('角色尚未实装')
return true
}

View File

@ -1,6 +1,6 @@
import { segment } from 'oicq'
import lodash from 'lodash'
import Calendar from './wiki/calendar.js'
import Calendar from './wiki/Calendar.js'
import { Format, Cfg, Common, App } from '../components/index.js'
import { Character } from '../models/index.js'
import CharWiki from './wiki/CharWiki.js'

View File

@ -117,6 +117,7 @@ let Cal = {
let dateList = []
let month = 0
let date = []
let week = []
let startDate, endDate
@ -131,16 +132,20 @@ let Cal = {
if (month !== m && date.length > 0) {
dateList.push({
month,
date
date,
week
})
date = []
week = []
month = m
}
date.push(d)
week.push(temp.weekday())
if (idx === 12) {
dateList.push({
month,
date
date,
week
})
endDate = temp.format('YYYY-MM-DD')
}
@ -159,6 +164,7 @@ let Cal = {
}
},
// 深渊日历信息
getAbyssCal (s1, e1) {
let now = moment()
let check = []
@ -185,6 +191,25 @@ let Cal = {
return ret
},
getCharData (dateList) {
let charBirth = {}
lodash.forEach(dateList, (m) => {
lodash.forEach(m.date, (d) => {
charBirth[`${m.month}-${d}`] = []
})
})
Character.forEach((char) => {
if (charBirth[char.birth]) {
charBirth[char.birth].push(char.getData('id,sName,star,face'))
}
}, 'release')
let charNum = 0
lodash.forEach(charBirth, (charList) => {
charNum = Math.max(charNum, charList.length)
})
return { charBirth, charNum }
},
getList (ds, target, { startTime, endTime, totalRange, now, timeMap = {} }, isAct = false) {
let type = isAct ? 'activity' : 'normal'
let id = ds.ann_id
@ -322,6 +347,7 @@ let Cal = {
return {
...dl,
...Cal.getCharData(dl.dateList),
list: ret,
abyss,
charMode: `char-${charCount}-${charOld}`,

View File

@ -12,7 +12,11 @@ import CharTalent from './character-lib/CharTalent.js'
import CharId from './character-lib/CharId.js'
import CharMeta from './character-lib/CharMeta.js'
let { abbrMap, wifeMap, idSort } = CharId
let { abbrMap, wifeMap, idSort, idMap } = CharId
let getMeta = function (name) {
return Data.readJSON(`resources/meta/character/${name}/data.json`)
}
class Character extends Base {
constructor ({ id, name = '', elem = '' }) {
@ -38,12 +42,13 @@ class Character extends Base {
// 默认获取的数据
_dataKey = 'id,name,abbr,title,star,elem,allegiance,weapon,birthday,astro,cncv,jpcv,ver,desc,talentCons'
// 是否为自定义角色
get isCustom () {
return !/[12]0\d{6}/.test(this._id)
// 是否为官方角色
get isOfficial () {
return /[12]0\d{6}/.test(this._id)
}
get isArrive () {
// 是否为实装官方角色
get isRelease () {
if (this.isCustom) {
return false
}
@ -53,10 +58,16 @@ class Character extends Base {
return true
}
// 是否为自定义角色
get isCustom () {
return !/[12]0\d{6}/.test(this._id)
}
get id () {
return this.isCustom ? this._id : this._id * 1
}
// 获取短名字
get sName () {
let name = this.name
let abbr = this.abbr
@ -86,6 +97,7 @@ class Character extends Base {
return CharId.getElemName(this.elem)
}
// 获取角色描述
get desc () {
return CharMeta.getDesc(this.meta.desc || '')
}
@ -126,6 +138,7 @@ class Character extends Base {
return CharMeta.getLvStat(this)
}
// 获取生日
get birthday () {
let birth = this.birth
if (!birth) {
@ -195,6 +208,8 @@ class Character extends Base {
return this._detail
}
// 设置旅行者数据
// TODO迁移至Avatar
setTraveler (uid = '') {
if (this.isTraveler && uid && uid.toString().length === 9) {
Data.setCacheJSON(`miao:uid-traveler:${uid}`, {
@ -204,6 +219,7 @@ class Character extends Base {
}
}
// 获取旅行者数据
async getTraveler (uid) {
if (this.isTraveler) {
let tData = await Data.getCacheJSON(`miao:uid-traveler:${uid}`)
@ -234,34 +250,52 @@ class Character extends Base {
}
return await this.getTraveler(uid)
}
}
let getMeta = function (name) {
return Data.readJSON(`resources/meta/character/${name}/data.json`)
}
Character.get = function (val) {
// 基于角色名获取Character
static get (val) {
let id = CharId.getId(val)
if (!id) {
return false
}
return new Character(id)
}
Character.getAvatar = async function (name, uid) {
}
static forEach (fn, type = 'all') {
lodash.forEach(idMap, (name, id) => {
let char = Character.get({ id, name })
if (type === 'release' && !char.isRelease) {
return true
}
if (type === 'official' && !char.isCustom) {
return true
}
return fn(char) !== false
})
}
// 基于角色名获取Character
// 当获取角色为旅行者时会考虑当前uid的账号情况返回对应旅行者
static async getAvatar (name, uid) {
let char = Character.get(name)
return await char.getTraveler(uid)
}
}
Character.getAbbr = function () {
// 获取别名数据
// TODO待废弃
static getAbbr () {
return abbrMap
}
}
Character.checkWifeType = function (charid, type) {
// 检查wife类型
// TODO待废弃
static checkWifeType (charid, type) {
return !!wifeMap[type][charid]
}
}
Character.sortIds = function (arr) {
// 获取排序ID
static sortIds (arr) {
return arr.sort((a, b) => (idSort[a] || 300) - (idSort[b] || 300))
}
}
export default Character

View File

@ -2,7 +2,7 @@ import fs from 'fs'
import lodash from 'lodash'
import Base from './Base.js'
import { Character } from './index.js'
import { attrMap } from './profile-lib/calc-meta.js'
import { attrMap } from './profile-lib/DmgCalcMeta.js'
import DmgBuffs from './profile-lib/DmgBuffs.js'
import DmgAttr from './profile-lib/DmgAttr.js'
import DmgCalc from './profile-lib/DmgCalc.js'

View File

@ -1,3 +1,6 @@
/*
* 角色别名及角色ID相关
* */
import lodash from 'lodash'
import { Data } from '../../components/index.js'
import { charPosIdx, elemAlias } from './CharMeta.js'

View File

@ -1,3 +1,6 @@
/*
* 角色照片及角色图像资源相关
* */
import fs from 'fs'
import lodash from 'lodash'
import sizeOf from 'image-size'

View File

@ -1,3 +1,6 @@
/*
* 角色资料数据相关
* */
import lodash from 'lodash'
import { Material } from '../index.js'
import { Format, Data } from '../../components/index.js'

View File

@ -1,3 +1,6 @@
/*
* 角色天赋相关处理
* */
import lodash from 'lodash'
const CharTalent = {

View File

@ -1,7 +1,7 @@
/*
* 伤害计算 - 属性计算
* */
import { attrMap, eleMap } from './calc-meta.js'
import { attrMap, eleMap } from './DmgCalcMeta.js'
import lodash from 'lodash'
import DmgMastery from './DmgMastery.js'
import { Format } from '../../components/index.js'

View File

@ -1,7 +1,7 @@
/*
* 伤害计算 - 计算伤害
* */
import { eleBaseDmg } from './calc-meta.js'
import { eleBaseDmg } from './DmgCalcMeta.js'
import DmgMastery from './DmgMastery.js'
let DmgCalc = {

View File

@ -1,4 +1,4 @@
import { erType } from './calc-meta.js'
import { erType } from './DmgCalcMeta.js'
let DmgMastery = {
getMultiple (type = 'zf', mastery = 0) {

View File

@ -58,22 +58,64 @@ body {
.cal-bg td.date {
width: 7.692%;
}
.cal-bg td.date span {
display: block;
line-height: 18px;
}
.cal-bg td.date span.date-week {
line-height: 12px;
font-size: 12px;
color: #888;
}
.cal-bg td.date.current-date {
background: #d3bc8e;
border: 1px solid #d3bc8e;
color: #000;
}
.cal-bg td.date.current-date span.date-week {
color: #000;
}
.cal-bg td.line {
background: rgba(0, 0, 0, 0.4);
vertical-align: top;
}
.cal-bg td.line.current-date {
background: rgba(211, 188, 142, 0.4);
}
.cal-bg .card {
width: 65px;
height: 76px;
margin: 8px auto -4px;
}
.cal-bg .card .img {
height: 60px;
}
.cal-bg .card .char-name {
position: absolute;
bottom: 0;
left: 0;
right: 0;
line-height: 17px;
font-size: 12px;
background: #e8e2d8;
}
.cal-list {
position: relative;
padding-top: 80px;
overflow: hidden;
}
.cal-list.char-num-0 {
padding-top: 80px;
}
.cal-list.char-num-1 {
padding-top: 160px;
}
.cal-list.char-num-2 {
padding-top: 240px;
}
.cal-list.char-num-3 {
padding-top: 320px;
}
.cal-list .cal-item {
margin-bottom: 15px;
border-radius: 5px;

View File

@ -5,6 +5,7 @@
{{/block}}
{{block 'main'}}
{{set weekName = '一二三四五六日'.split('')}}
<div class="calendar">
<div class="cal-bg for-calendar-mode">
<table class="cont-table" border-collapse="collapse">
@ -14,13 +15,26 @@
{{/each}}
</tr>
<tr class="tr thead">
{{each dateList d}}{{each d.date dn}}
<td class="td date {{dn === nowDate ? 'current-date':''}}">{{dn}}日</td>
{{each dateList d}}{{each d.date dn di}}
<td class="td date {{dn === nowDate ? 'current-date':''}}">
<span class="date-num">{{dn}}日</span>
<span class="date-week">周{{weekName[d.week[di]]}}</span>
</td>
{{/each}} {{/each}}
</tr>
<tr class="tr">
{{each dateList d}}{{each d.date dn}}
<td class="line {{dn === nowDate ? 'current-date':''}}"></td>
<td class="line {{dn === nowDate ? 'current-date':''}}">
{{each charBirth[`${d.month}-${dn}`] char}}
<div class="card">
<div class="item-icon star{{char.star}}">
<div class="img" style="background-image:url({{_res_path}}{{char.face}})"></div>
<span class="char-name">{{char.sName.length>=4?char.sName:`${char.sName}生日`}}</span>
</div>
</div>
{{char.name}}
{{/each}}
</td>
{{/each}} {{/each}}
</tr>
</table>
@ -35,7 +49,7 @@
</tr>
</table>
</div>
<div class="cal-list {{charMode}}">
<div class="cal-list {{charMode}} char-num-{{charNum}}">
<div class="cal-abyss-cont">
{{each abyss li}}
<div class="cal-item type-abyss" style="{{`left:${li.left}%;width:${li.width}%`}}">

View File

@ -75,21 +75,63 @@ body {
&.date {
width: 7.692%;
span {
display: block;
line-height: 18px;
}
span.date-num {
}
span.date-week {
line-height: 12px;
font-size: 12px;
color: #888;
}
&.current-date {
background: #d3bc8e;
border: 1px solid #d3bc8e;
color: #000;
span.date-week {
color: #000;
}
}
}
&.line {
background: rgba(0, 0, 0, 0.4);
vertical-align: top;
&.current-date {
background: rgba(211, 188, 142, .4)
}
}
}
.card {
width: 65px;
height: 76px;
margin: 8px auto -4px;
.img {
height: 60px;
}
.char-name {
position: absolute;
bottom: 0;
left: 0;
right: 0;
line-height: 17px;
font-size: 12px;
background: #e8e2d8;
}
}
}
.cal-list {
@ -97,6 +139,21 @@ body {
padding-top: 80px;
overflow: hidden;
&.char-num-0 {
padding-top: 80px;
}
&.char-num-1 {
padding-top: 160px;
}
&.char-num-2 {
padding-top: 240px;
}
&.char-num-3 {
padding-top: 320px;
}
.cal-item {
margin-bottom: 15px;

View File

@ -8,7 +8,7 @@ let costumes = {
刻晴: [204201], // 刻晴
凝光: [202701], // 凝光
迪卢克: [201601], // 迪卢克
菲谢尔: [203101], // 菲谢尔
菲谢尔: [203101] // 菲谢尔
}
const CharData = {