add code for 84 (WIP)
This commit is contained in:
+29
-4
@@ -56,6 +56,20 @@ pub enum Squares {
|
|||||||
enum CommunityChest {
|
enum CommunityChest {
|
||||||
AdvanceToGo,
|
AdvanceToGo,
|
||||||
GoToJail,
|
GoToJail,
|
||||||
|
DoNothing1,
|
||||||
|
DoNothing2,
|
||||||
|
DoNothing3,
|
||||||
|
DoNothing4,
|
||||||
|
DoNothing5,
|
||||||
|
DoNothing6,
|
||||||
|
DoNothing7,
|
||||||
|
DoNothing8,
|
||||||
|
DoNothing9,
|
||||||
|
DoNothing10,
|
||||||
|
DoNothing11,
|
||||||
|
DoNothing12,
|
||||||
|
DoNothing13,
|
||||||
|
DoNothing14,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, EnumIter, Clone)]
|
#[derive(Debug, EnumIter, Clone)]
|
||||||
@@ -70,6 +84,12 @@ enum Chance {
|
|||||||
GoToNextRAgain,
|
GoToNextRAgain,
|
||||||
GoToNextU,
|
GoToNextU,
|
||||||
GoBack3Squares,
|
GoBack3Squares,
|
||||||
|
DoNothing1,
|
||||||
|
DoNothing2,
|
||||||
|
DoNothing3,
|
||||||
|
DoNothing4,
|
||||||
|
DoNothing5,
|
||||||
|
DoNothing6,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@@ -143,8 +163,11 @@ impl Monopoly {
|
|||||||
let square = self.board.nth(distance).unwrap();
|
let square = self.board.nth(distance).unwrap();
|
||||||
match square {
|
match square {
|
||||||
Squares::G2J => self.go_to_jail(),
|
Squares::G2J => self.go_to_jail(),
|
||||||
Squares::CC1 | Squares::CC2 | Squares::CC3 => self.handle_community_chest(),
|
Squares::CC1 => self.handle_community_chest(Squares::CC1),
|
||||||
Squares::CH1 | Squares::CH2 => self.handle_chance(),
|
Squares::CC2 => self.handle_community_chest(Squares::CC2),
|
||||||
|
Squares::CC3 => self.handle_community_chest(Squares::CC3),
|
||||||
|
Squares::CH1 => self.handle_chance(Squares::CH1),
|
||||||
|
Squares::CH2 => self.handle_chance(Squares::CH2),
|
||||||
_ => square,
|
_ => square,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -154,7 +177,7 @@ impl Monopoly {
|
|||||||
Squares::Jail
|
Squares::Jail
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_chance(&mut self) -> Squares {
|
fn handle_chance(&mut self, square: Squares) -> Squares {
|
||||||
let card = self.draw_from_chance_pile_and_put_at_bottom();
|
let card = self.draw_from_chance_pile_and_put_at_bottom();
|
||||||
// dbg!(card);
|
// dbg!(card);
|
||||||
match card {
|
match card {
|
||||||
@@ -167,6 +190,7 @@ impl Monopoly {
|
|||||||
Chance::GoToNextR | Chance::GoToNextRAgain => self.go_to_railway(),
|
Chance::GoToNextR | Chance::GoToNextRAgain => self.go_to_railway(),
|
||||||
Chance::GoToNextU => self.go_to_utility(),
|
Chance::GoToNextU => self.go_to_utility(),
|
||||||
Chance::GoBack3Squares => self.go_back_3_squares(),
|
Chance::GoBack3Squares => self.go_back_3_squares(),
|
||||||
|
_ => square,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,11 +205,12 @@ impl Monopoly {
|
|||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_community_chest(&mut self) -> Squares {
|
fn handle_community_chest(&mut self, square: Squares) -> Squares {
|
||||||
let card = self.draw_from_community_chest_pile_and_put_at_bottom();
|
let card = self.draw_from_community_chest_pile_and_put_at_bottom();
|
||||||
match card {
|
match card {
|
||||||
CommunityChest::AdvanceToGo => self.advance_to_go(),
|
CommunityChest::AdvanceToGo => self.advance_to_go(),
|
||||||
CommunityChest::GoToJail => self.go_to_jail(),
|
CommunityChest::GoToJail => self.go_to_jail(),
|
||||||
|
_ => square,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ mod lib;
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let monopoly = lib::Monopoly::new();
|
let monopoly = lib::Monopoly::new();
|
||||||
let mut statistics = lib::Statistics::new(monopoly, 100_000);
|
let mut statistics = lib::Statistics::new(monopoly, 10_000_000);
|
||||||
statistics.run();
|
statistics.run();
|
||||||
statistics.show();
|
statistics.show();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user