public GameState drawPlayerCards(Player cp, int num = 2) { GameState newGS = new GameState(this); for (int i = 0; i < num; i++) { if (newGS.playerDeck.isNextCardEpidemic()) { newGS.epidemicCard(); newGS.playerDeck.cardWeAreOn++; } else { newGS.playerDeck = newGS.playerDeck.draw(1); if (newGS.playerDeck.isOverdrawn) { //we just lost return(newGS); } newGS = newGS.adjustPlayer(cp.addCard(newGS.playerDeck.mostRecent(1)[0])); newGS.recalcForAddCard(cp, newGS.playerDeck.mostRecent(1)[0]); } } return(newGS); }
public void epidemicTest() { Map map = new Map(); City atl = map.addCity("Atlanta", DiseaseColor.BLUE); City ny = map.addCity("New York", DiseaseColor.BLUE); City.makeAdjacent(atl,ny); Deck<City> playerDeck = new Deck<City>(map.allCities); int infectRate; GameState gs = new GameState(atl, map, 1, 4, new Deck<City>(map.allCities), playerDeck); infectRate = gs.map.infectionRate; gs.epidemicCard(); Assert.IsTrue(gs.map.diseaseLevel(atl, DiseaseColor.BLUE) == 3 || gs.map.diseaseLevel(ny, DiseaseColor.BLUE) == 3); Assert.AreEqual(infectRate + 1, gs.map.infectionRate); }
public GameState drawPlayerCards(Player cp, int num = 2) { GameState newGS = new GameState(this); for (int i = 0; i < num; i++) { if (newGS.playerDeck.isNextCardEpidemic()) { newGS.epidemicCard(); newGS.playerDeck.cardWeAreOn++; } else { newGS.playerDeck = newGS.playerDeck.draw(1); if (newGS.playerDeck.isOverdrawn) { //we just lost return newGS; } newGS = newGS.adjustPlayer(cp.addCard(newGS.playerDeck.mostRecent(1)[0])); newGS.recalcForAddCard(cp, newGS.playerDeck.mostRecent(1)[0]); } } return newGS; }