tennis scoring -> str8 b05

This commit is contained in:
Mashy
2019-09-19 15:07:16 +10:00
parent 948c62f9ef
commit f04d179023
5 changed files with 32 additions and 17 deletions
+2 -2
View File
@@ -15,9 +15,9 @@ use chrono::Duration;
use account::Account;
use account;
use events::{EventsTx, Event};
use player::{Player, Score, player_create};
use construct::{Construct, construct_get};
use mob::{bot_player, instance_mobs};
use game::{Game, Phase, game_get, game_write, game_update};
use item::{Item};
+3 -2
View File
@@ -655,9 +655,10 @@ impl Item {
Item::Banish|
Item::BanishPlus |
Item::BanishPlusPlus => format!("Banish target for {:?}T.
Item::BanishPlusPlus => format!("Banish target for {:?}T. Deal blue damage and red damage equal to {:?}% target red and blue life.
Banished constructs are immune to all skills and effects.",
self.into_skill().unwrap().effect()[0].get_duration()),
self.into_skill().unwrap().effect()[0].get_duration(),
self.into_skill().unwrap().multiplier()),
Item::Blast|
Item::BlastPlus |
+16 -11
View File
@@ -27,24 +27,26 @@ pub enum Score {
}
impl Score {
pub fn add_win(self, opp: &Score) -> Score {
pub fn add_win(self, _opp: &Score) -> Score {
match self {
Score::Zero => Score::One,
Score::One => Score::Two,
Score::Two => Score::Three,
Score::Three => match opp {
Score::Adv => Score::Three,
Score::Three => Score::Adv,
_ => Score::Win,
}
Score::Adv => Score::Win,
Score::Two => Score::Win,
// Tennis scoring
// Score::Three => match opp {
// Score::Adv => Score::Three,
// Score::Three => Score::Adv,
// _ => Score::Win,
// }
// Score::Adv => Score::Win,
_ => panic!("faulty score increment {:?}", self),
}
}
pub fn add_loss(self) -> Score {
match self {
Score::Adv => Score::Three,
// Score::Adv => Score::Three,
_ => self,
}
}
@@ -376,7 +378,10 @@ mod tests {
player.score = player.score.add_win(&Score::Zero);
player.score = player.score.add_win(&Score::Zero);
player.score = player.score.add_win(&Score::Zero);
assert_eq!(player.score, Score::Three); // 40 / 0
assert_eq!(player.score, Score::Win); // 40 / 0
// Bo7 tennis scoring
/*assert_eq!(player.score, Score::Three); // 40 / 0
player.score = player.score.add_loss(); // adv -> deuce
assert_eq!(player.score, Score::Three);
@@ -391,7 +396,7 @@ mod tests {
assert_eq!(player.score, Score::Adv);
player.score = player.score.add_win(&Score::Three);
assert_eq!(player.score, Score::Win);
assert_eq!(player.score, Score::Win);*/
}
}