6 Commits

Author SHA1 Message Date
DTieman
5f8c6994aa Added the ability to choose your cardtype when playing a jack or the newly added joker
Some checks failed
Build Mau & Deploy Mau / build (push) Successful in 1m29s
Build Mau & Deploy Mau / deploy (push) Has been cancelled
2024-04-19 22:12:31 +02:00
66c2d322a2 Update .gitea/workflows/main.yml
Some checks failed
Build Mau & Deploy Mau / build (push) Successful in 1m24s
Build Mau & Deploy Mau / deploy (push) Failing after 2m26s
2024-04-17 08:54:42 +00:00
03930d2d81 Update .gitea/workflows/main.yml
All checks were successful
Build Mau & Deploy Mau / build (push) Successful in 1m25s
Build Mau & Deploy Mau / deploy (push) Successful in 4m2s
2024-04-17 08:44:35 +00:00
6bd1f316d1 Merge pull request 'fix-url' (#2) from fix-url into mauster
Some checks failed
Build Mau & Deploy Mau / deploy (push) Has been cancelled
Build Mau & Deploy Mau / build (push) Has been cancelled
Reviewed-on: https://git.mau-mau.nl/MauMau/MauMau-Client/pulls/2
2024-04-17 08:42:00 +00:00
74f51d60d0 Merge pull request 'Update src/layout/pages/MainLobby.tsx' (#1) from fix-url into mauster
All checks were successful
Build Mau & Deploy Mau / build (push) Successful in 1m32s
Build Mau & Deploy Mau / deploy (push) Successful in 4m12s
Reviewed-on: https://git.mau-mau.nl/MauMau/MauMau-Client/pulls/1
2024-04-17 08:05:36 +00:00
dc4dd5c19b Update src/layout/pages/Rooms.tsx
Some checks are pending
Build Mau & Deploy Mau / build (push) Waiting to run
Build Mau & Deploy Mau / deploy (push) Blocked by required conditions
2024-04-17 08:05:23 +00:00
7 changed files with 45 additions and 21 deletions

View File

@@ -1,3 +1,5 @@
.env.example .env.example
.env
.idea .idea
README.md README.md
.gitea

View File

@@ -45,7 +45,8 @@ jobs:
- name: Create .env File - name: Create .env File
run: | run: |
touch .env touch .env
echo "REACT_APP_API_URL=https://mau-mau.nl/api \n REACT_APP_WEBSOCKET_URL=ws://mau-mau.nl/api" > .env echo "REACT_APP_API_URL=https://mau-mau.nl/api" > .env
echo "REACT_APP_WEBSOCKET_URL=wss://mau-mau.nl/api" >> .env
- name: Set up Docker BuildX - name: Set up Docker BuildX
uses: docker/setup-buildx-action@v2 uses: docker/setup-buildx-action@v2

1
.gitignore vendored
View File

@@ -24,3 +24,4 @@ yarn-debug.log*
yarn-error.log* yarn-error.log*
.idea .idea
.env

View File

@@ -11,9 +11,17 @@ const Card: FunctionComponent<Props> = ({cardString, handleClick, isHidden, isCl
const cardType = cardString.split(' ')[0].toLowerCase(); const cardType = cardString.split(' ')[0].toLowerCase();
const cardValue = cardString.split(' ')[1].toLowerCase(); const cardValue = cardString.split(' ')[1].toLowerCase();
const cardSource = isHidden ? const cardSource = (): string => {
require(`../../assets/cards/back.png`) : if (isHidden) return require("../../assets/cards/back.png");
require(`../../assets/cards/${cardType}_${cardValue}.png`); if (cardType === "JOKER") {
if (cardValue === "RED") {
return require("../../assets/cards/joker_red.png")
}
return require("../../assets/cards/joker_black.png")
}
return require(`../../assets/cards/${cardType}_${cardValue}.png`);
}
const cardName = isHidden ? 'back' : `${cardType} ${cardValue}`; const cardName = isHidden ? 'back' : `${cardType} ${cardValue}`;
const handleCardClick = () => { const handleCardClick = () => {
@@ -24,7 +32,7 @@ const Card: FunctionComponent<Props> = ({cardString, handleClick, isHidden, isCl
return ( return (
<div className={`card ${isClickable && 'card-clickable'}`}> <div className={`card ${isClickable && 'card-clickable'}`}>
<img className="card__texture" src={cardSource} alt={cardName} onClick={handleCardClick}/> <img className="card__texture" src={cardSource()} alt={cardName} onClick={handleCardClick}/>
</div> </div>
) )
} }

View File

@@ -1,9 +1,11 @@
import React, {FunctionComponent} from "react"; import React, {FunctionComponent} from "react";
import Deck from "./Deck"; import Deck from "./Deck";
import Hand from "./Hand"; import Hand from "./Hand";
import {GHButton} from "./Button";
interface GameState { export interface GameState {
PlayerName: string; PlayerName: string;
CurrentState: string;
Hand: string[]; Hand: string[];
CurrentCard: string; CurrentCard: string;
CurrentPlayer: string; CurrentPlayer: string;
@@ -14,9 +16,12 @@ interface Props {
gameState: GameState gameState: GameState
handleCardSend: (cardString: string) => void; handleCardSend: (cardString: string) => void;
handleDraw: () => void; handleDraw: () => void;
handleChoice: (choice: string) => void;
} }
const Game:FunctionComponent<Props> = ({gameState, handleCardSend, handleDraw}) => { const CHOICES = ['SPADES', 'HEARTS', 'DIAMONDS', 'CLUBS'];
const Game: FunctionComponent<Props> = ({gameState, handleCardSend, handleDraw, handleChoice}) => {
return ( return (
<div className="game"> <div className="game">
{ {
@@ -27,13 +32,17 @@ const Game:FunctionComponent<Props> = ({gameState, handleCardSend, handleDraw})
gameState.Hand && gameState.Hand &&
<Hand hand={gameState.Hand} actionOnClick={handleCardSend}/> <Hand hand={gameState.Hand} actionOnClick={handleCardSend}/>
} }
{
gameState.CurrentState === 'CHOOSE' &&
CHOICES.map(choice => <GHButton key={choice} onClick={() => handleChoice(choice)}>{choice}</GHButton>)
}
<ul> <ul>
{ {
gameState.Players && gameState?.Players &&
gameState.Players.map((player, index) => { gameState.Players.map((player) => {
const isCurrentPlayer = player === gameState.CurrentPlayer; const isCurrentPlayer = player === gameState.CurrentPlayer;
const isMe = player === gameState.PlayerName; const isMe = player === gameState.PlayerName;
return <li key={index} style={{fontWeight: isCurrentPlayer ? 'bold' : 'normal'}}> return <li key={player} style={{fontWeight: isCurrentPlayer ? 'bold' : 'normal'}}>
{player} {isMe && '(You)'} {player} {isMe && '(You)'}
</li> </li>
}) })

View File

@@ -3,15 +3,7 @@ import React from "react";
import {useNavigate, useParams} from "react-router"; import {useNavigate, useParams} from "react-router";
import {GHButton} from "../components/Button"; import {GHButton} from "../components/Button";
import useTitle from "../../utils/hooks/TitleHook"; import useTitle from "../../utils/hooks/TitleHook";
import Game from "../components/Game"; import Game, {GameState} from "../components/Game";
interface GameState {
PlayerName: string;
Hand: string[];
CurrentCard: string;
CurrentPlayer: string;
Players: string[];
}
interface ChatMessage { interface ChatMessage {
PlayerName: string; PlayerName: string;
@@ -35,6 +27,7 @@ const Room = () => {
const [gameState, setGameState] = React.useState<GameState>({ const [gameState, setGameState] = React.useState<GameState>({
PlayerName: '', PlayerName: '',
CurrentState: '',
Hand: [], Hand: [],
CurrentCard: '', CurrentCard: '',
CurrentPlayer: '', CurrentPlayer: '',
@@ -78,6 +71,16 @@ const Room = () => {
}) })
} }
const handleChoice = (choice: string) => {
handleSend({
Type: "GAME",
Payload: JSON.stringify({
Action: "CHOOSE",
Data: choice
})
});
}
const handleDraw = () => { const handleDraw = () => {
handleSend({ handleSend({
Type: "GAME", Type: "GAME",
@@ -99,7 +102,7 @@ const Room = () => {
<div> <div>
<h1>Room {roomId}</h1> <h1>Room {roomId}</h1>
<GHButton onClick={handleLeaveRoom}>Leave Room</GHButton> <GHButton onClick={handleLeaveRoom}>Leave Room</GHButton>
<Game gameState={gameState} handleCardSend={handleCardSend} handleDraw={handleDraw}/> <Game gameState={gameState} handleCardSend={handleCardSend} handleDraw={handleDraw} handleChoice={handleChoice}/>
<input type="text" placeholder={"Chat"} value={chatInput} onChange={(e) => setChatInput(e.target.value)} /> <input type="text" placeholder={"Chat"} value={chatInput} onChange={(e) => setChatInput(e.target.value)} />
<button onClick={() => handleChat(chatInput)}>Send</button> <button onClick={() => handleChat(chatInput)}>Send</button>
<ul> <ul>

View File

@@ -2,7 +2,7 @@ import useTitle from "../../utils/hooks/TitleHook";
import React from "react"; import React from "react";
import {useNavigate} from "react-router"; import {useNavigate} from "react-router";
const ROOM_URL = `http://${process.env.REACT_APP_API_URL}/room`; const ROOM_URL = `${process.env.REACT_APP_API_URL}/room`;
const Rooms = () => { const Rooms = () => {