Hong Kong Institute of Vocational Education (Tsing Yi)
Department of Information Technology
HD in Game Software Development (IT114107) ITP4708 Game Servers Design and Implementation Assignment
Project Due Date and Time
22 May 2020 (Sat) 23:55 (via moodle)
Project Specification
This project consists of two parts. In part 1, you are required to write a server program which can handle both chat messages and number guess game simultaneously. In part 2, one more game is added to part 1, it is a game that the server will pick a random player to be the one, and other players are required to guess who is the one. Note that, the chat and the two games are running simultaneously. The bonus of the project is to save all the chat history to the MongoDB and client will load the history and display when it is first connected to the server.
Resources
TCP ChatServer:
TCP Guessing Game:
WS & Socket.IO Chat: Socket.IO Guessing Game: JSON (Java):
JSON (Java):
Lab 6, Q3 (node.js server, java client) Lab 6, Q4
Topic 8 Demo (has html and Java client) Lab 8, Q1
Topic 6 Demo (using GSON),
Topic 8 Demo – See Client (another JSON lib)
In the project, server is implemented using node.js. You can choose to use TCP, WebSocket or Socket.IO as the network protocol. You are required to implement the client, either in Java or html with JavaScript to test your server. You can use any libraries but must be included in your submission.
1
Part 1 – Chat and Number Guessing Game: 40%
When a client is started, the player send his / her name to the server, after that he or she can start chatting or play the number guessing together with other players simultaneously. To distinguish chat messages and game messages, game messages are starting with a hash symbol followed by the name of the game and the input, for example:
Hello, my name is Peter. // A Chat message #guess 35 // Make a guess, 35
Chat messages are broadcast to all connected clients in the following format:
Besides, the following are displayed when a player is connected or
disconnected:
SYSTEM:
For the number guessing game, server will generate a random secret integer between 1 and 100 (inclusive) and stored. Every time a player made a guess, a hint (smaller or larger than the secret) will broadcast to all the connected players in the following format:
GUESS@SYSTEM:
When someone made a correct guess, the following message will be broadcast to call players:
GUESS@SYSTEM:
For any invalid input sent to the server, such as non-numeric strings, floating point numbers or input out of range, server will send the following message will be displayed on the client who has wrong input (not broadcast):
GUESS@SYSTEM: Invalid input, it should be an int from 1 to 100 (inclusive)
2
In this project, client and server are communicating using JSON String, client should convert user’s input to a JSON String and send to the server. The server will response or send message to client using JSON String too. After a client received a JSON String, it will parse and display appropriate message to the player.
You are required to design your own JSON String in this project.
Part 2 – WHO is the one: 40%
Part 2 is an add-on to Part 1; you should include Part 1 in this Part.
This game has two type of status, idle and playing. Any player can get the status by input:
#who status
The server will return the status and display either the following to the player: WHO@SYSTEM: Idle or
WHO@SYSTEM: Playing
When the game is idle, any player can start the game by
#who start
If the game can start successfully, the status will set to playing and the following message will be broadcast to all players:
WHO@SYSTEM:
If the state is already playing, the following message will be show to the player:
WHO@SYSTEM: The game is already started.
3
Note that, the game can only be started when there are 3 or more players, if there are not enough players, the following message will be show to the player:
WHO@SYSTEM: Not enough player (at least 3).
After the game is started, the server will randomly pick a player as “the one”, following message will be show to “the one” only:
WHO@SYSTEM: You are the one, hide yourself!
And the following message will send to all players:
WHO@SYSTEM: Let’s guess who is the one.
When the game is playing, players (except the one) can make guess by
#who guess
player and become inactive
WHO@SYSTEM: Incorrect guess, you cannot play until the game is restarted or ended.
If the number of active players is reduced to two, the game will be terminated, and the following message will be broadcast to all players:
WHO@SYSTEM: Two players left,
If the player make a correct guess, the following message will be broadcast to all players
WHO@SYSTEM:
WHO@SYSTEM: You are the one, you cannot make any guess.
4
There are some special cases when the game is playing.
When a player (not the one) is disconnected and the number of player is reduced to two, the game will be terminated, and the following message will be broadcast to all players:
WHO@SYSTEM: Game terminated, not enough players.
And the status will become idle again.
When the one is disconnected, the game will be terminated, and the following message will be broadcast to all players:
WHO@SYSTEM: Game terminated, the one left.
Like Part 1, you are required to design your own JSON String for the messages between client and server of this part. In general, the client in Part 1 can be reused, but it is not a must.
Assumption: You may assume players’ name are unique.
Note: It is optional for server to handle incorrect hashtag and other errors, such as receiving message from inactive player.
Documentation of Part 1 and 2: 20%
You should provide a document to explain your design of JSON String and the protocol between client and server. Besides, you should provide evidence of testing (screen capture), showing different inputs for different situations that your program may encountered. You should clearly state the purpose of different tests. Finally, you should prepare a 5 to 10 minutes video to demonstrate how you run and test the program.
5
Bonus – 10%
The bonus of the project is to save all the chat history to the MongoDB and client will load the history and display when it is first connected to the server.
Technical Requirement
In this project, you may choose TCP, WebSocket or Socket.IO as the protocol, but you are required to provide corresponding client to test with. Besides, you are free to choose any JSON libraries, but you must include them in your submission. Below is the mark distribution of this project:
Part 1 JSON Handling
Part 1 Chat Server & Client Part 1 Game Server & Client Part 2 JSON Handling
Part 2 Game Server & Client Documentation
10 marks 15 marks 15 marks 10 marks 30 marks 20 marks
Documentation includes evidence of testing; document and video (10%), explanation on the protocol and json format used in your program (10%)
6
Instructions to Students
1. The weighting of this assignment is 40% of the Continuous Assessment (20% of Module Mark).
2. This project should be done by each individual student. Plagiarism will be treated seriously. All assignments that have been found involved wholly or partly in plagiarism (no matter these assignments are from the original authors or from the plagiarists) will score Zero mark.
3. You must use Node.js and Java (optional) to develop the programs.
4. You are required to hand in
4.1 Explanation on the protocol and json format used in your program in Microsoft Word
4.2 Source code of all the programs which should be well-commented.
4.3 The evidence of testing. Prepare a word document with several test cases showing different inputs for different situations that your program may encounter and how your program responses to show the capability of your program. For each test case, states the objective of the test case, input data and expected result. You should also include screen dump for each test run as evidence.
4.4 A Video of 5 to 10 minutes to demonstrate your work, you may upload the file to the internet and submit the link or submit the video file directly
5. Submit all your works (in a zip file) to the Moodle website (http://moodle.vtc.edu.hk) by 23:55, 22 May 2021 (Sat). Late submission may score ZERO mark.
7
6. Folders in the zip file
Programs Part 1
Server
package.json game.js
…
Client (optional – not necessary if included in server program) Client.java
Part 2 Server
package.json game.js
…
Client (optional – not necessary if included in server program) Client.java
Bonus
Server package.json
game.js
…
Client (optional – not necessary if included in server program)
Client.java
Documents
Data_Structure_Explanation.doc Evidence_of_Testing.doc Video_or_Video_link.mp4
8