From de1325d1e297057ab55911e1c223e7230732bd42 Mon Sep 17 00:00:00 2001 From: Phillweston <2436559745@qq.com> Date: Sat, 18 Jan 2025 22:52:34 +0800 Subject: [PATCH] Add regulation and about dialog, update README.md --- README.md | 84 ++++++++++++++++++++++++++++++++- src/App.jsx | 130 +++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 211 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index be0b061..78f0ca2 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ A 3D dice simulator built on Three.js, utilizing Cannon.js as the physics engine, allowing users to control the number of the dices. -Now you can find a live version at [here](https://bti-us.github.io/DiceRollerSimulator-ThreeJS/). +Now you can find a live version at [here](https://dice,chubgame.com/). ## Features @@ -49,11 +49,93 @@ npm run dev |`VITE_SEND_DICE_DATA_API`|API endpoint to send dice data|`https://chubgame.com/wp-json/chubgame/v1/send`| |`VITE_MAX_DICE_AMOUNT`|Maximum number of dice allowed|`10`| +## WordPress API Endpoints + +### Validate Promotion Code + +This endpoint validates the promotion code provided by the user. + +**Endpoint:** + +```text +POST /wp-json/dice-roller/v1/validate +``` + +**Request Body:** + +```json +{ + "promotionCode": "string", + "username": "string" +} +``` + +**Response:** + +- **200 OK**: If the promotion code is valid. + + ```json + { + "valid": true + } + ``` + +- **400 Bad Request**: If the promotion code is invalid. + + ```json + { + "valid": false, + "error": "Invalid promotion code" + } + ``` + +### Send Dice Data + +This endpoint sends the dice data to the backend. + +**Endpoint:** + +```text +POST /wp-json/dice-roller/v1/send +``` + +**Request Body:** + +```json +{ + "diceAmount": "integer", + "totalPoints": "integer", + "promotionCode": "string", + "isPromotionUser": "boolean", + "username": "string", + "chips": "integer" +} +``` + +**Response:** + +- **200 OK**: If the data is successfully processed. + + ```json + { + "success": true + } + ``` + +- **400 Bad Request**: If there is an error processing the data. + + ```json + { + "error": "Error message" + } + ``` + ## Milestone - [x] Basic 3D dice simulator - [x] Send the current dice number to the server using HTTP POST - [x] Add the promotion code feature +- [x] Add the chip amount feature ## License diff --git a/src/App.jsx b/src/App.jsx index 4f3f91d..7989ee8 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -33,6 +33,8 @@ const App = () => { const [showCopyDialog, setShowCopyDialog] = useState(false); const [showHint, setShowHint] = useState(false); const [mousePosition, setMousePosition] = useState({ x: 0, y: 0}); + const [showRegulationDialog, setShowRegulationDialog] = useState(false); + const [showAboutDialog, setShowAboutDialog] = useState(false); useEffect(() => { const params = new URLSearchParams(window.location.search); @@ -45,6 +47,22 @@ const App = () => { } }, []); + const handleOpenRegulation = () => { + setShowRegulationDialog(true); + }; + + const handleOpenAbout = () => { + setShowAboutDialog(true); + }; + + const handleCloseRegulation = () => { + setShowRegulationDialog(false); + }; + + const handleCloseAbout = () => { + setShowAboutDialog(false); + }; + // Generate a random promotion code when the component mounts const generatePromotionCode = () => { const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; @@ -357,10 +375,118 @@ const App = () => { )}
DICE 3D
-ChubGame
++ Game Regulation
++ About ChubGame +
Objective:
+The goal of the game is to roll the dice and achieve the highest possible score.
+Rules:
+Scoring:
+Penalties:
+MIT License
+Copyright (c) 2025 ChubGame
++ Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: +
++ The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. +
++ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +
+AMOUNT: {diceAmount}