Commit 0b0587df authored by Chunchi Che's avatar Chunchi Che

enable athletics match

parent 5eb16f3d
Pipeline #24103 passed with stages
in 15 minutes and 22 seconds
......@@ -9,7 +9,7 @@ export interface MatchInfo {
export async function match(
username: string,
extraId: number,
arena: string = "entertain",
arena: "athletic" | "entertain" = "entertain",
): Promise<MatchInfo | undefined> {
const headers = {
Authorization: "Basic " + customBase64Encode(username + ":" + extraId),
......
......@@ -36,20 +36,20 @@ export const Component: React.FC = () => {
const user = accountStore.user;
const { joined } = useSnapshot(roomStore);
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 navigate = useNavigate();
// 竞技匹配
const onCompetitiveMatch = () => message.error("暂未开放,敬请期待");
// 娱乐匹配
const onEntertainMatch = async () => {
// 匹配
const onMatch = async (arena: "athletic" | "entertain") => {
if (!user) {
message.error("请先登录萌卡账号");
} else {
setMatchLoading(true);
const matchInfo = await match(user.username, user.external_id);
arena === "athletic"
? setAthleticMatchLoading(true)
: setEntertainMatchLoading(true);
const matchInfo = await match(user.username, user.external_id, arena);
if (matchInfo) {
await connectSrvpro({
......@@ -63,6 +63,12 @@ export const Component: React.FC = () => {
}
};
// 竞技匹配
const onCompetitiveMatch = async () => await onMatch("athletic");
// 娱乐匹配
const onEntertainMatch = async () => await onMatch("entertain");
// MC观战
const onMCWatch = () => {
if (!user) {
......@@ -121,7 +127,8 @@ export const Component: React.FC = () => {
useEffect(() => {
if (joined) {
setSingleLoading(false);
setMatchLoading(false);
setAthleticMatchLoading(false);
setEntertainMatchLoading(false);
setWatchLoading(false);
navigate(`/waitroom`);
}
......@@ -165,14 +172,20 @@ export const Component: React.FC = () => {
<Mode
title="MC竞技匹配"
desc="与MyCard天梯其他数万名玩家激战,力争最强。每月最后一天22点结算,公布排名并获取奖励。"
icon={<IconFont type="icon-battle" size={32} />}
icon={
athleticMatchLoading ? (
<LoadingOutlined />
) : (
<IconFont type="icon-battle" size={32} />
)
}
onClick={onCompetitiveMatch}
/>
<Mode
title="MC娱乐匹配"
desc="暂且搁置胜负,享受决斗的乐趣。过去一周竞技匹配使用数最多的20个卡组将被禁用。"
icon={
matchLoading ? (
entertainMatchLoading ? (
<LoadingOutlined />
) : (
<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