I was too tired and put the wrong variables :(
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
use std::fmt::{self, Display};
|
||||||
|
|
||||||
use raylib::{
|
use raylib::{
|
||||||
prelude::{Color, MouseButton},
|
prelude::{Color, MouseButton},
|
||||||
RaylibHandle,
|
RaylibHandle,
|
||||||
@@ -59,7 +61,7 @@ pub struct MenuState {
|
|||||||
pub selection: Selection,
|
pub selection: Selection,
|
||||||
pub strategy: Strategy,
|
pub strategy: Strategy,
|
||||||
}
|
}
|
||||||
#[derive(Clone)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum Strategy {
|
pub enum Strategy {
|
||||||
MiniMax,
|
MiniMax,
|
||||||
AlphaBeta,
|
AlphaBeta,
|
||||||
@@ -91,11 +93,11 @@ impl MenuState {
|
|||||||
}
|
}
|
||||||
Selection::Cooking => {
|
Selection::Cooking => {
|
||||||
if rl.is_mouse_button_pressed(MouseButton::MOUSE_LEFT_BUTTON) {
|
if rl.is_mouse_button_pressed(MouseButton::MOUSE_LEFT_BUTTON) {
|
||||||
self.difficulty = 3;
|
self.strategy = Strategy::MiniMax;
|
||||||
self.selection = Selection::Done;
|
self.selection = Selection::Done;
|
||||||
}
|
}
|
||||||
if rl.is_mouse_button_pressed(MouseButton::MOUSE_RIGHT_BUTTON) {
|
if rl.is_mouse_button_pressed(MouseButton::MOUSE_RIGHT_BUTTON) {
|
||||||
self.difficulty = 5;
|
self.strategy = Strategy::AlphaBeta;
|
||||||
self.selection = Selection::Done;
|
self.selection = Selection::Done;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -115,6 +117,16 @@ pub enum Selection {
|
|||||||
Cooking,
|
Cooking,
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
impl Display for Strategy {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
let name: String;
|
||||||
|
match self {
|
||||||
|
Self::MiniMax => name = String::from("MiniMax"),
|
||||||
|
Self::AlphaBeta => name = String::from("AlphaBeta"),
|
||||||
|
};
|
||||||
|
write!(f, "{}", name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn get_circle_coords(x: i32, y: i32) -> (i32, i32) {
|
fn get_circle_coords(x: i32, y: i32) -> (i32, i32) {
|
||||||
let mut returned: (i32, i32) = (0, 0);
|
let mut returned: (i32, i32) = (0, 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user