File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -34,8 +34,22 @@ impl Card {
3434 other : & mut Hare ,
3535 ) -> Result < ( ) , PyErr > {
3636 match self {
37- Card :: FallBack => current. move_to_field ( state, other. position - 1 ) ?,
38- Card :: HurryAhead => current. move_to_field ( state, other. position + 1 ) ?,
37+ Card :: FallBack => {
38+ if current. position < other. position {
39+ return Err ( CannotPlayCardError :: new_err (
40+ "You can only play this card if you are ahead of the other player" ,
41+ ) ) ;
42+ }
43+ current. move_to_field ( state, other. position - 1 ) ?;
44+ }
45+ Card :: HurryAhead => {
46+ if current. position > other. position {
47+ return Err ( CannotPlayCardError :: new_err (
48+ "You can only play this card if you are behind the other player" ,
49+ ) ) ;
50+ }
51+ current. move_to_field ( state, other. position + 1 ) ?;
52+ }
3953 Card :: EatSalad => current. eat_salad ( state) ?,
4054 Card :: SwapCarrots => swap ( & mut current. carrots , & mut other. carrots ) ,
4155 }
You can’t perform that action at this time.
0 commit comments