HuangFuSL / Werewolf

The final project of Computer Network in 2020A
MIT License
1 stars 3 forks source link

Werewolf

The final project of Computer Network in 2020A, written in Python.

Weekly Report Summary

Progress To-do List:

Meeting Summary:

2020/10/12

Function Demand: Gamerule, which is listed in docs.

Demo implementation:

Protocol implementation: Please refer to its introduction page

2020/10/16

Function Demand: Player's identity

All players in the game are summarized in a abstract class Person which provides the following attributes and methods.

Villager is the subclass of Person, corresponds to the villager identity in the game. This subclass does not have any more attributes or methods.

Wolf is the subclass of Person, corresponds to all the evil identities in the game, including werewolves, King of Werewolves, and the White Werewolf. The latter two is the subclass of Wolf. The Wolf class include the following attributes and methods:

SkilledPerson is the abstract subclass of Person, corresponds to the skilled villager identity in the game, including Predictor, Witch, Hunter, Guard and Idiot. The specific identity should be implemented in the subclass

It should be noticed that the all the method mentioned above are based on the protocol and sends a packet to the client when the method is called. These methods return the action status of the play. For werewolves, for example, kill() method should return a number indicating the person to be killed and destruct() method should return a boolean value indicating whether the werewolf want to reveal its identity.

This layer is implemented on 2020/10/24, in abstraction.py

Function Demand: Server interface

The server should control the game progress, and inform each player's action.

Task: GUI design

PyQt5 is used to design and implement the GUI. A prototype will be needed.

2020/10/25

Code Review Result of abstraction.py

The original file is modified to meet the function demand. Refer to the annotation in the file to get more information about the structure of the classes. UML graph is shown below:

UML

Implementation of server side

Implementation of client side

2020/10/31

Implementation of server side

The server plays a role as the God in the werewolf game, most game rules are carried out by the server and it follows the implementation logic like the following:

Server

Implementation of client side

Client

2020/11/08

Implementation of server side

The code is committed to server.py and logic.py

Currently pending for further implementation and code review!

Implementation of client side

Discussed implementation of the special ability of wolves (狼人自爆). The consensus was that this ability is triggered by Ctrl-C. Python will raise an KeyboardInterrupt exception to break out from the ongoing thread. The client use try-except to catch this input and start processing.

The current code is committed to client_subthread.py. This file is not designed to be a standalone Python script file. It is to be checked and modulized.

Currently pending for further implementation and code review!

2020/11/15

Implementation of server side

The code is committed to server.py and logic.py. For code review please refer to the following commits:

Issues during the development:

Currently pending for code review, static syntax check and joint debug with the client.

Implementation of client side

Progressed the implementation of the client side. Existing code is merged into client.py, and pending for code review. Please refer to history commits for more information.

Issues during the development: