The thing is working (forced to use a variable for the conversion with
into()).
This commit is contained in:
parent
a490b2a72f
commit
5aa28c2b07
@ -62,17 +62,39 @@ pub fn round_score(play: char, counter_play: char) -> i32 {
|
|||||||
let coup = Play::from(play); // translate to the play
|
let coup = Play::from(play); // translate to the play
|
||||||
let counter = Play::from(counter_play); // translate to the play
|
let counter = Play::from(counter_play); // translate to the play
|
||||||
if coup == counter {
|
if coup == counter {
|
||||||
(ResultPlay::Draw as i32) + (counter_play as i32)
|
let draw: i32 = ResultPlay::Draw.into();
|
||||||
|
let result: i32 = counter.into();
|
||||||
|
draw + result
|
||||||
} else {
|
} else {
|
||||||
use Play::*;
|
use Play::*;
|
||||||
use ResultPlay::*;
|
use ResultPlay::*;
|
||||||
|
let loss: i32 = Loss.into();
|
||||||
|
let win: i32 = Win.into();
|
||||||
match (&coup, &counter) {
|
match (&coup, &counter) {
|
||||||
(Rock, Paper) => (Win as i32) + (counter as i32),
|
(Rock, Paper) => {
|
||||||
(Rock, Scissors) => (Loss as i32) + (counter as i32),
|
let result: i32 = counter.into();
|
||||||
(Paper, Rock) => (Loss as i32) + (counter as i32),
|
win + result
|
||||||
(Paper, Scissors) => (Win as i32) + (counter as i32),
|
}
|
||||||
(Scissors, Rock) => (Win as i32) + (counter as i32),
|
(Rock, Scissors) => {
|
||||||
(Scissors, Paper) => (Loss as i32) + (counter as i32),
|
let result: i32 = counter.into();
|
||||||
|
loss + result
|
||||||
|
}
|
||||||
|
(Paper, Rock) => {
|
||||||
|
let result: i32 = counter.into();
|
||||||
|
loss + result
|
||||||
|
}
|
||||||
|
(Paper, Scissors) => {
|
||||||
|
let result: i32 = counter.into();
|
||||||
|
win + result
|
||||||
|
}
|
||||||
|
(Scissors, Rock) => {
|
||||||
|
let result: i32 = counter.into();
|
||||||
|
win + result
|
||||||
|
}
|
||||||
|
(Scissors, Paper) => {
|
||||||
|
let result: i32 = counter.into();
|
||||||
|
loss + result
|
||||||
|
}
|
||||||
_ => panic!("Case not covered, impossible to reach."),
|
_ => panic!("Case not covered, impossible to reach."),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user