Add: TODO.
This commit is contained in:
@@ -2,10 +2,10 @@ package it.polimi.ingsw.gc14;
|
||||
import it.polimi.ingsw.gc14.Controller.ClientController;
|
||||
import it.polimi.ingsw.gc14.Network.RMI.Client.RMIClient;
|
||||
import it.polimi.ingsw.gc14.View.IView;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
public class ClientLauncherTUI {
|
||||
//TODO Javadoc
|
||||
public void main() throws InterruptedException {
|
||||
ClientController controller = new ClientController();
|
||||
|
||||
|
||||
@@ -4,18 +4,25 @@ import it.polimi.ingsw.gc14.Model.Game;
|
||||
import it.polimi.ingsw.gc14.Network.Observer;
|
||||
import it.polimi.ingsw.gc14.View.IView;
|
||||
|
||||
//TODO Javadoc
|
||||
public class ClientController {
|
||||
|
||||
//TODO Javadoc
|
||||
public Game localModel;
|
||||
|
||||
//TODO Javadoc
|
||||
public GameController localController;
|
||||
|
||||
//TODO Javadoc
|
||||
public IView view=null;
|
||||
|
||||
//TODO Javadoc
|
||||
public ClientController(IView view,Game localModel) {
|
||||
this.view = view;
|
||||
this.localModel = localModel;
|
||||
this.localController = new GameController(localModel);
|
||||
}
|
||||
|
||||
//TODO Javadoc
|
||||
public ClientController() {
|
||||
this.localController = new GameController(localModel);
|
||||
}
|
||||
@@ -26,10 +33,8 @@ public class ClientController {
|
||||
// localModel.addObserver((Observer) view); // registra la view come observer
|
||||
}
|
||||
|
||||
|
||||
|
||||
//TODO Javadoc
|
||||
public void onError(String message) {
|
||||
view.showError(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,15 +2,21 @@ package it.polimi.ingsw.gc14;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
//TODO Javadoc
|
||||
public class LimitedList<T> extends ArrayList<T> {
|
||||
//TODO Javadoc
|
||||
private int limit;
|
||||
|
||||
//TODO Javadoc
|
||||
private Runnable action;
|
||||
|
||||
//TODO Javadoc
|
||||
public LimitedList(int limit, Runnable action) {
|
||||
this.limit = limit;
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
//TODO Javadoc
|
||||
@Override
|
||||
public boolean add(T element) {
|
||||
boolean result = super.add(element);
|
||||
@@ -20,12 +26,15 @@ public class LimitedList<T> extends ArrayList<T> {
|
||||
return result;
|
||||
}
|
||||
|
||||
//TODO Javadoc
|
||||
public void setLimit(int num) {
|
||||
this.limit=num;
|
||||
}
|
||||
|
||||
//TODO Javadoc
|
||||
public int getLimit(){return limit;}
|
||||
|
||||
//TODO Javadoc
|
||||
public void setAction(Runnable action) {
|
||||
this.action=action;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
|
||||
import it.polimi.ingsw.gc14.Model.Player;
|
||||
|
||||
public class Building13 extends BuildingCard{
|
||||
|
||||
/**
|
||||
* Creates a Building13 card with the specified era, price, and prestige value.
|
||||
*
|
||||
|
||||
@@ -4,9 +4,7 @@ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Character;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType;
|
||||
import it.polimi.ingsw.gc14.Model.Player;
|
||||
|
||||
public class Builder extends Character
|
||||
{
|
||||
|
||||
public class Builder extends Character {
|
||||
/**
|
||||
* The reduction value provided by this Builder card.
|
||||
*/
|
||||
|
||||
@@ -5,7 +5,6 @@ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType;
|
||||
import it.polimi.ingsw.gc14.Model.Player;
|
||||
|
||||
public class Gatherer extends Character {
|
||||
|
||||
/**
|
||||
* Creates a Gatherer character card with the specified era.
|
||||
*
|
||||
|
||||
@@ -6,8 +6,6 @@ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType;
|
||||
import it.polimi.ingsw.gc14.Model.Player;
|
||||
|
||||
public class Shaman extends Character {
|
||||
|
||||
|
||||
/**
|
||||
* The number of star {@code Icons} the card possesses.
|
||||
* During the {@link it.polimi.ingsw.gc14.Model.Cards.TribeCards.Events.ShamanicRitual Shamanic Ritual Event}, having the
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package it.polimi.ingsw.gc14.Model;
|
||||
|
||||
import com.google.gson.*;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.Building.EffectType;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.Building.Effects.*;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.BuildingCard;
|
||||
import it.polimi.ingsw.gc14.Model.Cards.TribeCards.CharacterType;
|
||||
@@ -16,9 +15,10 @@ import java.io.*;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
//TODO javadoc
|
||||
public class DecksCreator {
|
||||
|
||||
//TODO javadoc
|
||||
public static List<TribeCard> loadTribeDeckByEra(int era) throws IllegalArgumentException
|
||||
{
|
||||
return switch (era) {
|
||||
@@ -28,6 +28,8 @@ public class DecksCreator {
|
||||
default -> throw new IllegalArgumentException();
|
||||
};
|
||||
}
|
||||
|
||||
//TODO javadoc
|
||||
public static List<TribeCard> loadTribeDeck(String resourcePath) {
|
||||
Gson gson = new Gson();
|
||||
Type listType = new com.google.gson.reflect.TypeToken<List<TribeCardDefinition>>(){}.getType();
|
||||
@@ -48,11 +50,15 @@ public class DecksCreator {
|
||||
throw new RuntimeException("Errore caricamento mazzo: " + resourcePath, e);
|
||||
}
|
||||
}
|
||||
|
||||
//TODO javadoc
|
||||
public static List<BuildingCard> loadBuildingDeckByEra(int era) throws IllegalArgumentException
|
||||
{
|
||||
if(era<=0 || era>3) throw new IllegalArgumentException();
|
||||
return loadBuildingDeck("/Cards/buildingCards.json").stream().filter(x->x.getEra()==era).toList();
|
||||
}
|
||||
|
||||
//TODO javadoc
|
||||
public static List<BuildingCard> loadBuildingDeck(String resourcePath) {
|
||||
Gson gson = new Gson();
|
||||
Type listType = new com.google.gson.reflect.TypeToken<List<BuildingCardDefinition>>(){}.getType();
|
||||
@@ -74,6 +80,7 @@ public class DecksCreator {
|
||||
}
|
||||
}
|
||||
|
||||
//TODO javadoc
|
||||
public static List<Slot> loadSlotDeck()
|
||||
{
|
||||
List<Slot> slots = new ArrayList<>();
|
||||
@@ -82,6 +89,8 @@ public class DecksCreator {
|
||||
slots.add(new Slot(c));
|
||||
return slots;
|
||||
}
|
||||
|
||||
//TODO javadoc
|
||||
private static TribeCard createCard(TribeCardDefinition def) {
|
||||
int era = def.era;
|
||||
|
||||
@@ -129,6 +138,7 @@ public class DecksCreator {
|
||||
};
|
||||
}
|
||||
|
||||
//TODO javadoc
|
||||
private static BuildingCard createCard(BuildingCardDefinition def) {
|
||||
return switch (def.effectId) {
|
||||
case 0 -> new Building0(def.era, def.price, def.prestigeValue);
|
||||
@@ -143,7 +153,7 @@ public class DecksCreator {
|
||||
|
||||
}
|
||||
|
||||
|
||||
//TODO javadoc
|
||||
private static class TribeCardDefinition {
|
||||
String type;
|
||||
int era;
|
||||
@@ -152,6 +162,7 @@ public class DecksCreator {
|
||||
List<Object> params; // Object per gestire boolean e int misti
|
||||
}
|
||||
|
||||
//TODO javadoc
|
||||
private static class BuildingCardDefinition {
|
||||
int effectId;
|
||||
int era;
|
||||
|
||||
@@ -4,23 +4,39 @@ import it.polimi.ingsw.gc14.Controller.GameController;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
//TODO javadoc
|
||||
public abstract class NetworkEvent implements Serializable {
|
||||
//TODO javadoc
|
||||
protected String username;
|
||||
|
||||
//TODO javadoc
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
//TODO javadoc
|
||||
protected EventType eventType;
|
||||
|
||||
//TODO javadoc
|
||||
public EventType getEventType() {return eventType;}
|
||||
|
||||
//TODO javadoc
|
||||
protected boolean isError;
|
||||
|
||||
//TODO javadoc
|
||||
public boolean getIsError() {return isError;}
|
||||
|
||||
//TODO javadoc
|
||||
public void setIsError(boolean isError) {this.isError = isError;}
|
||||
|
||||
//TODO javadoc
|
||||
protected NetworkEvent(String username, EventType eventType, boolean isError) {
|
||||
this.username = username;
|
||||
this.eventType = eventType;
|
||||
this.isError = isError;
|
||||
}
|
||||
|
||||
//TODO javadoc
|
||||
@Override
|
||||
public String toString() {
|
||||
if(isError) {
|
||||
@@ -30,5 +46,6 @@ public abstract class NetworkEvent implements Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
//TODO javadoc
|
||||
public abstract boolean apply(GameController gameController);
|
||||
}
|
||||
|
||||
@@ -7,15 +7,23 @@ import it.polimi.ingsw.gc14.View.IView;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
//TODO javadoc
|
||||
public class AddPlayer extends NetworkEvent implements Serializable {
|
||||
//TODO javadoc
|
||||
private int proposedNPlayer;
|
||||
|
||||
//TODO javadoc
|
||||
public int getProposedNPlayer() {
|
||||
return proposedNPlayer;
|
||||
}
|
||||
|
||||
//TODO javadoc
|
||||
public AddPlayer(String username, int proposedNPlayer) {
|
||||
super(username, EventType.ADD_PLAYER, false);
|
||||
this.proposedNPlayer = proposedNPlayer;
|
||||
}
|
||||
|
||||
//TODO javadoc
|
||||
@Override
|
||||
public boolean apply(GameController gameController)
|
||||
{
|
||||
|
||||
@@ -7,19 +7,24 @@ import it.polimi.ingsw.gc14.View.IView;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
//TODO javadoc
|
||||
public class DrawLowerBuildingCard extends NetworkEvent implements Serializable{
|
||||
//TODO javadoc
|
||||
private int pos;
|
||||
|
||||
//TODO javadoc
|
||||
public DrawLowerBuildingCard(String username, int pos){
|
||||
super(username, EventType.DRAW_LOWER_BUILD, false);
|
||||
this.pos = pos;
|
||||
}
|
||||
|
||||
//TODO javadoc
|
||||
@Override
|
||||
public boolean apply(GameController gameController){
|
||||
return gameController.drawLowerBuildingCard(username, pos);
|
||||
}
|
||||
|
||||
//TODO javadoc
|
||||
public String apply(IView gameController){
|
||||
return gameController.toString();
|
||||
}
|
||||
|
||||
@@ -8,18 +8,22 @@ import it.polimi.ingsw.gc14.View.IView;
|
||||
import java.io.Serializable;
|
||||
|
||||
public class DrawLowerTribeCard extends NetworkEvent implements Serializable{
|
||||
//TODO javadoc
|
||||
private int pos;
|
||||
|
||||
//TODO javadoc
|
||||
public DrawLowerTribeCard(String username, int pos){
|
||||
super(username, EventType.DRAW_LOWER_TRIBE, false);
|
||||
this.pos = pos;
|
||||
}
|
||||
|
||||
//TODO javadoc
|
||||
@Override
|
||||
public boolean apply(GameController gameController){
|
||||
return gameController.drawLowerTribeCard(username, pos);
|
||||
}
|
||||
|
||||
//TODO javadoc
|
||||
public String apply(IView gameController){
|
||||
return gameController.toString();
|
||||
}
|
||||
|
||||
@@ -7,19 +7,24 @@ import it.polimi.ingsw.gc14.View.IView;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
//TODO javadoc
|
||||
public class DrawUpperBuildingCard extends NetworkEvent implements Serializable{
|
||||
//TODO javadoc
|
||||
private int pos;
|
||||
|
||||
//TODO javadoc
|
||||
public DrawUpperBuildingCard(String username, int pos){
|
||||
super(username, EventType.DRAW_UPPER_BUILD, false);
|
||||
this.pos = pos;
|
||||
}
|
||||
|
||||
//TODO javadoc
|
||||
@Override
|
||||
public boolean apply(GameController gameController){
|
||||
return gameController.drawUpperBuildingCard(username, pos);
|
||||
}
|
||||
|
||||
//TODO javadoc
|
||||
public String apply(IView gameController){
|
||||
return gameController.toString();
|
||||
}
|
||||
|
||||
@@ -7,19 +7,24 @@ import it.polimi.ingsw.gc14.View.IView;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
//TODO javadoc
|
||||
public class DrawUpperTribeCard extends NetworkEvent implements Serializable{
|
||||
//TODO javadoc
|
||||
private int pos;
|
||||
|
||||
//TODO javadoc
|
||||
public DrawUpperTribeCard(String username, int pos){
|
||||
super(username, EventType.DRAW_UPPER_TRIBE, false);
|
||||
this.pos = pos;
|
||||
}
|
||||
|
||||
//TODO javadoc
|
||||
@Override
|
||||
public boolean apply(GameController gameController){
|
||||
return gameController.drawUpperTribeCard(username, pos);
|
||||
}
|
||||
|
||||
//TODO javadoc
|
||||
public String apply(IView gameController){
|
||||
return gameController.toString();
|
||||
}
|
||||
|
||||
@@ -7,19 +7,24 @@ import it.polimi.ingsw.gc14.View.IView;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
//TODO javadoc
|
||||
public class PickOptionalBuildingCard extends NetworkEvent implements Serializable{
|
||||
//TODO javadoc
|
||||
private int pos;
|
||||
|
||||
//TODO javadoc
|
||||
public PickOptionalBuildingCard(String username, int pos){
|
||||
super(username, EventType.PICK_OPTIONAL_BUILD, false);
|
||||
this.pos = pos;
|
||||
}
|
||||
|
||||
//TODO javadoc
|
||||
@Override
|
||||
public boolean apply(GameController gameController){
|
||||
return gameController.pickOptionalBuildingCard(username, pos);
|
||||
}
|
||||
|
||||
//TODO javadoc
|
||||
public String apply(IView gameController){
|
||||
return gameController.toString();
|
||||
}
|
||||
|
||||
@@ -7,19 +7,25 @@ import it.polimi.ingsw.gc14.View.IView;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
//TODO javadoc
|
||||
|
||||
public class PickOptionalTribeCard extends NetworkEvent implements Serializable{
|
||||
//TODO javadoc
|
||||
private int pos;
|
||||
|
||||
//TODO javadoc
|
||||
public PickOptionalTribeCard(String username, int pos){
|
||||
super(username, EventType.PICK_OPTIONAL_TRIBE, false);
|
||||
this.pos = pos;
|
||||
}
|
||||
|
||||
//TODO javadoc
|
||||
@Override
|
||||
public boolean apply(GameController gameController){
|
||||
return gameController.pickOptionalTribeCard(username, pos);
|
||||
}
|
||||
|
||||
//TODO javadoc
|
||||
public String apply(IView gameController){
|
||||
return gameController.toString();
|
||||
}
|
||||
|
||||
@@ -7,19 +7,24 @@ import it.polimi.ingsw.gc14.View.IView;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
//TODO javadoc
|
||||
public class SlotChoice extends NetworkEvent implements Serializable {
|
||||
//TODO javadoc
|
||||
private int pos;
|
||||
|
||||
//TODO javadoc
|
||||
public SlotChoice(String username, int pos) {
|
||||
super(username, EventType.SLOT_CHOICE, false);
|
||||
this.pos = pos;
|
||||
}
|
||||
|
||||
//TODO javadoc
|
||||
@Override
|
||||
public boolean apply(GameController gameController) {
|
||||
return gameController.slotChoice(username, pos);
|
||||
}
|
||||
|
||||
//TODO javadoc
|
||||
public String apply(IView gameController) {
|
||||
return gameController.toString();
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public class RMIClient {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
|
||||
//TODO Javadoc fix
|
||||
/**
|
||||
* Connects to the RMI server and attempts to join the game.
|
||||
* Looks up the RMI registry to retrieve the {@link IGameServer} stub.
|
||||
|
||||
@@ -1,22 +1,39 @@
|
||||
package it.polimi.ingsw.gc14.View.TUI;
|
||||
import java.util.*;
|
||||
|
||||
//TODO javadoc
|
||||
// Helper generale per costruire tabelle ASCII
|
||||
public class AsciiTable {
|
||||
//TODO javadoc
|
||||
private final BorderStyle s;
|
||||
|
||||
//TODO javadoc
|
||||
private final int cols;
|
||||
|
||||
//TODO javadoc
|
||||
private final List<List<String>> rows = new ArrayList<>();
|
||||
|
||||
//TODO javadoc
|
||||
private final List<Integer> separators = new ArrayList<>();
|
||||
|
||||
//TODO javadoc
|
||||
public AsciiTable(BorderStyle s, int cols) {
|
||||
this.s = s; this.cols = cols;
|
||||
}
|
||||
|
||||
//TODO javadoc
|
||||
public void addRow(String... cells) { rows.add(Arrays.asList(cells)); }
|
||||
|
||||
//TODO javadoc
|
||||
public void addRow(List<String> cells) { rows.add(cells); }
|
||||
|
||||
//TODO javadoc
|
||||
public void addHeader(String... cells) { rows.add(0, Arrays.asList(cells)); separators.add(0); }
|
||||
|
||||
//TODO javadoc
|
||||
public void addSeparator() { separators.add(rows.size()-1); }
|
||||
|
||||
//TODO javadoc
|
||||
public String build() {
|
||||
var sb = new StringBuilder();
|
||||
int maxWidth = rows.stream().mapToInt(x->x.stream().mapToInt(y->y.length()).max().getAsInt()).max().getAsInt()+1;
|
||||
@@ -34,6 +51,7 @@ public class AsciiTable {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
//TODO javadoc
|
||||
private String hline(String l, String m, String r,int maxWidth) {
|
||||
var sb = new StringBuilder(l);
|
||||
for (int i = 0; i < cols; i++) {
|
||||
@@ -43,10 +61,13 @@ public class AsciiTable {
|
||||
return sb.append(r).toString();
|
||||
}
|
||||
|
||||
//TODO javadoc
|
||||
private static String rpad(String s, int w) {
|
||||
if (s.length() >= w) return s.substring(0, w);
|
||||
return s + " ".repeat(w - s.length());
|
||||
}
|
||||
|
||||
//TODO javadoc
|
||||
public static String sideBySide(List<String> left, List<String> right, int gap) {
|
||||
int leftWidth = left.stream().mapToInt(String::length).max().orElse(0);
|
||||
int maxHeight = Math.max(left.size(), right.size());
|
||||
|
||||
Reference in New Issue
Block a user