Git Product home page Git Product logo

sanguoshacard's Introduction

SanGuoShaCard

A test from PingCap which is about to deliver a backend of SanGuoSha game.

Blueprint for this Project

Framework

Websocket(Flask_SocketIO) + Flask

Work Flow

The work flow for this project can be separated into 3 stage: join stage, playing stage, ending

Join stage:

A player client will send a join request to server which includes the player id, requested room size, game type and some other game conditions, then waiting. The server will first put that request into the 'waiting room' and search condition fitting room on the room list. The server will return the room id and all the player list as return if it found a game room can be join. Otherwise, the server will create a empty room for that player and return a room id after that.

picture

Playing stage:

After all players be 'seperated' into a same room, all the game logic and game flow contoring will been done in the room instance, and the server will only works as a message dispatcher and receiver. After player send a 'Action'(game action or card action) to the client, the client will package that action with player id and room id and send to the server. The server will accept it and dispatch the message to correspond room. Then, inside the room,it will unpackages the message and begin a series of game logic dealing. The data will be sended as brodcast message to everyone in that room so all the players can update the other players' status and game stage, after the game logic done.

picture

And the server's message dealing flow are shown as follow: picture

Ending stage:

After the game end, the server will broadcast the ending message to all the clients. After all the session on that room ended, the server will recycle all the memory assigned to that room.

class design

Some core classes are shown as follow:

picture

Milestone

define basic data models

define core models for game

define cards, hero and other useful data structures

login and send message to other player

Assign cards and hero to player

define card action like slah(杀), dodge(闪), peach(桃)

add api for card action

add js and fornt to interact with back end

add unit test for all the models

Add database to instead of hard code Singleton data model

sanguoshacard's People

Contributors

mikeling avatar

Watchers

James Cloos avatar  avatar  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.