Git Product home page Git Product logo

underthelimits's Introduction

UTL logo

An open-source and horrible french card game

Dev

git clone https://github.com/Thenkei/UnderTheLimits
cd UnderTheLimits
node server/scripts/populate-dev.js
yarn start:dev

K8S

All the files needed to run UTL on K8S can be found in the infra folder. Be aware that K8S related files are NOT production ready. PORT variable can be customized to any of your wishes SHA1 is mainly used to keep a trace of the currently deployed version

Most of the configuration related to traefik should be updated to match your configuration

FAQ

Is there a demo ?

Here

Is there tests ?

No. We want to deploy an online, playable version before deploying some kind of production version

Is there a roadmap ?

Yes and no. You can find here stuff we currently plan to work on.

Why is the code so horrible ?

We didn't planish most of the stuff we did. If you find anything so aweful it hurts you, you can fork it and PR are welcome !

underthelimits's People

Contributors

thenkei avatar jeffladiray avatar damien-citaire avatar arnaud-moncel avatar sigmundfrog avatar

Stargazers

slimane avatar Hugo Le Goff avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

sigmundfrog

underthelimits's Issues

[WIP] Add basic card game proxy

Made a little plantUML basic card game workflow.

uml-diagram

@startuml

title Basic card game workflow

start

:onCreateGame();
while (isGameReady()) is (false)
    :onWaitingPlayers();
endwhile (true)
:onGameReady();
:onGameStart();
while (isGameOver()) is (false)
    :onRoundStart();
    while (isRoundOver()) is (false)
        :onTurnStart();
        :onPlayingTurn();
        :onTurnEnd();
    endwhile (true)
    :onRoundEnd();
endwhile (true)
:onGameOver();
:onGameEnd();

stop

@enduml

Could give some kind of abstraction on client side, and would be way easier to add any kind of card game

Protocol

Made this on to define once and for all a basic and extensible protocol for UTL related stuff

