Fix: Fixed "buy" Method In BuildingCard.java And Relative Tests In BuildingCardTest.java; Now Correctly Handles Discounts Given By Builders.
Fix: Fixed "toString" Method In BuildingCard.java And Relative Tests In BuildingCardTest.java.
This commit is contained in:
@@ -159,8 +159,16 @@ public class BuildingCard extends PlayableCard implements Cloneable , BuildingEf
|
||||
* @return {@code true} if the building card is successfully bought,
|
||||
* {@code false} otherwise.
|
||||
*/
|
||||
// sum reduction value builder=> sconto
|
||||
public boolean buy(Player player) {
|
||||
if( bought || !player.removeFood(getPrice()))
|
||||
int discount = 0;
|
||||
discount = player.builders.stream().mapToInt(x -> x.getReductionValue()).sum();
|
||||
|
||||
if(discount > this.price){
|
||||
discount = this.price;
|
||||
}
|
||||
|
||||
if(bought || !player.removeFood(this.price - discount))
|
||||
return false;
|
||||
player.buildingCards.add(this);
|
||||
bought=true;
|
||||
|
||||
Reference in New Issue
Block a user