Commit cf9fd846 authored by Chunchi Che's avatar Chunchi Che

Merge branch 'feat/athletics' into 'main'

enable athletics match

See merge request mycard/Neos!333
parents 5eb16f3d 0b0587df
...@@ -9,7 +9,7 @@ export interface MatchInfo { ...@@ -9,7 +9,7 @@ export interface MatchInfo {
export async function match( export async function match(
username: string, username: string,
extraId: number, extraId: number,
arena: string = "entertain", arena: "athletic" | "entertain" = "entertain",
): Promise<MatchInfo | undefined> { ): Promise<MatchInfo | undefined> {
const headers = { const headers = {
Authorization: "Basic " + customBase64Encode(username + ":" + extraId), Authorization: "Basic " + customBase64Encode(username + ":" + extraId),
......
...@@ -36,20 +36,20 @@ export const Component: React.FC = () => { ...@@ -36,20 +36,20 @@ export const Component: React.FC = () => {
const user = accountStore.user; const user = accountStore.user;
const { joined } = useSnapshot(roomStore); const { joined } = useSnapshot(roomStore);
const [singleLoading, setSingleLoading] = useState(false); // 单人模式的loading状态 const [singleLoading, setSingleLoading] = useState(false); // 单人模式的loading状态
const [matchLoading, setMatchLoading] = useState(false); // 匹配模式的loading状态 const [athleticMatchLoading, setAthleticMatchLoading] = useState(false); // 竞技匹配的loading状态
const [entertainMatchLoading, setEntertainMatchLoading] = useState(false); // 娱乐匹配的loading状态
const [watchLoading, setWatchLoading] = useState(false); // 观战模式的loading状态 const [watchLoading, setWatchLoading] = useState(false); // 观战模式的loading状态
const navigate = useNavigate(); const navigate = useNavigate();
// 竞技匹配 // 匹配
const onCompetitiveMatch = () => message.error("暂未开放,敬请期待"); const onMatch = async (arena: "athletic" | "entertain") => {
// 娱乐匹配
const onEntertainMatch = async () => {
if (!user) { if (!user) {
message.error("请先登录萌卡账号"); message.error("请先登录萌卡账号");
} else { } else {
setMatchLoading(true); arena === "athletic"
const matchInfo = await match(user.username, user.external_id); ? setAthleticMatchLoading(true)
: setEntertainMatchLoading(true);
const matchInfo = await match(user.username, user.external_id, arena);
if (matchInfo) { if (matchInfo) {
await connectSrvpro({ await connectSrvpro({
...@@ -63,6 +63,12 @@ export const Component: React.FC = () => { ...@@ -63,6 +63,12 @@ export const Component: React.FC = () => {
} }
}; };
// 竞技匹配
const onCompetitiveMatch = async () => await onMatch("athletic");
// 娱乐匹配
const onEntertainMatch = async () => await onMatch("entertain");
// MC观战 // MC观战
const onMCWatch = () => { const onMCWatch = () => {
if (!user) { if (!user) {
...@@ -121,7 +127,8 @@ export const Component: React.FC = () => { ...@@ -121,7 +127,8 @@ export const Component: React.FC = () => {
useEffect(() => { useEffect(() => {
if (joined) { if (joined) {
setSingleLoading(false); setSingleLoading(false);
setMatchLoading(false); setAthleticMatchLoading(false);
setEntertainMatchLoading(false);
setWatchLoading(false); setWatchLoading(false);
navigate(`/waitroom`); navigate(`/waitroom`);
} }
...@@ -165,14 +172,20 @@ export const Component: React.FC = () => { ...@@ -165,14 +172,20 @@ export const Component: React.FC = () => {
<Mode <Mode
title="MC竞技匹配" title="MC竞技匹配"
desc="与MyCard天梯其他数万名玩家激战,力争最强。每月最后一天22点结算,公布排名并获取奖励。" desc="与MyCard天梯其他数万名玩家激战,力争最强。每月最后一天22点结算,公布排名并获取奖励。"
icon={<IconFont type="icon-battle" size={32} />} icon={
athleticMatchLoading ? (
<LoadingOutlined />
) : (
<IconFont type="icon-battle" size={32} />
)
}
onClick={onCompetitiveMatch} onClick={onCompetitiveMatch}
/> />
<Mode <Mode
title="MC娱乐匹配" title="MC娱乐匹配"
desc="暂且搁置胜负,享受决斗的乐趣。过去一周竞技匹配使用数最多的20个卡组将被禁用。" desc="暂且搁置胜负,享受决斗的乐趣。过去一周竞技匹配使用数最多的20个卡组将被禁用。"
icon={ icon={
matchLoading ? ( entertainMatchLoading ? (
<LoadingOutlined /> <LoadingOutlined />
) : ( ) : (
<IconFont type="icon-coffee" size={28} /> <IconFont type="icon-coffee" size={28} />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment