Removed: PickOptionalTribeCard and PickOptionalBuildingCard in Network and ClientController
This commit is contained in:
@@ -157,52 +157,6 @@ public class ClientController {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Used to draw a tribe card from the upper list.
|
||||
* Available only if the player owns the building 12.
|
||||
* @param playerUsername the name of the player performing the action
|
||||
* @param pos the index of the card to draw
|
||||
*/
|
||||
public void pickOptionalTribeCard(String playerUsername,int pos) {
|
||||
if(!Objects.equals(playerUsername,miniModel.currentState.getCurrentPlayer().getUserName()))
|
||||
view.showError("It's not your turn!");
|
||||
else {
|
||||
client.pickOptionalTribeCard(playerUsername,pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Used to draw a building card from the upper list.
|
||||
* Available only if the player owns the building 12.
|
||||
* @param playerUsername the name of the player performing the action
|
||||
* @param pos the index of the card to draw
|
||||
*/
|
||||
public void pickOptionalBuildingCard(String playerUsername,int pos) {
|
||||
if(!Objects.equals(playerUsername, miniModel.currentState.getCurrentPlayer().getUserName()))
|
||||
view.showError("It's not your turn!");
|
||||
else {
|
||||
client.pickOptionalBuildingCard(playerUsername,pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Used to skip the action of drawing a card from the upper list.
|
||||
* Available only if the player owns the building 12.
|
||||
* @param playerUsername the name of the player performing the action
|
||||
*/
|
||||
public void noOptionalCard(String playerUsername) {
|
||||
if(!Objects.equals(playerUsername, miniModel.currentState.getCurrentPlayer().getUserName()))
|
||||
view.showError("It's not your turn!");
|
||||
else {
|
||||
client.noOptionalCard(playerUsername);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Used to perform the slot choice action for the specified player at the specified position.
|
||||
* @param playerUsername the name of the player performing the action
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
package it.polimi.ingsw.gc14.Network;
|
||||
//TODO
|
||||
public class ClientPlayer {
|
||||
private String username;
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
public boolean connected;
|
||||
|
||||
public ClientPlayer(String username,boolean connected) {
|
||||
this.username = username;
|
||||
this.connected = connected;
|
||||
}
|
||||
}
|
||||
@@ -12,12 +12,9 @@ public enum EventType {
|
||||
DRAW_LOWER_TRIBE,
|
||||
DRAW_UPPER_BUILD,
|
||||
DRAW_LOWER_BUILD,
|
||||
PICK_OPTIONAL_TRIBE,
|
||||
PICK_OPTIONAL_BUILD,
|
||||
SKIP_NO_DRAWABLE,
|
||||
SKIP_TURN,
|
||||
DISCONNECTED_PLAYER,
|
||||
RECONNECT_PLAYER,
|
||||
NEXT_ROUND,
|
||||
ENDED_GAME,
|
||||
NO_OPTIONAL_CARD
|
||||
ENDED_GAME
|
||||
}
|
||||
|
||||
@@ -18,15 +18,7 @@ public interface IClient {
|
||||
public void drawLowerBuildingCard(String playerUsername,int pos) ;
|
||||
|
||||
public void skipTurn(String playerUsername);
|
||||
|
||||
|
||||
|
||||
public void pickOptionalTribeCard(String playerUsername,int pos) ;
|
||||
|
||||
public void pickOptionalBuildingCard(String playerUsername,int pos) ;
|
||||
|
||||
|
||||
public void noOptionalCard(String playerUsername) ;
|
||||
|
||||
|
||||
public void slotChoice(String playerUsername,int pos) ;
|
||||
public void totemChoice(String playerUsername,String totem) ;
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
package it.polimi.ingsw.gc14.Network.NetworkEvents;
|
||||
|
||||
import it.polimi.ingsw.gc14.Controller.GameController;
|
||||
import it.polimi.ingsw.gc14.Model.MiniModel;
|
||||
import it.polimi.ingsw.gc14.Network.EventType;
|
||||
import it.polimi.ingsw.gc14.Network.NetworkEvent;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* NetworkEvent to avoid drawing a card from the upper list (see the effect of Building 12)
|
||||
*/
|
||||
public class NoOptionalCard extends NetworkEvent implements Serializable{
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
* Initialized all the attributes.
|
||||
* @param username the name of the player requesting the event
|
||||
*/
|
||||
public NoOptionalCard(String username){
|
||||
super(username, EventType.NO_OPTIONAL_CARD, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param gameController the Game Controller on which to apply the event
|
||||
* @return true if the player could draw the card, false otherwise
|
||||
*/
|
||||
@Override
|
||||
public boolean apply(GameController gameController){
|
||||
return gameController.SkipTurn(username);
|
||||
}
|
||||
//TODO
|
||||
@Override
|
||||
public boolean apply(MiniModel miniModel){
|
||||
if(isError)
|
||||
return false;
|
||||
miniModel.setPlayer(player);
|
||||
miniModel.setOrderLogicCard(orderLogicCard);
|
||||
miniModel.setCurrentState(currentState);
|
||||
miniModel.setSlotPlayerMap(slotPlayerMap);
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
-51
@@ -1,51 +0,0 @@
|
||||
package it.polimi.ingsw.gc14.Network.NetworkEvents;
|
||||
|
||||
import it.polimi.ingsw.gc14.Controller.GameController;
|
||||
import it.polimi.ingsw.gc14.Model.MiniModel;
|
||||
import it.polimi.ingsw.gc14.Network.EventType;
|
||||
import it.polimi.ingsw.gc14.Network.NetworkEvent;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* NetworkEvent to draw a building card from the upper list (see the effect of Building 12)
|
||||
*/
|
||||
public class PickOptionalBuildingCard extends NetworkEvent implements Serializable{
|
||||
|
||||
/** Index of the card to draw */
|
||||
private int pos;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
* Initialized all the attributes.
|
||||
* @param username the name of the player requesting the event
|
||||
* @param pos the index of the card to draw
|
||||
*/
|
||||
public PickOptionalBuildingCard(String username, int pos){
|
||||
super(username, EventType.PICK_OPTIONAL_BUILD, false);
|
||||
this.pos = pos;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param gameController the Game Controller on which to apply the event
|
||||
* @return true if the player could draw the card, false otherwise
|
||||
*/
|
||||
@Override
|
||||
public boolean apply(GameController gameController){
|
||||
return gameController.drawUpperBuildingCard(username, pos);
|
||||
}
|
||||
//TODO
|
||||
@Override
|
||||
public boolean apply(MiniModel miniModel){
|
||||
if(isError)
|
||||
return false;
|
||||
|
||||
miniModel.board.removeUpperBuildingCard(miniModel.board.upperListBuilding.get(pos));
|
||||
miniModel.setPlayer(player);
|
||||
miniModel.setOrderLogicCard(orderLogicCard);
|
||||
miniModel.setCurrentState(currentState);
|
||||
miniModel.setSlotPlayerMap(slotPlayerMap);
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
package it.polimi.ingsw.gc14.Network.NetworkEvents;
|
||||
|
||||
import it.polimi.ingsw.gc14.Controller.GameController;
|
||||
import it.polimi.ingsw.gc14.Model.MiniModel;
|
||||
import it.polimi.ingsw.gc14.Network.EventType;
|
||||
import it.polimi.ingsw.gc14.Network.NetworkEvent;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* NetworkEvent to draw a tribe card from the upper list (see the effect of Building 12)
|
||||
*/
|
||||
public class PickOptionalTribeCard extends NetworkEvent implements Serializable{
|
||||
|
||||
/** Index of the card to draw */
|
||||
private int pos;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
* Initialized all the attributes.
|
||||
* @param username the name of the player requesting the event
|
||||
* @param pos the index of the card to draw
|
||||
*/
|
||||
public PickOptionalTribeCard(String username, int pos){
|
||||
super(username, EventType.PICK_OPTIONAL_TRIBE, false);
|
||||
this.pos = pos;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param gameController the Game Controller on which to apply the event
|
||||
* @return true if the player could draw the card, false otherwise
|
||||
*/
|
||||
@Override
|
||||
public boolean apply(GameController gameController){
|
||||
return gameController.drawUpperTribeCard(username, pos);
|
||||
}
|
||||
|
||||
//TODO
|
||||
@Override
|
||||
public boolean apply(MiniModel miniModel){
|
||||
if(isError)
|
||||
return false;
|
||||
|
||||
miniModel.board.removeUpperTribeCard(miniModel.board.upperListTribe.get(pos));
|
||||
miniModel.setPlayer(player);
|
||||
miniModel.setOrderLogicCard(orderLogicCard);
|
||||
miniModel.setCurrentState(currentState);
|
||||
miniModel.setSlotPlayerMap(slotPlayerMap);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+3
-3
@@ -10,15 +10,15 @@ import java.io.Serializable;
|
||||
/**
|
||||
* NetworkEvent to avoid drawing a card from the lower card list
|
||||
*/
|
||||
public class SkipNoDrawable extends NetworkEvent implements Serializable{
|
||||
public class SkipTurn extends NetworkEvent implements Serializable{
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
* Initializes all the attributes.
|
||||
* @param username the name of the player requesting the event
|
||||
*/
|
||||
public SkipNoDrawable(String username){
|
||||
super(username, EventType.SKIP_NO_DRAWABLE, false);
|
||||
public SkipTurn(String username){
|
||||
super(username, EventType.SKIP_TURN, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -205,57 +205,11 @@ public class RMIClient implements IClient {
|
||||
System.out.println("Error during remote skip turn");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Used to draw a tribe card from the upper list.
|
||||
* Available only if the player owns the building 12.
|
||||
* @param playerUsername the name of the player performing the action
|
||||
* @param pos the index of the card to draw
|
||||
*/
|
||||
public void pickOptionalTribeCard(String playerUsername,int pos) {
|
||||
try{
|
||||
stub.pickOptionalTribeCard(playerUsername,pos);
|
||||
}
|
||||
catch (RemoteException e){
|
||||
System.out.println("Error during remote pick optional tribe card");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Used to draw a building card from the upper list.
|
||||
* Available only if the player owns the building 12.
|
||||
* @param playerUsername the name of the player performing the action
|
||||
* @param pos the index of the card to draw
|
||||
*/
|
||||
public void pickOptionalBuildingCard(String playerUsername,int pos) {
|
||||
try{
|
||||
stub.pickOptionalBuildingCard(playerUsername,pos);
|
||||
}
|
||||
catch (RemoteException e){
|
||||
System.out.println("Error during remote pick optional building card");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Used to skip the action of drawing a card from the upper list.
|
||||
* Available only if the player owns the building 12.
|
||||
* @param playerUsername the name of the player performing the action
|
||||
*/
|
||||
public void noOptionalCard(String playerUsername) {
|
||||
try{
|
||||
stub.noOptionalCard(playerUsername);
|
||||
}
|
||||
catch (RemoteException e){
|
||||
System.out.println("Error during remote no pick optional card");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Used to perform the slot choice action for the specified player at the specified position.
|
||||
* @param playerUsername the name of the player performing the action
|
||||
|
||||
@@ -18,9 +18,6 @@ public interface IGameServer extends Remote {
|
||||
void drawUpperBuildingCard(String playerUsername, int pos) throws RemoteException;
|
||||
void drawLowerBuildingCard(String playerUsername, int pos) throws RemoteException;
|
||||
void skipTurn(String playerUsername) throws RemoteException;
|
||||
void pickOptionalTribeCard(String playerUsername, int pos) throws RemoteException;
|
||||
void pickOptionalBuildingCard(String playerUsername, int pos) throws RemoteException;
|
||||
void noOptionalCard(String playerUsername) throws RemoteException;
|
||||
void slotChoice(String playerUsername, int pos) throws RemoteException;
|
||||
void totemChoice(String playerUsername, String totems) throws RemoteException;
|
||||
/**
|
||||
|
||||
@@ -3,7 +3,6 @@ package it.polimi.ingsw.gc14.Network.RMI.Server;
|
||||
import it.polimi.ingsw.gc14.Controller.GameController;
|
||||
import it.polimi.ingsw.gc14.LimitedMap;
|
||||
import it.polimi.ingsw.gc14.Model.Game;
|
||||
import it.polimi.ingsw.gc14.Model.GamePackage.CurrentState;
|
||||
import it.polimi.ingsw.gc14.Model.MiniModel;
|
||||
import it.polimi.ingsw.gc14.Network.NetworkEvent;
|
||||
import it.polimi.ingsw.gc14.Network.NetworkEvents.*;
|
||||
@@ -250,43 +249,11 @@ public class RMIServer extends UnicastRemoteObject implements IGameServer {
|
||||
* @param playerUsername the name of the player performing the action
|
||||
*/
|
||||
public void skipTurn(String playerUsername) {
|
||||
actionQueue.offer(new SkipNoDrawable(playerUsername));
|
||||
actionQueue.offer(new SkipTurn(playerUsername));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Used to draw a tribe card from the upper list.
|
||||
* Available only if the player owns the building 12.
|
||||
* @param playerUsername the name of the player performing the action
|
||||
* @param pos the index of the card to draw
|
||||
*/
|
||||
public void pickOptionalTribeCard(String playerUsername,int pos) {
|
||||
actionQueue.offer(new PickOptionalTribeCard(playerUsername,pos));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Used to draw a building card from the upper list.
|
||||
* Available only if the player owns the building 12.
|
||||
* @param playerUsername the name of the player performing the action
|
||||
* @param pos the index of the card to draw
|
||||
*/
|
||||
public void pickOptionalBuildingCard(String playerUsername,int pos) {
|
||||
actionQueue.offer(new PickOptionalBuildingCard(playerUsername,pos));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Used to skip the action of drawing a card from the upper list.
|
||||
* Available only if the player owns the building 12.
|
||||
* @param playerUsername the name of the player performing the action
|
||||
*/
|
||||
public void noOptionalCard(String playerUsername) {
|
||||
actionQueue.offer(new NoOptionalCard(playerUsername));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Used to perform the slot choice action for the specified player at the specified position.
|
||||
* @param playerUsername the name of the player performing the action
|
||||
|
||||
@@ -235,39 +235,7 @@ public class TCPClient implements IClient {
|
||||
* @param playerUsername the name of the player performing the action
|
||||
*/
|
||||
public void skipTurn(String playerUsername) {
|
||||
doEvent(new SkipNoDrawable(playerUsername));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Used to draw a tribe card from the upper list.
|
||||
* Available only if the player owns the building 12.
|
||||
* @param playerUsername the name of the player performing the action
|
||||
* @param pos the index of the card to draw
|
||||
*/
|
||||
public void pickOptionalTribeCard(String playerUsername,int pos) {
|
||||
doEvent(new PickOptionalTribeCard(playerUsername,pos));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Used to draw a building card from the upper list.
|
||||
* Available only if the player owns the building 12.
|
||||
* @param playerUsername the name of the player performing the action
|
||||
* @param pos the index of the card to draw
|
||||
*/
|
||||
public void pickOptionalBuildingCard(String playerUsername,int pos) {
|
||||
doEvent(new PickOptionalBuildingCard(playerUsername,pos));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Used to skip the action of drawing a card from the upper list.
|
||||
* Available only if the player owns the building 12.
|
||||
* @param playerUsername the name of the player performing the action
|
||||
*/
|
||||
public void noOptionalCard(String playerUsername) {
|
||||
doEvent(new NoOptionalCard(playerUsername));
|
||||
doEvent(new SkipTurn(playerUsername));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -4,8 +4,6 @@ import it.polimi.ingsw.gc14.Controller.GameController;
|
||||
import it.polimi.ingsw.gc14.LimitedMap;
|
||||
import it.polimi.ingsw.gc14.Model.Game;
|
||||
import it.polimi.ingsw.gc14.Model.MiniModel;
|
||||
import it.polimi.ingsw.gc14.Model.Player;
|
||||
import it.polimi.ingsw.gc14.Network.ClientPlayer;
|
||||
import it.polimi.ingsw.gc14.Network.EventType;
|
||||
import it.polimi.ingsw.gc14.Network.NetworkEvent;
|
||||
import it.polimi.ingsw.gc14.Network.NetworkEvents.AddPlayer;
|
||||
|
||||
Reference in New Issue
Block a user