diff --git a/game/src/config/mod.rs b/game/src/config/mod.rs index 905ab7e..9274570 100644 --- a/game/src/config/mod.rs +++ b/game/src/config/mod.rs @@ -1,4 +1,42 @@ +use crate::{Piece, PieceClass}; + +#[derive(Clone)] +pub struct TimingConfig { + game_limit:Option, + // Time available to each player + play_limit:Option, + // Time available per move + timeout_mode:u8, + // +} +impl TimingConfig { + pub fn new() -> Self + { + Self { + game_limit:None, + play_limit:None, + timeout_mode:0, + } + } +} + #[derive(Clone)] pub struct GameConfig { - + pieces:Vec, + board:Vec, + pools:[[u8; 7]; 2], + // rules + timing:TimingConfig, +} +impl GameConfig { + pub fn new() -> Self + { + Self { + pieces:Vec::new(), + board:Vec::new(), + pools:[[0; 7]; 2], + + timing:TimingConfig::new(), + } + } } diff --git a/game/src/lib.rs b/game/src/lib.rs index 956fa93..be3d99e 100644 --- a/game/src/lib.rs +++ b/game/src/lib.rs @@ -2,11 +2,12 @@ pub mod constant; use constant::*; pub mod util; use util::Hex; -pub mod piece; use piece::Piece; +pub mod piece; use piece::{Piece, PieceClass}; pub mod board; use board::Board; pub mod history; use history::*; pub mod config; use config::GameConfig; mod game; use game::*; +mod ranking; pub use ranking::Ranking; #[derive(Clone, Copy)] pub enum GameStatus { @@ -34,7 +35,7 @@ impl Game { pub fn new() -> Self { Self { - config:GameConfig { }, + config:GameConfig::new(), status:GameStatus::Normal, turn:0, @@ -593,7 +594,7 @@ impl Game { // Knight 1 => { for tile_id in subject_tiles { - if self.can_drop(piece, tile_id, flags::IGNORE_CHECK) { + if self.board.tiles[tile_id as usize].piece.is_none() { plays.push(PlayInfo { valid: true, threat: false, @@ -605,7 +606,7 @@ impl Game { } } - // Caslte + // Castle 2 => { for tile_id in subject_tiles { let piece_hex = Hex::from_tile(piece.tile); diff --git a/server/src/system/cache/mod.rs b/server/src/system/cache/mod.rs index 40bd461..342e445 100644 --- a/server/src/system/cache/mod.rs +++ b/server/src/system/cache/mod.rs @@ -108,6 +108,6 @@ impl WebCache { pub fn raw(data:Vec) -> Source { Source::Raw(data) } pub fn string(text:&str) -> Source { Source::String(text.to_string()) } - pub fn file

>(path:P) -> Source { Source::File((path.as_ref() as &Path).to_path_buf())} - pub fn markdown

