added locale
This commit is contained in:
8
TODO
8
TODO
@@ -22,6 +22,14 @@
|
||||
✔ Create, join, delete and leave lobbies @done(21-04-12 20:51)
|
||||
→ Make lobbies publically discoverable on a list
|
||||
|
||||
[ ] Dictionary
|
||||
→ Find appropriate scrabble dictionary for
|
||||
→ Portuagese
|
||||
→ Spanish
|
||||
→ French
|
||||
→ Czech
|
||||
→ Optimise! nary tree
|
||||
|
||||
[ ] Game logic
|
||||
✘ Singleplayer game logic - OUT OF SCOPE @cancelled(21-04-11 01:04)
|
||||
✘ AI CPU player @cancelled(21-04-11 01:07)
|
||||
|
||||
@@ -20,7 +20,8 @@ async function onUsernameSubmit(e)
|
||||
const chosenUsername = UsernameInput.value;
|
||||
|
||||
const req = {
|
||||
username: chosenUsername
|
||||
username: chosenUsername,
|
||||
locale: localStorage.getItem('locale')
|
||||
};
|
||||
|
||||
const res = await fetch('/login', {
|
||||
|
||||
@@ -26,6 +26,7 @@ async function main()
|
||||
function benchmarkDictionary()
|
||||
{
|
||||
let hrTime = process.hrtime();
|
||||
// convert to ns
|
||||
let startTime = hrTime[0] * 1000000 + hrTime[1] / 1000;
|
||||
|
||||
// Time 10 thousand reads
|
||||
@@ -37,7 +38,7 @@ function benchmarkDictionary()
|
||||
hrTime = process.hrtime();
|
||||
let endTime = hrTime[0] * 1000000 + hrTime[1] / 1000;
|
||||
|
||||
Logger.debug(`10 000 Reads (unoptimised): ${endTime - startTime}μs`)
|
||||
Logger.debug(`10 000 Reads (unoptimised): ${endTime - startTime}μs`);
|
||||
|
||||
|
||||
Dict.Optimise();
|
||||
@@ -55,7 +56,7 @@ function benchmarkDictionary()
|
||||
hrTime = process.hrtime();
|
||||
endTime = hrTime[0] * 1000000 + hrTime[1] / 1000;
|
||||
|
||||
Logger.debug(`10 000 Reads (optimised): ${endTime - startTime}μs`)
|
||||
Logger.debug(`10 000 Reads (optimised): ${endTime - startTime}μs`);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -37,11 +37,37 @@ function LoadTextDictionaries()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// TODO: optimisation code for dict
|
||||
class Node
|
||||
{
|
||||
value;
|
||||
children = [];
|
||||
|
||||
#root;
|
||||
|
||||
constructor(root, value, children)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class Tree
|
||||
{
|
||||
#root;
|
||||
|
||||
}
|
||||
|
||||
function Optimise()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
function findInTree()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
function FindWord(lang, word)
|
||||
{
|
||||
word = word.toUpperCase();
|
||||
|
||||
@@ -1,8 +1,25 @@
|
||||
|
||||
/*
|
||||
GAME OBJECT
|
||||
{
|
||||
|
||||
locale
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
NOTES
|
||||
- The locale is the language of the *owner of the lobby*, the dictionary
|
||||
will reflect this language choice
|
||||
*/
|
||||
let ActiveGames = [];
|
||||
|
||||
function StartGame()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
module.exports = {
|
||||
StartGame: StartGame,
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ USER OBJECT
|
||||
username: username,
|
||||
uid: uid,
|
||||
ip: ip,
|
||||
locale: en,
|
||||
// REGISTERED, CONNECTED, DISCONNECTED
|
||||
state: 'CONNECTED',
|
||||
// LOBYING, GAMETRANSITION, GAME, UNDECIDED
|
||||
@@ -19,6 +20,7 @@ USER OBJECT
|
||||
NOTES
|
||||
- Socket relations are handled by the socket server in order
|
||||
to seperate domain logic from game and networking logic
|
||||
- locale is language, supported languages in /data/
|
||||
*/
|
||||
// TODO: Maybe stringify this for easy session persistence
|
||||
// poor substitute for a proper database but it's better
|
||||
@@ -100,7 +102,7 @@ function GetUserIntent(useruid)
|
||||
}
|
||||
|
||||
|
||||
function RegisterUser(username, ip)
|
||||
function RegisterUser(username, ip, locale)
|
||||
{
|
||||
// TODO: Don't assume this is unique, even with Crypto, UUIDv4?
|
||||
const uid = Crypto.randomBytes(8).toString("hex");
|
||||
@@ -118,6 +120,7 @@ function RegisterUser(username, ip)
|
||||
username: username,
|
||||
uid: uid,
|
||||
ip: ip,
|
||||
locale: locale || 'en',
|
||||
// REGISTERED, CONNECTED, DISCONNECTED
|
||||
state: 'REGISTERED',
|
||||
// LOBYING, GAMETRANSITION, GAME, UNDECIDED
|
||||
|
||||
@@ -57,6 +57,7 @@ function HandleLogin(req, res, next)
|
||||
}
|
||||
|
||||
const username = req.body.username;
|
||||
const locale = req.body.locale;
|
||||
|
||||
if (!Game.Registrar.ValidUsername(username))
|
||||
{
|
||||
@@ -85,7 +86,7 @@ function HandleLogin(req, res, next)
|
||||
return;
|
||||
}
|
||||
|
||||
const user = Game.Registrar.RegisterUser(username, ip);
|
||||
const user = Game.Registrar.RegisterUser(username, ip, locale);
|
||||
|
||||
if (!user)
|
||||
{
|
||||
|
||||
@@ -133,6 +133,9 @@ function ClientIdentify(socket, args)
|
||||
if (Game.Lobbies.IsLobbyReadyForGame(lobby.uid))
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user