1
1
use dojo :: world :: {IWorldDispatcher , IWorldDispatcherTrait };
2
- use bytebeasts :: {
3
- models :: {player :: Player , tournament :: Tournament , tournament :: TournamentStatus },
4
- };
2
+ use bytebeasts :: {models :: {player :: Player , tournament :: Tournament , tournament :: TournamentStatus },};
5
3
6
4
#[dojo:: interface]
7
5
trait ITournamentAction {
8
- fn create_tournament (ref world : IWorldDispatcher , tournament_id : u32 , name : felt252 ,
6
+ fn create_tournament (
7
+ ref world : IWorldDispatcher ,
8
+ tournament_id : u32 ,
9
+ name : felt252 ,
9
10
status : TournamentStatus ,
10
11
entry_fee : u32 ,
11
12
max_participants : u32 ,
12
13
current_participants : Array <Player >,
13
- prize_pool : u32 ) -> Tournament ;
14
- fn register_player (ref world : IWorldDispatcher , tournament_id : u32 , player_id : u32 );
15
- fn start_tournament (ref world : IWorldDispatcher , tournament_id : u32 , player_id : u32 );
16
- fn complete_torunament (ref world : IWorldDispatcher , tournament_id : u32 , player_id : u32 );
17
- fn get_tournament (ref world : IWorldDispatcher , tournament_id : u32 ) -> Tournament ;
14
+ prize_pool : u32
15
+ );
16
+ // fn register_player(ref world: IWorldDispatcher, tournament_id: u32, player_id: u32);
17
+ // fn start_tournament(ref world: IWorldDispatcher, tournament_id: u32, player_id: u32);
18
+ // fn complete_torunament(ref world: IWorldDispatcher, tournament_id: u32, player_id: u32);
19
+ fn get_tournament (world : @ IWorldDispatcher , tournament_id : u32 ) -> Tournament ;
18
20
}
19
21
20
22
21
23
#[dojo:: contract]
22
- mod spawn_action {
24
+ mod tournament_system {
23
25
use super :: ITournamentAction ;
24
26
use bytebeasts :: {
25
- models :: {player :: Player , tournament :: Tournament },
27
+ models :: {player :: Player , tournament :: Tournament , tournament :: TournamentStatus },
26
28
};
27
29
28
30
#[abi(embed_v0)]
29
31
impl TournamentActionImpl of ITournamentAction <ContractState > {
32
+ fn create_tournament (
33
+ ref world : IWorldDispatcher ,
34
+ tournament_id : u32 ,
35
+ name : felt252 ,
36
+ status : TournamentStatus ,
37
+ entry_fee : u32 ,
38
+ max_participants : u32 ,
39
+ current_participants : Array <Player >,
40
+ prize_pool : u32
41
+ ) {
42
+ let tournament = Tournament {
43
+ tournament_id : tournament_id ,
44
+ name : name ,
45
+ status : status ,
46
+ entry_fee : entry_fee ,
47
+ max_participants : max_participants ,
48
+ current_participants : current_participants ,
49
+ prize_pool : prize_pool
50
+ };
51
+ set! (world , (tournament ))
52
+ }
53
+
30
54
fn get_tournament (world : @ IWorldDispatcher , tournament_id : u32 ) -> Tournament {
31
55
let tournament_from_world = get! (world , tournament_id , (Tournament ));
32
56
tournament_from_world
33
57
}
34
58
}
35
- }
59
+ }
0 commit comments