Giter VIP home page Giter VIP logo

go_mahjong's Introduction

go mahjong

UI

----> login.html <----> register.html
         |
         +----> game_list.html <----+-----------+
         |          |               |           |
         +----------+----> ready_view.html      |
         |          |           |               |
         +----------+-----------+----> playing_view.html

API

login
    >username
    >password
    <token
info
    >token
    <gameList
    <gameInfo
create
    >token
    >option
join
    >token
    >gameId
next
    >token
leave
    >token
op
    >token
    >op
    >indexs

FSM

player create
|playerList = []  |playerList = [...]  |playerChain        |playerChain
|rule             |rule                |rule               |ruleGuard
|game = prepare   |game = prepare      |game = ing         |game = ing
|set = prepare    |set = prepare       |set = prepare      |set = ing
|---------------->|------------------->|------------------>|
 player join       playerCount match    player ready
                                    start game           init set

init ruleGuard
|playerEventStack = []  |playerEventStack = [...]  |                  |playerEventStack = [...]
|                       |                          |curPlayerEvent    |
|---------------------->|------------------------->|----------------->|
  init player event       pop player event           do event or pass
                                                     rebuild palyer event or
                                                     pop next player event

if player event stack empty
|game = ing    |game = ing     |game = ing
|set = end     |set = prepare  |set = ing
|              |winInfo        |
|------------->|-------------->|
  calc result    player ready
  restart set    init set

player event stack
init stack
|{player 0 PULL4}        |{player x BUHUA}    |{player x after pull}   |{player x+1 HU}
|{player 1 PULL4}        |------------------->|                        |{player x+2 HU}         |empty
|{player 2 PULL4}        | op is BUHUA                                 |{player x+3 HU}         |
|{player 3 PULL4}        |                                             |----------------------->|
| ... * 3                |                                             | op is HU
|{player 0 PULL2}        |{player x HU,GANG}  |empty                   |                        |empty
|{player 1 PULL1}        |                    |                        |{player x+1 GANG}       |{player y+1 HU}   |empty
|{player 2 PULL1}        |------------------->|                        |{player x+2 GANG}       |{player y+2 HU}   |
|{player 3 PULL1}        | op is HU                                    |{player x+3 GANG}       |{player y+3 HU}   |
|{player 0 BUHUA}        |                                             |----------------------->|----------------->|
|{player 1 BUHUA}        |                                             | y op is GANG           | op is HU
|{player 2 BUHUA}        |                    |{player x CI}           |                        |
|{player 3 BUHUA}        |                    |{player x after pull}   |{player x+1 PENG}       |{player y CI}
|{player 0 after pull}   |------------------->|                        |{player x+2 PENG}       |{player y after pull}
|                        | op is GANG                                  |{player x+3 PENG}
|                        |                                             |{player x+1 CHI}        |empty
|                        |                                             |----------------------->|{player y PUSH}
|                        |                                             | y op is PENG or CHI    |{player y after push}
|                        |                    |{player x after push}   |
|                        |{player x PUSH}     |                        |{palyer x+1 PULL}
|                        |                    |                        |{player x+1 after pull}
|----------------------->|------------------->|----------------------->|
  after pull               all pass is push     after push

go_mahjong's People

Contributors

mapleque avatar

Stargazers

 avatar

Watchers

 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.