Coverage Summary for Class: Inventor (it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters)
| Class |
Class, %
|
Method, %
|
Branch, %
|
Line, %
|
| Inventor |
100%
(1/1)
|
100%
(9/9)
|
100%
(18/18)
|
100%
(23/23)
|
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 an Inventor character card.
*
* <p>An Inventor is a specific type of {@link Character} initialized with
* {@link CharacterType#INVENTOR}.
*/
public class Inventor extends Character {
/**
* The {@code Icons}'s ID. There are a total of 10 different Icons.
*/
private final int icon;
/**
* Returns the icon value of this Inventor card.
*
* @return the icon value of this Inventor card.
*/
public int getIcon() {
return icon;
}
/**
* Creates an Inventor character card with the specified era and icon value.
*
* @param Era the era of the Inventor card.
* @param icon the icon value of the Inventor card.
* @throws IllegalArgumentException if {@code icon < 0} or {@code icon > 9}.
*/
public Inventor(int Era,int icon) throws IllegalArgumentException {
super(Era, CharacterType.INVENTOR);
if(icon<0 || icon>9)
throw new IllegalArgumentException();
this.icon = icon;
}
/**
* Creates an Inventor character card with the specified era, icon value,
* and minimum number of players.
*
* @param Era the era of the Inventor card.
* @param icon the icon value of the Inventor card.
* @param nMin the minimum number of players required for the card.
* @throws IllegalArgumentException if {@code icon < 0} or {@code icon > 9}.
*/
public Inventor(int Era,int icon,int nMin) throws IllegalArgumentException {
super(Era, CharacterType.INVENTOR,nMin);
if(icon<0 || icon>9)
throw new IllegalArgumentException();
this.icon = icon;
}
/**
* Creates an Inventor character card with the specified image id, era and icon value.
*
* @param idIMG the image identifier of the Inventor card.
* @param Era the era of the Inventor card.
* @param icon the icon value of the Inventor card.
* @throws IllegalArgumentException if {@code icon < 0} or {@code icon > 9}.
*/
public Inventor(String idIMG,int Era,int icon) throws IllegalArgumentException {
super(idIMG,Era, CharacterType.INVENTOR);
if(icon<0 || icon>9)
throw new IllegalArgumentException();
this.icon = icon;
}
/**
* Creates an Inventor character card with the specified image id, era, icon value,
* and minimum number of players.
*
* @param idIMG the image identifier of the Inventor card.
* @param Era the era of the Inventor card.
* @param icon the icon value of the Inventor card.
* @param nMin the minimum number of players required for the card.
* @throws IllegalArgumentException if {@code icon < 0} or {@code icon > 9}.
*/
public Inventor(String idIMG,int Era,int icon,int nMin) throws IllegalArgumentException {
super(idIMG,Era, CharacterType.INVENTOR,nMin);
if(icon<0 || icon>9)
throw new IllegalArgumentException();
this.icon = icon;
}
@Override
public String toStringPlayer() {
return "ID:" + icon;
}
@Override
public String toStringBoard() {
return "INVENTOR ID:" + icon;
}
/**
* Creates and returns a copy of this Inventor card.
*
* @return a clone of this Inventor card.
*/
@Override
public Character clone() {
return new Inventor(getIdIMG(),getEra(),icon, getNMin());
}
/**
* Inserts this Inventor card into the specified player's Inventor collection.
*
* <p>The method also applies the building effects related to inventor pairs
* and any building effects triggered by character set completion.
*
* @param player the player who receives the card.
*/
@Override
public void insert(Player player) {
player.getInventors().add(this);
player.getBuildingCards().stream().filter(b -> b.getEffectId() == 4).forEach(b4 -> b4.applyEffect(player));
player.getBuildingCards().stream().filter(x->x.getEffectId()==0).forEach(x->x.applyEffect(player));
}
}