Fix: Building10Test Correcly Handles Buying / Utilising .buy Method From BuildingCard Class
This commit is contained in:
@@ -16,8 +16,8 @@ class Building0Test {
|
||||
// Corretta creazione / esecuzione building card
|
||||
Building0 b0 = new Building0(1, 1);
|
||||
Player p = new Player("test");
|
||||
p.addFood(b0.getPrice());
|
||||
b0.buy(p);
|
||||
p.buildingCards.add(b0);
|
||||
b0.applyEffect(p);
|
||||
|
||||
assertEquals(0, p.getFoodValue());
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
package it.polimi.ingsw.gc14.Model.Cards.Building.Effects;
|
||||
|
||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCard;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.*;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events.Hunt;
|
||||
import it.polimi.ingsw.gc14.Model.Player;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class Building10Test {
|
||||
|
||||
@Test
|
||||
void applyEffect() {
|
||||
Building10 b10 = new Building10(1, 1);
|
||||
Player p = new Player("test");
|
||||
p.addPrestige(b10.getPrice());
|
||||
b10.buy(p);
|
||||
|
||||
int Era = 1;
|
||||
int Nset = 2;
|
||||
|
||||
ArrayList<Artist> Artists = new ArrayList<>();
|
||||
ArrayList<Builder> Builders = new ArrayList<>();
|
||||
ArrayList<Gatherers> Gatherers = new ArrayList<>();
|
||||
ArrayList<Hunter> Hunters = new ArrayList<>();
|
||||
ArrayList<Inventor> Inventors = new ArrayList<>();
|
||||
ArrayList<Shaman> Shamans = new ArrayList<>();
|
||||
|
||||
for(int i = 1; i < Nset; i++) {
|
||||
Artists.add(new Artist(Era));
|
||||
Builders.add(new Builder(Era, 0, 0));
|
||||
Gatherers.add(new Gatherers(Era));
|
||||
Hunters.add(new Hunter(Era, true));
|
||||
Inventors.add(new Inventor(Era, 1));
|
||||
Shamans.add(new Shaman(Era, 1));
|
||||
}
|
||||
|
||||
p.artists.addAll(Artists);
|
||||
p.builders.addAll(Builders);
|
||||
p.gatherers.addAll(Gatherers);
|
||||
p.hunters.addAll(Hunters);
|
||||
p.inventors.addAll(Inventors);
|
||||
p.shamans.addAll(Shamans);
|
||||
b10.applyEffect(p);
|
||||
|
||||
assertEquals(Nset * 6, p.getFoodValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
void applyEffectException() {
|
||||
assertThrows(IllegalArgumentException.class, () -> {
|
||||
Building10 b10 = new Building10(1, 1);
|
||||
Player p = new Player("test");
|
||||
b10.applyEffect(p);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void applyEffectMultiplePlayerException() {
|
||||
Building10 b10 = new Building10(1, 1);
|
||||
Player p1 = new Player("test1");
|
||||
Player p2 = new Player("test2");
|
||||
b10.buy(p1);
|
||||
assertFalse(b10.buy(p2));
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,8 @@ class Building13Test {
|
||||
Player p1 = new Player("gigi");
|
||||
p1.addPrestige(10);
|
||||
Building13 b1 = new Building13(1, 10);
|
||||
b1.buy(p1);
|
||||
p1.buildingCards.add(b1);
|
||||
b1.applyEffect(p1);
|
||||
assertEquals(35, p1.getPrestigeValue());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package it.polimi.ingsw.gc14.Model.Cards.Building.Effects;
|
||||
|
||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.Builder;
|
||||
import it.polimi.ingsw.gc14.Model.Player;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class Building8Test {
|
||||
|
||||
@Test
|
||||
void applyEffect() {
|
||||
Building8 b8 = new Building8(1, 1);
|
||||
Player p = new Player("test");
|
||||
p.addFood(b8.getPrice());
|
||||
b8.buy(p);
|
||||
|
||||
int Era = 1;
|
||||
int PrestigeMul = 1;
|
||||
Builder builder1 = new Builder(Era, 1, PrestigeMul);
|
||||
p.builders.add(builder1);
|
||||
|
||||
b8.applyEffect(p);
|
||||
|
||||
assertEquals(1, p.buildingCards.stream().filter(x -> x.getEffectId() == 8).count());
|
||||
assertEquals(PrestigeMul * 2 * p.buildingCards.stream().filter(x -> x.getEffectId() == 8).count(), p.getPrestigeValue());
|
||||
|
||||
Builder b2 = new Builder(Era, 1, PrestigeMul);
|
||||
p.builders.add(b2);
|
||||
b8.applyEffect(p);
|
||||
|
||||
assertEquals(2 + 4, p.getPrestigeValue());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user