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:
GabrieleRadice
2026-05-02 17:24:00 +02:00
parent 42a6644f8e
commit 32d1cca2ad
2 changed files with 162 additions and 3 deletions
@@ -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;