Fix back tile checking for x=0.

This commit is contained in:
yukirij 2024-10-18 01:09:40 -07:00
parent 08562d9a3e
commit e5377cd64a
3 changed files with 3 additions and 10 deletions

View File

@ -337,12 +337,9 @@ impl Game {
2 => {
if let Some(piece_id) = self.board.tiles[play.from as usize].piece {
println!("A");
if let Some(piece) = &self.board.pieces[piece_id as usize] {
println!("B");
if piece.player == player {
let plays = self.get_alts(piece);
println!("plays {}", plays.len());
for p in plays {
if p.to == play.to {
valid = true;
@ -591,9 +588,7 @@ impl Game {
/*
** Filter valid tiles from allowed.
*/
println!("C2 {} {} {}", piece.class, piece.promoted, piece_moves.alt.is_some());
if let Some(alt_mode) = piece_moves.alt {
println!("C3 {}", alt_mode);
match alt_mode {
// Knight
1 => {
@ -616,9 +611,6 @@ impl Game {
let piece_hex = Hex::from_tile(piece.tile);
let tile_hex = Hex::from_tile(tile_id);
println!("piece_hex {} {} {}", piece_hex.x, piece_hex.y, piece_hex.y);
println!("tile_hex {} {} {}", tile_hex.x, tile_hex.y, tile_hex.y);
let in_rear_cone = if piece.player == 0 {
if tile_hex.x >= piece_hex.x {
tile_hex.y <= piece_hex.y
@ -654,7 +646,6 @@ impl Game {
pub fn get_alts(&self, piece:&Piece) -> Vec<Play>
{
println!("C1");
self.get_alts_data(piece).iter().map(|info| info.play).collect()
}

View File

@ -76,7 +76,7 @@ impl Hex {
[3, 8],
[4, 8],
];
if x > 0 && x < 9 {
if x >= 0 && x < 9 {
y == COLUMNS[x as usize][1 ^ player as usize]
} else { false }
}

View File

@ -1084,6 +1084,8 @@ fn generate_game_state(app:&App, session:&Session) -> protocol::PacketGameStateR
async fn change_context(app:&mut App, conn_id:u32, user_id:Option<u32>, context:Context)
{
println!("Context Change: {}", conn_id, );
// Clear existing context
if let Some(conn) = app.connections.get(conn_id as usize).cloned() {
match conn.context {