Fix: toString refactor
This commit is contained in:
@@ -212,7 +212,7 @@ public class ClientLauncherTUI {
|
||||
node("building"))),
|
||||
node("totem"),
|
||||
node("skip"),
|
||||
node("render"),
|
||||
node("clear"),
|
||||
node("help"),
|
||||
node("details", node("buildings"), node("events"), node("characters")),
|
||||
node("rematch"),
|
||||
@@ -245,8 +245,8 @@ public class ClientLauncherTUI {
|
||||
if (pos >= 0) controller.totemChoice(pos);
|
||||
}
|
||||
case "skip" -> controller.skipTurn();
|
||||
case "render" -> handleRender(parts);
|
||||
case "help" -> gameReader.printAbove("Commands: slot, draw, totem, skip, render, help, details, rematch, quit");
|
||||
case "clear" -> handleRender(parts);
|
||||
case "help" -> gameReader.printAbove("Commands: slot, draw, totem, skip, clear, help, details, rematch, quit");
|
||||
case "details" -> {
|
||||
if (parts.length > 1 && parts[1].equalsIgnoreCase("buildings"))
|
||||
gameReader.printAbove(BUILDING_DETAILS);
|
||||
|
||||
@@ -66,18 +66,11 @@ public class Building1 extends BuildingCard {
|
||||
return new Building1(getIdIMG(),getEra(),getPrice(),getPrestigeValue(),getIcon());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this building, including the character
|
||||
* type associated with its effect.
|
||||
*
|
||||
* @return a string representation of this building.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString() + " (Icon:" + this.icon.toString().substring(0, 3) + ")";
|
||||
public String toStringBoard() {
|
||||
return super.toStringBoard() + " (Icon:" + this.icon.toString().substring(0, 3) + ")";
|
||||
}
|
||||
|
||||
// TODO
|
||||
@Override
|
||||
public String toStringPlayer() {
|
||||
return super.toStringPlayer() + " (Icon:" + this.icon.toString().substring(0, 3) + ")";
|
||||
|
||||
@@ -100,20 +100,13 @@ public class Building11 extends BuildingCard {
|
||||
player.addPrestige(player.getNType(getIcon()) * this.getPrestigeMul());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this {@code Building11}, including the
|
||||
* character type associated with its effect and its prestige multiplier.
|
||||
*
|
||||
* @return a string representation of this {@code Building11}.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString() + "+" + this.characterType.toString().substring(0, 3) + "×" + this.prestigeMul;
|
||||
public String toStringBoard() {
|
||||
return super.toStringBoard() + "+" + this.characterType.toString().substring(0, 3) + "×" + this.prestigeMul;
|
||||
}
|
||||
|
||||
// TODO
|
||||
@Override
|
||||
public String toStringPlayer() {
|
||||
return super.toStringPlayer() + " (\uD83C\uDFC5:" + this.characterType.toString().substring(0, 3) + "×" + this.prestigeMul + ")";
|
||||
return super.toStringPlayer() + " (🏅:" + this.characterType.toString().substring(0, 3) + "×" + this.prestigeMul + ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,21 +228,12 @@ public class BuildingCard extends PlayableCard implements Cloneable , BuildingEf
|
||||
@Override
|
||||
public void applyEffect(Player player) {}
|
||||
|
||||
/**
|
||||
* Returns the string representation of this building card.
|
||||
*
|
||||
* @return the string representation of this building card.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return ":" + " ID:" + getEffectId() + " \uD83C\uDF56:" + getPrice() + " \uD83C\uDFC5:" + getPrestigeValue();
|
||||
public String toStringBoard() {
|
||||
return "ID:" + getEffectId() + " \uD83C\uDF56:" + getPrice() + " \uD83C\uDFC5:" + getPrestigeValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a compact player-view string representation of this building card.
|
||||
*
|
||||
* @return a compact string showing the effect identifier.
|
||||
*/
|
||||
@Override
|
||||
public String toStringPlayer() {
|
||||
return "ID:" + getEffectId();
|
||||
}
|
||||
|
||||
@@ -76,22 +76,6 @@ public abstract class Character extends TribeCard implements Cloneable {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this {@code Character}. This specific variation is used in the {@code Game}'s
|
||||
* toString to provide a more detailed version.
|
||||
* <p>Includes:
|
||||
* <li>{@link it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType Type}
|
||||
* </p>
|
||||
* @return {@code String} - a string representation of this {@code Character}.
|
||||
* @see it.polimi.ingsw.gc14.Model.Game Game
|
||||
* @see it.polimi.ingsw.gc14.Model.GamePackage.Board Board
|
||||
*/
|
||||
@Override
|
||||
public String toStringBoard()
|
||||
{
|
||||
return super.toStringBoard()+" "+getType().toString()+" ";
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns a copy of this character card.
|
||||
*
|
||||
|
||||
@@ -75,4 +75,14 @@ public class Artist extends Character {
|
||||
player.getBuildingCards().stream().filter(x->x.getEffectId()==0).forEach(x->x.applyEffect(player));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toStringPlayer() {
|
||||
return "🎨";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toStringBoard() {
|
||||
return "ARTIST";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -132,29 +132,14 @@ public class Builder extends Character {
|
||||
this.prestigeValue = prestigeValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string representation of this Builder card.
|
||||
*
|
||||
* @return the string representation of this Builder card.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toStringBoard() + "\uD83D\uDD28:" + String.valueOf(reductionValue) + " \uD83C\uDFC5:" + String.valueOf(prestigeValue);
|
||||
public String toStringPlayer() {
|
||||
return "\uD83D\uDD28:" + reductionValue + " \uD83C\uDFC5:" + prestigeValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a detailed string representation of this {@code Builder} card,
|
||||
* including its reduction value and prestige value.
|
||||
*
|
||||
* @return a detailed string representation of this {@code Builder} card.
|
||||
* @see it.polimi.ingsw.gc14.Model.Cards.TribeCard TribeCard
|
||||
* @see it.polimi.ingsw.gc14.Model.Game Game
|
||||
* @see it.polimi.ingsw.gc14.Model.GamePackage.Board Board
|
||||
*/
|
||||
@Override
|
||||
public String toStringBoard()
|
||||
{
|
||||
return super.toStringBoard()+"\uD83D\uDD28:" + String.valueOf(reductionValue) + " \uD83C\uDFC5:" + String.valueOf(prestigeValue);
|
||||
public String toStringBoard() {
|
||||
return "BUILDER \uD83D\uDD28:" + reductionValue + " \uD83C\uDFC5:" + prestigeValue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -74,4 +74,14 @@ public class Gatherer extends Character {
|
||||
player.getGatherers().add(this);
|
||||
player.getBuildingCards().stream().filter(x->x.getEffectId()==0).forEach(x->x.applyEffect(player));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toStringPlayer() {
|
||||
return "-🥗";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toStringBoard() {
|
||||
return "GATHERER";
|
||||
}
|
||||
}
|
||||
@@ -78,41 +78,14 @@ public class Hunter extends Character {
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string representation of this Hunter card.
|
||||
*
|
||||
* @return the string representation of this Hunter card.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
String toPrint = super.toString();
|
||||
if(this.icon){
|
||||
toPrint += "\uD83C\uDF56";
|
||||
}
|
||||
return toPrint;
|
||||
public String toStringPlayer() {
|
||||
return this.icon ? "\uD83C\uDF56" : "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a detailed string representation of this {@code TribeCard}.
|
||||
* This specific variation is used in the {@code Game}'s
|
||||
* toString to provide a more detailed version.
|
||||
*
|
||||
* <p>Potentially includes:
|
||||
* <li>{@link #icon Icon}
|
||||
* </p>
|
||||
*
|
||||
* @return {@code String} - a string representation of this {@code TribeCard}.
|
||||
* @see it.polimi.ingsw.gc14.Model.Cards.TribeCard TribeCard
|
||||
* @see it.polimi.ingsw.gc14.Model.Game Game
|
||||
* @see it.polimi.ingsw.gc14.Model.GamePackage.Board Board
|
||||
*/
|
||||
@Override
|
||||
public String toStringBoard() {
|
||||
String toPrint = super.toStringBoard();
|
||||
if(this.icon){
|
||||
toPrint += "\uD83C\uDF56";
|
||||
}
|
||||
return toPrint;
|
||||
return "HUNTER" + (this.icon ? " \uD83C\uDF56" : "");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -86,33 +86,14 @@ public class Inventor extends Character {
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string representation of this Inventor card.
|
||||
*
|
||||
* @return the string representation of this Inventor card.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString() + "ID:" + String.valueOf(icon);
|
||||
public String toStringPlayer() {
|
||||
return "ID:" + icon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a detailed string representation of this {@code TribeCard}.
|
||||
* This specific variation is used in the {@code Game}'s toString
|
||||
* to provide a more detailed version.
|
||||
*
|
||||
* <p>Includes:
|
||||
* <li>{@link #icon Icons's ID}
|
||||
* </p>
|
||||
*
|
||||
* @return {@code String} - a string representation of this {@code TribeCard}.
|
||||
* @see it.polimi.ingsw.gc14.Model.Cards.TribeCard TribeCard
|
||||
* @see it.polimi.ingsw.gc14.Model.Game Game
|
||||
* @see it.polimi.ingsw.gc14.Model.GamePackage.Board Board
|
||||
*/
|
||||
@Override
|
||||
public String toStringBoard() {
|
||||
return super.toStringBoard() + "ID:" + String.valueOf(icon);
|
||||
return "INVENTOR ID:" + icon;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -79,30 +79,14 @@ public class Shaman extends Character {
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string representation of this Shaman card.
|
||||
*
|
||||
* @return the string representation of this Shaman card.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString() + "🌟:" + icon;
|
||||
public String toStringPlayer() {
|
||||
return "🌟:" + icon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this {@code TribeCard}. This specific variation is used in the {@code Game}'s
|
||||
* toString to provide a more detailed version.
|
||||
* <p>Includes:
|
||||
* <li>{@link #icon Number of stars}
|
||||
* </p>
|
||||
* @return {@code String} - a string representation of this {@code TribeCard}.
|
||||
* @see it.polimi.ingsw.gc14.Model.Cards.TribeCard TribeCard
|
||||
* @see it.polimi.ingsw.gc14.Model.Game Game
|
||||
* @see it.polimi.ingsw.gc14.Model.GamePackage.Board Board
|
||||
*/
|
||||
@Override
|
||||
public String toStringBoard() {
|
||||
return super.toStringBoard() + "🌟:" + icon;
|
||||
return "SHAMAN 🌟:" + icon;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -55,33 +55,6 @@ public abstract class EventCard extends TribeCard {
|
||||
@Override
|
||||
public abstract TribeCard clone();
|
||||
|
||||
/**
|
||||
* Returns the string representation of this event card.
|
||||
* The returned string includes the string representation of the superclass
|
||||
* and the string representation of the event type.
|
||||
*
|
||||
* @return the string representation of this event card.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString() + " " + type.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints a string representation of this {@code EventCard}. This specific variation is used in the {@code Game}'s
|
||||
* toString to print a more detailed version.
|
||||
* <p>Includes:
|
||||
* <li>{@link #type Type}
|
||||
* </p>
|
||||
* @return {@code String} - a string representation of this {@code EventCard}.
|
||||
* @see it.polimi.ingsw.gc14.Model.Game Game
|
||||
* @see it.polimi.ingsw.gc14.Model.GamePackage.Board Board
|
||||
*/
|
||||
@Override
|
||||
public String toStringBoard() {
|
||||
return super.toStringBoard() + " " + type.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Activates the effect of this event card on the specified list of players.
|
||||
*
|
||||
|
||||
@@ -124,8 +124,13 @@ public class CavePaintings extends EventCard {
|
||||
* @see it.polimi.ingsw.gc14.Model.Game Game
|
||||
* @see it.polimi.ingsw.gc14.Model.GamePackage.Board Board
|
||||
*/
|
||||
@Override
|
||||
public String toStringPlayer() {
|
||||
return "CAVE_PAINTINGS";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toStringBoard() {
|
||||
return super.toStringBoard()+" 0-"+(nLower-1)+":"+nPrestigeRem+" "+nLower+"+:"+nPrestigeMul;
|
||||
return "CAVE_PAINTINGS 0-" + (nLower-1) + ":" + nPrestigeRem + " " + nLower + "+:" + nPrestigeMul;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,20 +84,14 @@ public class Hunt extends EventCard {
|
||||
return new Hunt(getIdIMG(),getEra(), prestigeMultiplier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints a string representation of this {@code TribeCard}. This specific variation is used in the {@code Game}'s
|
||||
* toString to print a more detailed version.
|
||||
* <p>includes:
|
||||
* <li>{@link #prestigeMultiplier}
|
||||
* </p>
|
||||
* @return {@code String} - a string representation of this {@code TribeCard}.
|
||||
* @see it.polimi.ingsw.gc14.Model.Cards.TribeCard TribeCard
|
||||
* @see it.polimi.ingsw.gc14.Model.Game Game
|
||||
* @see it.polimi.ingsw.gc14.Model.GamePackage.Board Board
|
||||
*/
|
||||
@Override
|
||||
public String toStringPlayer() {
|
||||
return "HUNT";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toStringBoard() {
|
||||
return super.toStringBoard()+" 1\uD83C\uDF56+"+prestigeMultiplier+"\uD83C\uDFC5"+"×\uD83C\uDFF9";
|
||||
return "HUNT 1🍖+" + prestigeMultiplier + "🏅×🏹";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+6
-1
@@ -132,9 +132,14 @@ public class ShamanicRitual extends EventCard {
|
||||
* @see it.polimi.ingsw.gc14.Model.Game Game
|
||||
* @see it.polimi.ingsw.gc14.Model.GamePackage.Board Board
|
||||
*/
|
||||
@Override
|
||||
public String toStringPlayer() {
|
||||
return "SHAMANIC_RITUAL";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toStringBoard() {
|
||||
return super.toStringBoard()+" \uD83C\uDF1F>:"+prestigeToAdd+" \uD83C\uDF1F<:"+prestigeToRemove;
|
||||
return "SHAMANIC_RITUAL \uD83C\uDF1F>:" + prestigeToAdd + " \uD83C\uDF1F<:" + prestigeToRemove;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -119,8 +119,13 @@ public class Sustenance extends EventCard {
|
||||
* @see it.polimi.ingsw.gc14.Model.Game Game
|
||||
* @see it.polimi.ingsw.gc14.Model.GamePackage.Board Board
|
||||
*/
|
||||
@Override
|
||||
public String toStringPlayer() {
|
||||
return "SUSTENANCE";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toStringBoard() {
|
||||
return super.toStringBoard()+" -1\uD83C\uDF56/-"+prestigeDebt+"\uD83C\uDFC5";
|
||||
return "SUSTENANCE -1\uD83C\uDF56/-" + prestigeDebt + "\uD83C\uDFC5";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,22 +67,9 @@ public abstract class PlayableCard implements Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this playable card.
|
||||
*
|
||||
* @return a string representation of this playable card.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "";
|
||||
}
|
||||
/** Returns the compact representation shown in the player hand panel. */
|
||||
public abstract String toStringPlayer();
|
||||
|
||||
/**
|
||||
* Returns a compact string representation used when rendering the board in the TUI.
|
||||
*
|
||||
* @return a compact board representation of this card.
|
||||
*/
|
||||
public String toStringBoard() {
|
||||
return ":";
|
||||
}
|
||||
/** Returns the representation shown on the board (offer track cards). */
|
||||
public abstract String toStringBoard();
|
||||
}
|
||||
|
||||
@@ -282,15 +282,15 @@ public class TUI implements IView {
|
||||
|
||||
int maxU = Math.max(model.upperListTribeCards.size(), model.upperListBuildingCards.size());
|
||||
for (int i = 0; i < maxU; i++) {
|
||||
String t = i < model.upperListTribeCards.size() ? i + model.upperListTribeCards.get(i).toStringBoard() : "";
|
||||
String b = i < model.upperListBuildingCards.size() ? i + model.upperListBuildingCards.get(i).toString() : "";
|
||||
String t = i < model.upperListTribeCards.size() ? i + ":" + model.upperListTribeCards.get(i).toStringBoard() : "";
|
||||
String b = i < model.upperListBuildingCards.size() ? i + ":" + model.upperListBuildingCards.get(i).toStringBoard() : "";
|
||||
upperCards.addRow(t, b);
|
||||
}
|
||||
|
||||
int maxL = Math.max(model.lowerListTribeCards.size(), model.lowerListBuildingCards.size());
|
||||
for (int i = 0; i < maxL; i++) {
|
||||
String t = i < model.lowerListTribeCards.size() ? i + model.lowerListTribeCards.get(i).toStringBoard() : "";
|
||||
String b = i < model.lowerListBuildingCards.size() ? i + model.lowerListBuildingCards.get(i).toString() : "";
|
||||
String t = i < model.lowerListTribeCards.size() ? i + ":" + model.lowerListTribeCards.get(i).toStringBoard() : "";
|
||||
String b = i < model.lowerListBuildingCards.size() ? i + ":" + model.lowerListBuildingCards.get(i).toStringBoard() : "";
|
||||
lowerCards.addRow(t, b);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user