@@ -8,7 +8,9 @@ pub struct Board(pub u8);
8
8
9
9
#[ derive( Copy , Clone , Eq , PartialEq , Debug ) ]
10
10
pub struct Progress {
11
+ /// How many points the player already has.
11
12
pub done : u16 ,
13
+ /// How many points the player needs to earn the badge.
12
14
pub goal : u16 ,
13
15
}
14
16
@@ -19,11 +21,19 @@ impl Progress {
19
21
}
20
22
}
21
23
24
+ /// Get the progress of earning the badge.
22
25
#[ must_use]
23
26
pub fn get_progress ( p : Peer , b : Badge ) -> Progress {
24
27
add_progress ( p, b, 0 )
25
28
}
26
29
30
+ /// Add the given value to the progress for the badge.
31
+ ///
32
+ /// May be negative if you want to decrease the progress.
33
+ /// If zero, does not change the progress.
34
+ ///
35
+ /// If the Peer is [`Peer::COMBINED`], the progress is added to every peer
36
+ /// and the returned value is the lowest progress.
27
37
#[ expect( clippy:: must_use_candidate) ]
28
38
pub fn add_progress ( p : Peer , b : Badge , v : i16 ) -> Progress {
29
39
let r = unsafe { bindings:: add_progress ( u32:: from ( p. 0 ) , u32:: from ( b. 0 ) , i32:: from ( v) ) } ;
@@ -33,11 +43,19 @@ pub fn add_progress(p: Peer, b: Badge, v: i16) -> Progress {
33
43
}
34
44
}
35
45
46
+ /// Get the personal best of the player.
36
47
#[ must_use]
37
48
pub fn get_score ( p : Peer , b : Badge ) -> i16 {
38
49
add_score ( p, b, 0 )
39
50
}
40
51
52
+ /// Add the given score to the board.
53
+ ///
54
+ /// May be negative if you want the lower scores
55
+ /// to rank higher. Zero value is not added to the board.
56
+ ///
57
+ /// If the Peer is [`Peer::COMBINED`], the score is added for every peer
58
+ /// and the returned value is the lowest of their best scores.
41
59
#[ expect( clippy:: must_use_candidate) ]
42
60
pub fn add_score ( p : Peer , b : Badge , v : i16 ) -> i16 {
43
61
let r = unsafe { bindings:: add_score ( u32:: from ( p. 0 ) , u32:: from ( b. 0 ) , i32:: from ( v) ) } ;
0 commit comments