Commit cb1bc9b7 authored by Mahmoud Aglan's avatar Mahmoud Aglan

feat: rename backgammon variants to Arabic — شيش بيش، محبوسة، ٣١

- sheshbesh (شيش بيش): standard backgammon with hitting
- mahbousa (محبوسة): tapa-style, land on opponent to trap (no hitting)
- thirtyone (٣١): gul-bara race variant, all pieces start stacked
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 6d2431c7
...@@ -29,7 +29,7 @@ switch ($action) { ...@@ -29,7 +29,7 @@ switch ($action) {
function handleQueue(string $userId, array $input): void { function handleQueue(string $userId, array $input): void {
$sdb = supabaseService(); $sdb = supabaseService();
$variant = $input['variant'] ?? 'standard'; $variant = $input['variant'] ?? 'sheshbesh';
$matchLength = intval($input['match_length'] ?? 3); $matchLength = intval($input['match_length'] ?? 3);
// Clean old queue entries // Clean old queue entries
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import { WHITE, BLACK, createGame, getGameScore } from './rules.js'; import { WHITE, BLACK, createGame, getGameScore } from './rules.js';
import { createCube } from './doubling.js'; import { createCube } from './doubling.js';
export function createMatch(matchLength = 5, variant = 'standard') { export function createMatch(matchLength = 5, variant = 'sheshbesh') {
return { return {
length: matchLength, length: matchLength,
variant, variant,
......
...@@ -75,8 +75,9 @@ function getBarTopPiece(state, type) { ...@@ -75,8 +75,9 @@ function getBarTopPiece(state, type) {
// ===== VARIANTS ===== // ===== VARIANTS =====
const VARIANTS = { const VARIANTS = {
standard: { sheshbesh: {
name: 'Standard', name: 'شيش بيش',
nameEn: 'Shesh Besh',
allowHit: true, allowHit: true,
resetState(state) { resetState(state) {
place(state, 5, WHITE, 5); place(state, 5, WHITE, 5);
...@@ -98,8 +99,27 @@ const VARIANTS = { ...@@ -98,8 +99,27 @@ const VARIANTS = {
return type === BLACK ? 23 - pos : pos; return type === BLACK ? 23 - pos : pos;
} }
}, },
gulbara: { mahbousa: {
name: 'Gul Bara', name: 'محبوسة',
nameEn: 'Mahbousa',
allowHit: false,
resetState(state) {
place(state, 15, WHITE, 23);
place(state, 15, BLACK, 0);
},
incPos(pos, type, steps) {
return type === WHITE ? pos - steps : pos + steps;
},
normPos(pos, type) {
return type === BLACK ? 23 - pos : pos;
},
denormPos(pos, type) {
return type === BLACK ? 23 - pos : pos;
}
},
thirtyone: {
name: '٣١',
nameEn: '31',
allowHit: false, allowHit: false,
resetState(state) { resetState(state) {
place(state, 15, WHITE, 23); place(state, 15, WHITE, 23);
...@@ -124,23 +144,6 @@ const VARIANTS = { ...@@ -124,23 +144,6 @@ const VARIANTS = {
if (pos >= 12) return pos - 12; if (pos >= 12) return pos - 12;
return pos + 12; return pos + 12;
} }
},
tapa: {
name: 'Tapa',
allowHit: false,
resetState(state) {
place(state, 15, WHITE, 23);
place(state, 15, BLACK, 0);
},
incPos(pos, type, steps) {
return type === WHITE ? pos - steps : pos + steps;
},
normPos(pos, type) {
return type === BLACK ? 23 - pos : pos;
},
denormPos(pos, type) {
return type === BLACK ? 23 - pos : pos;
}
} }
}; };
...@@ -150,7 +153,7 @@ export function getVariants() { ...@@ -150,7 +153,7 @@ export function getVariants() {
// ===== GAME ===== // ===== GAME =====
export function createGame(variant = 'standard') { export function createGame(variant = 'sheshbesh') {
const rule = VARIANTS[variant]; const rule = VARIANTS[variant];
const state = createState(); const state = createState();
rule.resetState(state); rule.resetState(state);
......
...@@ -28,7 +28,7 @@ let turnTimeLeft = 30; ...@@ -28,7 +28,7 @@ let turnTimeLeft = 30;
export function mountGame(el, p) { export function mountGame(el, p) {
params = p || {}; params = p || {};
const { mode = 'bot', variant = 'standard', matchLength = 3, difficulty = 'medium', useCube = true } = params; const { mode = 'bot', variant = 'sheshbesh', matchLength = 3, difficulty = 'medium', useCube = true } = params;
myColor = mode === 'live' ? (params.color === 'black' ? BLACK : WHITE) : WHITE; myColor = mode === 'live' ? (params.color === 'black' ? BLACK : WHITE) : WHITE;
......
...@@ -84,14 +84,14 @@ function renderSetup(el, params) { ...@@ -84,14 +84,14 @@ function renderSetup(el, params) {
<div class="bg-section"> <div class="bg-section">
<div class="bg-section-title">نوع اللعبة</div> <div class="bg-section-title">نوع اللعبة</div>
<div class="bg-grid" id="variant-grid"> <div class="bg-grid" id="variant-grid">
<button class="bg-chip bg-chip-active" data-variant="standard"> <button class="bg-chip bg-chip-active" data-variant="sheshbesh">
<span class="bg-chip-label">عادية</span> <span class="bg-chip-label">شيش بيش</span>
</button> </button>
<button class="bg-chip" data-variant="gulbara"> <button class="bg-chip" data-variant="mahbousa">
<span class="bg-chip-label">گلبرة</span> <span class="bg-chip-label">محبوسة</span>
</button> </button>
<button class="bg-chip" data-variant="tapa"> <button class="bg-chip" data-variant="thirtyone">
<span class="bg-chip-label">طاپا</span> <span class="bg-chip-label">٣١</span>
</button> </button>
</div> </div>
</div> </div>
...@@ -161,7 +161,7 @@ function renderSetup(el, params) { ...@@ -161,7 +161,7 @@ function renderSetup(el, params) {
${getStyles()} ${getStyles()}
`; `;
let variant = 'standard'; let variant = 'sheshbesh';
let matchLength = 3; let matchLength = 3;
let difficulty = 'medium'; let difficulty = 'medium';
let useCube = true; let useCube = true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment