Skip to content

Commit

Permalink
Add return to the welcome dialog if the regulation or about dialog is…
Browse files Browse the repository at this point in the history
… opened from the welcome dialog
  • Loading branch information
Phillweston committed Jan 21, 2025
1 parent 1df44c4 commit deeda29
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
2 changes: 1 addition & 1 deletion API_Implementation.md
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ function handle_send_dice_data(WP_REST_Request $request) {
'message' => 'Game processed successfully',
'data' => array(
'status' => 'success',
'balance' => $child_balance
'balance' => $child_balance,
'result' => ($winner_user_id === $user_id) ? $winner_chips : -$chips // Positive for win, negative for loss
)
), 200);
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,8 @@ Handles the dice game data and manages the chips for parent and child users.
"message" => "Game processed successfully",
"data" => {
"status" => "success",
"balance" => 1000
"balance" => 1000,
"result" => 100
}
}
```
Expand Down
25 changes: 23 additions & 2 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: Phillweston 2436559745@qq.com
* @Date: 2025-01-01 22:00:54
* @LastEditors: Phillweston
* @LastEditTime: 2025-01-17 14:40:19
* @LastEditTime: 2025-01-21 14:40:19
* @FilePath: \DiceRollerSimulator-ThreeJS\src\App.jsx
* @Description:
*
Expand Down Expand Up @@ -41,6 +41,7 @@ const App = () => {
const [showResultDialog, setShowResultDialog] = useState(false);
const [resultData, setResultData] = useState(null);
const [showFinalDialog, setShowFinalDialog] = useState(false);
const [openedFromWelcome, setOpenedFromWelcome] = useState(false);

useEffect(() => {
const params = new URLSearchParams(window.location.search);
Expand All @@ -67,18 +68,34 @@ const App = () => {

const handleOpenRegulation = () => {
setShowRegulationDialog(true);
if (showWelcomeDialog) {
setOpenedFromWelcome(true);
setShowWelcomeDialog(false);
}
};

const handleOpenAbout = () => {
setShowAboutDialog(true);
if (showWelcomeDialog) {
setOpenedFromWelcome(true);
setShowWelcomeDialog(false);
}
};

const handleCloseRegulation = () => {
setShowRegulationDialog(false);
if (openedFromWelcome) {
setShowWelcomeDialog(true);
setOpenedFromWelcome(false); // Reset the state
}
};

const handleCloseAbout = () => {
setShowAboutDialog(false);
if (openedFromWelcome) {
setShowWelcomeDialog(true);
setOpenedFromWelcome(false); // Reset the state
}
};

const handleShowResult = async () => {
Expand Down Expand Up @@ -471,7 +488,11 @@ const App = () => {
<button
onClick={() => {
setShowChipsDialog(false);
setShowPromotionDialog(true);
if (singlePlayer) {
setShowWelcomeDialog(true);
} else {
setShowPromotionDialog(true);
}
}}
className="px-4 py-2 bg-gray-500 text-white rounded transition-transform duration-300 hover:bg-yellow-500 hover:scale-105 active:bg-green-500 flex items-center"
>
Expand Down

0 comments on commit deeda29

Please sign in to comment.