Game loop and fight

This commit is contained in:
L3o15 2025-05-14 19:38:38 +02:00
parent 9a24645cab
commit 228c410a1a
9 changed files with 34 additions and 2 deletions

View file

@ -58,5 +58,19 @@ public class ElementGraph {
return elements;
}
public int getInteractionBetween(Element fromElement, Element toElement) {
for (GraphElement el : elements) {
if (el.getElement().equals(fromElement)){
for (ElementLink link : el.getLinks()) {
if (link.getElement().equals(toElement)){
return link.getValue();
}
}
}
}
return 0;
}
}

5
src/FightEsit.java Normal file
View file

@ -0,0 +1,5 @@
package it.arnaldo.unibs.tamagolem;
public enum FightEsit {
GOLEM1, GOLEM2
}

View file

@ -14,6 +14,7 @@ public class Game {
this.player1 = player1;
this.player2 = player2;
this.worldBalance = worldBalance;
this.stonesPerElement = new HashMap<>();
}
public Player getPlayer1() {

View file

@ -29,7 +29,7 @@ public class GameLoop {
Player p2 = new Player(InputData.readNonEmptyString("""
\s
Player 1:
Player 2:
\tChoose your name:\s""", true));
int difficultyChoise = difficultyMenu.choose();

View file

@ -18,7 +18,9 @@ public class TamaGolem {
public Element useElementalStone() {
if (!elementalStones.isEmpty()) {
return elementalStones.poll();
Element removedStone = elementalStones.removeFirst();
elementalStones.add(removedStone);
return removedStone;
}
return null;
}
@ -35,4 +37,14 @@ public class TamaGolem {
public boolean isAlive() {
return lifePoints > 0;
}
@Override
public String toString() {
return "LP: " + lifePoints + ", Elemental stones:" + elementalStones.toString();
}
public void print() {
System.out.println(toString());
}
}