fix tiles not being unclaimed after multiple marble creations block each other
This commit is contained in:
parent
ce2e7c252a
commit
bb2b1fea7c
2 changed files with 31 additions and 2 deletions
26
src/config.rs
Normal file
26
src/config.rs
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
use raylib::ffi::KeyboardKey;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Debug, Default, Deserialize, Serialize)]
|
||||||
|
pub struct Config {
|
||||||
|
hotkeys: Hotkeys,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Default, Deserialize, Serialize)]
|
||||||
|
pub struct Hotkeys {
|
||||||
|
map: HashMap<String, Hotkey>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
pub struct Hotkey {
|
||||||
|
modifiers: Vec<u32>,
|
||||||
|
trigger: Trigger,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
|
pub enum Trigger {
|
||||||
|
Mouse(u32),
|
||||||
|
Key(u32),
|
||||||
|
}
|
|
@ -255,13 +255,17 @@ impl Machine {
|
||||||
}
|
}
|
||||||
|
|
||||||
// #### new marbles ####
|
// #### new marbles ####
|
||||||
|
let mut claim_positions = Vec::new();
|
||||||
// prepare creating the new marbles
|
// prepare creating the new marbles
|
||||||
for &(pos, _val, _dir) in &new_marbles {
|
for &(pos, _val, _dir) in &new_marbles {
|
||||||
let Some(Tile::Open(OpenTile::Blank, claim)) = self.board.get_mut(pos) else {
|
let Some(Tile::Open(OpenTile::Blank, claim)) = self.board.get_mut(pos) else {
|
||||||
unreachable!()
|
unreachable!()
|
||||||
};
|
};
|
||||||
*claim = match claim {
|
*claim = match claim {
|
||||||
Claim::Free => Claim::Claimed,
|
Claim::Free => {
|
||||||
|
claim_positions.push(pos);
|
||||||
|
Claim::Claimed
|
||||||
|
}
|
||||||
Claim::Claimed | Claim::Blocked => Claim::Blocked,
|
Claim::Claimed | Claim::Blocked => Claim::Blocked,
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
|
@ -277,7 +281,6 @@ impl Machine {
|
||||||
}
|
}
|
||||||
|
|
||||||
// #### movement ####
|
// #### movement ####
|
||||||
let mut claim_positions = Vec::new();
|
|
||||||
// mark claims to figure out what spaces can be moved to
|
// mark claims to figure out what spaces can be moved to
|
||||||
for &pos in &self.marbles[..old_marbles] {
|
for &pos in &self.marbles[..old_marbles] {
|
||||||
let Some(Tile::Marble { value: _, dir }) = self.board.get(pos) else {
|
let Some(Tile::Marble { value: _, dir }) = self.board.get(pos) else {
|
||||||
|
|
Loading…
Add table
Reference in a new issue