small bugfixes
This commit is contained in:
parent
1ad4f9b825
commit
093a65ae96
2 changed files with 13 additions and 6 deletions
|
@ -182,6 +182,8 @@ pub struct GameOptions {
|
||||||
pub num_hints: u32,
|
pub num_hints: u32,
|
||||||
// when hits 0, you lose
|
// when hits 0, you lose
|
||||||
pub num_lives: u32,
|
pub num_lives: u32,
|
||||||
|
// TODO:
|
||||||
|
// pub allow_empty_hints: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
// The state of a given player: all other players may see this
|
// The state of a given player: all other players may see this
|
||||||
|
|
11
src/info.rs
11
src/info.rs
|
@ -28,7 +28,8 @@ pub trait Info<T> where T: Hash + Eq + Clone {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_possible(&self, value: &T) -> bool {
|
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<T, bool> {
|
fn initialize() -> HashMap<T, bool> {
|
||||||
|
@ -131,16 +132,20 @@ impl CardInfo {
|
||||||
impl fmt::Display for CardInfo {
|
impl fmt::Display for CardInfo {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
let mut string = String::new();
|
let mut string = String::new();
|
||||||
for color in &self.color_info.get_possibilities() {
|
for color in &COLORS {
|
||||||
|
if self.color_info.is_possible(color) {
|
||||||
let colorchar = color.chars().next().unwrap();
|
let colorchar = color.chars().next().unwrap();
|
||||||
string.push(colorchar);
|
string.push(colorchar);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// while string.len() < COLORS.len() + 1 {
|
// while string.len() < COLORS.len() + 1 {
|
||||||
string.push(' ');
|
string.push(' ');
|
||||||
//}
|
//}
|
||||||
for value in &self.value_info.get_possibilities() {
|
for value in &VALUES {
|
||||||
|
if self.value_info.is_possible(value) {
|
||||||
string.push_str(&format!("{}", value));
|
string.push_str(&format!("{}", value));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
f.pad(&string)
|
f.pad(&string)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue