improvements logging
This commit is contained in:
@@ -99,7 +99,7 @@ public class Game {
|
||||
*/
|
||||
public void newGame(InputStream csvStream) {
|
||||
try {
|
||||
logger.info("STARTING NEW GAME");
|
||||
logger.info(" ---- STARTING NEW GAME ----- ");
|
||||
|
||||
CardDeck deck = new CardDeck();
|
||||
deck.setForNPlayer(csvStream, players.size());
|
||||
@@ -115,11 +115,10 @@ public class Game {
|
||||
totemPlacedCount = 0;
|
||||
state = GameState.TOTEM_PLACEMENT;
|
||||
|
||||
logger.info("Game started! Round 1.");
|
||||
logTurnOrder();
|
||||
|
||||
} catch (LoadingCardsException e) {
|
||||
System.err.println("Fatal: could not load cards — " + e.getMessage());
|
||||
logger.error("Fatal: could not load cards — " + e.getMessage());
|
||||
state = GameState.GAME_OVER;
|
||||
}
|
||||
}
|
||||
@@ -129,7 +128,7 @@ public class Game {
|
||||
for (int i = 0; i < order.length; i++) {
|
||||
int food = (i == 0) ? 2 : (i <= 2) ? 3 : 4;
|
||||
order[i].addFood(food);
|
||||
logger.info(" " + order[i].getNickname() + " starts with " + food + " food.");
|
||||
logger.debug(" " + order[i].getNickname() + " starts with " + food + " food.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,37 +148,37 @@ public class Game {
|
||||
*/
|
||||
public boolean placeTotem(Player player, int tileIndex) {
|
||||
if (state != GameState.TOTEM_PLACEMENT) {
|
||||
logger.info("Error: not the totem-placement phase.");
|
||||
logger.error("Error: not the totem-placement phase.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Enforce turn order
|
||||
Player expected = gameBoard.getTurnTile().getPositions()[totemPlacedCount];
|
||||
if (expected != player) {
|
||||
logger.info("Error: it is " + expected.getNickname()
|
||||
logger.error("Error: it is " + expected.getNickname()
|
||||
+ "'s turn to place, not " + player.getNickname() + ".");
|
||||
return false;
|
||||
}
|
||||
|
||||
List<OfferingTile> tiles = gameBoard.getOfferingTiles();
|
||||
if (tileIndex < 0 || tileIndex >= tiles.size()) {
|
||||
logger.info("Error: tile index " + tileIndex + " out of range.");
|
||||
logger.error("Error: tile index " + tileIndex + " out of range.");
|
||||
return false;
|
||||
}
|
||||
|
||||
OfferingTile chosen = tiles.get(tileIndex);
|
||||
if (!gameBoard.placeTotem(player, chosen, gameBoard.getTurnTile())) {
|
||||
logger.info("Tile " + chosen.getLetter() + " is already occupied.");
|
||||
logger.debug("Tile " + chosen.getLetter() + " is already occupied.");
|
||||
return false;
|
||||
}
|
||||
|
||||
totemPlacedCount++;
|
||||
logger.info("player {} TOTEM PLACED ON TILE {}", player.getNickname() , chosen.getLetter());
|
||||
logger.debug("player {} TOTEM PLACED ON TILE {}", player.getNickname() , chosen.getLetter());
|
||||
|
||||
// + " (" + totemPlacedCount + "/" + players.size() + ").");
|
||||
|
||||
if (totemPlacedCount == players.size()) {
|
||||
logger.info("START ACTION RESOLUTION");
|
||||
logger.info(" ----- START ACTION RESOLUTION ---- ");
|
||||
startActionResolution();
|
||||
}
|
||||
return true;
|
||||
@@ -192,7 +191,7 @@ public class Game {
|
||||
private void startActionResolution() {
|
||||
state = GameState.ACTION_RESOLUTION;
|
||||
currentOfferingTileIndex = 0;
|
||||
logger.info("All totems placed — resolving actions left to right.");
|
||||
logger.info("ALL TOTEMS PLACED -> ACTION_RESOLUTION ");
|
||||
loadNextPlayerActions();
|
||||
}
|
||||
|
||||
@@ -216,15 +215,15 @@ public class Game {
|
||||
|
||||
Player player = tile.getOccupant();
|
||||
pendingActions = new ArrayList<>(tile.getActions());
|
||||
logger.info(" PLAYER {} PENDING_ACTIONS {} ", player.getNickname() , pendingActions );
|
||||
logger.debug(" PLAYER {} PENDING_ACTIONS {} ", player.getNickname() , pendingActions );
|
||||
// --- Food tile: resolve entirely without player input ---
|
||||
if (pendingActions.get(0) == Symbol.FOOD) {
|
||||
|
||||
int food = pendingActions.size();
|
||||
player.addFood(food);
|
||||
BuildingManager.bonusEndTurn(player, food); // BONUS_FOOD_ENDTURN building effect
|
||||
logger.info(player.getNickname() + " receives " + food
|
||||
+ " food from tile " + tile.getLetter() + ".");
|
||||
logger.info("ACTION FOOD {} GET {} ", player.getNickname() , food
|
||||
+ " FROM TILE " + tile.getLetter() );
|
||||
pendingActions.clear();
|
||||
finishPlayerTurn(player);
|
||||
currentOfferingTileIndex++;
|
||||
@@ -242,7 +241,7 @@ public class Game {
|
||||
}
|
||||
|
||||
// Wait for the player to call resolveCardAction()
|
||||
logger.info("player {} pending ACTIONS {}" , player.getNickname() , pendingActions);
|
||||
logger.debug("player {} pending ACTIONS {}" , player.getNickname() , pendingActions);
|
||||
// logger.info("It is " + player.getNickname() + "'s turn — actions: " + pendingActions);
|
||||
return;
|
||||
}
|
||||
@@ -294,20 +293,20 @@ public class Game {
|
||||
*/
|
||||
public ActionResult resolveCardAction(Player player, boolean fromTop, int cardId) {
|
||||
if (state != GameState.ACTION_RESOLUTION) {
|
||||
logger.info("Error: not in ACTION_RESOLUTION phase.");
|
||||
logger.error("Error: not in ACTION_RESOLUTION phase.");
|
||||
return ActionResult.failure("Error: not in ACTION_RESOLUTION phase.");
|
||||
|
||||
}
|
||||
|
||||
OfferingTile currentTile = gameBoard.getOfferingTiles().get(currentOfferingTileIndex);
|
||||
if (currentTile.getOccupant() != player) {
|
||||
logger.info("Error: it is not " + player.getNickname() + "'s turn to act.");
|
||||
logger.error("Error: it is not " + player.getNickname() + "'s turn to act.");
|
||||
return ActionResult.failure("Error: it is not " + player.getNickname() + "'s turn to act.");
|
||||
}
|
||||
|
||||
Symbol required = fromTop ? Symbol.UP : Symbol.DOWN;
|
||||
if (!pendingActions.contains(required)) {
|
||||
logger.info("Error: no " + required + " action available for "
|
||||
logger.error("Error: no " + required + " action available for "
|
||||
+ player.getNickname() + ".");
|
||||
return ActionResult.failure("Error: no " + required + " action available for "
|
||||
+ player.getNickname() + ".");
|
||||
@@ -319,7 +318,7 @@ public class Game {
|
||||
: gameBoard.takeFromBottomRow(cardId);
|
||||
|
||||
if (card == null) {
|
||||
logger.info("Error: card " + cardId + " not found in the "
|
||||
logger.error("Error: card " + cardId + " not found in the "
|
||||
+ (fromTop ? "top" : "bottom") + " row.");
|
||||
return ActionResult.failure("Error: card " + cardId + " not found in the "
|
||||
+ (fromTop ? "top" : "bottom") + " row.");
|
||||
@@ -328,7 +327,7 @@ public class Game {
|
||||
// Event cards can never be taken by players
|
||||
if (card instanceof EventCard) {
|
||||
putCardBack(card, fromTop);
|
||||
logger.info("Error: Event cards cannot be taken.");
|
||||
logger.error("Error: Event cards cannot be taken.");
|
||||
return ActionResult.failure("Error: Event cards cannot be taken.");
|
||||
}
|
||||
|
||||
@@ -345,7 +344,7 @@ public class Game {
|
||||
|
||||
// Consume the action
|
||||
pendingActions.remove(required);
|
||||
logger.info("player {} TOOK CARD {} --> PEDNING ACTIONS {}",player.getNickname(), cardId, pendingActions);
|
||||
logger.debug("player {} TOOK CARD {} --> PEDNING ACTIONS {}",player.getNickname(), cardId, pendingActions);
|
||||
|
||||
|
||||
// A row may have become empty after this draw — re-check impossible actions
|
||||
@@ -414,8 +413,7 @@ public class Game {
|
||||
&& character.getIconValue() > 0) {
|
||||
int food = player.getPlayerTribe().huntersNumber() * character.getIconValue();
|
||||
player.addFood(food);
|
||||
logger.info(player.getNickname() + "'s hunter (leg icon) grants +"
|
||||
+ food + " food.");
|
||||
logger.info("GET HUNTER FOOD {} for player {}",food, player.getNickname() );
|
||||
}
|
||||
|
||||
// Building-triggered effects on character draw
|
||||
@@ -424,8 +422,7 @@ public class Game {
|
||||
gameBoard.getBuildingManager().foodPerInventors(player, character);
|
||||
}
|
||||
|
||||
logger.info(player.getNickname() + " drew "
|
||||
+ character.getCharacterType() + " (id " + character.getCardId() + ").");
|
||||
logger.info("{} PICKED {}", player.getNickname() , character);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -436,9 +433,9 @@ public class Game {
|
||||
private void finishPlayerTurn(Player player) {
|
||||
int slot = gameBoard.getTurnTile().returnTotem(player);
|
||||
OfferingTile off = gameBoard.getOfferingTile(player);
|
||||
logger.info("player {} leaving offering {} " ,player.getNickname(), off);
|
||||
//logger.info("player {} leaving offering {} " ,player.getNickname(), off);
|
||||
if(off!=null) off.setOccupant(null);
|
||||
logger.info("player {} left offering {} slot {} " ,player.getNickname(), off, slot);
|
||||
logger.debug("player {} left offering {} slot {} " ,player.getNickname(), off, slot);
|
||||
|
||||
}
|
||||
|
||||
@@ -456,7 +453,7 @@ public class Game {
|
||||
* Character or Building card (paying its cost) from the top row."
|
||||
*/
|
||||
private void onAllActionsResolved() {
|
||||
logger.info("All actions resolved.");
|
||||
logger.info("--- ALL ACTIONS RESOLVED ---");
|
||||
|
||||
extraDrawQueue.clear();
|
||||
// Iterate in turn order so extra draws happen in a consistent sequence
|
||||
@@ -563,7 +560,7 @@ public class Game {
|
||||
state = GameState.EVENT_RESOLUTION;
|
||||
//notify( GameState.EVENT_RESOLUTION);
|
||||
|
||||
logger.info("--- End of round " + round + " ---");
|
||||
logger.info("--- START NEXT ROUND " + round + " ---");
|
||||
|
||||
boolean isFinalRound = (round == TOTAL_ROUNDS);
|
||||
|
||||
@@ -573,7 +570,7 @@ public class Game {
|
||||
if (isFinalRound) {
|
||||
state = GameState.GAME_OVER;
|
||||
notify( GameState.GAME_OVER, endGame());
|
||||
logger.info("Round 10 complete — game over!");
|
||||
logger.info("============= GAME OVER ============");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -605,7 +602,7 @@ public class Game {
|
||||
: gameBoard.getVisibleEvents(); // already sorted by Era ordinal
|
||||
|
||||
if (events.isEmpty()) {
|
||||
logger.info("No events to resolve this round.");
|
||||
logger.info("NO EVENTS TO SOLVE");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -634,7 +631,7 @@ public class Game {
|
||||
round++;
|
||||
|
||||
notify( GameState.NEXT_ROUND, "Round="+ round);
|
||||
logger.info("startNewRound: {}", round );
|
||||
logger.debug("startNewRound: {}", round );
|
||||
totemPlacedCount = 0;
|
||||
currentOfferingTileIndex = 0;
|
||||
pendingActions.clear();
|
||||
|
||||
Reference in New Issue
Block a user