Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
N
Neos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
love_飞影
Neos
Commits
0bb9debe
Commit
0bb9debe
authored
Mar 10, 2024
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rerange some code
parent
1b0f132d
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
66 additions
and
52 deletions
+66
-52
src/api/mycard/index.ts
src/api/mycard/index.ts
+2
-0
src/api/mycard/options.ts
src/api/mycard/options.ts
+16
-0
src/api/mycard/room.ts
src/api/mycard/room.ts
+41
-0
src/ui/Match/WatchContent.tsx
src/ui/Match/WatchContent.tsx
+1
-23
src/ui/Match/index.tsx
src/ui/Match/index.tsx
+6
-3
src/ui/Match/util.ts
src/ui/Match/util.ts
+0
-26
No files found.
src/api/mycard/index.ts
View file @
0bb9debe
// Collection of APIs provided by MyCard
// Collection of APIs provided by MyCard
export
*
from
"
./account
"
;
export
*
from
"
./account
"
;
export
*
from
"
./match
"
;
export
*
from
"
./match
"
;
export
*
from
"
./options
"
;
export
*
from
"
./room
"
;
export
*
from
"
./user
"
;
export
*
from
"
./user
"
;
src/api/mycard/options.ts
0 → 100644
View file @
0bb9debe
/* MC服房间的选项 */
export
interface
Options
{
mode
:
number
;
rule
:
number
;
start_lp
:
number
;
start_lp_tag
:
number
;
start_hand
:
number
;
draw_count
:
number
;
duel_rule
:
number
;
no_check_deck
:
boolean
;
no_shuffle_deck
:
boolean
;
lflist
?:
number
;
time_limit
?:
number
;
auto_death
:
boolean
;
}
src/api/mycard/room.ts
0 → 100644
View file @
0bb9debe
/* 一些MC服创建/加入房间相关的通用函数 */
import
{
Options
}
from
"
./options
"
;
export
interface
Room
{
id
?:
string
;
title
?:
string
;
users
?:
{
username
:
string
;
position
:
number
;
avatar
?:
string
}[];
options
:
Options
;
}
// 通过房间ID和external_id加密得出房间密码
//
// 用于加入MC服房间
export
function
getEncryptedPasswd
(
roomID
:
string
,
external_id
:
number
,
):
string
{
const
optionsBuffer
=
new
Uint8Array
(
6
);
optionsBuffer
[
1
]
=
3
<<
4
;
let
checksum
=
0
;
for
(
let
i
=
1
;
i
<
optionsBuffer
.
length
;
i
++
)
{
checksum
-=
optionsBuffer
[
i
];
}
optionsBuffer
[
0
]
=
checksum
&
0xff
;
const
secret
=
(
external_id
%
65535
)
+
1
;
for
(
let
i
=
0
;
i
<
optionsBuffer
.
length
;
i
+=
2
)
{
const
value
=
(
optionsBuffer
[
i
+
1
]
<<
8
)
|
optionsBuffer
[
i
];
const
xorResult
=
value
^
secret
;
optionsBuffer
[
i
+
1
]
=
(
xorResult
>>
8
)
&
0xff
;
optionsBuffer
[
i
]
=
xorResult
&
0xff
;
}
const
base64String
=
btoa
(
String
.
fromCharCode
(...
optionsBuffer
));
return
base64String
+
roomID
;
}
src/ui/Match/WatchContent.tsx
View file @
0bb9debe
...
@@ -5,7 +5,7 @@ import React, { useState } from "react";
...
@@ -5,7 +5,7 @@ import React, { useState } from "react";
import
useWebSocket
,
{
ReadyState
}
from
"
react-use-websocket
"
;
import
useWebSocket
,
{
ReadyState
}
from
"
react-use-websocket
"
;
import
{
proxy
,
useSnapshot
}
from
"
valtio
"
;
import
{
proxy
,
useSnapshot
}
from
"
valtio
"
;
import
{
getUserInfo
}
from
"
@/api
"
;
import
{
getUserInfo
,
Room
}
from
"
@/api
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
ScrollableArea
}
from
"
../Shared
"
;
import
{
ScrollableArea
}
from
"
../Shared
"
;
...
@@ -18,28 +18,6 @@ interface Info {
...
@@ -18,28 +18,6 @@ interface Info {
data
:
Room
|
Room
[]
|
string
;
data
:
Room
|
Room
[]
|
string
;
}
}
interface
Room
{
id
?:
string
;
title
?:
string
;
users
?:
{
username
:
string
;
position
:
number
;
avatar
?:
string
}[];
options
:
Options
;
}
interface
Options
{
mode
:
number
;
rule
:
number
;
start_lp
:
number
;
start_lp_tag
:
number
;
start_hand
:
number
;
draw_count
:
number
;
duel_rule
:
number
;
no_check_deck
:
boolean
;
no_shuffle_deck
:
boolean
;
lflist
?:
number
;
time_limit
?:
number
;
auto_death
:
boolean
;
}
export
const
watchStore
=
proxy
<
{
watchID
:
string
|
undefined
}
>
({
export
const
watchStore
=
proxy
<
{
watchID
:
string
|
undefined
}
>
({
watchID
:
undefined
,
watchID
:
undefined
,
});
});
...
...
src/ui/Match/index.tsx
View file @
0bb9debe
...
@@ -9,7 +9,7 @@ import { useEffect, useState } from "react";
...
@@ -9,7 +9,7 @@ import { useEffect, useState } from "react";
import
{
LoaderFunction
,
useNavigate
}
from
"
react-router-dom
"
;
import
{
LoaderFunction
,
useNavigate
}
from
"
react-router-dom
"
;
import
{
useSnapshot
}
from
"
valtio
"
;
import
{
useSnapshot
}
from
"
valtio
"
;
import
{
match
}
from
"
@/api
"
;
import
{
getEncryptedPasswd
,
match
}
from
"
@/api
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
accountStore
,
deckStore
,
resetUniverse
,
roomStore
}
from
"
@/stores
"
;
import
{
accountStore
,
deckStore
,
resetUniverse
,
roomStore
}
from
"
@/stores
"
;
import
{
Background
,
IconFont
,
Select
}
from
"
@/ui/Shared
"
;
import
{
Background
,
IconFont
,
Select
}
from
"
@/ui/Shared
"
;
...
@@ -17,7 +17,7 @@ import { Background, IconFont, Select } from "@/ui/Shared";
...
@@ -17,7 +17,7 @@ import { Background, IconFont, Select } from "@/ui/Shared";
import
styles
from
"
./index.module.scss
"
;
import
styles
from
"
./index.module.scss
"
;
import
{
MatchModal
,
matchStore
}
from
"
./MatchModal
"
;
import
{
MatchModal
,
matchStore
}
from
"
./MatchModal
"
;
import
{
ReplayModal
,
replayOpen
}
from
"
./ReplayModal
"
;
import
{
ReplayModal
,
replayOpen
}
from
"
./ReplayModal
"
;
import
{
connectSrvpro
,
getEncryptedPasswd
}
from
"
./util
"
;
import
{
connectSrvpro
}
from
"
./util
"
;
import
{
WatchContent
,
watchStore
}
from
"
./WatchContent
"
;
import
{
WatchContent
,
watchStore
}
from
"
./WatchContent
"
;
const
{
servers
:
serverList
}
=
useConfig
();
const
{
servers
:
serverList
}
=
useConfig
();
...
@@ -87,7 +87,10 @@ export const Component: React.FC = () => {
...
@@ -87,7 +87,10 @@ export const Component: React.FC = () => {
(
server
)
=>
server
.
name
===
"
mycard-athletic
"
,
(
server
)
=>
server
.
name
===
"
mycard-athletic
"
,
);
);
if
(
mcServer
)
{
if
(
mcServer
)
{
const
passWd
=
getEncryptedPasswd
(
watchStore
.
watchID
,
user
);
const
passWd
=
getEncryptedPasswd
(
watchStore
.
watchID
,
user
.
external_id
,
);
await
connectSrvpro
({
await
connectSrvpro
({
ip
:
mcServer
.
ip
+
"
:
"
+
mcServer
.
port
,
ip
:
mcServer
.
ip
+
"
:
"
+
mcServer
.
port
,
player
:
user
.
username
,
player
:
user
.
username
,
...
...
src/ui/Match/util.ts
View file @
0bb9debe
...
@@ -4,7 +4,6 @@ import { initStrings } from "@/api";
...
@@ -4,7 +4,6 @@ import { initStrings } from "@/api";
import
{
useConfig
}
from
"
@/config
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
socketMiddleWare
,
{
socketCmd
}
from
"
@/middleware/socket
"
;
import
socketMiddleWare
,
{
socketCmd
}
from
"
@/middleware/socket
"
;
import
sqliteMiddleWare
,
{
sqliteCmd
}
from
"
@/middleware/sqlite
"
;
import
sqliteMiddleWare
,
{
sqliteCmd
}
from
"
@/middleware/sqlite
"
;
import
{
User
}
from
"
@/stores
"
;
const
NeosConfig
=
useConfig
();
const
NeosConfig
=
useConfig
();
...
@@ -53,28 +52,3 @@ export const connectSrvpro = async (params: {
...
@@ -53,28 +52,3 @@ export const connectSrvpro = async (params: {
});
});
}
}
};
};
export
function
getEncryptedPasswd
(
roomID
:
string
,
user
:
User
):
string
{
const
optionsBuffer
=
new
Uint8Array
(
6
);
optionsBuffer
[
1
]
=
3
<<
4
;
let
checksum
=
0
;
for
(
let
i
=
1
;
i
<
optionsBuffer
.
length
;
i
++
)
{
checksum
-=
optionsBuffer
[
i
];
}
optionsBuffer
[
0
]
=
checksum
&
0xff
;
const
secret
=
(
user
.
external_id
%
65535
)
+
1
;
for
(
let
i
=
0
;
i
<
optionsBuffer
.
length
;
i
+=
2
)
{
const
value
=
(
optionsBuffer
[
i
+
1
]
<<
8
)
|
optionsBuffer
[
i
];
const
xorResult
=
value
^
secret
;
optionsBuffer
[
i
+
1
]
=
(
xorResult
>>
8
)
&
0xff
;
optionsBuffer
[
i
]
=
xorResult
&
0xff
;
}
const
base64String
=
btoa
(
String
.
fromCharCode
(...
optionsBuffer
));
return
base64String
+
roomID
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment