High level overview
This document describes the design of simple game using Domain-Driven Design (DDD) principles. The game allows players to earn points, join a clan, and contribute points to their clans.
- Player: The user
- PlayerEarn: The player earning points (when entered the playing state in client app).
- PlayerContribution: The player earning in a clan (already joined a clan).
-
Player: The player is the main entity. Each player has a unique ID, a name and a PlayerEarn records, which the some of it indicate the player total earned points.
-
Clan: A clan is a group of players. Each clan has a unique ID, a name, and points which is the sum of its players contributions.
- PlayerEarn: Player earning records, the total of records indicate player total points.
- PlayerContribution: Player points contribution in a clan, the total contributions in a clan indicate the clan total points, the total contributions of a player in a clan indicate the player total points in the clan.
- Player: The player is an aggregate root. All operations related to a player must go through the player aggregate.
- Clan: Similarly, the clan is also an aggregate root. All operations related to a clan must go through the clan aggregate.
- PlayerEarned: This event is triggered when a player earn points.
- PointsContributed: This event is triggered when a player earn point in a clan.
- ClanManagement Service: This service handles the clan operations, adding and removing players, and managing clan points.
- PlayerManagement Service: This service handles player operation, currently, earning only.
Open a new terminal and navigate to Console app cli-afk
.
install dependencies, then run the app
dotnet restore
dotnet run
The app will run and wait for messages to consume.
Service is running and waiting for messages to consume!
|
Open a new terminal and navigate to Console app cli-afk-client
.
install dependencies, then run the app
dotnet restore
dotnet run
The app will run and you'll be asked to login with a username.
----------- Welcome! -------
Enter your player name to login
|
Welcome <name>
Enter the following options to perform an action:
1 - Start playing
2 - List clans
Enter 1 to start playing.
Every time you play, you start with 0, the number will increase by 1 for every second as long as you playing.
Welcome <name>
5507
from Database
sqlite> select name from player;
Ali
Mona
nafie
sqlite> select name from clan;
Knights
Samurai
Vikings
sqlite> select sum(points) from player_contribution where player_id = 'nafie' and clan_id = 'Knights';
2208
sqlite> select name, clan_id from player;
nafie|Knights
Mona|
Ali|
sqlite> select sum(points) from player_contribution where player_id = 'nafie' and clan_id = 'Knights';
2208
sqlite> select sum(points) from player_earn where player_id = 'Mona';
5667
sqlite> select sum(points) from player_earn where player_id = 'Ali';
3410