Open SergioB-dev opened 2 years ago
Not sure how we want this to work. The current implementation calculates the score from the number of correct or wrong answers given. I.e would conflict with any additional score incrementation.
I.e adding this that I wrote out:
pub fn increment(&mut self, qta: &mut Level) {
//TODO: Current implementation is basic and not correct, see above documentation
self.score += match qta {
Level::Easy => 1,
Level::Medium => 3,
Level::Hard => 5,
}
}
Kind of conflicts with what is there already:
pub fn calculate_score(&self) -> u32 {
let total: i8 = (self.correct as i8) - (self.wrong as i8);
if total < 0 {
0u32
} else {
(total * 100) as u32
}
}
Any opinions of where we should take this?
Good point. The original idea behind increment
was just for it to be a way to adjust how a user's score is calculated. For example if a user gets 100% on easy, it shouldn't be worth getting 100% on medium or hard.
calculate_score
is just a way at getting the pct of correct answers while increment
does a little more.
That being said I see it looks like we can fix this by renaming score
to reflect more accurately what it is. Something like pct
or correct_pct
etc. Then once increment
is no longer modifying the only property calculate_score
is reading we are clear.
Increment should increase or decrease the score based on level, correct? I see also that questions have points and this should be baked into the final score as well. We have too many factors for that final calculate_score
function I think.
If we remove let total: i8 = (self.correct as i8) - (self.wrong as i8);
and make the final score a factoring of question points and level, possibly. Then correct and wrong are still part of the final win pct
. Sort of brainstorming here.
Right. I'm thinking that we should have two different properties on a User
at least.
A Score
which really represents their percentage of correct answers so this is always 0 - 100%
And Points
which represents their total throughout the game, and this is what increment
should affect.