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) {
function handleQueue(string $userId, array $input): void {
$sdb = supabaseService();
$variant = $input['variant'] ?? 'standard';
$variant = $input['variant'] ?? 'sheshbesh';
$matchLength = intval($input['match_length'] ?? 3);
// Clean old queue entries
......
......@@ -2,7 +2,7 @@
import { WHITE, BLACK, createGame, getGameScore } from './rules.js';
import { createCube } from './doubling.js';
export function createMatch(matchLength = 5, variant = 'standard') {
export function createMatch(matchLength = 5, variant = 'sheshbesh') {
return {
length: matchLength,
variant,
......
......@@ -75,8 +75,9 @@ function getBarTopPiece(state, type) {
// ===== VARIANTS =====
const VARIANTS = {
standard: {
name: 'Standard',
sheshbesh: {
name: 'شيش بيش',
nameEn: 'Shesh Besh',
allowHit: true,
resetState(state) {
place(state, 5, WHITE, 5);
......@@ -98,8 +99,27 @@ const VARIANTS = {
return type === BLACK ? 23 - pos : pos;
}
},
gulbara: {
name: 'Gul Bara',
mahbousa: {
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,
resetState(state) {
place(state, 15, WHITE, 23);
......@@ -124,23 +144,6 @@ const VARIANTS = {
if (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() {
// ===== GAME =====
export function createGame(variant = 'standard') {
export function createGame(variant = 'sheshbesh') {
const rule = VARIANTS[variant];
const state = createState();
rule.resetState(state);
......
......@@ -28,7 +28,7 @@ let turnTimeLeft = 30;
export function mountGame(el, 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;
......
......@@ -84,14 +84,14 @@ function renderSetup(el, params) {
<div class="bg-section">
<div class="bg-section-title">نوع اللعبة</div>
<div class="bg-grid" id="variant-grid">
<button class="bg-chip bg-chip-active" data-variant="standard">
<span class="bg-chip-label">عادية</span>
<button class="bg-chip bg-chip-active" data-variant="sheshbesh">
<span class="bg-chip-label">شيش بيش</span>
</button>
<button class="bg-chip" data-variant="gulbara">
<span class="bg-chip-label">گلبرة</span>
<button class="bg-chip" data-variant="mahbousa">
<span class="bg-chip-label">محبوسة</span>
</button>
<button class="bg-chip" data-variant="tapa">
<span class="bg-chip-label">طاپا</span>
<button class="bg-chip" data-variant="thirtyone">
<span class="bg-chip-label">٣١</span>
</button>
</div>
</div>
......@@ -161,7 +161,7 @@ function renderSetup(el, params) {
${getStyles()}
`;
let variant = 'standard';
let variant = 'sheshbesh';
let matchLength = 3;
let difficulty = 'medium';
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