I prefixed all the "message" with an identifier, so redux code will be easier to segment.

  • ON - connection : (client)

  • ON - disconnect : EMIT - lobby/update && if connected to channel channel/update && (if don't reconnected => disconnect from game after 45 s)

  • ON - init/createPlayer : ({player})

    • EMIT - INITIATOR ONLY - init/playerCreated : () => ({player}) # Send created user
    • JOIN IO ROOM -> LOBBY # Since user exist, add it to lobby
    • EMIT - `lobby/update
  • ON - channel/create : ({channel})

    • EMIT - lobby/update # Update lobby with new channel
    • EMIT - INITIATOR ONLY - channel/created
    • EMIT - channel/update # Contains info to redirect the user to the correct page
  • ON - channel/join : ({channelId})

    • EMIT - lobby/update : () => ({lobby}) # Update lobby, without initiator
    • JOIN IO ROOM -> UTL_GAME_ROOM(channelId) # Since user exist, add it to lobby
    • EMIT - channel/update: # Update current channel for all player # contains info to redirect the user to the correct page
  • ON - utl/nextRound : ()

    • EMIT - channel/update # Update current channel for all player
  • ON - utl/selectedAnswers : ({answers})

    • EMIT - channel/update: # Update current channel for all player
  • ON - utl/selectedJudgment : ({judgment})

    • EMIT - channel/update: # Update current channel for all player

We should also strictly define and serialize response message sent from the server in order to avoid ppl looking trough js code to find opponents card

EMIT - lobby/update

{
  $id: 'lobby',
    type: 'object',
    properties: {
      lobbyUsers: { type: 'User', default: '' },
      channels: {
       name: {type: 'string', default: '' },
       id: {type: 'integer', default: '' },
    },
  };

EMIT - channel/update (UTLGame & UTLPlus (protocol)

{
  $id: 'channel',
    type: 'object',
    properties: {
      id: {type: 'integer', default: '' },
      name: {type: 'string', default: '' },
      admin: {type: PLAYER (NEED TO BE CHANGED)},
      players: {
       id: {type: 'integer', default: '' },
       name: {type: 'string', default: '' },
       score: {type: 'integer', default: '0' },
       hand: {type: Answer, default: '' },
       answers: {type: Array[type: 'integer'], default: '0' },
       isGameMaster: {type: 'boolean', default: '0' },
      },
      currentStatus: {type: 'string', default: 'IDLE' },
      timer: {type: 'integer', default: '0' },
      deckQuestion: {type: 'string', default: '' },
    },
  };

This is the UTL games definition of a channel.

EMIT/ON/EMIT - INITIATOR ONLY : BROADCAST/ON NEW REQ RECEIVED/SEND RES ONLY TO THE SPECIFIC CLIENT

Server - Manage data sent

Use home made serializer in order to reduce data during channel class updates through socket, don't send deckAnswers and deckQuestions anymore !

Reducer handling error

We need to change Socket server side API in order to make the following wssFunctionType work.

Reducer

export function wssCreatePlayer(wsCreatePlayerReq) {
return (dispatch) => {
try {
dispatch(createPlayerRequest());
createPlayer(wsCreatePlayerReq, (err, wsCreatePlayerRes) => {
if (err) {
throw err;
}
// eslint-disable-next-line prefer-destructuring
id = wsCreatePlayerRes.id;
if (wsCreatePlayerRes) {
dispatch(createPlayerSucess(wsCreatePlayerRes));
}
});
} catch (error) {
dispatch(createPlayerFailure(error));
}
};
}

Another implementation:

export function wssCreatePlayer(wsCreatePlayerReq) { 
   return (dispatch) => { 
     dispatch(createPlayerRequest()); 
     createPlayer(wsCreatePlayerReq, (err, wsCreatePlayerRes) => { 
       if (wsCreatePlayerRes) {
         // eslint-disable-next-line prefer-destructuring 
         id = wsCreatePlayerRes.id; 
         dispatch(createPlayerSucess(wsCreatePlayerRes)); 
         retrurn;
       }
       dispatch(createPlayerFailure(error));
     }); 
   }; 
 } 

Client API

function createPlayer(playerName, cb) {
global.socket.emit('createPlayer', playerName);
global.socket.on('playerCreated', lobbyResponse => cb(null, lobbyResponse.player));
}

Changes:

 function createPlayer(playerName, cb) { 
   global.socket.emit('createPlayer', playerName); 
   global.socket.on('playerCreated', lobbyResponse => cb(lobbyResponse.error, lobbyResponse.player)); 
 } 

Server API

client.emit('err', err.message);

Becomes:

client.emit('playerCreated', { error: err.message });

So, we need to talk about this and also about the RESQUEST -> FAILLURE | SUCCESS system.

Optimize build when building qa

For now, "development" mode is used to build qa. We should only use "production" style kind of build, since it improve performances and security

Use sqlite3

Since we do only 2 calls on app start, Mysql might be a little bit too much ๐Ÿคฃ
docker-compose-dev.yml should start way faster

DB anwers enhancement grammar column

A new column is here to qualify the answer gramma. Value definition as following :

0 = NounsMale
1 = NounsFemale
2 = NounsPlural
3 = Verbs
4 = ProperNoun

This will be use for statistics and for gammar automation.

Add more timer

We should more timer (On winner vote, on admin next round, ...)

CreateChannel custom choices

const range = (start, end) => new Array(end - start).fill().map((d, i) => i + start);
const gamesChoices = [{
value: 'utlgame',
text: 'UTL Game (Simple)',
minPlayersChoices: range(2, maxPlayersCount),
maxPlayersChoices: range(minPlayersCount + 1, 9),
maxPointsChoices: range(1, 10),
}, {
value: 'utlplus',
text: 'UTL Plus (Difficile)',
minPlayersChoices: range(4, maxPlayersCount),
maxPlayersChoices: range(minPlayersCount + 1, 12),
maxPointsChoices: range(6, 20),
}];

BUG : range start value > to end value

Public and private game

As a Player, I want to be able to share "private" url so I can play with friends.

Channel id shouldn't be sequential, and we should generate semi random channel id. Adding private room feature would be easy since we can handle this on client only

Crash -Server

A player got disconnected just before this call and server crashed.

currentPlayer.answers = answers;

utl-server    | channel Salon4Jardin next round starting...
utl-server    | Player Sigmund  got disconnected from lobby
utl-server    | Player removed from channel
utl-server    | /server/index.js:181
utl-server    |         currentPlayer.answers = answers;
utl-server    |                               ^
utl-server    |
utl-server    | TypeError: Cannot set property 'answers' of undefined
utl-server    |     at Socket.client.on (/server/index.js:181:31)
utl-server    |     at Socket.emit (events.js:182:13)
utl-server    |     at /server/node_modules/socket.io/lib/socket.js:528:12
utl-server    |     at process._tickCallback (internal/process/next_tick.js:61:11)
utl-server    | [nodemon] app crashed - waiting for file changes before starting...

Gameplay - Change party life cycle

In a channel, when the admin start a game, the game will automatically run until it ends or channel don't have enough players to pursue.

Tchat service

Simple tchat implementation.

Will be then used in lobby and channels.

Customizable party

When creating the game, the salon creator can choose several parameters:

  • number of points to accumulate to win the game
  • maximum number of players and spectators in the game (example: min 3, max 8)
  • Play the Vanilla version or the "UTL PLUS" version
  • the deck he wants to use (for "UTL PLUS" versions)
  • change the method of allocation of points, indicate to the creator of the show that he must provide
    a higher point limit and explain the difference (for "UTL PLUS" versions)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.