@@ -26,6 +26,7 @@ struct Game {
26
26
price : u256 ,
27
27
clock : u64 ,
28
28
penalty : u64 ,
29
+ limit : u32 ,
29
30
}
30
31
31
32
#[derive(Drop , PartialEq )]
@@ -62,7 +63,18 @@ impl GameImpl of GameTrait {
62
63
assert (host != 0 , errors :: GAME_INVALID_HOST );
63
64
64
65
// [Return] Default game
65
- Game { id , host , over : false , seed : 0 , player_count : 0 , nonce : 0 , price , clock : 0 , penalty }
66
+ Game {
67
+ id ,
68
+ host ,
69
+ over : false ,
70
+ seed : 0 ,
71
+ player_count : 0 ,
72
+ nonce : 0 ,
73
+ price ,
74
+ clock : 0 ,
75
+ penalty ,
76
+ limit : 0
77
+ }
66
78
}
67
79
68
80
#[inline(always)]
@@ -160,7 +172,7 @@ impl GameImpl of GameTrait {
160
172
self . host = host ;
161
173
}
162
174
163
- fn start (ref self : Game , time : u64 , mut players : Array <felt252 >) {
175
+ fn start (ref self : Game , time : u64 , round_count : u32 , mut players : Array <felt252 >) {
164
176
// [Check] Game is valid
165
177
self . assert_exists ();
166
178
self . assert_not_over ();
@@ -178,6 +190,7 @@ impl GameImpl of GameTrait {
178
190
};
179
191
self . seed = state . finalize ();
180
192
self . clock = time ;
193
+ self . limit = self . player_count. into () * round_count * TURN_COUNT ;
181
194
}
182
195
183
196
#[inline(always)]
@@ -308,7 +321,8 @@ impl ZeroableGame of core::Zeroable<Game> {
308
321
nonce : 0 ,
309
322
price : 0 ,
310
323
clock : 0 ,
311
- penalty : 0
324
+ penalty : 0 ,
325
+ limit : 0 ,
312
326
}
313
327
}
314
328
@@ -345,6 +359,7 @@ mod tests {
345
359
const HOST : felt252 = ' HOST' ;
346
360
const PLAYER : felt252 = ' PLAYER' ;
347
361
const TIME : u64 = 1337 ;
362
+ const ROUND_COUNT : u32 = 100 ;
348
363
349
364
#[test]
350
365
#[available_gas(100_000)]
@@ -491,7 +506,7 @@ mod tests {
491
506
game . join ();
492
507
};
493
508
let players = array! [HOST , PLAYER ];
494
- game . start (TIME , players );
509
+ game . start (TIME , ROUND_COUNT , players );
495
510
assert (game . seed != 0 , ' Game: wrong seed' );
496
511
}
497
512
@@ -502,7 +517,7 @@ mod tests {
502
517
let mut game = GameTrait :: new (ID , HOST , PRICE , PENALTY );
503
518
game . player_count = 0 ;
504
519
let players = array! [HOST , PLAYER ];
505
- game . start (TIME , players );
520
+ game . start (TIME , ROUND_COUNT , players );
506
521
}
507
522
508
523
#[test]
@@ -512,7 +527,7 @@ mod tests {
512
527
let mut game = GameTrait :: new (ID , HOST , PRICE , PENALTY );
513
528
game . over = true ;
514
529
let players = array! [HOST , PLAYER ];
515
- game . start (TIME , players );
530
+ game . start (TIME , ROUND_COUNT , players );
516
531
}
517
532
518
533
#[test]
@@ -522,7 +537,7 @@ mod tests {
522
537
let mut game = GameTrait :: new (ID , HOST , PRICE , PENALTY );
523
538
game . seed = 1 ;
524
539
let players = array! [HOST , PLAYER ];
525
- game . start (TIME , players );
540
+ game . start (TIME , ROUND_COUNT , players );
526
541
}
527
542
528
543
#[test]
0 commit comments