Partial BuildingEffects implementation
This commit is contained in:
@@ -25,18 +25,22 @@ public class Building0 extends BuildingCard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setSetCards(Player player)
|
public void initialize(Player player)
|
||||||
{
|
{
|
||||||
if(purchased)
|
if(purchased)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
HashMap<CharacterType,Integer> map = new HashMap<CharacterType,Integer>();
|
HashMap<CharacterType,Integer> map = new HashMap<CharacterType,Integer>();
|
||||||
for(CharacterType type : CharacterType.values())
|
for(CharacterType t : CharacterType.values())
|
||||||
{
|
{
|
||||||
map.merge(type, 1, Integer::sum);
|
map.put(t, 0);
|
||||||
}
|
}
|
||||||
|
for(Character c : player.getCharacterCards())
|
||||||
|
{
|
||||||
|
map.merge(c.getType(), 1, Integer::sum);
|
||||||
|
}
|
||||||
|
numSet= map.values().stream().min(Integer::compareTo).get();
|
||||||
purchased = true;
|
purchased = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -45,10 +49,23 @@ public class Building0 extends BuildingCard {
|
|||||||
return new Building0(getEra(),getPrice());
|
return new Building0(getEra(),getPrice());
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void applyEffect(ArrayList<Player> players) {
|
public void applyEffect(Player player) {
|
||||||
for (Player p : players) {
|
HashMap<CharacterType,Integer> map = new HashMap<CharacterType,Integer>();
|
||||||
p.addFood(3);
|
|
||||||
|
for(CharacterType t : CharacterType.values())
|
||||||
|
{
|
||||||
|
map.put(t, 0);
|
||||||
}
|
}
|
||||||
|
for(Character c : player.getCharacterCards())
|
||||||
|
{
|
||||||
|
map.merge(c.getType(), 1, Integer::sum);
|
||||||
|
}
|
||||||
|
int temp = map.values().stream().min(Integer::compareTo).get();
|
||||||
|
if(temp<=numSet)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
player.addFood(5*(temp-numSet));
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package it.polimi.ingsw.gc14.Model.Cards.Building.Effects;
|
||||||
|
|
||||||
|
import it.polimi.ingsw.gc14.Model.Cards.Building.EffectType;
|
||||||
|
import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
|
||||||
|
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;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
public class Building1 extends BuildingCard {
|
||||||
|
private CharacterType icon ;
|
||||||
|
public CharacterType getIcon() {return icon;}
|
||||||
|
|
||||||
|
public Building1(int era, int price, CharacterType icon) {
|
||||||
|
super(era,price);
|
||||||
|
effectType= EffectType.ON_EVENT;
|
||||||
|
effectId=1;
|
||||||
|
this.icon=icon;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public BuildingCard clone() {
|
||||||
|
return new Building1(getEra(),getPrice(),getIcon());
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void applyEffect(Player player) {
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
package it.polimi.ingsw.gc14.Model.Cards.Building.Effects;
|
||||||
|
|
||||||
|
import it.polimi.ingsw.gc14.Model.Cards.Building.EffectType;
|
||||||
|
import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
|
||||||
|
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Character;
|
||||||
|
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.Inventor;
|
||||||
|
import it.polimi.ingsw.gc14.Model.Player;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
public class Building4 extends BuildingCard {
|
||||||
|
|
||||||
|
boolean purchased ;
|
||||||
|
int numPair;
|
||||||
|
public Building4(int era, int price) {
|
||||||
|
super(era,price);
|
||||||
|
effectType= EffectType.INVENTORPAIR;
|
||||||
|
effectId=4;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initialize(Player player)
|
||||||
|
{
|
||||||
|
if(purchased)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
HashMap<Integer,Integer> map = new HashMap<>();
|
||||||
|
for(int i=0;i<10;i++)
|
||||||
|
{
|
||||||
|
map.put(i,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(Character c : player.getCharacterCards())
|
||||||
|
{
|
||||||
|
if(c instanceof Inventor inv)
|
||||||
|
{
|
||||||
|
map.merge(inv.Icon(),1,Integer::sum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
numPair=0;
|
||||||
|
for(Integer i : map.values())
|
||||||
|
{
|
||||||
|
numPair+=(i%2);
|
||||||
|
}
|
||||||
|
purchased = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public BuildingCard clone() {
|
||||||
|
return new Building4(getEra(),getPrice());
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void applyEffect(Player player) {
|
||||||
|
HashMap<Integer,Integer> map = new HashMap<>();
|
||||||
|
for(int i=0;i<10;i++)
|
||||||
|
{
|
||||||
|
map.put(i,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(Character c : player.getCharacterCards())
|
||||||
|
{
|
||||||
|
if(c instanceof Inventor inv)
|
||||||
|
{
|
||||||
|
map.merge(inv.Icon(),1,Integer::sum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int temp=0;
|
||||||
|
for(Integer i : map.values())
|
||||||
|
{
|
||||||
|
temp+=(i%2);
|
||||||
|
}
|
||||||
|
if(temp<= numPair)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
player.addFood(3*(temp-numPair));
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -30,5 +30,5 @@ public abstract class BuildingCard extends PlayableCard implements Cloneable {
|
|||||||
@Override
|
@Override
|
||||||
public abstract BuildingCard clone() ;
|
public abstract BuildingCard clone() ;
|
||||||
|
|
||||||
public abstract void applyEffect(ArrayList<Player> players);
|
public abstract void applyEffect(Player player);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ module it.polimi.ingsw.gc14 {
|
|||||||
requires org.controlsfx.controls;
|
requires org.controlsfx.controls;
|
||||||
requires java.rmi;
|
requires java.rmi;
|
||||||
requires java.smartcardio;
|
requires java.smartcardio;
|
||||||
|
requires it.polimi.ingsw.gc14;
|
||||||
|
|
||||||
opens it.polimi.ingsw.gc14 to javafx.fxml;
|
opens it.polimi.ingsw.gc14 to javafx.fxml;
|
||||||
exports it.polimi.ingsw.gc14;
|
exports it.polimi.ingsw.gc14;
|
||||||
|
|||||||
Reference in New Issue
Block a user