1 / 24

Mahjong Game

Mahjong Game. Clients. Server. Mahjong Game. Clients. Server. Mahjong Game. Good design will pay off in the long run Item Identify appropriate classes and interfaces. Mahjong Game. Clients. JOIN, PlayerName. Server. Design a communication protocol. Mahjong Game. Clients.

Download Presentation

Mahjong Game

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Mahjong Game Clients Server

  2. Mahjong Game Clients Server

  3. Mahjong Game Good design will pay off in the long run Item Identify appropriate classes and interfaces

  4. Mahjong Game Clients JOIN, PlayerName Server Design a communication protocol

  5. Mahjong Game Clients Server Design a communication protocol PLAYER_JOINED, PlayerName PLAYER_JOINED, PlayerName PLAYER_JOINED, PlayerName

  6. Mahjong Game Clients READY Server Design a communication protocol READY READY

  7. Mahjong Game Clients Server Design a communication protocol TILE_SET, … … … TILE_SET, … … … TILE_SET, … … …

  8. Mahjong Game Clients Server Design a communication protocol GUESS, 9, 2

  9. Mahjong Game Clients Server Good design will pay off in the long run Item Identify appropriate classes and interfaces Design a communication protocol SCORE, +1

  10. Mahjong Game Clients Server Design a communication protocol NEW_TILES, 8, 3 NEW_TILES, 8, 3 NEW_TILES, 8, 3

  11. Mahjong Game JOIN PlayerName Design communication protocol – packets of data of agreed upon format Join Request:

  12. Mahjong Game JOIN PlayerName READY Design communication protocol – packets of data of agreed upon format Join Request: Ready Request:

  13. Mahjong Game JOIN PlayerName READY Design communication protocol – packets of data of agreed upon format Join Request: Ready Request: Player Joined: PLAYER_JOINED PlayerName

  14. Mahjong Game JOIN PlayerName READY Design communication protocol – packets of data of agreed upon format Join Request: Ready Request: Player Joined: Player Guess: PLAYER_JOINED PlayerName Guess Tile 1 Tile 2

  15. Mahjong Game JOIN PlayerName READY Design communication protocol – packets of data of agreed upon format Join Request: Ready Request: Player Joined: Player Guess: Replace Tiles: PLAYER_JOINED PlayerName Guess Tile 1 Tile 2 REPLACE Old Tile 1 New Tile 1 Old Tile 2 New Tile 2

  16. Mahjong Game JOIN PlayerName READY Design communication protocol – packets of data of agreed upon format Join Request: Ready Request: Player Joined: Player Guess: Replace Tiles: Initial Tiles: PLAYER_JOINED PlayerName Guess Tile 1 Tile 2 REPLACE Old Tile 1 New Tile 1 Old Tile 2 New Tile 2 TILES Count Tile 1 Tile 2 Tile N

  17. Mahjong Game JOIN PlayerName READY Design communication protocol – packets of data of agreed upon format Join Request: Ready Request: Player Joined: Player Guess: Replace Tiles: Initial Tiles: Update Score: PLAYER_JOINED PlayerName Guess Tile 1 Tile 2 REPLACE Old Tile 1 New Tile 1 Old Tile 2 New Tile 2 TILES Count Tile 1 Tile 2 Tile N UPDATE_SCORE Amount

  18. Mahjong Game JOIN PlayerName READY Design communication protocol – packets of data of agreed upon format Join Request: Ready Request: Player Joined: Player Guess: Replace Tiles: Initial Tiles: Update Score: PLAYER_JOINED PlayerName Guess Tile 1 Tile 2 REPLACE Old Tile 1 New Tile 1 Old Tile 2 New Tile 2 TILES Count Tile 1 Tile 2 Tile N UPDATE_SCORE Amount

  19. Mahjong Game Server listening thread while (...) { int action = input.readInt(); if (action == JOIN) { processPlayerJoin(); // <-- read rest of data } else if (action == READY) { processPlayerReady(); // <-- read rest of data } else if (action == GUESS) { processPlayerGuess(); // <-- read rest of data } }

  20. Mahjong Game Client listening thread (similar structure as server) while (...) { int action = input.readInt(); if (action == REPLACE) { processReplaceTiles(); // <-- read rest of data } else if (action == TILES) { processTileSet(); // <-- read rest of data } else if (action == UPDATE_SCORE) { processUpdateScore(); // <-- read rest of data } }

  21. Mahjong Game SERVER players Class design round tiles

  22. Mahjong Game SERVER PLAYER players name Class design (server side) score socket connection round input channel tiles output channel

  23. Mahjong Game MIDLET (main app) TILES CANVAS TILE user interface widgets displayed tiles image Class design (client side) ulx, uly name selected tiles selected score round

  24. Mahjong Game SOCKET IO (Thread) Class design (client side) input steam (reads in run method) output steam (writes as needed)

More Related