From 7c5f67eab832e520e14354e00aa3287fcc09d1ae Mon Sep 17 00:00:00 2001 From: emil Date: Sat, 9 May 2026 17:18:16 +0300 Subject: [PATCH] Upgrade Dice Generator: notation input, advantage/disadvantage, history, D&D presets Adds XdY+Z notation parsing with bidirectional sync, 3-way advantage/disadvantage toggle, last-10 roll history in sessionStorage, and D&D quick presets (Attack, Damage, Fireball, Sneak Attack, Stat Roll). Updates SEO meta and SeoBlock content in both EN and RU pages. Co-Authored-By: Claude Sonnet 4.6 --- src/components/generators/DiceGenerator.astro | 513 +++++++++++++++--- src/data/generators.ts | 8 +- src/pages/generators/dice.astro | 10 +- src/pages/ru/generators/dice.astro | 9 +- 4 files changed, 463 insertions(+), 77 deletions(-) diff --git a/src/components/generators/DiceGenerator.astro b/src/components/generators/DiceGenerator.astro index 5ba14de..26ef6eb 100644 --- a/src/components/generators/DiceGenerator.astro +++ b/src/components/generators/DiceGenerator.astro @@ -2,9 +2,57 @@ import { useT } from '../../i18n/translations'; const isRu = Astro.url.pathname.startsWith('/ru'); const T = useT(isRu ? 'ru' : 'en'); + +const notationLabel = isRu ? 'Нотация' : 'Notation'; +const notationPlaceholder = isRu ? 'напр. 2d6+3, 1d20, 4d4-1' : 'e.g. 2d6+3, 1d20, 4d4-1'; +const modeLabel = isRu ? 'Режим' : 'Mode'; +const modeNormal = isRu ? 'Обычный' : 'Normal'; +const modeAdvantage = isRu ? 'Преимущество' : 'Advantage'; +const modeDisadvantage = isRu ? 'Помеха' : 'Disadvantage'; +const advOnly = isRu ? 'Преимущество работает только с одним кубиком' : 'Advantage only works with a single die'; +const historyTitle = isRu ? 'История бросков' : 'Roll history'; +const clearHistory = isRu ? 'Очистить историю' : 'Clear history'; + +const presets = [ + { label: isRu ? 'Атака' : 'Attack', notation: '1d20', stat: false }, + { label: isRu ? 'Урон (1d8)' : 'Damage (1d8)', notation: '1d8+3', stat: false }, + { label: isRu ? 'Огненный шар' : 'Fireball', notation: '8d6', stat: false }, + { label: isRu ? 'Скрытая атака' : 'Sneak Attack', notation: '3d6', stat: false }, + { label: isRu ? 'Характеристика' : 'Stat Roll', notation: '4d6', stat: true }, +]; ---
+ + +
+ {presets.map((p) => ( + + ))} +
+ + +
+ + + +
+ +
@@ -33,26 +81,43 @@ const T = useT(isRu ? 'ru' : 'en');
- - -
+ +
+
+ id="dg-mode-wrap" + class="inline-flex rounded-lg border border-zinc-700 overflow-hidden transition-opacity" + role="radiogroup" + aria-label={modeLabel} + > + {[ + { value: 'normal', label: modeNormal }, + { value: 'advantage', label: modeAdvantage }, + { value: 'disadvantage',label: modeDisadvantage }, + ].map(({ value, label }, i) => ( + + ))} +
+ +
+ + + + +
+
+ + -
+
+ + + +
diff --git a/src/data/generators.ts b/src/data/generators.ts index 74f20d9..f919094 100644 --- a/src/data/generators.ts +++ b/src/data/generators.ts @@ -71,12 +71,12 @@ export const generators: Generator[] = [ description: 'Roll one or more dice with any number of sides.', icon: 'dice-6', status: 'live', - seoTitle: 'Online Dice Roller — d4, d6, d20 and more | Randify', - seoDescription: 'Roll virtual dice online. Supports d4, d6, d8, d10, d12, d20 and d100. Roll multiple dice at once — great for D&D, board games and tabletop RPGs.', + seoTitle: 'Dice Roller — d4 d6 d8 d10 d12 d20 | D&D Dice | Randify', + seoDescription: 'Free online dice roller for D&D and tabletop RPGs. Supports any XdY+Z notation, advantage/disadvantage, roll history, and quick presets for attacks, damage, and stat rolls.', ruTitle: 'Кубик', ruDescription: 'Бросьте один или несколько кубиков с любым числом граней.', - ruSeoTitle: 'Бросить кубик онлайн — d4, d6, d20 | Randify', - ruSeoDescription: 'Бросайте виртуальные кубики онлайн. Поддержка d4, d6, d8, d10, d12, d20, d100. Отлично для D&D и настольных RPG.', + ruSeoTitle: 'Бросить кубик онлайн — d4 d6 d8 d10 d12 d20 | D&D | Randify', + ruSeoDescription: 'Бесплатный онлайн-бросок кубиков для D&D и настольных RPG. Поддерживает нотацию XdY+Z, преимущество/помеху, историю бросков и быстрые пресеты.', }, { slug: 'cards', diff --git a/src/pages/generators/dice.astro b/src/pages/generators/dice.astro index e66f3b1..cf99023 100644 --- a/src/pages/generators/dice.astro +++ b/src/pages/generators/dice.astro @@ -61,16 +61,16 @@ const generator = generators.find((g) => g.slug === 'dice')!; diff --git a/src/pages/ru/generators/dice.astro b/src/pages/ru/generators/dice.astro index 7ff73ab..8224b43 100644 --- a/src/pages/ru/generators/dice.astro +++ b/src/pages/ru/generators/dice.astro @@ -27,14 +27,15 @@ const generator = generators.find((g) => g.slug === 'dice')!;