The repository contains the realization of the concepts described in this repo
The player who starts the match is decided randomly before the game starts, and the game play consists in a fight between two players who start the match with some health points. On each of the players turns, they have to choose one of the actions below:
- give some damage to the opponent;
- heal some damage itself;
- a random option above with a bonus in the result;
- wait the timeout and pass the turn doing nothing.
The loser is the player who reaches zero life points first.
- Two players, both sitting in the respective positions: Top and Bottom; (can be extended to more players)
- Events such as Start and End match integrated with a simple UI;
- Events like Player Started and Finished Turn also integrated with a simple UI;
- Events that when players Heal and Deal damage;
- Timeouts for players turns;
- Restart point.
I am not going to go further with details about the implementation because you can check the repo. But the idea is to have a MVC with a separation between logic and the data. The game logic driven by pure C# classes named Processes which change the game data and dispatch events to the interested listeners.
The listeners are the UI components and the following State Machine that has two purposes: to control the flow in the client side and hold the controllers (States) that provide access to the Processes mentioned earlier:
All the comunication among the Views and Controller is done using the Singleton Pattern and the Observer Pattern.
- Game Controller and Turn-Based States
- Processes
- Game Model
- Game Events
- Game Data
- Game UI
- Game AI
- Some Patterns Used in the Implementation
- Configurations
Gif for a better visualization of the Game Flow:
The game is also a bit configurable, you can define:
- Players Health;
- Turn time out and time until start game;
- Damage, Heal and Bonus for Random
- AI Archetypes for both players;