You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.3 KiB

  1. //Imports
  2. const uno = require("./uno");
  3. const Card = require("./cards/Card");
  4. const ChooseColor = require("./cards/special/ChooseColor");
  5. const Skip = require("./cards/special/Skip");
  6. const PlusAmount = require("./cards/special/PlusAmount");
  7. const Reverse = require("./cards/special/Reverse");
  8. class Game {
  9. constructor(playerAmount, rules) {
  10. this._playerAmount = playerAmount;
  11. this._rules = rules;
  12. this.initGame();
  13. }
  14. initGame(){
  15. this._cardPool = this.generatePool();
  16. }
  17. generatePool(){
  18. let pool = [];
  19. for (let k = 0; k < 2; k++) {
  20. for (let j = 1; j < (uno.CARD_COLORS.length); j++) {
  21. pool.push(new Reverse("R", uno.CARD_COLORS[j]));
  22. pool.push(new PlusAmount("+2", uno.CARD_COLORS[j]));
  23. pool.push(new Skip("S", uno.CARD_COLORS[j]));
  24. if (k === 0) {
  25. pool.push(new ChooseColor("CC"));
  26. pool.push(new PlusAmount("+4", uno.CARD_COLORS[0]));
  27. }
  28. for (let i = 0; i <= 9; i++) {
  29. if (k === 1 && i === 0) continue;
  30. pool.push(new Card(i, uno.CARD_COLORS[j]));
  31. }
  32. }
  33. }
  34. return pool;
  35. }
  36. get cardPool(){
  37. return this._cardPool;
  38. }
  39. }
  40. module.exports = Game;