mirror of
https://github.com/yoimiya-kokomi/miao-plugin.git
synced 2024-11-22 15:36:27 +00:00
#抽卡统计
支持常驻池
This commit is contained in:
parent
347280f1b4
commit
20a7c59a9b
@ -14,7 +14,7 @@ app.reg({
|
||||
stat: {
|
||||
name: '抽卡统计',
|
||||
fn: Gacha.stat,
|
||||
rule: /^#*(抽卡|抽奖|角色|武器|常驻|up|版本)池*统计$/
|
||||
rule: /^#*(全部|抽卡|抽奖|角色|武器|常驻|up|版本)池*统计$/
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -36,12 +36,23 @@ let Gacha = {
|
||||
}, { e, scale: 1.1, retMsgId: true })
|
||||
},
|
||||
async stat (e) {
|
||||
let msg = e.msg.replace(/#|统计|分析|池/g, '')
|
||||
let type = 'up'
|
||||
if (/武器/.test(msg)) {
|
||||
type = 'weapon'
|
||||
} else if (/角色/.test(msg)) {
|
||||
type = 'char'
|
||||
} else if (/常驻/.test(msg)) {
|
||||
type = 'normal'
|
||||
} else if (/全部/.test(msg)) {
|
||||
type = 'all'
|
||||
}
|
||||
let uid = e.uid || await getTargetUid(e)
|
||||
let qq = e.user_id
|
||||
if (!uid || !qq) {
|
||||
return false
|
||||
}
|
||||
let gacha = GachaData.stat(e.user_id, uid)
|
||||
let gacha = GachaData.stat(e.user_id, uid, type)
|
||||
await Common.render('gacha/gacha-stat', {
|
||||
save_id: uid,
|
||||
uid,
|
||||
|
@ -24,6 +24,8 @@ poolVersion.push({
|
||||
})
|
||||
|
||||
let GachaData = {
|
||||
|
||||
// 获取JSON数据
|
||||
readJSON (qq, uid, type) {
|
||||
let logJson = []
|
||||
// 获取本地数据 进行数据合并
|
||||
@ -36,20 +38,44 @@ let GachaData = {
|
||||
if (!nameMap[ds.name]) {
|
||||
if (ds.item_type === '武器') {
|
||||
let weapon = Weapon.get(ds.name)
|
||||
if (weapon) {
|
||||
nameMap[ds.name] = weapon.id
|
||||
itemMap[weapon.id] = {
|
||||
type: 'weapon',
|
||||
count: 0,
|
||||
...weapon.getData('star,name,abbr,img')
|
||||
}
|
||||
} else {
|
||||
nameMap[ds.name] = 403
|
||||
itemMap[403] = {
|
||||
type: 'weapon',
|
||||
count: 0,
|
||||
star: 3,
|
||||
name: '未知',
|
||||
abbr: '未知',
|
||||
img: ''
|
||||
}
|
||||
}
|
||||
} else if (ds.item_type === '角色') {
|
||||
let char = Character.get(ds.name)
|
||||
if (char) {
|
||||
nameMap[ds.name] = char.id
|
||||
itemMap[char.id] = {
|
||||
type: 'char',
|
||||
count: 0,
|
||||
...char.getData('star,name,abbr,img:face')
|
||||
}
|
||||
} else {
|
||||
nameMap[ds.name] = 404
|
||||
itemMap[404] = {
|
||||
type: 'char',
|
||||
count: 0,
|
||||
star: 4,
|
||||
name: '未知',
|
||||
abbr: '未知',
|
||||
img: ''
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
let id = nameMap[ds.name]
|
||||
@ -66,6 +92,7 @@ let GachaData = {
|
||||
items = items.sort((a, b) => b.time - a.time)
|
||||
return { items, itemMap }
|
||||
},
|
||||
|
||||
// 卡池分析
|
||||
analyse (qq, uid, type) {
|
||||
let logData = GachaData.readJSON(qq, uid, type)
|
||||
@ -207,12 +234,27 @@ let GachaData = {
|
||||
|
||||
// 卡池统计
|
||||
stat (qq, uid, type) {
|
||||
let charData = GachaData.readJSON(qq, uid, 301)
|
||||
let weaponData = GachaData.readJSON(qq, uid, 302)
|
||||
let items = []
|
||||
let itemMap = {}
|
||||
let hasVersion = true
|
||||
let loadData = function (poolId) {
|
||||
let gachaData = GachaData.readJSON(qq, uid, poolId)
|
||||
items = items.concat(gachaData.items)
|
||||
lodash.extend(itemMap, gachaData.itemMap || {})
|
||||
}
|
||||
console.log('gacha data', type)
|
||||
if (['up', 'char', 'all'].includes(type)) {
|
||||
loadData(301)
|
||||
}
|
||||
if (['up', 'weapon', 'all'].includes(type)) {
|
||||
loadData(302)
|
||||
}
|
||||
if (['all', 'normal'].includes(type)) {
|
||||
hasVersion = false
|
||||
loadData(200)
|
||||
}
|
||||
|
||||
let items = charData.items.concat(weaponData.items || [])
|
||||
items = items.sort((a, b) => b.time - a.time)
|
||||
let itemMap = lodash.extend({}, charData.itemMap, weaponData.itemMap)
|
||||
|
||||
let versionData = []
|
||||
let currVersion
|
||||
@ -223,8 +265,8 @@ let GachaData = {
|
||||
let temp = {
|
||||
version: cv.version,
|
||||
half: cv.half,
|
||||
from: moment(new Date(cv.from)).format('YY-MM-DD'),
|
||||
to: moment(new Date(cv.to)).format('YY-MM-DD'),
|
||||
from: hasVersion ? moment(new Date(cv.from)).format('YY-MM-DD') : '',
|
||||
to: hasVersion ? moment(new Date(cv.to)).format('YY-MM-DD') : '',
|
||||
upIds: {}
|
||||
}
|
||||
let upName = {}
|
||||
@ -290,11 +332,14 @@ let GachaData = {
|
||||
}
|
||||
|
||||
lodash.forEach(items, (ds) => {
|
||||
if (!currVersion || ds.time < currVersion.start) {
|
||||
if (!currVersion || (ds.time < currVersion.start && hasVersion)) {
|
||||
if (currVersion) {
|
||||
versionData.push(getCurr())
|
||||
}
|
||||
let v = GachaData.getVersion(ds.time)
|
||||
let v = GachaData.getVersion(ds.time, hasVersion)
|
||||
if (!hasVersion) {
|
||||
v.version = type === 'all' ? '全部统计' : '常驻池'
|
||||
}
|
||||
if (!v) {
|
||||
console.log('no v')
|
||||
return true
|
||||
@ -318,13 +363,22 @@ let GachaData = {
|
||||
}
|
||||
},
|
||||
|
||||
getVersion (time) {
|
||||
getVersion (time, hasVersion = true) {
|
||||
if (hasVersion) {
|
||||
for (let ds of poolVersion) {
|
||||
if (time > ds.start && time < ds.end) {
|
||||
return ds
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
return {
|
||||
version: hasVersion === false ? '全部' : '未知',
|
||||
half: '',
|
||||
char5: [],
|
||||
char4: [],
|
||||
weapon5: [],
|
||||
weapon4: []
|
||||
}
|
||||
},
|
||||
|
||||
getItem (ds) {
|
||||
|
@ -38,6 +38,10 @@
|
||||
font-weight: bold;
|
||||
text-align: right;
|
||||
}
|
||||
.gacha-pool .version-name.all-version {
|
||||
width: 130px;
|
||||
text-align: center;
|
||||
}
|
||||
.gacha-pool .pool-name {
|
||||
width: 125px;
|
||||
text-align: left;
|
||||
|
@ -45,6 +45,7 @@
|
||||
<div class="cont-title">
|
||||
<div class="gacha-pool">
|
||||
<div class="version">
|
||||
{{if vData.from}}
|
||||
<div class="version-name line">
|
||||
{{vData.version}}{{vData.half}}
|
||||
</div>
|
||||
@ -52,6 +53,9 @@
|
||||
<div class="name">{{vData.name}}</div>
|
||||
<div class="time">{{vData.from}}~{{vData.to}}</div>
|
||||
</div>
|
||||
{{else}}
|
||||
<div class="version-name all-version"> {{vData.version}}</div>
|
||||
{{/if}}
|
||||
</div>
|
||||
<div class="stat-info">
|
||||
{{set keyMap = {totalNum:'总抽卡',star5Num:'金卡',upNum:'UP金卡', c4Num:'紫角色', w4Num:'紫武器'} }}
|
||||
|
@ -42,6 +42,11 @@
|
||||
font-size: 20px;
|
||||
font-weight: bold;
|
||||
text-align: right;
|
||||
|
||||
&.all-version {
|
||||
width: 130px;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
.pool-name {
|
||||
|
Loading…
Reference in New Issue
Block a user