Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor fixes in varaman #681

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 83 additions & 31 deletions docs/examples/Gaming/varaman.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ The VaraMan program contains the following information:

```rust title="vara-man/src/lib.rs"
struct VaraMan {
games: HashMap<ActorId, GameInstance>,
players: HashMap<ActorId, Player>,
tournaments: HashMap<ActorId, Tournament>,
players_to_game_id: HashMap<ActorId, ActorId>,
status: Status,
config: Config,
admins: Vec<ActorId>,
Expand All @@ -47,14 +47,19 @@ struct VaraMan {
* `config` - program configuration
* `admins` - admins addresses

Where the structure of the `GameInstance` and the `GameInstance` is defined as follows
Where the structure of the `Tournament` is defined as follows

```rust title="vara-man/io/src/lib.rs"
pub struct GameInstance {
pub level: Level,
pub gold_coins: u64,
pub silver_coins: u64,
```rust title="vara-man/src/lib.rs"
pub struct Tournament {
tournament_name: String,
admin: ActorId,
level: Level,
participants: HashMap<ActorId, Player>,
bid: u128,
stage: Stage,
duration_ms: u32,
}

```
* `level` - level of difficulty (Easy/Medium/Hard)
* `gold_coins` - number of gold coins collected
Expand All @@ -63,9 +68,8 @@ pub struct GameInstance {
```rust title="vara-man/io/src/lib.rs"
pub struct Player {
pub name: String,
pub lives: u64,
pub claimed_gold_coins: u64,
pub claimed_silver_coins: u64,
pub time: u128,
pub points: u128,
}
```

Expand Down Expand Up @@ -103,16 +107,15 @@ pub struct VaraManInit {
```
```rust title="vara-man/io/src/lib.rs"
pub struct Config {
pub one_coin_in_value: u64,
pub tokens_per_gold_coin_easy: u64,
pub tokens_per_silver_coin_easy: u64,
pub tokens_per_gold_coin_medium: u64,
pub tokens_per_silver_coin_medium: u64,
pub tokens_per_gold_coin_hard: u64,
pub tokens_per_silver_coin_hard: u64,
pub gold_coins: u64,
pub silver_coins: u64,
pub number_of_lives: u64,
pub one_point_in_value: u128,
pub points_per_gold_coin_easy: u128,
pub points_per_silver_coin_easy: u128,
pub points_per_gold_coin_medium: u128,
pub points_per_silver_coin_medium: u128,
pub points_per_gold_coin_hard: u128,
pub points_per_silver_coin_hard: u128,
pub gas_for_finish_tournament: u64,
pub time_for_single_round: u32,
}
```

Expand All @@ -131,9 +134,37 @@ pub struct Config {

```rust title="vara-man/io/src/lib.rs"
pub enum VaraManAction {
StartGame { level: Level },
RegisterPlayer { name: String },
ClaimReward { silver_coins: u64, gold_coins: u64 },
CreateNewTournament {
tournament_name: String,
name: String,
level: Level,
duration_ms: u32,
},
StartTournament,
RegisterForTournament {
admin_id: ActorId,
name: String,
},
CancelRegister,
CancelTournament,
DeletePlayer {
player_id: ActorId,
},
RecordTournamentResult {
time: u128,
gold_coins: u128,
silver_coins: u128,
},
FinishTournament {
admin_id: ActorId,
time_start: u64,
},
FinishSingleGame {
gold_coins: u128,
silver_coins: u128,
level: Level,
},
LeaveGame,
ChangeStatus(Status),
ChangeConfig(Config),
AddAdmin(ActorId),
Expand All @@ -145,17 +176,38 @@ pub enum VaraManAction {

```rust title="vara-man/io/src/lib.rs"
pub enum VaraManEvent {
GameStarted,
RewardClaimed {
player_address: ActorId,
silver_coins: u64,
gold_coins: u64,
GameFinished {
winners: Vec<ActorId>,
participants: Vec<ActorId>,
prize: u128,
},
NewTournamentCreated {
tournament_name: String,
name: String,
level: Level,
bid: u128,
},
PlayerRegistered {
admin_id: ActorId,
name: String,
bid: u128,
},
RegisterCanceled,
TournamentCanceled {
admin_id: ActorId,
},
PlayerDeleted {
player_id: ActorId,
},
ResultTournamentRecorded {
time: u128,
points: u128,
},
GameStarted,
AdminAdded(ActorId),
PlayerRegistered(ActorId),
StatusChanged(Status),
ConfigChanged(Config),
Error(String),
LeftGame,
}
```

Expand Down