Coverage Summary for Class: Builder (it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters)
| Class |
Class, %
|
Method, %
|
Branch, %
|
Line, %
|
| Builder |
100%
(1/1)
|
90%
(9/10)
|
100%
(16/16)
|
97.1%
(34/35)
|
package it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters;
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Character;
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType;
import it.polimi.ingsw.gc14.Model.Player;
/**
* Represents a Builder character card.
*
* <p>A Builder is a specific type of {@link Character} that provides
* a reduction value when buying building cards.
*/
public class Builder extends Character {
/**
* The reduction value provided by this Builder card.
*/
private final int reductionValue;
/**
* The prestige value provided by this Builder card.
*/
private final int prestigeValue;
/**
* Returns the reduction value of this Builder card.
*
* @return the reduction value of this Builder card.
*/
public int getReductionValue() {
return reductionValue;
}
/**
* Returns the prestige value of this Builder card.
*
* @return the prestige value of this Builder card.
*/
public int getPrestigeValue() {
return prestigeValue;
}
/**
* Creates a Builder character card with the specified era, reduction value,
* and prestige value.
*
* @param Era the era of the Builder card.
* @param reductionValue the reduction value of the Builder card.
* @param prestigeValue the prestige value of the Builder card.
* @throws IllegalArgumentException if {@code reductionValue < 0} or {@code prestigeValue < 0}.
*/
public Builder(int Era, int reductionValue, int prestigeValue) throws IllegalArgumentException {
super(Era,CharacterType.BUILDER);
if(reductionValue < 0) {
throw new IllegalArgumentException();
}
this.reductionValue = reductionValue;
if(prestigeValue < 0) {
throw new IllegalArgumentException();
}
this.prestigeValue = prestigeValue;
}
/**
* Creates a Builder character card with the specified era, reduction value,
* prestige value, and minimum number of players.
*
* @param Era the era of the Builder card.
* @param reductionValue the reduction value of the Builder card.
* @param prestigeValue the prestige value of the Builder card.
* @param nMin the minimum number of players required for the card.
* @throws IllegalArgumentException if {@code reductionValue < 0} or {@code prestigeValue < 0}.
*/
public Builder(int Era, int reductionValue, int prestigeValue,int nMin) throws IllegalArgumentException {
super(Era,CharacterType.BUILDER,nMin);
if(reductionValue < 0) {
throw new IllegalArgumentException();
}
this.reductionValue = reductionValue;
if(prestigeValue < 0) {
throw new IllegalArgumentException();
}
this.prestigeValue = prestigeValue;
}
/**
* Creates a Builder character card with the specified era, reduction value,
* and prestige value.
*
* @param idIMG the image identifier of the Builder card.
* @param Era the era of the Builder card.
* @param reductionValue the reduction value of the Builder card.
* @param prestigeValue the prestige value of the Builder card.
* @throws IllegalArgumentException if {@code reductionValue < 0} or {@code prestigeValue < 0}.
*/
public Builder(String idIMG,int Era, int reductionValue, int prestigeValue) throws IllegalArgumentException {
super(idIMG,Era,CharacterType.BUILDER);
if(reductionValue < 0) {
throw new IllegalArgumentException();
}
this.reductionValue = reductionValue;
if(prestigeValue < 0) {
throw new IllegalArgumentException();
}
this.prestigeValue = prestigeValue;
}
/**
* Creates a Builder character card with the specified era, reduction value,
* prestige value, and minimum number of players.
*
* @param idIMG the image identifier of the Builder card.
* @param Era the era of the Builder card.
* @param reductionValue the reduction value of the Builder card.
* @param prestigeValue the prestige value of the Builder card.
* @param nMin the minimum number of players required for the card.
* @throws IllegalArgumentException if {@code reductionValue < 0} or {@code prestigeValue < 0}.
*/
public Builder(String idIMG,int Era, int reductionValue, int prestigeValue,int nMin) throws IllegalArgumentException {
super(idIMG,Era,CharacterType.BUILDER,nMin);
if(reductionValue < 0) {
throw new IllegalArgumentException();
}
this.reductionValue = reductionValue;
if(prestigeValue < 0) {
throw new IllegalArgumentException();
}
this.prestigeValue = prestigeValue;
}
@Override
public String toStringPlayer() {
return "\uD83D\uDD28:" + reductionValue + " \uD83C\uDFC5:" + prestigeValue;
}
@Override
public String toStringBoard() {
return "BUILDER \uD83D\uDD28:" + reductionValue + " \uD83C\uDFC5:" + prestigeValue;
}
/**
* Creates and returns a copy of this Builder card.
*
* @return a clone of this Builder card.
*/
@Override
public Character clone() {
return new Builder(getIdIMG(),getEra(),getReductionValue(), getPrestigeValue(), getNMin());
}
/**
* Inserts this Builder card into the specified player's Builder collection
* and applies any building effects triggered by character set completion.
*
* @param player the player who receives the card.
*/
@Override
public void insert(Player player) {
player.getBuilders().add(this);
player.getBuildingCards().stream().filter(x->x.getEffectId()==0).forEach(x->x.applyEffect(player));
}
}