diff --git a/README.md b/README.md
index 560758d..3a4b162 100644
--- a/README.md
+++ b/README.md
@@ -5,21 +5,34 @@ SEE BELOW FOR CONFIGURATION GUIDE
### Product Description
-https://scrabble.hasbro.com/en-us/rules
-https://www.zapsplat.com/?s=scrabble
+The following resources were used for the creation of the game's logic:
+* https://scrabble.hasbro.com/en-us/rules
+* https://www.zapsplat.com/?s=scrabble
+* https://www.scrabble3d.info/t2342f139-Default-rules.html
-https://www.scrabble3d.info/t2342f139-Default-rules.html
-
-
-If the scope allowed for it, every function would be (reasonably) unit tested.
The solution to locale-ise language in HTML is extremely naive and there are a lot better ways to do it, i did what i could in the time without a full refractor and SSR.
However it is not at much detriment of readability and maintainability of the code so i didn't deem it neccesary.
The locales are stored in different language files so it is easier for people to contribute and thus more maintanable.
+If the scope allowed for it, every function would be (reasonably) unit tested.
+
### Configuration Guide
+Make sure your working directory is root/server
+
+1. run ```npm i```
+2. run ```npm run setup```
+3. run ```npm run start```
+
+If you want a custom port create a .env file and use the variable PORT
+or just use environment variables
+
+### Implementation Rationale
+
+
+### Bugs and Issues
### Contributing
@@ -27,4 +40,6 @@ To contribute a translation
### Acknowledgements
+Express.js - HTTP Routing and Management
+Socket.io - Socket Routing and Management
Inês Filipa Baiõa Antunes - Tranlations (Portuguese, Spanish)
diff --git a/TODO b/TODO
index c807fb0..e714100 100644
--- a/TODO
+++ b/TODO
@@ -52,6 +52,7 @@
→ Refactor to code portsoc eslint
→ Refactor game client
→ WHY THE HELL ARE THEY CALLED USERS IN SOME PLACES AND PLAYERS IN OTHERS
+ → Why in some places is it user.name and others user.username
☐ Bugfixes
→ If a user leaves their current game then makes a new one, it's corrupted
diff --git a/client/public/scrabble/dragable.js b/client/public/scrabble/dragable.js
index 7387345..b23e43d 100644
--- a/client/public/scrabble/dragable.js
+++ b/client/public/scrabble/dragable.js
@@ -14,7 +14,7 @@ function mouseDown(event, element)
event.preventDefault();
// disalow picking up of played pieces
- if (element.classList.contains('played-piece')) return;
+ if (element.classList.contains('played-piece') || element.classList.contains('locked')) return;
piecePickedUp(element);
diff --git a/client/public/scrabble/game.css b/client/public/scrabble/game.css
index bdc3c5a..6126bba 100644
--- a/client/public/scrabble/game.css
+++ b/client/public/scrabble/game.css
@@ -137,11 +137,19 @@ score {
#game-controls {
border: 1px dotted black;
+ height: 5%;
display: flex;
+ flex-direction: column;
+
flex-direction: row;
}
+.game-control {
+ background-color: #A79AFF;
+ color: white;
+ flex-grow: 2;
+}
#moves {
border: 1px dotted black;
diff --git a/client/public/scrabble/index.html b/client/public/scrabble/index.html
index 4e3182c..b98b4aa 100644
--- a/client/public/scrabble/index.html
+++ b/client/public/scrabble/index.html
@@ -312,9 +312,9 @@
Jerry played OXYPHENBUTAZONE for 40 points
diff --git a/client/public/scrabble/ui.js b/client/public/scrabble/ui.js
index 074c342..85fd185 100644
--- a/client/public/scrabble/ui.js
+++ b/client/public/scrabble/ui.js
@@ -33,6 +33,10 @@ function initUI()
IPlayButton.forEach(e => {
e.disabled = true;
});
+ if (MyTurn)
+ startMyTurnUI();
+ else
+ stopMyTurnUI();
}
const UserUIReplacer = (p, u, n, s) => `
@@ -88,6 +92,10 @@ function updateUsersUI(users)
function startMyTurnUI()
{
+ for (const piece of document.querySelectorAll('piece, nopiece'))
+ {
+ piece.classList.remove('locked');
+ }
IExchangeButton.forEach(e => {
e.disabled = false;
});
@@ -97,14 +105,14 @@ function startMyTurnUI()
IPlayButton.forEach(e => {
e.disabled = false;
});
- document.querySelectorAll('.unplayed-piece').forEach(e => {
- if (e.classList.contains('played-piece'))
- e.classList.remove('played-piece');
- });
}
function stopMyTurnUI()
{
+ for (const piece of document.querySelectorAll('piece, nopiece'))
+ {
+ piece.classList.add('locked');
+ }
IExchangeButton.forEach(e => {
e.disabled = true;
});
@@ -114,10 +122,6 @@ function stopMyTurnUI()
IPlayButton.forEach(e => {
e.disabled = true;
});
- document.querySelectorAll('.unplayed-piece').forEach(e => {
- if (!e.classList.contains('played-piece'))
- e.classList.add('played-piece');
- });
}
function onExchangeTiles()
diff --git a/server/src/game-logic.js b/server/src/game-logic.js
index 97fabb1..d0b9c32 100644
--- a/server/src/game-logic.js
+++ b/server/src/game-logic.js
@@ -181,9 +181,10 @@ function BeginGame(lobby)
{
let t, r;
do {
+ // TODO: this goes out of range
r = Math.floor(Math.random() * tilebag.length + 1);
t = tilebag[r];
- } while (t === null)
+ } while (t === undefined)
tilebag.splice(r, 1);
players[player].activetiles.push(t);
}
@@ -260,28 +261,37 @@ NOTES
function PlayTurn(gameuid, playeruid, turn)
{
const game = ActiveGames[gameuid];
-
- ActiveGames[gameuid].gamestates.push(turn);
-
const turninfo = gameNextTurn(gameuid);
+ ActiveGames[gameuid].gamestates.push(turn);
+
+ // give user new tiles
+
+ console.log(game);
return [turn, turninfo];
}
function SkipTurn(gameuid, playeruid)
{
- gameNextTurn(gameuid);
+ const turninfo = gameNextTurn(gameuid);
+ // get last game state
+ const turn = {
+ playeruid:
+ };
+
+ return [turn, turninfo];
}
function gameNextTurn(gameuid)
{
- const PlayerCount = ActiveGames[gameuid].players.length;
- ActiveGames[gameuid].turn++;
- ActiveGames[gameuid].turn %= PlayerCount;
- ActiveGames[gameuid].turntotal++;
+ const playerCount = ActiveGames[gameuid].players.length;
+ let newTurn = ActiveGames[gameuid].turn += 1;
+ newTurn = ActiveGames[gameuid].turn % PlayerCount;
+ const newTotalTurn = ActiveGames[gameuid].turntotal += 1;
return {
- // i forgot why this is an object, there's more attributes i forgot about
turnplayer: ActiveGames[gameuid].players[ActiveGames[gameuid].turn],
+ newTurn: newTurn,
+ newTotalTurn: newTotalTurn
};
}
diff --git a/server/src/socketserver.js b/server/src/socketserver.js
index 30fe77c..773cc7b 100644
--- a/server/src/socketserver.js
+++ b/server/src/socketserver.js
@@ -401,17 +401,27 @@ function GamePlayTurn(socket, args)
return;
}
- Logger.game(`USER ${user.uid} (${user.name}) IS ATTEMPTING TO PLAY A TURN IN GAME ${game.uid}`);
+ Logger.game(`USER ${user.uid} (${user.username}) IS ATTEMPTING TO PLAY A TURN IN GAME ${game.uid}`);
if (args.skip === true)
{
- const {outcome, turninfo} = Game.Logic.SkipTurn(game.uid, user.uid);
+ const [outcome, turninfo] = Game.Logic.SkipTurn(game.uid, user.uid);
+ io.to(game.uid).emit('game-turn-processed', {
+ outcome: outcome
+ });
+
+ const nextuser = Game.Registrar.GetConnectionByUser(turninfo.turnplayer.uid);
+
+ io.to(game.uid).emit('game-turn-start', {
+ turninfo: turninfo
+ });
+
+ io.to(nextuser).emit('game-your-turn');
} else
{
// TODO: validate args
const [outcome, turninfo] = Game.Logic.PlayTurn(game.uid, user.uid, args)
- // give user new tiles
// process errorsq
io.to(game.uid).emit('game-turn-processed', {