Refactor: Gatherers->Gatherer

This commit is contained in:
rubenpirreram
2026-03-20 19:07:59 +01:00
parent d80c2888ee
commit 0e9a4781bb
8 changed files with 24 additions and 28 deletions
@@ -4,16 +4,16 @@ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Character;
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType; import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType;
import it.polimi.ingsw.gc14.Model.Player; import it.polimi.ingsw.gc14.Model.Player;
public class Gatherers extends Character { public class Gatherer extends Character {
/** /**
* *
* @param Era gatherers era * @param Era gatherers era
*/ */
public Gatherers(int Era) { public Gatherer(int Era) {
super(Era, CharacterType.GATHERERS); super(Era, CharacterType.GATHERERS);
} }
public Gatherers(int Era,int nMin) { public Gatherer(int Era, int nMin) {
super(Era, CharacterType.GATHERERS,nMin); super(Era, CharacterType.GATHERERS,nMin);
} }
@Override @Override
@@ -23,7 +23,7 @@ public class Gatherers extends Character {
@Override @Override
public Character clone() { public Character clone() {
return new Gatherers(getEra()); return new Gatherer(getEra());
} }
public void insert(Player player) { public void insert(Player player) {
player.gatherers.add(this); player.gatherers.add(this);
@@ -1,10 +1,8 @@
package it.polimi.ingsw.gc14.Model; package it.polimi.ingsw.gc14.Model;
import com.google.gson.*; import com.google.gson.*;
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType;
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.*; import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.*;
import it.polimi.ingsw.gc14.Model.Cards.TribeCard; import it.polimi.ingsw.gc14.Model.Cards.TribeCard;
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.EventType;
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events.CavePaintings; import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events.CavePaintings;
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events.Hunt; import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events.Hunt;
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events.ShamanicRitual; import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events.ShamanicRitual;
@@ -61,10 +59,10 @@ public class DecksCreator {
case 3 -> new Builder(era, p[0], p[1], p[2]); case 3 -> new Builder(era, p[0], p[1], p[2]);
default -> throw new IllegalArgumentException("Builder: parametri non validi"); default -> throw new IllegalArgumentException("Builder: parametri non validi");
}; };
case "Gatherers" -> switch (p.length) { case "Gatherer" -> switch (p.length) {
case 0 -> new Gatherers(era); case 0 -> new Gatherer(era);
case 1 -> new Gatherers(era, p[0]); case 1 -> new Gatherer(era, p[0]);
default -> throw new IllegalArgumentException("Gatherers: parametri non validi"); default -> throw new IllegalArgumentException("Gatherer: parametri non validi");
}; };
case "Artist" -> switch (p.length) { case "Artist" -> switch (p.length) {
case 0 -> new Artist(era); case 0 -> new Artist(era);
@@ -37,7 +37,7 @@ public class Player {
public ArrayList <Artist> artists; public ArrayList <Artist> artists;
public ArrayList <Builder> builders; public ArrayList <Builder> builders;
public ArrayList <Inventor> inventors; public ArrayList <Inventor> inventors;
public ArrayList <Gatherers> gatherers; public ArrayList <Gatherer> gatherers;
public ArrayList <Shaman> shamans; public ArrayList <Shaman> shamans;
public ArrayList <Hunter> hunters; public ArrayList <Hunter> hunters;
+4 -4
View File
@@ -81,21 +81,21 @@
}, },
{ {
"isEvent": false, "isEvent": false,
"type": "Gatherers", "type": "Gatherer",
"era": 1, "era": 1,
"armed": false, "armed": false,
"params": [] "params": []
}, },
{ {
"isEvent": false, "isEvent": false,
"type": "Gatherers", "type": "Gatherer",
"era": 1, "era": 1,
"armed": false, "armed": false,
"params": [] "params": []
}, },
{ {
"isEvent": false, "isEvent": false,
"type": "Gatherers", "type": "Gatherer",
"era": 1, "era": 1,
"armed": false, "armed": false,
"params": [ "params": [
@@ -104,7 +104,7 @@
}, },
{ {
"isEvent": false, "isEvent": false,
"type": "Gatherers", "type": "Gatherer",
"era": 1, "era": 1,
"armed": false, "armed": false,
"params": [ "params": [
+4 -4
View File
@@ -88,14 +88,14 @@
}, },
{ {
"isEvent": false, "isEvent": false,
"type": "Gatherers", "type": "Gatherer",
"era": 2, "era": 2,
"armed": false, "armed": false,
"params": [] "params": []
}, },
{ {
"isEvent": false, "isEvent": false,
"type": "Gatherers", "type": "Gatherer",
"era": 2, "era": 2,
"armed": false, "armed": false,
"params": [ "params": [
@@ -104,7 +104,7 @@
}, },
{ {
"isEvent": false, "isEvent": false,
"type": "Gatherers", "type": "Gatherer",
"era": 2, "era": 2,
"armed": false, "armed": false,
"params": [ "params": [
@@ -113,7 +113,7 @@
}, },
{ {
"isEvent": false, "isEvent": false,
"type": "Gatherers", "type": "Gatherer",
"era": 2, "era": 2,
"armed": false, "armed": false,
"params": [ "params": [
+3 -3
View File
@@ -72,7 +72,7 @@
}, },
{ {
"isEvent": false, "isEvent": false,
"type": "Gatherers", "type": "Gatherer",
"era": 3, "era": 3,
"armed": false, "armed": false,
"params": [ "params": [
@@ -81,7 +81,7 @@
}, },
{ {
"isEvent": false, "isEvent": false,
"type": "Gatherers", "type": "Gatherer",
"era": 3, "era": 3,
"armed": false, "armed": false,
"params": [ "params": [
@@ -90,7 +90,7 @@
}, },
{ {
"isEvent": false, "isEvent": false,
"type": "Gatherers", "type": "Gatherer",
"era": 3, "era": 3,
"armed": false, "armed": false,
"params": [] "params": []
@@ -23,7 +23,7 @@ class Building0Test {
assertEquals(0, p.getFoodValue()); assertEquals(0, p.getFoodValue());
Artist a = new Artist(Era); Artist a = new Artist(Era);
Builder b = new Builder(Era, 0, 0); Builder b = new Builder(Era, 0, 0);
Gatherers g = new Gatherers(Era); Gatherer g = new Gatherer(Era);
Hunter h = new Hunter(Era, true); Hunter h = new Hunter(Era, true);
Inventor i = new Inventor(Era, 1); Inventor i = new Inventor(Era, 1);
Shaman s = new Shaman(Era,1); Shaman s = new Shaman(Era,1);
@@ -46,7 +46,7 @@ class Building0Test {
assertEquals(0, p.getFoodValue()); assertEquals(0, p.getFoodValue());
Artist a = new Artist(Era); Artist a = new Artist(Era);
Builder b = new Builder(Era, 0, 0); Builder b = new Builder(Era, 0, 0);
Gatherers g = new Gatherers(Era); Gatherer g = new Gatherer(Era);
Hunter h = new Hunter(Era, true); Hunter h = new Hunter(Era, true);
Inventor i = new Inventor(Era, 1); Inventor i = new Inventor(Era, 1);
Shaman s = new Shaman(Era,1); Shaman s = new Shaman(Era,1);
@@ -1,8 +1,6 @@
package it.polimi.ingsw.gc14.Model.Cards.Building.Effects; package it.polimi.ingsw.gc14.Model.Cards.Building.Effects;
import it.polimi.ingsw.gc14.Model.Cards.TribeCard;
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.*; import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.*;
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events.Hunt;
import it.polimi.ingsw.gc14.Model.Player; import it.polimi.ingsw.gc14.Model.Player;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@@ -24,7 +22,7 @@ class Building10Test {
ArrayList<Artist> Artists = new ArrayList<>(); ArrayList<Artist> Artists = new ArrayList<>();
ArrayList<Builder> Builders = new ArrayList<>(); ArrayList<Builder> Builders = new ArrayList<>();
ArrayList<Gatherers> Gatherers = new ArrayList<>(); ArrayList<Gatherer> Gatherers = new ArrayList<>();
ArrayList<Hunter> Hunters = new ArrayList<>(); ArrayList<Hunter> Hunters = new ArrayList<>();
ArrayList<Inventor> Inventors = new ArrayList<>(); ArrayList<Inventor> Inventors = new ArrayList<>();
ArrayList<Shaman> Shamans = new ArrayList<>(); ArrayList<Shaman> Shamans = new ArrayList<>();
@@ -32,7 +30,7 @@ class Building10Test {
for(int i = 0; i < Nset; i++) { for(int i = 0; i < Nset; i++) {
Artists.add(new Artist(Era)); Artists.add(new Artist(Era));
Builders.add(new Builder(Era, 0, 0)); Builders.add(new Builder(Era, 0, 0));
Gatherers.add(new Gatherers(Era)); Gatherers.add(new Gatherer(Era));
Hunters.add(new Hunter(Era, true)); Hunters.add(new Hunter(Era, true));
Inventors.add(new Inventor(Era, 1)); Inventors.add(new Inventor(Era, 1));
Shamans.add(new Shaman(Era, 1)); Shamans.add(new Shaman(Era, 1));