|
@ -5,6 +5,7 @@ const ChooseColor = require('../js/cards/special/ChooseColor'); |
|
|
const Skip = require('../js/cards/special/Skip'); |
|
|
const Skip = require('../js/cards/special/Skip'); |
|
|
const Reverse = require('../js/cards/special/Reverse'); |
|
|
const Reverse = require('../js/cards/special/Reverse'); |
|
|
const PlusAmount = require('../js/cards/special/PlusAmount'); |
|
|
const PlusAmount = require('../js/cards/special/PlusAmount'); |
|
|
|
|
|
const Game = require('../js/Game'); |
|
|
|
|
|
|
|
|
//Instanz CARD_COLORS aus uno.js
|
|
|
//Instanz CARD_COLORS aus uno.js
|
|
|
const CARD_COLORS = uno.CARD_COLORS; |
|
|
const CARD_COLORS = uno.CARD_COLORS; |
|
@ -99,6 +100,103 @@ describe('Karten erstellen', () => { |
|
|
|
|
|
|
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
describe('Kartenfunktionen', () => { |
|
|
|
|
|
|
|
|
|
|
|
let game = new Game(2, null); |
|
|
|
|
|
let card; |
|
|
|
|
|
|
|
|
|
|
|
//Spieler brauchen karten, sonst beendet sich das Spiel
|
|
|
|
|
|
game.players[0].canPlay = true; |
|
|
|
|
|
game.players[1].canPlay = true; |
|
|
|
|
|
game.players[0].drawCard(2); |
|
|
|
|
|
game.players[1].drawCard(2); |
|
|
|
|
|
|
|
|
|
|
|
it('Card - nächster Spieler an der Reihe', () => { |
|
|
|
|
|
|
|
|
|
|
|
card = new Card('8', CARD_COLORS[2], game); |
|
|
|
|
|
|
|
|
|
|
|
let player = game.currentPlayer; |
|
|
|
|
|
|
|
|
|
|
|
card.putSelf(); |
|
|
|
|
|
|
|
|
|
|
|
//Der nächste Spieler muss an der Reihe sein
|
|
|
|
|
|
expect(player).toBe(game.nextPlayer()); |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('CC - Setzen der KartenFarbe', () => { |
|
|
|
|
|
|
|
|
|
|
|
card = new ChooseColor(game); |
|
|
|
|
|
|
|
|
|
|
|
card.putSelf(); |
|
|
|
|
|
|
|
|
|
|
|
//Die farbe von CC muss gesetzt werden
|
|
|
|
|
|
let bool = (card.color === "NONE"); |
|
|
|
|
|
expect(bool).toBe(false); |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('R - Wechseln der Spielrichtung', () => { |
|
|
|
|
|
|
|
|
|
|
|
card = new Reverse(CARD_COLORS[2], game); |
|
|
|
|
|
|
|
|
|
|
|
card.putSelf(); |
|
|
|
|
|
|
|
|
|
|
|
//Die Spielrichtung muss geändert werden
|
|
|
|
|
|
expect(game.direction).toBe(2); |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('S - nächster Spieler wird übersprungen', () => { |
|
|
|
|
|
|
|
|
|
|
|
card = new Skip(CARD_COLORS[2], game); |
|
|
|
|
|
|
|
|
|
|
|
let currentPlayer = game.currentPlayer; |
|
|
|
|
|
|
|
|
|
|
|
card.putSelf(); |
|
|
|
|
|
|
|
|
|
|
|
//Der 2te Spieler wurde übersprungen, der Gleiche Spieler muss an der Reihe sein
|
|
|
|
|
|
expect(currentPlayer).toBe(game.currentPlayer); |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('+2 - nächster Spieler +2 Karten', () => { |
|
|
|
|
|
|
|
|
|
|
|
card = new PlusAmount(game, CARD_COLORS[2]); |
|
|
|
|
|
|
|
|
|
|
|
let nextPlayer = game.players[game.nextPlayer()]; |
|
|
|
|
|
|
|
|
|
|
|
let playerDeck = nextPlayer.hand.length |
|
|
|
|
|
|
|
|
|
|
|
card.putSelf(); |
|
|
|
|
|
|
|
|
|
|
|
//Der nächste Spieler muss 2 Karten mehr auf der Hand haben
|
|
|
|
|
|
expect(playerDeck).toBe(nextPlayer.hand.length - 2); |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('+4 - Farbe gesetzt, nächster Spieler +4 Karten', () => { |
|
|
|
|
|
|
|
|
|
|
|
card = new PlusAmount(game); |
|
|
|
|
|
|
|
|
|
|
|
let nextPlayer = game.players[game.nextPlayer()]; |
|
|
|
|
|
|
|
|
|
|
|
let playerDeck = nextPlayer.hand.length |
|
|
|
|
|
|
|
|
|
|
|
card.putSelf(); |
|
|
|
|
|
|
|
|
|
|
|
//Der nächste Spieler muss 4 Karten mehr auf der Hand haben
|
|
|
|
|
|
expect(playerDeck).toBe(nextPlayer.hand.length - 4); |
|
|
|
|
|
|
|
|
|
|
|
//Die farbe von +4 muss gesetzt werden
|
|
|
|
|
|
let bool = (card.color === "NONE"); |
|
|
|
|
|
expect(bool).toBe(false); |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
//Testet eine Karte auf die Eigenschaften von Card.js
|
|
|
//Testet eine Karte auf die Eigenschaften von Card.js
|
|
|
function testCreatedCard(card, number, card_colors){ |
|
|
function testCreatedCard(card, number, card_colors){ |
|
|
|
|
|
|
|
|