Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
TomyJan committed Jun 3, 2024
2 parents 9d99692 + aa68f6e commit f540191
Show file tree
Hide file tree
Showing 15 changed files with 298 additions and 45 deletions.
16 changes: 15 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
## [0.2.6-rel](https://github.com/TomyJan/Yunzai-Kuro-Plugin/compare/v0.2.5-rel...v0.2.6-rel) (2024-06-03)

### Bug Fixes

* 完善鸣潮卡片, 修改资源路径 ([f3d84ee](https://github.com/TomyJan/Yunzai-Kuro-Plugin/commit/f3d84ee3b6f74508f0423b3b7580b3734dec6959))


### Features

* 鸣潮抽卡分析展示是否up ([4cfefc6](https://github.com/TomyJan/Yunzai-Kuro-Plugin/commit/4cfefc63a98eb8b783aaa6d2a8a1a1aa58f78851))
* 优化鸣潮抽卡分析卡片[WIP] ([134877f](https://github.com/TomyJan/Yunzai-Kuro-Plugin/commit/134877f7cdb2c9c248a98703b45a2d76d9d852f5))



## [0.2.5-rel](https://github.com/TomyJan/Yunzai-Kuro-Plugin/compare/v0.2.4-rel...v0.2.5-rel) (2024-06-03)


### Bug Fixes

* 明朝抽卡记录增加更多判定词缀 ([3762e7c](https://github.com/TomyJan/Yunzai-Kuro-Plugin/commit/3762e7cba5df2622b4dc77a408729179d68b7a2e))
* 鸣潮抽卡记录增加更多判定词缀 ([b6a57f5](https://github.com/TomyJan/Yunzai-Kuro-Plugin/commit/b6a57f5293253f7db158be4605c4fa87190cffb9))
* 忘了写鸣潮签到获得的物品了 ([ee80c4c](https://github.com/TomyJan/Yunzai-Kuro-Plugin/commit/ee80c4cca5818a7cbb5d5ff7445ac0257afbca07))
* 修复鸣言误判 ([cd3ff73](https://github.com/TomyJan/Yunzai-Kuro-Plugin/commit/cd3ff73765241d1a886515665c1f544856027300))

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ git -C ./plugins/Yunzai-Kuro-Plugin/ pull

### 咕咕咕

- [ ] 完善鸣潮卡片
- [x] 完善鸣潮卡片

- [ ] 优化战双抽卡分析卡片样式
- [ ] 优化鸣潮抽卡分析卡片样式

- [ ] 游戏签到获得物品和特殊奖励的显示

Expand Down
20 changes: 20 additions & 0 deletions data/system/pluginConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,23 @@ export const mcGachaDataPath = dataPath + '/gachaData/mc'

// 其它信息
export const pluginThemeColor = chalk.rgb(57, 197, 187)

// 鸣潮历史 up 池时间和物品 id
export const mcGachaUpPools = [
{
// 1.0 上半
startTime: '1716429600', // 2024.05.23 10:00
endTime: '1717639200', // 2024.06.06 10:00
itemId: '1404',
itemName: '忌炎',
itemType: 1, // 1 为角色, 2 为武器
},
{
// 1.0 上半
startTime: '1716429600', // 2024.05.23 10:00
endTime: '1717639200', // 2024.06.06 10:00
itemId: '21010016',
itemName: '苍鳞千嶂',
itemType: 2,
},
]
84 changes: 82 additions & 2 deletions model/mcGachaCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import {
pluginVer,
resPath,
_ResPath,
mcGachaUpPools,
} from '../data/system/pluginConstants.js'
import mcGachaData from './mcGachaData.js'
import userConfig from './userConfig.js'
import kuroApi from './kuroApi.js'

export default class mcGachaCard {
constructor(e, gachaType) {
Expand All @@ -17,6 +19,7 @@ export default class mcGachaCard {
/** 获取抽卡记录卡片数据
* @param {object} e - 消息对象
* @param {number} gachaType - 抽卡类型
* @param {string} cardPoolName - 卡池名称
* @returns {object|string} - 抽卡记录卡片数据 json, 失败返回错误信息 str
*/
static async get(e, gachaType, cardPoolName) {
Expand All @@ -39,9 +42,13 @@ export default class mcGachaCard {
return `抽卡记录卡片数据获取失败: ${OriginGachaRecord}`
}

// 提取符合 gachaType 的记录
// 提取符合 gachaType 的记录, 顺便记录紫卡数量
let fourStarItemCount = 0
let gachaRecord = []
for (let i = 0; i < OriginGachaRecord.list.length; i++) {
if (OriginGachaRecord.list[i].rank_type == '4') {
fourStarItemCount++
}
if (OriginGachaRecord.list[i].gacha_type == gachaType.toString()) {
gachaRecord.push(OriginGachaRecord.list[i])
}
Expand All @@ -65,6 +72,7 @@ export default class mcGachaCard {
time: gachaRecord[i].time,
totalGachaTimes: i + 1,
thisCardCost: i - lastGoldIndex,
isUpItem: false,
})
lastGoldIndex = i
}
Expand All @@ -82,20 +90,92 @@ export default class mcGachaCard {
time: gachaRecord[i].time,
totalGachaTimes: i + 1,
thisCardCost: i - lastGoldIndex,
isUpItem: false,
})
}
}

// 遍历所有五星, 判断是否为 up 物品
for (let i = 0; i < goldCardRecord.length; i++) {
if (goldCardRecord[i].itemId === '-1') continue
for (let j = 0; j < mcGachaUpPools.length; j++) {
if (
// 注意时间需要转换为时间戳
goldCardRecord[i].itemId === mcGachaUpPools[j].itemId &&
new Date(goldCardRecord[i].time).getTime() >=
mcGachaUpPools[j].startTime * 1000 &&
new Date(goldCardRecord[i].time).getTime() <=
mcGachaUpPools[j].endTime * 1000
) {
goldCardRecord[i].isUpItem = true
break
}
}
}

// 再次倒序, 把新的记录放在最前面
goldCardRecord.reverse()

kuroLogger.debug('分析后的抽卡记录:', JSON.stringify(goldCardRecord))

// return JSON.stringify(goldCardRecord)
// 生成用户基本信息
// 计算每张金卡平均抽数
let everyGoldCost = 0
let goldCount = 0
if (goldCardRecord.length !== 0) {
let hasNoGold = false
for (let i = 0; i < goldCardRecord.length; i++) {
if (goldCardRecord[i].itemId == -1) {
// 排除未出金记录
hasNoGold = true
continue
}
goldCount++
everyGoldCost += goldCardRecord[i].thisCardCost
}
everyGoldCost =
Math.floor(
(everyGoldCost / (goldCardRecord.length - (hasNoGold ? 1 : 0))) * 100
) / 100
}
// 通过 API 获取用户昵称和头像
let gameName = '未获取'
let gameHeadUrl =
'https://prod-alicdn-community.kurobbs.com/game/mingchaoIcon.png'
let kuroapi = new kuroApi(e.user_id)
// 根据用户游戏 uid 获取库洛 id
let kuro_uid = (await user.getCurGameUidLocal(e.user_id, 3))?.inKuroUid
kuroLogger.debug(`用户 ${e.user_id} 的库洛 id: ${kuro_uid}`)
if (kuro_uid !== 0 && (await kuroapi.mineV2(kuro_uid)) !== `token 失效`) {
// 绑定了 token 且有效
let rsp_roleList = await kuroapi.roleList(kuro_uid, { gameId: 3 })
if (typeof rsp_roleList !== 'string' && rsp_roleList?.data?.length > 0) {
// 遍历 data 成员, 寻找 roleId 对应的 roleName
for (let i = 0; i < rsp_roleList.data.length; i++) {
if (rsp_roleList.data[i].roleId === OriginGachaRecord.info.uid) {
gameName = rsp_roleList.data[i].roleName
gameHeadUrl = rsp_roleList.data[i].gameHeadUrl
break
}
}
}
}
let userInfo = {
gameName,
gameUid: OriginGachaRecord.info.uid,
gameHeadUrl,
gacha: {
count: OriginGachaRecord.list.length,
goldCount,
everyGoldCost,
fourStarItemCount,
},
}

let ret = {
tplFile: `${resPath}/html/mcGachaRecord/index.html`,
goldCardRecord,
userInfo,
cardPoolName,
pluResPath: _ResPath,
pluginName,
Expand Down
23 changes: 23 additions & 0 deletions model/userConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,29 @@ export default class userConfig {
kuroLogger.debug(
`保存用户 ${qq} 使用的游戏 ${gameId} 的 uid ${uid} 和所在库洛 uid ${kuro_uid}...`
)
// 如果 kuro_uid 为 0, 则通过 api 遍历找出 uid
if (kuro_uid === 0) {
kuroLogger.debug(`库洛 uid 为 0, 尝试通过 api 遍历找出 uid...`)
let tokenData = await getToken(qq)
let kuroUidIndex = 0
let kuroUidToFetch = Object.keys(tokenData)[kuroUidIndex]
let kuroapi = new kuroApi(qq)
do {
let rsp_roleList = await kuroapi.roleList(kuroUidToFetch, { gameId })
if (typeof rsp_roleList !== 'string') {
if (rsp_roleList.data.length > 0) {
for (const role of rsp_roleList.data) {
if (role.roleId === uid) {
kuro_uid = kuroUidToFetch
kuroLogger.debug(`找到 uid: ${uid} 所在的库洛 uid: ${kuro_uid}`)
break
}
}
}
}
kuroUidToFetch = Object.keys(tokenData)[++kuroUidIndex]
} while (kuroUidIndex < Object.keys(tokenData).length)
}
try {
const qqData = { gameUid: uid, inKuroUid: kuro_uid }
const filePath = dataPath + `/userSetting/${qq}.json`
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Yunzai-Kuro-Plugin",
"version": "0.2.5-rel",
"version": "0.2.6-rel",
"author": "TomyJan",
"description": "Yunzai-Bot plugin for kuro games.",
"type": "module",
Expand Down
4 changes: 2 additions & 2 deletions resources/html/gameCardMc/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
body {
transform: scale(1);
width: 725px;
background: url(../../img/help/background/0.jpg) no-repeat;
background: url(../../img/common/bg/Alisa-Echo_0.jpg) no-repeat;
background-size: cover;
}

Expand Down Expand Up @@ -135,7 +135,7 @@ div {
.pns .game-box[data-v-08c4bfda] {
width: 662px;
height: 256px;
background: url(https://web-static.kurobbs.com/resource/prod/assets/game-box-pns-02781a5b.png);
background: url(../../img/common/bg/game-box-pns-02781a5b.png);
background-size: 100% 100%
}

Expand Down
8 changes: 4 additions & 4 deletions resources/html/gameCardMc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@
</div>
<div class="game-box-footer flex" data-v-08c4bfda>
<div class=item data-v-08c4bfda>
<span class=number data-v-08c4bfda>{{@item.roleScore}}</span>
<span class=title data-v-08c4bfda>角色总评分</span>
<span class=number data-v-08c4bfda>{{@item.achievementCount}}</span>
<span class=title data-v-08c4bfda>成就数量</span>
</div>
<div class=item data-v-08c4bfda>
<span class=number data-v-08c4bfda>{{@item.roleNum}}</span>
<span class=title data-v-08c4bfda>角色数量</span>
</div>
<div class=item data-v-08c4bfda>
<span class=number data-v-08c4bfda>{{@item.fashionCollectionPercent*1000/10}}%</span>
<span class=title data-v-08c4bfda>涂装收集率</span>
<span class=number data-v-08c4bfda>{{@item.phantomPercent*1000/10}}%</span>
<span class=title data-v-08c4bfda>声骸收集进度</span>
</div>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions resources/html/gameCardPns/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
body {
transform: scale(1);
width: 725px;
background: url(../../img/help/background/0.jpg) no-repeat;
background: url(../../img/common/bg/Alisa-Echo_0.jpg) no-repeat;
background-size: cover;
}

Expand Down Expand Up @@ -135,7 +135,7 @@ div {
.pns .game-box[data-v-08c4bfda] {
width: 662px;
height: 256px;
background: url(https://web-static.kurobbs.com/resource/prod/assets/game-box-pns-02781a5b.png);
background: url(../../img/common/bg/game-box-pns-02781a5b.png);
background-size: 100% 100%
}

Expand Down
2 changes: 1 addition & 1 deletion resources/html/help/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
body {
transform: scale(1);
width: 800px;
background: url(../../img/help/background/0.jpg) no-repeat;
background: url(../../img/common/bg/Alisa-Echo_0.jpg) no-repeat;
background-size:cover;
}

Expand Down
Loading

0 comments on commit f540191

Please sign in to comment.