52 lines
1.9 KiB
JavaScript
52 lines
1.9 KiB
JavaScript
// Deck de base de Regnum
|
|
// Types: Royaume (points fixes), Armée (attaque), Commerce (multiplicateur), Magie (effets spéciaux)
|
|
|
|
const BASE_DECK = [
|
|
// === ROYAUME ===
|
|
{ id: 'r1', name: 'Village', type: 'Royaume', points: 2, effect: null },
|
|
{ id: 'r2', name: 'Château', type: 'Royaume', points: 5, effect: null },
|
|
{ id: 'r3', name: 'Cathédrale', type: 'Royaume', points: 4, effect: null },
|
|
{ id: 'r4', name: 'Forteresse', type: 'Royaume', points: 3, effect: null },
|
|
{ id: 'r5', name: 'Palais Royal', type: 'Royaume', points: 7, effect: null },
|
|
|
|
// === ARMÉE ===
|
|
{ id: 'a1', name: 'Chevaliers', type: 'Armée', points: 3, effect: 'steal:1' },
|
|
{ id: 'a2', name: 'Archers', type: 'Armée', points: 2, effect: 'steal:1' },
|
|
{ id: 'a3', name: 'Catapulte', type: 'Armée', points: 1, effect: 'steal:2' },
|
|
{ id: 'a4', name: 'Légion', type: 'Armée', points: 4, effect: 'steal:2' },
|
|
|
|
// === COMMERCE ===
|
|
{ id: 'c1', name: 'Marché', type: 'Commerce', points: 2, effect: 'bonus:1' },
|
|
{ id: 'c2', name: 'Port', type: 'Commerce', points: 3, effect: 'bonus:2' },
|
|
{ id: 'c3', name: 'Route de soie', type: 'Commerce', points: 5, effect: 'bonus:1' },
|
|
|
|
// === MAGIE ===
|
|
{ id: 'm1', name: 'Oracle', type: 'Magie', points: 1, effect: 'draw:1' },
|
|
{ id: 'm2', name: 'Enchanteur', type: 'Magie', points: 2, effect: 'protect' },
|
|
{ id: 'm3', name: 'Alchimiste', type: 'Magie', points: 3, effect: 'double' },
|
|
]
|
|
|
|
function shuffle(arr) {
|
|
const a = [...arr]
|
|
for (let i = a.length - 1; i > 0; i--) {
|
|
const j = Math.floor(Math.random() * (i + 1));
|
|
[a[i], a[j]] = [a[j], a[i]]
|
|
}
|
|
return a
|
|
}
|
|
|
|
function createDeck() {
|
|
return shuffle([...BASE_DECK, ...BASE_DECK]) // 2 exemplaires
|
|
}
|
|
|
|
function dealHands(playerCount, handSize = 5) {
|
|
const deck = createDeck()
|
|
const hands = []
|
|
for (let i = 0; i < playerCount; i++) {
|
|
hands.push(deck.splice(0, handSize))
|
|
}
|
|
return { hands, remaining: deck }
|
|
}
|
|
|
|
module.exports = { createDeck, dealHands, BASE_DECK }
|