Fix subtract with overflow bug.

This commit is contained in:
yukirij 2024-08-18 16:55:30 -07:00
parent b119775293
commit aaae17c6b2
2 changed files with 4 additions and 4 deletions

View File

@ -31,11 +31,11 @@ impl Hex {
pub fn from_tile(tile:u8) -> Self
{
let mut x = 0;
let mut x = 0i32;
while tile >= ROWS[x as usize + 1] { x += 1; }
let y = tile - ROWS[x as usize] + ((x > 4) as u8 * (x - 4));
let y = tile - ROWS[x as usize] + ((x > 4) as i32 * (x - 4)) as u8;
Self {
x,
x:x as u8,
y,
tile,
}

View File

@ -5,7 +5,7 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="application-name" content="Omen">
<meta name="description" content="Abstract strategy wargame.">
<meta name="description" content="Strategy board game played on a hexagon grid.">
<link rel="icon" href="/favicon.png">
<link rel="stylesheet" href=".css">
<script src=".js"></script>