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