-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deployment
- Loading branch information
Showing
168 changed files
with
5,419 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Api Documentation | ||
|
||
## Endpoints | ||
|
||
### Websockets | ||
|
||
* POST `/api/pusher` | ||
|
||
### User auth | ||
|
||
* POST `/api/auth/register` -> if 201 returns a User | ||
* POST `/api/auth/login` -> if 200 returns a User | ||
|
||
```json | ||
- same request body for both POST endpoints: | ||
{ | ||
"username": "letters and numbers only", | ||
"password": "letters, numbers and special characters except spaces" | ||
} | ||
``` | ||
|
||
* GET `/api/auth/session` -> if 200 returns a User | ||
* GET `/api/auth/logout` | ||
|
||
### Friend requests | ||
|
||
* GET `/api/friends/friendRequest/:targetUsername` | ||
* GET `/api/friends/acceptFriendRequest/:targetUsername` | ||
|
||
### Stats | ||
|
||
* PUT `/api/stats/addWin` | ||
* PUT `/api/stats/addLoss` | ||
* PUT `/api/stats/updateRating` | ||
|
||
```json | ||
- request body for updateRating (the rest can be an empty body) | ||
{ | ||
"ratingDifferential": 27 // it can be a possitive number to add rating or negative to substract | ||
} | ||
``` | ||
|
||
## Models | ||
|
||
### User | ||
|
||
* _id: string | ||
* username: string | ||
* password: string | ||
* rating: number | ||
* wins: number | ||
* losses: number | ||
* friends: User[] | ||
* friendRequests: User[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,93 @@ | ||
# Game rules | ||
# Truco Rules | ||
|
||
## Game | ||
|
||
Truco is a card game played between two players (or in pairs) with a spanish deck (40 cards) wihout 8s, 9s or jokers. There are three ways of scoring points: | ||
|
||
* **Flor**: the players compare three cards of the same suits. | ||
* **Envido**: the players compare two cards of the same suits. | ||
* **Truco**: the cards are compared individually. | ||
|
||
After the **Flor** and **Envido**, the game is divided in three rounds. In each round, each player chooses one of the cards in their hand to compete against the card of the other player. The winner is the one who wins two rounds out of three. | ||
|
||
The player who first reaches 30 points(or 15 points depending the variant of the game) in total wins the match. | ||
|
||
## Truco | ||
|
||
The players can make a bet called "**Truco**" any time in the game. If **Truco** is called and accepted, the players lose the chance to call **Envido**, but the other player can call envido over the truco call invalidating it (although it can be called again after envido). If there is no bet one point goes to the winner of the round. The players can raise the bet only one time in this order: | ||
|
||
* **Truco**: 2 points. | ||
* **Retruco**: 3 points. | ||
* **Vale 4**: 4 points. | ||
|
||
Players can accept, reject or raise the bet: | ||
|
||
* **accept**: the points in dispute go to the winner of the round. | ||
* **reject**: the player loses the round and the points go to the other player. | ||
* **raise**: the player can raise the bet in this sequence. | ||
|
||
|
||
no bet -> truco -> retruco -> quiero vale 4 | ||
|
||
## Envido | ||
|
||
At the beginning of the round, a player in his turn can call for **envido** then an option will apear for the other player to respond to this bet in any of these ways: | ||
|
||
* **Quiero**: accepts to take the bet. | ||
* **Envido**: raise the bet by 2 points. | ||
* **Real envido**: raise the bet by 3 points. | ||
* **Falta envido**: if accepted the one who wins, wins the game. | ||
* **No quiero** - refuses to take the last bet. | ||
|
||
the hierarchy of envido bet is as follows: | ||
|
||
no bet -> envido -> real envido -> falta envido | ||
|
||
if a player raises envido bet the other can't go back. | ||
An example of a envido bet could be like this: | ||
|
||
envido (player 1) -> envido (player 2) -> real envido (player 1) -> quiero (player 2) | ||
The player who has the best pair will win 7 points (2 + 2 + 3). | ||
|
||
Another example with _No quiero_ could be: | ||
|
||
envido (player 1) -> envido (player 2) -> real envido (player 1) -> falta envido (player 1) -> no quiero (player 2) | ||
player 1 wins 7 points (2 + 2 + 3). | ||
|
||
A player can make any of the envido bets first, for example a player could start with real envido. If any of this bets is rejected wihout a raise the winner obtains 1 point. Players can't call **real envido** or **falta envido** more than one time. | ||
|
||
If no one calls for envido, there is no score for it. | ||
The cards are counted as follow: | ||
* same suit: the sum of the two cards + 20 (10,11 and 12 add no value). | ||
* all different suits: the value of the highest card in the hand. | ||
|
||
the highest envido is worth 33 (7-6 of the same suit) and the lowest 0 (11-13 different suits; 10, 11 and 12 add no value). | ||
The players compare the two cards they have chosen and whoever has the highest score wins the points of envido. If there is a tie the winner is the hand-player. | ||
|
||
## Flor | ||
|
||
A player whose three cards are of the same suit is said to have a Flor (flower), and must announce this, saying "flor". If more than one person has a Flor, and all of these are simply announced by saying "flor", the team of the person with the best Flor scores 3 points for each Flor that was announced. | ||
The value of flor is the same as the "envido" (sum three cards + 20 if same suit and 10, 11 and 12 have no value). | ||
|
||
* **Flor**: 3 points (one player has flor and the other doesn't). | ||
* **Contra Flor**: if it is accepted 6 points to the winner, else 4 points (can be called only if both sides have flor). | ||
|
||
|
||
|
||
## Card Values | ||
|
||
![trucoCards](https://github.com/maxogod/Truco/assets/85034225/627d81df-2c5d-404a-9927-695783b62e58) | ||
|
||
### Sources | ||
|
||
1. [wikipedia truco](https://en.wikipedia.org/wiki/Truco) | ||
1. [argentinian truco rules](https://www.pagat.com/put/truco_ar.html) | ||
1. [description truco in city Buenos Aires page](https://turismo.buenosaires.gob.ar/en/article/get-tricks-%E2%80%9Ctruco%E2%80%9D) | ||
1. [rules truco in a online game](https://www.mundigames.com/multiplayer/argentinian-truco/rules/) | ||
1. Truco blyts app | ||
|
||
|
||
Implement me | ||
|
||
[go to readme](../README.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
|
||
# BUILD FRONT AND COPY IT TO BACKEND/SRC/PUBLIC | ||
|
||
# Navigate to the frontend directory | ||
cd .\truco-front | ||
|
||
# Install packages | ||
npm install | ||
|
||
# Run the npm build script | ||
npm run build | ||
|
||
# Check if the build was successful | ||
if ($LASTEXITCODE -eq 0) { | ||
Write-Host "Frontend build successful. Copying files to backend." | ||
|
||
# Navigate back to the original directory | ||
cd .. | ||
|
||
# Remove existing files in backend/src/public/ | ||
if (Test-Path ".\truco-back\src\public\") { | ||
Remove-Item -Recurse -Force .\truco-back\src\public\ | ||
} | ||
|
||
# Copy the contents of frontend/dist to backend/src/public | ||
xcopy /y /s /e .\truco-front\dist\* .\truco-back\src\public\ | ||
|
||
Write-Host "Copy completed." | ||
} else { | ||
Write-Host "Frontend build failed. Aborting copy to backend." | ||
} | ||
|
||
# COMPILE BACKEND AND RUN IT | ||
|
||
cd ./truco-back | ||
|
||
npm install | ||
|
||
npm run build-windows | ||
|
||
if ($LASTEXITCODE -eq 0) { | ||
Write-Host "Backend build successful. Starting server." | ||
|
||
npm run start | ||
} else { | ||
Write-Host "Backend build failed. Aborting server start." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.