Fix: complete refactor of TUI
Tests updated
This commit is contained in:
@@ -74,6 +74,11 @@ public class Building1 extends BuildingCard {
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString() + " Icon: " + this.icon.toString().charAt(0);
|
||||
return super.toString() + " (Icon:" + this.icon.toString().substring(0, 3) + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toStringPlayer() {
|
||||
return super.toStringPlayer() + " (Icon:" + this.icon.toString().substring(0, 3) + ")";
|
||||
}
|
||||
}
|
||||
@@ -105,6 +105,11 @@ public class Building11 extends BuildingCard {
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString() + " Icon: " + this.icon.toString().charAt(0) + " MP: " + this.PrestigeMul;
|
||||
return super.toString() + "+" + this.icon.toString().substring(0, 3) + "×" + this.PrestigeMul;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toStringPlayer() {
|
||||
return super.toStringPlayer() + " (\uD83C\uDFC5:" + this.icon.toString().substring(0, 3) + "×" + this.PrestigeMul + ")";
|
||||
}
|
||||
}
|
||||
@@ -141,7 +141,7 @@ public class BuildingCard extends PlayableCard implements Cloneable , BuildingEf
|
||||
* if {@code price <= 0}, or if {@code prestigeValue < 0}
|
||||
*/
|
||||
public BuildingCard(int effectId ,int era,int price,int prestigeValue) throws IllegalArgumentException{
|
||||
this.effectId = effectId;
|
||||
this(era,price,prestigeValue);
|
||||
switch (effectId){
|
||||
case 2:
|
||||
this.effectType=EffectType.ON_EVENT;
|
||||
@@ -168,7 +168,7 @@ public class BuildingCard extends PlayableCard implements Cloneable , BuildingEf
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
}
|
||||
this(era,price,prestigeValue);
|
||||
this.effectId = effectId;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -186,7 +186,7 @@ public class BuildingCard extends PlayableCard implements Cloneable , BuildingEf
|
||||
* if {@code price <= 0}, or if {@code prestigeValue < 0}.
|
||||
*/
|
||||
public BuildingCard(String idIMG,int effectId ,int era,int price,int prestigeValue) throws IllegalArgumentException{
|
||||
this.effectId = effectId;
|
||||
this(idIMG,era,price,prestigeValue);
|
||||
switch (effectId){
|
||||
case 2:
|
||||
this.effectType=EffectType.ON_EVENT;
|
||||
@@ -213,7 +213,7 @@ public class BuildingCard extends PlayableCard implements Cloneable , BuildingEf
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
}
|
||||
this(idIMG,era,price,prestigeValue);
|
||||
this.effectId = effectId;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -274,6 +274,10 @@ public class BuildingCard extends PlayableCard implements Cloneable , BuildingEf
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return ":" + " ID:" + String.valueOf(getEffectId())+ " \uD83C\uDF56:"+String.valueOf(getPrice())+" \uD83C\uDFC5:"+String.valueOf(getPrestigeValue());
|
||||
return ":" + " ID:" + getEffectId()+ " \uD83C\uDF56:"+String.valueOf(getPrice())+" \uD83C\uDFC5:"+String.valueOf(getPrestigeValue());
|
||||
}
|
||||
|
||||
public String toStringPlayer() {
|
||||
return "ID:" + getEffectId();
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package it.polimi.ingsw.gc14.Model.Orders;
|
||||
|
||||
import it.polimi.ingsw.gc14.Model.OrderLogicCard;
|
||||
import it.polimi.ingsw.gc14.Model.Player;
|
||||
import it.polimi.ingsw.gc14.Model.Totems;
|
||||
import it.polimi.ingsw.gc14.View.TUI.AsciiTable;
|
||||
import it.polimi.ingsw.gc14.View.TUI.BorderStyle;
|
||||
|
||||
@@ -23,10 +24,9 @@ public class Order2 extends OrderLogicCard {
|
||||
* @throws NoSuchElementException if the number of players is not equal to 2.
|
||||
*/
|
||||
public Order2(ArrayList<Player> players) throws NoSuchElementException {
|
||||
super(players);
|
||||
if(players.size()!=2)
|
||||
throw new NoSuchElementException();
|
||||
super(players);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,7 +74,7 @@ public class Order2 extends OrderLogicCard {
|
||||
if(playerList.get(i).played)
|
||||
stringUp.add("");
|
||||
else
|
||||
stringUp.add(playerList.get(i).player.getUserName());
|
||||
stringUp.add(playerList.get(i).player.getTotem() != null ? playerList.get(i).player.getTotem().toString() : playerList.get(i).player.getUserName());
|
||||
}
|
||||
catch (IndexOutOfBoundsException e) {
|
||||
stringUp.add("");
|
||||
|
||||
@@ -2,6 +2,7 @@ package it.polimi.ingsw.gc14.Model.Orders;
|
||||
|
||||
import it.polimi.ingsw.gc14.Model.OrderLogicCard;
|
||||
import it.polimi.ingsw.gc14.Model.Player;
|
||||
import it.polimi.ingsw.gc14.Model.Totems;
|
||||
import it.polimi.ingsw.gc14.View.TUI.AsciiTable;
|
||||
import it.polimi.ingsw.gc14.View.TUI.BorderStyle;
|
||||
|
||||
@@ -24,9 +25,9 @@ public class Order3 extends OrderLogicCard {
|
||||
* @throws NoSuchElementException if the number of players is not equal to 3.
|
||||
*/
|
||||
public Order3(ArrayList<Player> players) throws NoSuchElementException{
|
||||
super(players);
|
||||
if(players.size()!=3)
|
||||
throw new NoSuchElementException();
|
||||
super(players);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,7 +78,7 @@ public class Order3 extends OrderLogicCard {
|
||||
if(playerList.get(i).played)
|
||||
stringUp.add("");
|
||||
else
|
||||
stringUp.add(playerList.get(i).player.getUserName());
|
||||
stringUp.add(i + ". " + (playerList.get(i).player.getTotem() != null ? playerList.get(i).player.getTotem().toString() : playerList.get(i).player.getUserName()));
|
||||
}
|
||||
catch (IndexOutOfBoundsException e) {
|
||||
stringUp.add("");
|
||||
|
||||
@@ -2,6 +2,7 @@ package it.polimi.ingsw.gc14.Model.Orders;
|
||||
|
||||
import it.polimi.ingsw.gc14.Model.OrderLogicCard;
|
||||
import it.polimi.ingsw.gc14.Model.Player;
|
||||
import it.polimi.ingsw.gc14.Model.Totems;
|
||||
import it.polimi.ingsw.gc14.View.TUI.AsciiTable;
|
||||
import it.polimi.ingsw.gc14.View.TUI.BorderStyle;
|
||||
|
||||
@@ -24,9 +25,9 @@ public class Order4 extends OrderLogicCard {
|
||||
* @throws NoSuchElementException if the number of players is not equal to 4.
|
||||
*/
|
||||
public Order4(ArrayList<Player> players)throws NoSuchElementException {
|
||||
super(players);
|
||||
if(players.size()!=4)
|
||||
throw new NoSuchElementException();
|
||||
super(players);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,7 +84,7 @@ public class Order4 extends OrderLogicCard {
|
||||
if(playerList.get(i).played)
|
||||
stringUp.add("");
|
||||
else
|
||||
stringUp.add(playerList.get(i).player.getUserName());
|
||||
stringUp.add(i + ". " + (playerList.get(i).player.getTotem() != null ? playerList.get(i).player.getTotem().toString() : playerList.get(i).player.getUserName()));
|
||||
}
|
||||
catch (IndexOutOfBoundsException e) {
|
||||
stringUp.add("");
|
||||
|
||||
@@ -2,6 +2,7 @@ package it.polimi.ingsw.gc14.Model.Orders;
|
||||
|
||||
import it.polimi.ingsw.gc14.Model.OrderLogicCard;
|
||||
import it.polimi.ingsw.gc14.Model.Player;
|
||||
import it.polimi.ingsw.gc14.Model.Totems;
|
||||
import it.polimi.ingsw.gc14.View.TUI.AsciiTable;
|
||||
import it.polimi.ingsw.gc14.View.TUI.BorderStyle;
|
||||
|
||||
@@ -24,9 +25,9 @@ public class Order5 extends OrderLogicCard {
|
||||
* @throws NoSuchElementException if the number of players is not equal to 5.
|
||||
*/
|
||||
public Order5(ArrayList<Player> players) throws NoSuchElementException{
|
||||
super(players);
|
||||
if(players.size()!=5)
|
||||
throw new NoSuchElementException();
|
||||
super(players);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,7 +85,7 @@ public class Order5 extends OrderLogicCard {
|
||||
if(playerList.get(i).played)
|
||||
stringUp.add("");
|
||||
else
|
||||
stringUp.add(playerList.get(i).player.getUserName());
|
||||
stringUp.add(i + ". " + (playerList.get(i).player.getTotem() != null ? playerList.get(i).player.getTotem().toString() : playerList.get(i).player.getUserName()));
|
||||
}
|
||||
catch (IndexOutOfBoundsException e) {
|
||||
stringUp.add("");
|
||||
|
||||
@@ -276,7 +276,7 @@ public class Player implements Serializable {
|
||||
var table = new AsciiTable(ROUNDED, 1);
|
||||
|
||||
String totemStr = (this.totem != null) ? " (" + this.totem.toString() + ")" : "";
|
||||
table.addHeader(this.getUserName() + totemStr + " | \uD83C\uDF56:" + this.getFoodValue() + " | \uD83C\uDFC5:" + this.getPrestigeValue() + " ");
|
||||
table.addHeader(this.getUserName() + totemStr + " | \uD83C\uDF56:" + this.getFoodValue() + " | \uD83C\uDFC5:" + this.getPrestigeValue());
|
||||
table.addSeparator();
|
||||
|
||||
if(!this.hunters.isEmpty()){
|
||||
@@ -304,7 +304,7 @@ public class Player implements Serializable {
|
||||
if(Last == 0){
|
||||
table.addSeparator();
|
||||
}
|
||||
table.addRow("CHARACTERS:");
|
||||
table.addRow("CHARACTERS");
|
||||
if(!this.artists.isEmpty()){
|
||||
table.addRow(this.artists.size() + " Artists: \uD83C\uDFA8:" + this.artists.size());
|
||||
if(Last == 1){
|
||||
@@ -313,7 +313,7 @@ public class Player implements Serializable {
|
||||
}
|
||||
|
||||
if(!this.builders.isEmpty()){
|
||||
table.addRow(this.builders.size() + " Builders: " + "-\uD83C\uDF56:" + this.builders.stream().mapToInt(Builder::getReductionValue).sum() + " \uD83C\uDFC5:" + this.builders.stream().mapToInt(Builder::getPrestigeValue).sum());
|
||||
table.addRow(this.builders.size() + " Builders: " + "\uD83D\uDD28:" + this.builders.stream().mapToInt(Builder::getReductionValue).sum() + " \uD83C\uDFC5:" + this.builders.stream().mapToInt(Builder::getPrestigeValue).sum());
|
||||
if(Last == 2){
|
||||
table.addSeparator();
|
||||
}
|
||||
@@ -342,7 +342,7 @@ public class Player implements Serializable {
|
||||
.entrySet().stream()
|
||||
.sorted(Map.Entry.comparingByKey())
|
||||
.map(e -> e.getKey() + ":" + e.getValue())
|
||||
.collect(Collectors.joining(" ")));
|
||||
.collect(Collectors.joining(", ")));
|
||||
if(Last == 5){
|
||||
table.addSeparator();
|
||||
}
|
||||
@@ -353,10 +353,13 @@ public class Player implements Serializable {
|
||||
table.addRow(this.hunters.size() + " Hunters: \uD83C\uDF56" + this.hunters.stream().filter(Hunter::getIcon).count());
|
||||
table.addSeparator();
|
||||
}
|
||||
|
||||
table.addRow("BUILDING CARDS:");
|
||||
table.addSeparator();
|
||||
table.addRow("BUILDING CARDS" +
|
||||
(this.buildingCards.stream().mapToInt(BuildingCard::getPrestigeValue).sum() != 0
|
||||
? " 🏅:" + this.buildingCards.stream().mapToInt(BuildingCard::getPrestigeValue).sum()
|
||||
: ""));
|
||||
if(!this.buildingCards.isEmpty()){
|
||||
table.addRow(this.buildingCards.size() + " Buildings: " + this.buildingCards.toString());
|
||||
table.addRow(this.buildingCards.size() + " Buildings: " + this.buildingCards.stream().map(BuildingCard::toStringPlayer).collect(Collectors.joining(", ")));
|
||||
}
|
||||
|
||||
return table.build();
|
||||
|
||||
@@ -171,18 +171,11 @@ public class Slot implements Serializable {
|
||||
*/
|
||||
public String toStringTUI()
|
||||
{
|
||||
StringBuilder s = new StringBuilder();
|
||||
//s.append(this.getSlotId()+" ");
|
||||
for(int i=0;i<this.getNUpper();i++)
|
||||
{
|
||||
s.append("↑");
|
||||
}
|
||||
for(int i=0;i<this.getNLower();i++)
|
||||
{
|
||||
s.append("↓");
|
||||
}
|
||||
if(getFood()!=0)
|
||||
s.append("+"+getFood()+" \uD83C\uDF56");
|
||||
StringBuilder s = new StringBuilder(" ");
|
||||
for(int i=0;i<this.getNUpper();i++) s.append("▲");
|
||||
for(int i=0;i<this.getNLower();i++) s.append("▼");
|
||||
if(getFood()!=0) s.append("+"+getFood()+" \uD83C\uDF56");
|
||||
s.append(" ");
|
||||
return s.toString();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user