tests improvements
This commit is contained in:
@@ -143,6 +143,23 @@ public class OfferingTile {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Tile " + letter + " " + actions + (isEmpty() ? " [empty]" : " [" + occupant.getNickname() + "]");
|
||||
return "(" + letter + " " + getActionsIcon(actions) + (isEmpty() ? " [empty]" : " [" + occupant + "])");
|
||||
}
|
||||
|
||||
|
||||
public static String getActionIcon(Symbol s){
|
||||
if (Symbol.UP==s) return "\u001B[32m↑\u001B[0m";
|
||||
if (Symbol.DOWN==s) return "\u001B[31m↓\u001B[0m";
|
||||
if (Symbol.FOOD==s) return "\u001B[32m*\u001B[0m";
|
||||
return null;
|
||||
}
|
||||
public static String getActionsIcon(List<Symbol> act) {
|
||||
//if (act.size()==3) return "\u001B[32m*\u001B[0m";
|
||||
String res="";
|
||||
for (Symbol s : act){
|
||||
res+=getActionIcon(s);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,10 +87,43 @@ public class Player {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Player(" +
|
||||
"name='" + nickname + '\'' +
|
||||
", food=" + foodTokens +
|
||||
", pp=" + prestigePoints +
|
||||
')';
|
||||
|
||||
//🟡👤 Yellow Player
|
||||
//🔵👤 Blue Player
|
||||
//🔴👤 Red Player
|
||||
//🟢👤 Green Player
|
||||
//🟣👤 Purple Player
|
||||
|
||||
return ( "("+getAnsiColorIcon(getTotemColor()) +" " + nickname +
|
||||
" - food=" + foodTokens +
|
||||
", pp=" + prestigePoints + ")");
|
||||
}
|
||||
|
||||
public static String getAnsiColorIcon(TotemColor c) {
|
||||
switch (c) {
|
||||
case RED: return "\u001B[31m●\u001B[0m";
|
||||
case BLUE: return "\u001B[34m●\u001B[0m";
|
||||
case GREEN: return "\u001B[32m●\u001B[0m";
|
||||
case YELLOW: return "\u001B[33m●\u001B[0m";
|
||||
case PURPLE: return "\u001B[35m●\u001B[0m";
|
||||
default: return "●";
|
||||
}
|
||||
}
|
||||
|
||||
public static String getColorIcon(TotemColor c) {
|
||||
switch (c) {
|
||||
case BLUE:
|
||||
return "\uD83D\uDD35"; // 🔵 blue circle
|
||||
case RED:
|
||||
return "\uD83D\uDD34"; // 🔴 red circle
|
||||
case GREEN:
|
||||
return "\uD83D\uDFE2"; // 🟢 green circle
|
||||
case YELLOW:
|
||||
return "\uD83D\uDFE1"; // 🟡 yellow circle
|
||||
case PURPLE:
|
||||
return "\uD83D\uDFE3"; // 🟣 purple circle
|
||||
default:
|
||||
return "\u25CF"; // ● fallback black circle
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,10 +167,5 @@ public class TurnTile {
|
||||
return nextFreeSlot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TurnTile{" +
|
||||
"positions=" + Arrays.toString(positions) +
|
||||
'}';
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package server.cards;
|
||||
|
||||
import server.Era;
|
||||
import server.utils.GameUtils;
|
||||
|
||||
public abstract class Card {
|
||||
private final int cardId;
|
||||
@@ -27,9 +28,6 @@ public abstract class Card {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Card{" +
|
||||
"cardId=" + cardId +
|
||||
", era=" + era +
|
||||
'}';
|
||||
return GameUtils.formatCard(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ public class CardDeck {
|
||||
String cleanRow = row.trim();
|
||||
String[] fields = cleanRow.split(";");
|
||||
|
||||
logger.info((p++) + " ROW " + row);
|
||||
logger.debug((p++) + " ROW " + row);
|
||||
|
||||
switch (fields[0]) {
|
||||
case "C":
|
||||
|
||||
@@ -47,12 +47,5 @@ public class CharacterCard extends Card{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CharacterCard{" +
|
||||
"characterType=" + characterType +
|
||||
", value=" + iconValue +
|
||||
", points=" + prestigePoints +
|
||||
'}';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -44,12 +44,5 @@ public class EventCard extends Card {
|
||||
return new EventCard(cardId, forMinPlayer, era, event, firstValue, secondValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EventCard{" +
|
||||
"event=" + event +
|
||||
", firstValue=" + firstValue +
|
||||
", secondValue=" + secondValue +
|
||||
'}';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
47
src/main/java/server/utils/GameUtils.java
Normal file
47
src/main/java/server/utils/GameUtils.java
Normal file
@@ -0,0 +1,47 @@
|
||||
package server.utils;
|
||||
|
||||
import server.OfferingTile;
|
||||
import server.Player;
|
||||
import server.TurnTile;
|
||||
import server.cards.BuildingCard;
|
||||
import server.cards.Card;
|
||||
import server.cards.CharacterCard;
|
||||
import server.cards.EventCard;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class GameUtils {
|
||||
|
||||
public static String formatCard(Card c) {
|
||||
if (c instanceof EventCard e) {
|
||||
return "(E "+e.getCardId() + " " + e.getEvent()+ " Era" +e.getEra() +")";
|
||||
}
|
||||
if (c instanceof CharacterCard cc) {
|
||||
return "(C "+cc.getCardId() + " " +cc.getCharacterType() + " Era" +cc.getEra() + ")";
|
||||
}
|
||||
if (c instanceof BuildingCard b) {
|
||||
return "(B "+b.getCardId() + " Era" +b.getEra() + ")";
|
||||
}
|
||||
return "(#" + c.getCardId() + " UNKNOWN)";
|
||||
}
|
||||
|
||||
public static String formatTurnTile(TurnTile t) {
|
||||
//for (Player p : t.getPositions()){" : "occupied");
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("[TURN ORDER]\n");
|
||||
for (int i = 0; i < t.getPositions().length; i++) {
|
||||
Player p = t.getPositions()[i];
|
||||
sb.append(" ").append(i + 1).append(". ")
|
||||
.append(p.toString()+ "\n");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static String formatOffTile(OfferingTile o) {
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -31,8 +31,8 @@ class OfferingTileTest {
|
||||
void RemoveOccupant(){
|
||||
|
||||
//test that the occupant has been removed
|
||||
|
||||
assertNull(offeringTile.removeOccupant());
|
||||
offeringTile.removeOccupant();
|
||||
assertTrue(offeringTile.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,11 +1,36 @@
|
||||
package server.automaton;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import server.Player;
|
||||
import server.TotemColor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static server.utils.GameUtils.formatTurnTile;
|
||||
|
||||
class GameTest {
|
||||
|
||||
@Test
|
||||
void newGame() {
|
||||
List<Player> players = new ArrayList<>();
|
||||
players.add(new Player("Yellow", TotemColor.YELLOW));
|
||||
players.add(new Player("Blue", TotemColor.BLUE));
|
||||
players.add(new Player("Purple", TotemColor.PURPLE));
|
||||
players.add(new Player("Red", TotemColor.RED));
|
||||
players.add(new Player("Green", TotemColor.GREEN));
|
||||
|
||||
Game game = new Game(players);
|
||||
game.newGame(getClass().getResourceAsStream("/files/cards.csv"));
|
||||
|
||||
System.out.println("Round " + game.getRound());
|
||||
System.out.println("Game State " + game.getState());
|
||||
|
||||
System.out.println("-- Turn Tile --\n" +formatTurnTile( game.getGameBoard().getTurnTile()));
|
||||
System.out.println("---- Offering Tiles ----\n" + game.getGameBoard().getOfferingTiles());
|
||||
|
||||
System.out.println("______ Top _________ \n" + game.getGameBoard().getTopRow());
|
||||
System.out.println("______ Bottom _________ \n" + game.getGameBoard().getBottomRow());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -13,7 +13,8 @@ class CardDeckTest {
|
||||
@Test
|
||||
void loadOnlyCharacter(){
|
||||
CardDeck cardDeck = new CardDeck();
|
||||
cardDeck.setForNPlayer(getClass().getResourceAsStream("/files/cards.csv"), 4);
|
||||
cardDeck.setForNPlayer(getClass().getResourceAsStream("/files/only_character_deck.csv"), 4);
|
||||
|
||||
assertEquals(2, cardDeck.getTribeDeck().size());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user