Commit b077b9f2 authored by Chunchi Che's avatar Chunchi Che

add mora v2

parent 12f150aa
Pipeline #20109 passed with stages
in 5 minutes and 51 seconds
.mora_container {
display: flex;
margin: auto;
padding: 0;
}
.item {
text-align: center;
flex: 1;
margin: auto;
padding: 10%;
}
.wait_container {
display: flex;
margin: auto;
padding: 0;
}
.playerRegion {
text-align: center;
flex: 1;
margin: auto;
padding: 10%;
}
.roomRegion {
flex: 1;
margin: auto;
padding: 10%;
}
.roomRegion > p {
text-align: start;
}
...@@ -52,9 +52,7 @@ url("https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.1/css/all.min.css") ...@@ -52,9 +52,7 @@ url("https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.1/css/all.min.css")
"commom", "commom",
"header", "header",
"login-form", "login-form",
"sign-in", "sign-in";
"wait-room",
"mora";
* { * {
......
/*
* 猜拳页面
*
* */
import React from "react"; import React from "react";
import { sendHandResult, sendTpResult } from "../api/ocgcore/ocgHelper"; import { sendHandResult, sendTpResult } from "../api/ocgcore/ocgHelper";
import { useAppSelector } from "../hook"; import { useAppSelector } from "../hook";
...@@ -12,23 +7,17 @@ import { ...@@ -12,23 +7,17 @@ import {
selectTpSelectAble, selectTpSelectAble,
unSelectTpAble, unSelectTpAble,
} from "../reducers/moraSlice"; } from "../reducers/moraSlice";
import { selectPlayer0, selectPlayer1 } from "../reducers/playerSlice";
import { selectDuelHsStart } from "../reducers/duel/mod"; import { selectDuelHsStart } from "../reducers/duel/mod";
import { store } from "../store"; import { store } from "../store";
import { useEffect } from "react"; import { useEffect } from "react";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import { Button } from "antd"; import { Button, Modal } from "antd";
import "../styles/core.scss";
// TODO: 应该展示聊天信息 const Mora = () => {
export default function Mora() {
const dispatch = store.dispatch; const dispatch = store.dispatch;
const selectHandAble = useAppSelector(selectHandSelectAble); const selectHandAble = useAppSelector(selectHandSelectAble);
const selectTpAble = useAppSelector(selectTpSelectAble); const selectTpAble = useAppSelector(selectTpSelectAble);
const player0 = useAppSelector(selectPlayer0);
const player1 = useAppSelector(selectPlayer1);
const duelHsStart = useAppSelector(selectDuelHsStart); const duelHsStart = useAppSelector(selectDuelHsStart);
const navigate = useNavigate(); const navigate = useNavigate();
useEffect(() => { useEffect(() => {
...@@ -38,58 +27,63 @@ export default function Mora() { ...@@ -38,58 +27,63 @@ export default function Mora() {
} }
}, [duelHsStart]); }, [duelHsStart]);
const handleSelectScissors = () => { const handleSelectMora = (selected: string) => {
sendHandResult("scissors"); sendHandResult(selected);
dispatch(unSelectHandAble()); dispatch(unSelectHandAble());
}; };
const handleSelectRock = () => { const handleSelectTp = (isFirst: boolean) => {
sendHandResult("rock"); sendTpResult(isFirst);
dispatch(unSelectHandAble());
};
const handleSelectPaper = () => {
sendHandResult("paper");
dispatch(unSelectHandAble());
};
const handleSelectFirst = () => {
sendTpResult(true);
dispatch(unSelectTpAble());
};
const handleSelectSecond = () => {
sendTpResult(false);
dispatch(unSelectTpAble()); dispatch(unSelectTpAble());
}; };
return ( return (
<div className="mora_container"> <>
<div className="item"> <Modal open={selectHandAble} footer={<></>}>
<Button disabled={!selectHandAble} onClick={handleSelectScissors}> <Button
scissors disabled={!selectHandAble}
onClick={() => {
handleSelectMora("scissors");
}}
>
剪刀
</Button> </Button>
<Button disabled={!selectHandAble} onClick={handleSelectRock}> <Button
rock disabled={!selectHandAble}
onClick={() => {
handleSelectMora("rock");
}}
>
石头
</Button> </Button>
<Button disabled={!selectHandAble} onClick={handleSelectPaper}> <Button
paper disabled={!selectHandAble}
onClick={() => {
handleSelectMora("paper");
}}
>
</Button> </Button>
</div> </Modal>
<div className="item"> <Modal open={!selectHandAble && selectTpAble} footer={<></>}>
<Button disabled={!selectTpAble} onClick={handleSelectFirst}> <Button
first disabled={!selectTpAble}
onClick={() => {
handleSelectTp(true);
}}
>
先攻
</Button> </Button>
<Button disabled={!selectTpAble} onClick={handleSelectSecond}> <Button
second disabled={!selectTpAble}
onClick={() => {
handleSelectTp(false);
}}
>
后攻
</Button> </Button>
</div> </Modal>
<div className="item"> </>
<p>
Me: main={player0.deckInfo?.mainCnt}, extra=
{player0.deckInfo?.extraCnt}, side={player0.deckInfo?.sideCnt}
</p>
<p>
Me: main={player1.deckInfo?.mainCnt}, extra=
{player1.deckInfo?.extraCnt}, side={player1.deckInfo?.sideCnt}
</p>
</div>
</div>
); );
} };
export default Mora;
import React from "react"; import React from "react";
import JoinRoom from "./JoinRoom"; import JoinRoom from "./JoinRoom";
import WaitRoomV2 from "./WaitRoom"; import WaitRoomV2 from "./WaitRoom";
import MoraV2 from "./Mora";
import { Routes, Route } from "react-router-dom"; import { Routes, Route } from "react-router-dom";
import Mora from "./Mora";
import NeosDuel from "./Duel/main"; import NeosDuel from "./Duel/main";
export default function () { export default function () {
...@@ -11,7 +11,7 @@ export default function () { ...@@ -11,7 +11,7 @@ export default function () {
<Routes> <Routes>
<Route path="/" element={<JoinRoom />} /> <Route path="/" element={<JoinRoom />} />
<Route path="/:player/:passWd/:ip" element={<WaitRoomV2 />} /> <Route path="/:player/:passWd/:ip" element={<WaitRoomV2 />} />
<Route path="/mora" element={<Mora />} /> <Route path="/mora" element={<MoraV2 />} />
<Route path="/duel" element={<NeosDuel />} /> <Route path="/duel" element={<NeosDuel />} />
</Routes> </Routes>
); );
......
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