From 02e05c2897764b7df7ed4252d53dd097604e4d66 Mon Sep 17 00:00:00 2001 From: yukirij Date: Sun, 24 Nov 2024 13:22:43 -0800 Subject: [PATCH 01/12] Minor changes; remove drop restrictions on Knight alt. --- game/src/config/mod.rs | 40 ++++++++++++++++++++++++++++- game/src/lib.rs | 9 ++++--- server/src/system/cache/mod.rs | 4 +-- server/src/system/filesystem/mod.rs | 16 +++++++----- www/css/util.css | 1 + www/js/game.js | 2 +- www/js/interface.js | 7 +++++ www/js/scene.js | 5 +++- www/pages/about/main.md | 2 +- 9 files changed, 69 insertions(+), 17 deletions(-) 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 From 9ca78fb8d7e38780f45743aeca4c24779717983c Mon Sep 17 00:00:00 2001 From: yukirij Date: Sun, 24 Nov 2024 13:24:10 -0800 Subject: [PATCH 02/12] Add missing ranking struct. --- game/src/ranking.rs | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 game/src/ranking.rs diff --git a/game/src/ranking.rs b/game/src/ranking.rs new file mode 100644 index 0000000..3593b49 --- /dev/null +++ b/game/src/ranking.rs @@ -0,0 +1,6 @@ +pub struct Ranking { + +} +impl Ranking { + +} From da84e49ad3a369cbfca333e018f5b3305e4148f0 Mon Sep 17 00:00:00 2001 From: yukirij Date: Sun, 24 Nov 2024 13:27:21 -0800 Subject: [PATCH 03/12] Fix knight alt move non-blocking case. --- www/js/game.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/js/game.js b/www/js/game.js index b99969b..b07d7f0 100644 --- a/www/js/game.js +++ b/www/js/game.js @@ -646,7 +646,7 @@ GAME.Game = class { // Check all tiles if not blocking. if(block_directions == 0) { for(let i = 0; i < GAME_DATA.board.tiles.length; ++i) { - if(this.placable_tile(piece, i, {check:false})) { + if(this.board.tiles[tile_id].piece === null) { tiles.push(new GAME.MovementTile(i, true, false, 0, 0)); } } From ac5a189d13d2612f881d79a9d45765cdd02fd2ec Mon Sep 17 00:00:00 2001 From: yukirij Date: Sun, 24 Nov 2024 13:28:26 -0800 Subject: [PATCH 04/12] Fix copy/paste error. --- www/js/game.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/js/game.js b/www/js/game.js index b07d7f0..ad91c23 100644 --- a/www/js/game.js +++ b/www/js/game.js @@ -646,7 +646,7 @@ GAME.Game = class { // Check all tiles if not blocking. if(block_directions == 0) { for(let i = 0; i < GAME_DATA.board.tiles.length; ++i) { - if(this.board.tiles[tile_id].piece === null) { + if(this.board.tiles[i].piece === null) { tiles.push(new GAME.MovementTile(i, true, false, 0, 0)); } } From e0e888f861ab296b13474115d656fb08eb838a31 Mon Sep 17 00:00:00 2001 From: yukirij Date: Sun, 24 Nov 2024 14:16:42 -0800 Subject: [PATCH 05/12] Fix knight alt move check. --- game/src/lib.rs | 2 +- www/js/game.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/game/src/lib.rs b/game/src/lib.rs index be3d99e..f57e817 100644 --- a/game/src/lib.rs +++ b/game/src/lib.rs @@ -594,7 +594,7 @@ impl Game { // Knight 1 => { for tile_id in subject_tiles { - if self.board.tiles[tile_id as usize].piece.is_none() { + if self.can_drop(piece, tile_id, flags::IGNORE_CHECK | flags::IGNORE_EXTENT) { plays.push(PlayInfo { valid: true, threat: false, diff --git a/www/js/game.js b/www/js/game.js index ad91c23..01b8362 100644 --- a/www/js/game.js +++ b/www/js/game.js @@ -646,7 +646,7 @@ GAME.Game = class { // Check all tiles if not blocking. if(block_directions == 0) { for(let i = 0; i < GAME_DATA.board.tiles.length; ++i) { - if(this.board.tiles[i].piece === null) { + if(this.placable_tile(piece, tile_id, {check:false, extent:false})) { tiles.push(new GAME.MovementTile(i, true, false, 0, 0)); } } @@ -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.board.tiles[tile_id].piece === null) { + if(this.placable_tile(piece, tile_id, {check:false, extent:false})) { tiles.push(new GAME.MovementTile(tile_id, true, false, 0, 0)); } } else { break; } From 712525b8eae15ee41cc586ee6b7d36ae1ffce9ac Mon Sep 17 00:00:00 2001 From: yukirij Date: Sun, 24 Nov 2024 14:18:22 -0800 Subject: [PATCH 06/12] Fix copy/paste error. --- www/js/game.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/js/game.js b/www/js/game.js index 01b8362..a9dcd0a 100644 --- a/www/js/game.js +++ b/www/js/game.js @@ -646,7 +646,7 @@ GAME.Game = class { // Check all tiles if not blocking. if(block_directions == 0) { for(let i = 0; i < GAME_DATA.board.tiles.length; ++i) { - if(this.placable_tile(piece, tile_id, {check:false, extent:false})) { + if(this.placable_tile(piece, i, {check:false, extent:false})) { tiles.push(new GAME.MovementTile(i, true, false, 0, 0)); } } From cbb22e2b88051429a14090d9a810e0a61545f912 Mon Sep 17 00:00:00 2001 From: yukirij Date: Sun, 24 Nov 2024 20:27:53 -0800 Subject: [PATCH 07/12] Remove subscription page and payment info. --- www/js/scene.js | 23 --------------------- www/js/ui.js | 1 - www/pages/about/main.md | 46 ----------------------------------------- 3 files changed, 70 deletions(-) diff --git a/www/js/scene.js b/www/js/scene.js index bcea4a8..8a94368 100644 --- a/www/js/scene.js +++ b/www/js/scene.js @@ -877,29 +877,6 @@ const SCENES = { } }, - Subscription:class{ - constructor() { } - load(data) { - if(sessionStorage.getItem("auth") === null) return false; - - UI.mainmenu_account(null, "subscription"); - - // Left Buttons - let buttons_left = [ ]; - - // Right Buttons - let buttons_right = [ ]; - buttons_right.push(UI.button("Cancel", () => { })); - - UI.mainnav(buttons_left, buttons_right); - - // Main Content - - history.pushState(null, "Dzura - About", "/u/" + CONTEXT.Auth.handle); - return true; - } - }, - Invitations:class{ constructor() { this.data = null; diff --git a/www/js/ui.js b/www/js/ui.js index ae303ad..e426126 100644 --- a/www/js/ui.js +++ b/www/js/ui.js @@ -206,7 +206,6 @@ const UI = { // Bottom Buttons if(CONTEXT.Auth !== null && (handle === null || handle == CONTEXT.Auth.handle)) { buttons_bottom.push(UI.button("Account", () => { SCENE.load(SCENES.Account) }, page == "account")); - buttons_bottom.push(UI.button("Subscription", () => { SCENE.load(SCENES.Subscription) }, page == "subscription")); buttons_bottom.push(UI.button("Invitations", () => { SCENE.load(SCENES.Invitations) }, page == "invitations")); } buttons_bottom.push(UI.button(LANG("back"), () => { SCENE.load(SCENES.Browse); })); diff --git a/www/pages/about/main.md b/www/pages/about/main.md index 53e7762..8b6c154 100644 --- a/www/pages/about/main.md +++ b/www/pages/about/main.md @@ -16,49 +16,3 @@ Dzura is a work of [Project Kirisame](https://kirisame.com). This website does not collect any information beyond that used to implement user accounts and gameplay. Information is not provided to third parties except in serving the application to clients. - - -# Payment Policy - -### Subscription - -Dzura's core monetization is a modest subscription for access to extra content, including additional reactions, custom games, and media. - -The exact benefits of the subscription may change over time as more content is added. - - -### Pricing - -Dzura's subscription is offered at: - - - USD $2.00 ($1.00 reduced period) - - -### Reduced Period - -Subscriptions activated after the 14th day of the month will be offered at reduced price for the period. - -Subscriptions activated after the 21st day will be included with the next month's period at no additional cost. - - -### Refunds - -Refunds will be automatically accepted up to 3 days after activation of subscription or start of the payment period if the subscription is canceled during that time. - -Refunds or free periods will also be provided at our discretion for any inconveniences to our users. - - -### Cancellation - -Users may cancel their subscriptions at any time under the Subscription page of Account Management. - -Canceled subscriptions will remain active until the end of the period. - -A canceled subscription may be reinstated until the next payment period. - -If a user is not active for a full payment period, their subscription will be automatically canceled. - - -### Customer Service - -**Contact:** service@dzura.com From ce804a5c51b672ce52a2c527f4844a485daf367f Mon Sep 17 00:00:00 2001 From: yukirij Date: Mon, 25 Nov 2024 21:52:22 -0800 Subject: [PATCH 08/12] Update handling of auto replay button. --- www/css/util.css | 4 +++- www/js/interface.js | 20 +++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/www/css/util.css b/www/css/util.css index 8ce8029..ac2fbdd 100644 --- a/www/css/util.css +++ b/www/css/util.css @@ -1,5 +1,4 @@ span.text-system{color:#909090;} -span.active{color:#d0b040;} span.c_dawn{color:#ffe082;} span.c_dusk{color:#f6a1bd;} span.bold{font-weight:bold;} @@ -8,6 +7,9 @@ button.warn { background-color:#471414; color:#e0e0e0; } +button.active{ + color:#d0b040; +} span.monospace {font-family:monospace;} diff --git a/www/js/interface.js b/www/js/interface.js index ea7b731..73dd32d 100644 --- a/www/js/interface.js +++ b/www/js/interface.js @@ -437,12 +437,7 @@ const INTERFACE = { 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"); - } + this.replay_update_button(); } break; } @@ -1675,11 +1670,22 @@ const INTERFACE = { INTERFACE_DATA.Replay.auto = false; } } + this.replay_update_button(); }, replay_off() { INTERFACE_DATA.Replay.auto = false; + this.replay_update_button(); + }, + replay_update_button() { + let b_auto = document.getElementById("button-auto"); + if(b_auto !== null) { + if(INTERFACE_DATA.Replay.auto) { + b_auto.setAttribute("class", "active"); + } else { + b_auto.removeAttribute("class"); + } + } }, - auto() { let bit = 1 << (INTERFACE_DATA.rotate ^ 1); From b09c3d93698859d0b03de99af57b9d0792b40b3b Mon Sep 17 00:00:00 2001 From: yukirij Date: Mon, 25 Nov 2024 21:56:21 -0800 Subject: [PATCH 09/12] Fix replay auto toggle handling. --- www/js/interface.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/www/js/interface.js b/www/js/interface.js index 73dd32d..6ba057a 100644 --- a/www/js/interface.js +++ b/www/js/interface.js @@ -437,7 +437,7 @@ const INTERFACE = { 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); - this.replay_update_button(); + this.replay_update_auto(); } break; } @@ -1660,6 +1660,7 @@ const INTERFACE = { if(INTERFACE_DATA.Replay.auto) { setTimeout(INTERFACE.replay_auto, 1000); } + this.replay_update_auto(); }, replay_auto() { if(INTERFACE_DATA.Replay.auto) { @@ -1670,13 +1671,9 @@ const INTERFACE = { INTERFACE_DATA.Replay.auto = false; } } - this.replay_update_button(); + this.replay_update_auto(); }, - replay_off() { - INTERFACE_DATA.Replay.auto = false; - this.replay_update_button(); - }, - replay_update_button() { + replay_update_auto() { let b_auto = document.getElementById("button-auto"); if(b_auto !== null) { if(INTERFACE_DATA.Replay.auto) { From e739149d0c62a6527ae5b54e02f5fd7ad9262f65 Mon Sep 17 00:00:00 2001 From: yukirij Date: Mon, 25 Nov 2024 21:57:13 -0800 Subject: [PATCH 10/12] Restore replay_off function. --- www/js/interface.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/www/js/interface.js b/www/js/interface.js index 6ba057a..e8e07cd 100644 --- a/www/js/interface.js +++ b/www/js/interface.js @@ -1673,6 +1673,10 @@ const INTERFACE = { } this.replay_update_auto(); }, + replay_off() { + INTERFACE_DATA.Replay.auto = false; + this.replay_update_auto(); + }, replay_update_auto() { let b_auto = document.getElementById("button-auto"); if(b_auto !== null) { From 600a83d3e2e183b7f158a9bda44d35b974d885d6 Mon Sep 17 00:00:00 2001 From: yukirij Date: Mon, 25 Nov 2024 21:58:23 -0800 Subject: [PATCH 11/12] Change usage of replay auto update function. --- www/js/interface.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/www/js/interface.js b/www/js/interface.js index e8e07cd..a10a09a 100644 --- a/www/js/interface.js +++ b/www/js/interface.js @@ -437,7 +437,7 @@ const INTERFACE = { 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); - this.replay_update_auto(); + INTERFACE.replay_update_auto(); } break; } @@ -1660,7 +1660,7 @@ const INTERFACE = { if(INTERFACE_DATA.Replay.auto) { setTimeout(INTERFACE.replay_auto, 1000); } - this.replay_update_auto(); + INTERFACE.replay_update_auto(); }, replay_auto() { if(INTERFACE_DATA.Replay.auto) { @@ -1671,11 +1671,11 @@ const INTERFACE = { INTERFACE_DATA.Replay.auto = false; } } - this.replay_update_auto(); + INTERFACE.replay_update_auto(); }, replay_off() { INTERFACE_DATA.Replay.auto = false; - this.replay_update_auto(); + INTERFACE.replay_update_auto(); }, replay_update_auto() { let b_auto = document.getElementById("button-auto"); From cecfdbc7857824b905336a6a1ac952bbbbbb8894 Mon Sep 17 00:00:00 2001 From: yukirij Date: Tue, 26 Nov 2024 19:56:55 -0800 Subject: [PATCH 12/12] Add discord link to about page. --- www/pages/about/main.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/www/pages/about/main.md b/www/pages/about/main.md index 8b6c154..42ba01b 100644 --- a/www/pages/about/main.md +++ b/www/pages/about/main.md @@ -4,6 +4,10 @@ Dzura is a two-player abstract strategy game contending the armies of Dawn and D Inspired by the chess family, the game features a variety of pieces, each with its own pattern of movement. Borrowing from shogi, captured pieces may be returned to the board on the capturer's side and pieces that reach the far side of the board are promoted. +Those interested may get more information here: + + - [Discord](https://discord.gg/u2HpSCRkTS) + Dzura is a work of [Project Kirisame](https://kirisame.com). - [Project License](https://ykr.info/license)