File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,30 @@ impl GameState {
40
40
let mut new_state = self . clone ( ) ;
41
41
r#move. perform ( & mut new_state) ?;
42
42
new_state. turn += 1 ;
43
+
44
+ fn update_carrots ( player : & mut Hare , opponent_position : usize , board : & Board ) {
45
+ match board. get_field ( player. position ) {
46
+ Some ( Field :: Position1 ) if player. position > opponent_position => {
47
+ player. carrots += 10
48
+ }
49
+ Some ( Field :: Position2 ) if player. position > opponent_position => {
50
+ player. carrots += 30
51
+ }
52
+ _ => { }
53
+ }
54
+ }
55
+
56
+ update_carrots (
57
+ & mut new_state. player_one ,
58
+ new_state. player_two . position ,
59
+ & new_state. board ,
60
+ ) ;
61
+ update_carrots (
62
+ & mut new_state. player_two ,
63
+ new_state. player_one . position ,
64
+ & new_state. board ,
65
+ ) ;
66
+
43
67
Ok ( new_state)
44
68
}
45
69
You can’t perform that action at this time.
0 commit comments