Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
<classpathentry kind="src" path=""/>
<classpathentry exported="true" kind="lib" path="jgoodies-forms-1.8.0.jar" sourcepath="jgoodies-forms-1.8.0-sources.jar"/>
<classpathentry exported="true" kind="lib" path="json-20231013.jar" sourcepath="json-20231013.jar"/>
Expand Down
7 changes: 6 additions & 1 deletion domain/GameController.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ public static GameController getInstance() {
}
return instance;
}
public static void clearInstance() {
instance = null;
}


//This func initializes the game by calling creating a new instance of initliazegamehelper
Expand All @@ -48,10 +51,12 @@ public void initializeGame() {
initalizeGameHelper=new InitializeGameHelper();
}
else {
System.out.println("Not able to initialize");
System.out.println("Not able to initialize, have " + activePlayers.size() + "players, need 2");
}

}



//This func changes rounds
public void changeRounds() {
Expand Down
6 changes: 6 additions & 0 deletions domain/player/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,10 @@ public boolean equals(Player p2) {
else return false;
}

@Override
public String toString() {

String str = playerName + playerToken;
return str;
}
}
35 changes: 21 additions & 14 deletions domain/player/PlayerInventory.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ public class PlayerInventory {
final ArrayList<PublicationCard> playerPublicationCardList;

public PlayerInventory() {

playerRecipeList = new ArrayList<Recipe>();
playerPotionList = new ArrayList<Potion>();
playerHypothesesList = new ArrayList<Hypotheses>();
playerIngredientCardList = new ArrayList<IngredientCard>();
playerArtifactCardList = new ArrayList<ArtifactCard>();
playerPublicationCardList = new ArrayList<PublicationCard>();
}

public ArrayList<Recipe> getPlayerRecipeList() {
return playerRecipeList;
}
Expand Down Expand Up @@ -58,49 +58,56 @@ public ArrayList<PublicationCard> getPlayerPublicationCardList() {
public void addPotion(Potion potion) {
this.playerPotionList.add(potion);
}

public void addRecipe(Recipe recipe) {
this.playerRecipeList.add(recipe);
}

public void addHypoteses(Hypotheses hyp) {
this.playerHypothesesList.add(hyp);
}

public void addAIngredientCard(IngredientCard ing) {
this.playerIngredientCardList.add(ing);
}

public void addArtifactCard(ArtifactCard art) {
this.playerArtifactCardList.add(art);
}

public void addPublicationCard(PublicationCard pub) {
this.playerPublicationCardList.add(pub);
}

public void removePotion(Potion potion) {
this.playerPotionList.remove(potion);
}

public void removeRecipe(Recipe recipe) {
this.playerRecipeList.remove(recipe);
}

public void removeHypoteses(Hypotheses hyp) {
this.playerHypothesesList.remove(hyp);
}

public void removeIngredientCard(IngredientCard ing) {
this.playerIngredientCardList.remove(ing);
}

public void removeArtifactCard(ArtifactCard art) {
this.playerArtifactCardList.remove(art);
}

public void removePublicationCard(PublicationCard pub) {
this.playerPublicationCardList.remove(pub);
}


@Override
public String toString() {

String str = "\nIngredient Cards: " + playerIngredientCardList + "\nArtifact Cards: " + playerArtifactCardList + "\nPotion List: " + playerPotionList + "\nRecipes: " + playerRecipeList ;
return str;
}

}
88 changes: 48 additions & 40 deletions domain/player/PlayerToken.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,39 +18,39 @@ public class PlayerToken {
int playerAction=3;
String playerAvatar; // the directory of the playeravatar is kept in this as a string.
PlayerInventory playerInventory;


public PlayerToken() {

this.playerInventory= new PlayerInventory();
}


public void addGold(int gold) {
this.gold=this.gold+gold;

}
public void subtractGold(int gold) {
this.gold=this.gold-gold;

}

public void addReputationPoint(int point) {
this.reputation=this.reputation+point;

}
public void subtractReputationPoint(int point) {
this.reputation=this.reputation-point;

}


public void addHealth() {
if(this.playerHealth<3) {
this.playerHealth++;
}
}

public void reduceHealth() {
if(this.playerHealth>0) {
this.playerHealth--;
Expand All @@ -60,56 +60,56 @@ public void reduceHealth() {
this.gold=0;
}
}





public void addPotion(Potion potion) {
playerInventory.playerPotionList.add(potion);
}

public void addRecipe(Recipe recipe) {
playerInventory.playerRecipeList.add(recipe);
}

public void addHypoteses(Hypotheses hyp) {
playerInventory.playerHypothesesList.add(hyp);
}

public void addAIngredientCard(IngredientCard ing) {
playerInventory.playerIngredientCardList.add(ing);
}

public void addArtifactCard(ArtifactCard art) {
playerInventory.playerArtifactCardList.add(art);
}

public void addPublicationCard(PublicationCard pub) {
playerInventory.playerPublicationCardList.add(pub);
}


public void removePotion(Potion potion) {
playerInventory.playerPotionList.remove(potion);
}

public void removeRecipe(Recipe recipe) {
playerInventory.playerRecipeList.remove(recipe);
}

public void removeHypoteses(Hypotheses hyp) {
playerInventory.playerHypothesesList.remove(hyp);
}

public void removeIngredientCard(IngredientCard ing) {
playerInventory.playerIngredientCardList.remove(ing);
}

public void removeArtifactCard(ArtifactCard art) {
playerInventory.playerArtifactCardList.remove(art);
}

public void removePublicationCard(PublicationCard pub) {
playerInventory.playerPublicationCardList.remove(pub);
}
Expand Down Expand Up @@ -173,26 +173,26 @@ public void setPlayerAvatar(String playerAvatar) {
*/
public void reducePlayerAction() throws RuntimeException{
if(this.playerAction<=0) {


throw new RuntimeException("Tried to reduce user actions when the user had no actions left");

}
this.playerAction -= 1;

//GameController.changeCurrentPlayer();
if(this.playerAction ==0) {
GameController.getInstance().changeCurrentPlayer();
}


if(GameController.getInstance().shouldChangeRound()) {
GameController.getInstance().changeRounds();
}


}

public PlayerInventory getPlayerInventory() {
return playerInventory;
}
Expand All @@ -201,8 +201,16 @@ public PlayerInventory getPlayerInventory() {
public void setPlayerInventory(PlayerInventory playerInventory) {
this.playerInventory = playerInventory;
}





@Override
public String toString() {

String str = "\nGold: " + gold + " Reputation: " + reputation + " Health: " + playerHealth + " Left Actions: " + playerAction;
str += playerInventory;
return str;
}




}
41 changes: 31 additions & 10 deletions domain/potion/Molecule.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import java.util.Objects;

public class Molecule {

int moleculeId;
Atom redAtom;
Atom greenAtom;
Atom blueAtom;

public Molecule(int moleculeId, Atom redAtom, Atom greenAtom, Atom blueAtom) {

this.moleculeId = moleculeId;
this.redAtom = redAtom;
this.greenAtom = greenAtom;
Expand Down Expand Up @@ -38,27 +38,27 @@ public boolean equals(Object obj) {
}

public void setAtom(Atom atom) {

if(atom.getAtomColor()==0) {
this.redAtom=atom;
}else if(atom.getAtomColor()==1) {

this.greenAtom=atom;
}else if(atom.getAtomColor()==2) {

this.blueAtom=atom;
}
}

public Atom getAtomByColor(int atomColorId) {
if(redAtom.getAtomColor() == atomColorId) {
return redAtom;
}

else if(greenAtom.getAtomColor() == atomColorId) {
return greenAtom;
}

else if(blueAtom.getAtomColor() == atomColorId) {
return blueAtom;
}
Expand Down Expand Up @@ -113,6 +113,27 @@ public Atom getBlueAtom() {
public void setBlueAtom(Atom blueAtom) {
this.blueAtom = blueAtom;
}



@Override
public String toString() {

Atom redAtom = this.getRedAtom();
String redAtomSize = (redAtom.getAtomSize() == 1? "Big" : "Small");
String redAtomSign = (redAtom.getAtomSign() == 0? "Negative" : "Positive");

Atom blueAtom = this.getBlueAtom();
String blueAtomSize = (blueAtom.getAtomSize() == 1? "Big" : "Small");
String blueAtomSign = (blueAtom.getAtomSign() == 0? "Negative" : "Positive");

Atom greenAtom = this.getGreenAtom();
String greenAtomSize = (greenAtom.getAtomSize() == 1? "Big" : "Small");
String greenAtomSign = (greenAtom.getAtomSign() == 0? "Negative" : "Positive");

String str = "Red: " + redAtomSize + " " + redAtomSign;
str += "\nBlue: " + blueAtomSize + " " + blueAtomSign;
str += "\nGreen: " + greenAtomSize + " " + greenAtomSign;

return str;
}

}
Loading