|
@ -6,8 +6,10 @@ const Skip = require("./cards/special/Skip"); |
|
|
const PlusAmount = require("./cards/special/PlusAmount"); |
|
|
const PlusAmount = require("./cards/special/PlusAmount"); |
|
|
const Reverse = require("./cards/special/Reverse"); |
|
|
const Reverse = require("./cards/special/Reverse"); |
|
|
|
|
|
|
|
|
|
|
|
//Um generatePool zu exportieren, muss es in eine Klasse konvertiert werden
|
|
|
class Game { |
|
|
class Game { |
|
|
|
|
|
|
|
|
|
|
|
//Erstellt ein Spiel mit SpielerAnzahl und Array mit Regeln, initialisiert dann das Spiel
|
|
|
constructor(playerAmount, rules) { |
|
|
constructor(playerAmount, rules) { |
|
|
|
|
|
|
|
|
this._playerAmount = playerAmount; |
|
|
this._playerAmount = playerAmount; |
|
@ -20,31 +22,51 @@ class Game { |
|
|
this._cardPool = this.generatePool(); |
|
|
this._cardPool = this.generatePool(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//Gibt ein Array zurück mit allen Karten, die in einem Uno Spiel sind
|
|
|
generatePool(){ |
|
|
generatePool(){ |
|
|
|
|
|
|
|
|
|
|
|
//Array wird erstellt, welches später zurückgegeben wird und alle Karten beinhaltet
|
|
|
let pool = []; |
|
|
let pool = []; |
|
|
|
|
|
|
|
|
|
|
|
//Pool aus Karten generieren
|
|
|
for (let k = 0; k < 2; k++) { |
|
|
for (let k = 0; k < 2; k++) { |
|
|
|
|
|
|
|
|
|
|
|
//Special Karten werden hinzugefügt
|
|
|
for (let j = 1; j < (uno.CARD_COLORS.length); j++) { |
|
|
for (let j = 1; j < (uno.CARD_COLORS.length); j++) { |
|
|
pool.push(new Reverse("R", uno.CARD_COLORS[j])); |
|
|
|
|
|
pool.push(new PlusAmount("+2", uno.CARD_COLORS[j])); |
|
|
|
|
|
pool.push(new Skip("S", uno.CARD_COLORS[j])); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pool.push(new Reverse("R", uno.CARD_COLORS[j])); // 8x Reverse
|
|
|
|
|
|
pool.push(new PlusAmount("+2", uno.CARD_COLORS[j])); // 8x +2
|
|
|
|
|
|
pool.push(new Skip("S", uno.CARD_COLORS[j])); // 8x Skip
|
|
|
|
|
|
|
|
|
if (k === 0) { |
|
|
if (k === 0) { |
|
|
pool.push(new ChooseColor("CC")); |
|
|
|
|
|
pool.push(new PlusAmount("+4", uno.CARD_COLORS[0])); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pool.push(new ChooseColor("CC")); // 4x ChooseColor
|
|
|
|
|
|
pool.push(new PlusAmount("+4", uno.CARD_COLORS[0])); // 4x +4
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//Normale Karten werden hinzugefügt
|
|
|
for (let i = 0; i <= 9; i++) { |
|
|
for (let i = 0; i <= 9; i++) { |
|
|
|
|
|
|
|
|
if (k === 1 && i === 0) continue; |
|
|
if (k === 1 && i === 0) continue; |
|
|
pool.push(new Card(i, uno.CARD_COLORS[j])); |
|
|
|
|
|
|
|
|
pool.push(new Card(i, uno.CARD_COLORS[j])); // 76x (2x 4x 1-9 + 4x 0)
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//Array mit Karten wird zurückgegeben
|
|
|
return pool; |
|
|
return pool; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//Gib den Pool mit allen UnoKarten zurück
|
|
|
get cardPool(){ |
|
|
get cardPool(){ |
|
|
return this._cardPool; |
|
|
return this._cardPool; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//Exportiert Modul Game
|
|
|
module.exports = Game; |
|
|
module.exports = Game; |