From 093a65ae9640f2765834f7b2c53bffdfabf288af Mon Sep 17 00:00:00 2001 From: Jeff Wu Date: Thu, 10 Mar 2016 22:49:20 -0800 Subject: [PATCH] small bugfixes --- src/game.rs | 2 ++ src/info.rs | 17 +++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/game.rs b/src/game.rs index dd1cde5..85ce2f9 100644 --- a/src/game.rs +++ b/src/game.rs @@ -182,6 +182,8 @@ pub struct GameOptions { pub num_hints: u32, // when hits 0, you lose pub num_lives: u32, + // TODO: + // pub allow_empty_hints: bool, } // The state of a given player: all other players may see this diff --git a/src/info.rs b/src/info.rs index 6dea5de..0300e19 100644 --- a/src/info.rs +++ b/src/info.rs @@ -28,7 +28,8 @@ pub trait Info where T: Hash + Eq + Clone { } fn is_possible(&self, value: &T) -> bool { - self.get_possibility_map().contains_key(value) + // self.get_possibility_map().contains_key(value) + *self.get_possibility_map().get(value).unwrap() } fn initialize() -> HashMap { @@ -131,15 +132,19 @@ impl CardInfo { impl fmt::Display for CardInfo { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let mut string = String::new(); - for color in &self.color_info.get_possibilities() { - let colorchar = color.chars().next().unwrap(); - string.push(colorchar); + for color in &COLORS { + if self.color_info.is_possible(color) { + let colorchar = color.chars().next().unwrap(); + string.push(colorchar); + } } // while string.len() < COLORS.len() + 1 { string.push(' '); //} - for value in &self.value_info.get_possibilities() { - string.push_str(&format!("{}", value)); + for value in &VALUES { + if self.value_info.is_possible(value) { + string.push_str(&format!("{}", value)); + } } f.pad(&string) }