角色图鉴增加角色持有率及命座分布展示

This commit is contained in:
yoimiya-kokomi 2022-09-06 03:02:06 +08:00
parent ac418b012a
commit f9e5240ecc
8 changed files with 258 additions and 13 deletions

View File

@ -81,6 +81,24 @@ export async function wiki (e) {
async function renderWiki ({ e, char }) {
let data = char.getData()
lodash.extend(data, char.getData('weaponType,elemName'))
// 命座持有
let consData = (await HutaoApi.getCons()).data || {}
consData = lodash.find(consData, (ds) => ds.avatar === char.id)
let holding = {}
if (consData) {
let { holdingRate, rate } = consData
rate = lodash.sortBy(rate, 'id')
holding.num = Format.percent(holdingRate)
holding.cons = []
lodash.forEach(rate, (ds) => {
holding.cons.push({
cons: ds.id,
num: Format.percent(ds.value)
})
})
}
// 武器使用
let wu = (await HutaoApi.getWeaponUsage()).data || {}
let weapons = []
if (wu[char.id]) {
@ -99,6 +117,7 @@ async function renderWiki ({ e, char }) {
detail: char.getDetail(),
imgs: char.getImgs(),
weapons,
holding,
materials: char.getMaterials(),
elem: char.elem
}, { e, scale: 1.4 })

View File

@ -58,8 +58,17 @@ let Profile = {
if (fs.existsSync(userFile)) {
userData = JSON.parse(fs.readFileSync(userFile, 'utf8')) || {}
}
if (userData && userData.chars && userData.chars[charId]) {
return userData.chars[charId]
if (userData && userData.chars) {
let char = Character.get(charId)
if (char.isTraveler) {
let charData = userData.chars['10000005'] || userData.chars['10000007'] || false
if (charData) {
char.checkAvatars(charData, uid)
}
return charData
} else {
return userData.chars[charId]
}
}
return false
},

View File

@ -17,7 +17,7 @@ class Character extends Base {
return cacheObj
}
// 设置数据
this.id = id
this._id = id
this.name = name
if (!this.isCustom) {
let meta = getMeta(name)
@ -37,7 +37,11 @@ class Character extends Base {
// 是否为自定义角色
get isCustom () {
return !/[12]0\d{6}/.test(this.id)
return !/[12]0\d{6}/.test(this._id)
}
get id () {
return this.isCustom ? this._id : this._id * 1
}
// 是否是旅行者

View File

@ -281,6 +281,11 @@ body {
margin-left: 10px;
font-weight: normal;
}
.cont-title.border-less {
background: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0));
box-shadow: none;
padding-bottom: 5px;
}
.cont-body {
padding: 10px 15px;
font-size: 12px;

View File

@ -200,13 +200,19 @@ each(@elems, {
padding: 10px 20px;
text-align: left;
border-radius: 10px 10px 0 0;
}
.cont-title span {
font-size: 12px;
color: #aaa;
margin-left: 10px;
font-weight: normal;
span {
font-size: 12px;
color: #aaa;
margin-left: 10px;
font-weight: normal;
}
&.border-less {
background: linear-gradient(rgba(0, 0, 0, .5), rgba(0, 0, 0, 0));
box-shadow: none;
padding-bottom: 5px;
}
}
.cont-body {

View File

@ -102,6 +102,20 @@ body {
transform: scale(0.7);
text-shadow: 0 0 2px #000;
}
.talent-notice {
color: #fff;
font-size: 13px;
text-align: center;
padding: 3px;
text-shadow: 0 0 1px #000, 1px 1px 2px #000;
}
.talent-notice strong {
color: #d3bc8e;
font-weight: normal;
}
.cont .cont-title.border-less {
padding: 10px 10px 3px;
}
.talent-cont {
text-align: center;
}
@ -114,4 +128,70 @@ body {
.weapon-list .item {
margin: 3px;
}
.char-holding {
display: flex;
padding: 8px;
}
.char-holding .cons-title {
height: 15px;
line-height: 15px;
font-size: 13px;
color: #d3bc8e;
text-shadow: 0 0 2px #000;
}
.char-pct {
width: 125px;
margin-right: 10px;
text-align: center;
position: relative;
}
.char-pct strong {
margin-top: 10px;
display: block;
height: 60px;
line-height: 60px;
font-size: 30px;
text-shadow: 0 0 1px #000, 1px 1px 3px #000;
}
.char-pct span {
display: block;
font-size: 13px;
color: #d3bc8e;
height: 15px;
line-height: 15px;
}
.char-pct:after {
content: "";
display: block;
width: 1px;
height: 50px;
position: absolute;
right: 1px;
top: 30px;
background: rgba(255, 255, 255, 0.8);
transform: scaleX(0.7);
}
.char-cons {
position: initial;
width: initial;
}
.char-cons .cons0 .talent-icon {
opacity: 0.3;
}
.char-cons .cons-item {
width: 60px;
text-align: center;
}
.char-cons .cons-item .talent-icon {
width: 60px;
height: 60px;
margin: 0 auto;
}
.char-cons .cons-num {
margin-top: -5px;
height: 25px;
line-height: 25px;
font-size: 16px;
text-shadow: 0 0 1px #000, 1px 1px 3px #000;
}
/*# sourceMappingURL=character-wiki.css.map */

View File

@ -54,12 +54,36 @@
{{/each}}
</div>
</div>
<div class="cont talent-cont">
<div class="cont-footer">输入<strong>#{{data.abbr}}天赋、#{{data.abbr}}命座</strong>可查看详细天赋/命座信息</div>
<div class="talent-notice">输入<strong>#{{data.abbr}}天赋、#{{data.abbr}}命座</strong>可查看详细天赋/命座信息</div>
{{if holding.num}}
{{set cNum ='零一二三四五满'.split('')}}
<div class="cont cont-bg">
<div class="char-holding">
<div class="char-pct">
<strong>{{holding.num}}</strong>
<div class="cons-title">角色持有率</div>
</div>
<div class="char-cons">
{{each holding.cons cons}}
<div class="cons-item cons{{cons.cons}}">
<div class="talent-icon">
{{if cons.cons > 0}}
<div class="talent-icon-img" style="background-image:url({{_res_path}}{{imgs[`cons${cons.cons}`]}})"></div>
{{/if}}
</div>
<div class="cons-num">{{cons.num}}</div>
<div class="cons-title">{{cNum[cons.cons]}}命</div>
</div>
{{/each}}
</div>
</div>
</div>
{{/if}}
{{if weapons.length >0}}
<div class="cont">
<div class="cont-title">常用武器<span>武器统计来自胡桃Api</span></div>
<div class="cont-title border-less">常用武器<span>武器统计来自胡桃Api</span></div>
<div class="item-list weapon-list">
{{each weapons weapon}}
<div class="item item-card">

View File

@ -134,6 +134,23 @@ body {
}
}
.talent-notice {
color: #fff;
font-size: 13px;
text-align: center;
padding: 3px;
text-shadow: 0 0 1px #000, 1px 1px 2px #000;
strong {
color: #d3bc8e;
font-weight: normal;
}
}
.cont .cont-title.border-less {
padding: 10px 10px 3px;
}
.talent-cont {
text-align: center;
@ -149,3 +166,84 @@ body {
margin: 3px;
}
}
.char-holding {
display: flex;
padding: 8px;
.cons-title {
height: 15px;
line-height: 15px;
font-size: 13px;
color: #d3bc8e;
text-shadow: 0 0 2px #000;
}
}
.char-pct {
width: 125px;
margin-right: 10px;
text-align: center;
position: relative;
strong {
margin-top: 10px;
display: block;
height: 60px;
line-height: 60px;
font-size: 30px;
text-shadow: 0 0 1px #000, 1px 1px 3px #000;
}
span {
display: block;
font-size: 13px;
color: #d3bc8e;
height: 15px;
line-height: 15px;
}
&:after {
content: "";
display: block;
width: 1px;
height: 50px;
position: absolute;
right: 1px;
top: 30px;
background: rgba(255, 255, 255, .8);
transform: scaleX(.7);
}
}
.char-cons {
position: initial;
width: initial;
.cons0 {
.talent-icon {
opacity: .3;
}
}
.cons-item {
width: 60px;
text-align: center;
.talent-icon {
width: 60px;
height: 60px;
margin: 0 auto;
}
}
.cons-num {
margin-top: -5px;
height: 25px;
line-height: 25px;
font-size: 16px;
text-shadow: 0 0 1px #000, 1px 1px 3px #000;
}
}