Skip to content

Commit

Permalink
feat: 鸣潮卡片[WIP]
Browse files Browse the repository at this point in the history
  • Loading branch information
TomyJan committed May 30, 2024
1 parent d931236 commit 9f19053
Show file tree
Hide file tree
Showing 7 changed files with 381 additions and 9 deletions.
47 changes: 44 additions & 3 deletions apps/gameCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ export class gameCard extends plugin {
reg: '^#?战双(帕弥什)?(卡片|面板)(.*)$',
fnc: 'gameCardPns',
},
{
reg: '^#?鸣潮?(卡片|面板)(.*)$',
fnc: 'gameCardMc',
},
],
})
}
Expand All @@ -37,15 +41,15 @@ export class gameCard extends plugin {
let user = new userConfig()
if (await user.saveCurGameUidByIndex(this.e.user_id, index - 1, 2))
await this.reply(`已切换至第 ${index} 个账号, UID: ${(await user.getCurGameUidLocal(this.e.user_id, 2))?.gameUid}`)
else await this.reply(`切换账号失败`)
else await this.reply(`切换账号失败, 请检查索引是否正确`)
}
let data = await gameCardData.get(this.e, 'gameCardPns', this.e.user_id)
if (!data) return false
let img = await this.cache(data)
let img = await this.cachePns(data)
await this.reply(img)
}