>(path:P) -> Source { Source::MarkdownFile((path.as_ref() as &Path).to_path_buf())} + pub fn file>(path:P) -> Source { Source::File((path.as_ref() as &Path).to_path_buf())} + pub fn markdown>(path:P) -> Source { Source::MarkdownFile((path.as_ref() as &Path).to_path_buf())} } diff --git a/server/src/system/filesystem/mod.rs b/server/src/system/filesystem/mod.rs index 7419b94..109dd16 100644 --- a/server/src/system/filesystem/mod.rs +++ b/server/src/system/filesystem/mod.rs @@ -2,6 +2,8 @@ use std::{ fs::{self, File}, io::{Read, Seek, SeekFrom, Write}, path::Path }; +use const_format::*; + use game::{ history::Play, Game, @@ -25,15 +27,15 @@ const GENERIC_REQUEST :&str = "r.bin"; const GENERIC_STATUS :&str = "s.bin"; const DIR_DATA :&str = "data"; -const DIR_HANDLE :&str = const_format::formatcp!("{}/h", DIR_DATA); -const DIR_SESSION :&str = const_format::formatcp!("{}/s", DIR_DATA); -const DIR_USER :&str = const_format::formatcp!("{}/u", DIR_DATA); +const DIR_HANDLE :&str = formatcp!("{}/h", DIR_DATA); +const DIR_SESSION :&str = formatcp!("{}/s", DIR_DATA); +const DIR_USER :&str = formatcp!("{}/u", DIR_DATA); -const INDEX_HANDLE :&str = const_format::formatcp!("{d}/{f}", d= DIR_HANDLE, f= GENERIC_INDEX); -const INDEX_SESSION :&str = const_format::formatcp!("{d}/{f}", d= DIR_SESSION, f= GENERIC_INDEX); -const INDEX_USER :&str = const_format::formatcp!("{d}/{f}", d= DIR_USER, f= GENERIC_INDEX); +const INDEX_HANDLE :&str = formatcp!("{d}/{f}", d= DIR_HANDLE, f= GENERIC_INDEX); +const INDEX_SESSION :&str = formatcp!("{d}/{f}", d= DIR_SESSION, f= GENERIC_INDEX); +const INDEX_USER :&str = formatcp!("{d}/{f}", d= DIR_USER, f= GENERIC_INDEX); -pub const FILE_SALT :&str = const_format::formatcp!("{}/x.bin", DIR_DATA); +pub const FILE_SALT :&str = formatcp!("{}/x.bin", DIR_DATA); pub struct FileSystem { index_handle:File, diff --git a/www/css/util.css b/www/css/util.css index f60b912..8ce8029 100644 --- a/www/css/util.css +++ b/www/css/util.css @@ -1,4 +1,5 @@ span.text-system{color:#909090;} +span.active{color:#d0b040;} span.c_dawn{color:#ffe082;} span.c_dusk{color:#f6a1bd;} span.bold{font-weight:bold;} diff --git a/www/js/game.js b/www/js/game.js index 2236e1f..b99969b 100644 --- a/www/js/game.js +++ b/www/js/game.js @@ -667,7 +667,7 @@ GAME.Game = class { if(HEX.is_valid_board(tile_hex)) { let tile_id = HEX.hex_to_tile(tile_hex); - if(this.placable_tile(piece, tile_id, {check:false})) { + if(this.board.tiles[tile_id].piece === null) { tiles.push(new GAME.MovementTile(tile_id, true, false, 0, 0)); } } else { break; } diff --git a/www/js/interface.js b/www/js/interface.js index 650828a..ea7b731 100644 --- a/www/js/interface.js +++ b/www/js/interface.js @@ -436,6 +436,13 @@ const INTERFACE = { case INTERFACE.Mode.Review: { document.getElementById("indicator-turn").innerText = INTERFACE_DATA.Replay.turn + " / " + INTERFACE_DATA.Game.history.length; document.getElementById("turn-slider").setAttribute("max", INTERFACE_DATA.Game.history.length); + + let b_auto = document.getElementById("button-auto"); + if(INTERFACE_DATA.Replay.auto) { + b_auto.setAttribute("class", "active"); + } else { + b_auto.removeAttribute("class"); + } } break; } diff --git a/www/js/scene.js b/www/js/scene.js index af7c717..bcea4a8 100644 --- a/www/js/scene.js +++ b/www/js/scene.js @@ -1076,10 +1076,13 @@ const SCENES = { let ind_turn = UI.div([UI.text("0 / 0")]); ind_turn.setAttribute("id", "indicator-turn"); + let button_auto = UI.button(LANG("auto"), () => { INTERFACE.replay_toggle_auto(); }); + button_auto.setAttribute("id", "button-auto"); + UI.mainnav( [ ], [ - UI.button(LANG("auto"), () => { INTERFACE.replay_toggle_auto(); }), + button_auto, UI.button("◀", () => { INTERFACE.replay_off(); INTERFACE.replay_first(); }), UI.button("◁", () => { INTERFACE.replay_off(); INTERFACE.replay_prev(); }), ind_turn, diff --git a/www/pages/about/main.md b/www/pages/about/main.md index 0bc4054..53e7762 100644 --- a/www/pages/about/main.md +++ b/www/pages/about/main.md @@ -8,7 +8,7 @@ Dzura is a work of [Project Kirisame](https://kirisame.com). - [Project License](https://ykr.info/license) -© 2024 Yukiri Corporation +© 2024 Yukiri Corporation et al. # User Privacy