GithubHelp home page GithubHelp logo

instantwinnergames's Introduction

Big Picture

Big picture is in an other document but to make it short :

  • InstantWinnerGames can be created and linked to Places. Meaning they can only be played if you are close enough to the Place of the InstantWinnerGame. InstantWinnerGames have a start/endDate : they cannot be playout outside this time range. InstantWinnerGames have also a Won status (true/false)

  • Players can request for InstantWinnerGames they can play, based on their GPS and time (server time)

  • A player can only play once to an InstantWinnerGame (we provide a fingerpring, outside of this project). Everytime a player plays to an InstantWinnerGame, we create a InstantWinnerPlayer instance, for stats purposes.

  • The player who wons is the one that plays the first after InstantWinnerGames.playTime. You can see details below

Install

go get .. whatever will be requested

go build -o service-api

./service-api

Need to be done

Switch to mysql

Add small populate go script with a few examples

Add 1 apis : GetListOfOpenedInstantGames

Should take as input latitude and longitude

Should return all InstantWinnerGames + Place where

InstantWinnerGames.won == false && InstantWinnerGames.startDate< serverTime < InstantWinnerGames.endDate

&& Place.id==InstantWinnerGames.id && (latitude-0.1)< Place.latitude <(latitude+0.1) && (longitude-0.1)< Place.longitude <(longitude+0.1)

Modify CreateInstantWinnerPlayer

Should take as input a InstantWinnerGames id, latitude and longitude and returns according to below procedure

(I have a complex issue there. I could have concurrent calls ? Let’s say we will have one single server is enough ?)

Here is detailed process.

First we get server time => serverTime.

Then we get matching InstantWinnerGame And

0/ We check if InstantWinnerGame is not won If InstantWinnerGame.won => returns{ result : false, code : 1, message : 'Already won game' }

1/ We check if InstantWinnerGame is linked to a Place whose latitude and longitude are OK (see above API)

If GPS is not OK returns{ result : false, code : 2, message : 'Not allowed from here' }

else (We check if InstantWinnerGame is still available)

If !(InstantWinnerGame.startTime < serverTime < InstantWinnerGame.endTime) => returns{ result : false, code : 2, message : 'game is over' }

From then on, we know InstantWinnerGame is open and available for the player

2/ We check if this player already played in this game

check if one InstantWinnerPlayer where InstantWinnerPlayer.InstantWinnerGameID==instantWinnerGameId && (InstantWinnerPlayer.fp==fp || InstantWinnerPlayer.email==email)

If true returns { result : false, code : 3, message : 'Already played' }

else

2/ It means that game is open, player allowed to play

if (serverTime>InstantWinnerGame.playTime && InstantWinnerGame.won == false) then

a/ set InstantWinnerGame.won=true

b/ save new InstantWinnerPlayer with result=true and time=serverTime

c/ returns{ result : true, message : 'game won' }

else (played but too early)

a/ save new InstantWinnerPlayer with result=false and time=serverTime

b/ returns{ result : false, code : 4, message : 'you lost' }

Dockerfile and Dockerfile composer

instantwinnergames's People

Contributors

mmerlangera avatar vithanidarpan avatar

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.