async cache(data) {
async cachePns(data) {
let tmp = md5(JSON.stringify(data))
if (gameCard.pnsCardData.md5 === tmp) {
return gameCard.pnsCardData.img
Expand All @@ -61,4 +65,41 @@ export class gameCard extends plugin {
md5: '',
img: '',
}

async gameCardMc(e) {
kuroLogger.debug('鸣潮卡片:', e.msg)
// 提取消息文本末尾的数字
let index = this.e.msg
.replace(/鸣潮|卡片|面板|:|:/g, '')
.replace(/,|,/g, ',')
.replace(/#| /g, '')
kuroLogger.debug('鸣潮卡片索引:', index)
if (index) {
let user = new userConfig()
if (await user.saveCurGameUidByIndex(this.e.user_id, index - 1, 3))
await this.reply(`已切换至第 ${index} 个账号, UID: ${await user.getCurGameUidLocal(this.e.user_id, 3)?.gameUid}`)
else await this.reply(`切换账号失败, 请检查索引是否正确`)
}
let data = await gameCardData.get(this.e, 'gameCardMc', this.e.user_id)
if (!data) return false
let img = await this.cacheMc(data)
await this.reply(img)
}

async cacheMc(data) {
let tmp = md5(JSON.stringify(data))
if (gameCard.mcCardData.md5 === tmp) {
return gameCard.mcCardData.img
}

gameCard.mcCardData.img = await puppeteer.screenshot('gameCardMc', data)
gameCard.mcCardData.md5 = tmp

return gameCard.mcCardData.img
}

static mcCardData = {
md5: '',
img: '',
}
}
2 changes: 1 addition & 1 deletion model/bbsActivityTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default class bbsActivityTask {

async bbsActivityTask() {
const tokenData = await getToken(this.e.user_id)
console.log(tokenData)
kuroLogger.debug(`QQ ${this.e.user_id}tokenData: ${tokenData}`)

if (tokenData && Object.keys(tokenData).length > 0) {
const accNum = Object.keys(tokenData).length
Expand Down
7 changes: 5 additions & 2 deletions model/gameCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@ export default class gameCard {
const tokenData = await getToken(e.user_id)

if (tokenData && Object.keys(tokenData).length > 0) {
let gameId = 2
if (model === 'gameCardMc') gameId = 3

for (const kuro_uid in tokenData) {
if (tokenData.hasOwnProperty(kuro_uid)) {
let kuroapi = new kuroApi(e.user_id)
// 获取昵称
let rsp_mineV2 = await kuroapi.mineV2(kuro_uid)
let accName = rsp_mineV2?.data?.mine?.userName || '未知昵称'
accName += ` (${kuro_uid})`
let rsp_roleList = await kuroapi.roleList(kuro_uid, { gameId: 2 })
let rsp_roleList = await kuroapi.roleList(kuro_uid, { gameId })
let acc = { account: accName, msg: '', data: null }
if (typeof rsp_roleList !== 'string') {
if (rsp_roleList.data.length > 0) {
Expand All @@ -52,7 +55,7 @@ export default class gameCard {
let ret = {
tplFile: `${resPath}/html/${model}/index.html`,
accArr,
accCurPnsUidIndex: (await user.getCurGameUidIndex(e.user_id, 2)) + 1,
curGameUidIndex: (await user.getCurGameUidIndex(e.user_id, gameId)) + 1,
pluResPath: _ResPath,
pluginName,
pluginVer,
Expand Down
2 changes: 1 addition & 1 deletion model/userConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export default class userConfig {
* @param {number} uin QQ
* @param {number} uidIndex uid 索引
* @param {number} gameId 游戏 id, 战双=2, 鸣潮=3
* @returns {boolean} 是否成功
* @returns {boolean} 是否成功, 失败一般原因是索引不存在
*/
async saveCurGameUidByIndex(qq, uidIndex, gameId) {
kuroLogger.debug(`保存用户 ${qq} 使用的游戏 ${gameId} 的 uid 索引 ${uidIndex}...`)
Expand Down
259 changes: 259 additions & 0 deletions resources/html/gameCardMc/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,259 @@
@font-face {
font-family: "MiSans-Normal";
src: url("../../font/MiSans-Normal.ttf");
font-weight: normal;
font-style: normal;
}

@font-face {
font-family: "HYWenHei-55W";
src: url("../../font/HYWenHei-55W.ttf");
font-weight: normal;
font-style: normal;
}

* {
margin: 0;
padding: 0;
box-sizing: border-box;
user-select: none;
font-family: MiSans-Normal
}

body {
transform: scale(1);
width: 725px;
background: url(../../img/help/background/0.jpg) no-repeat;
background-size: cover;
}

.container {
width: 745px;
padding: 20px 15px 10px 15px;
}

.head-box {
margin: 60px 0 0 0;
padding-bottom: 0;
}

.head-box .title {
font-size: 50px;
font-family: HYWenHei-55W
}

.head-box .label {
font-family: HYWenHei-55W
}

.cont-box {
margin-top: 20px;
margin-bottom: 30px;
overflow: hidden;
position: relative;
font-size: 20px;
background: rgba(62, 62, 62, 0.3);

-webkit-backdrop-filter: blur(10px);
backdrop-filter: blur(10px);
border-radius: 30px;
}

.help-group {
font-size: 20px;
font-weight: bold;
padding: 15px 15px 10px 20px;
display: inline-block;
}

.list {
display: flex;

flex-wrap: wrap;
}



.mr-4 {
margin-right: 8px
}

.mr-12 {
margin-right: 24px;
}

.pd-16 {
padding: 32px
}

.mb-16 {
margin-bottom: 32px
}

div,
body {
box-sizing: border-box;
list-style: none;
margin: 0;
padding: 0
}

span,
div {
word-break: break-word;
vertical-align: middle
/*英文和中文竖直居中*/
}

.text-12 {
font-size: 24px;
line-height: 40px
}

.text-14 {
font-size: 28px;
line-height: 44px
}

.flex {
display: flex
}

.flex-vertical-center {
display: flex;
align-items: center
}

.game-box-container[data-v-08c4bfda] {
display: flex;
justify-content: center;
align-items: center;
width: 710px;
height: 304px
}

.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-size: 100% 100%
}

.game-box[data-v-08c4bfda] {
position: absolute;
font-size: 32px;
color: #fff;
flex: 1
}

.game-box-header .icon[data-v-08c4bfda] {
width: 80px;
height: 80px;
border-radius: 8px
}

.game-box-header .role-info[data-v-08c4bfda] {
flex: 1
}

.game-box-header .role-info .name[data-v-08c4bfda] {
font-weight: 700
}

.game-box-header .role-info .level[data-v-08c4bfda] {
height: 32px;
font-size: 24px;
line-height: 24px;
padding: 4px 8px;
color: #fff;
background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, .32) 100%);
border: .8px solid rgba(255, 255, 255, .5);
border-radius: 4px
}

.game-box-header .role-info .show[data-v-08c4bfda] {
margin-left: auto;
display: flex;
align-items: center;
}

.game-box-header .sub-info[data-v-08c4bfda] {
color: #aeb6c2;
font-weight: 400;
opacity: .5
}

.game-box-footer[data-v-08c4bfda] {

display: flex;
justify-content: space-between
}

.game-box-footer .item[data-v-08c4bfda] {
flex: 1;
font-size: 24px;
line-height: 40px;
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: flex-start;
color: #8c95a3
}

.game-box-footer .item .number[data-v-08c4bfda] {
display: flex;
align-items: center;
font-size: 32px;
line-height: 48px;
font-weight: 700;
color: #fff
}

.game-box-footer .item .title[data-v-08c4bfda] {
width: 100%;
color: #8c95a3;
font-weight: 400;
text-align: center
}

.game-box-footer .item .icon[data-v-08c4bfda] {
cursor: pointer
}

.better-checkbox:checked {
border: none;
background: #1673ff
}

.better-checkbox {
width: 32px;
height: 32px;
border: solid 3px #dddddd;
border-radius: 50%;
vertical-align: top;
margin-right: 8px;
position: relative;
appearance: none
}

.better-checkbox:checked::after {
content: '';
top: 9px;
left: 8px;
position: absolute;
background: transparent;
border: #fff solid 3px;
border-top: none;
border-right: none;
height: 8px;
width: 14px;
transform: rotate(-45deg)
}

.copyright {
text-align: center;
font-size: 14px;
color: white;
font-family: HYWenHei-55W
}
Loading

0 comments on commit 9f19053

Please sign in to comment.