Fix: Replaced Model With MiniModel in the client implementation and in the view
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
package it.polimi.ingsw.gc14.Controller;
|
||||
|
||||
import it.polimi.ingsw.gc14.Model.Game;
|
||||
import it.polimi.ingsw.gc14.Model.*;
|
||||
import it.polimi.ingsw.gc14.Model.GamePackage.Board;
|
||||
import it.polimi.ingsw.gc14.Model.GamePackage.CurrentState;
|
||||
import it.polimi.ingsw.gc14.Network.IClient;
|
||||
import it.polimi.ingsw.gc14.Network.NetworkEvents.*;
|
||||
import it.polimi.ingsw.gc14.View.IView;
|
||||
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
@@ -15,7 +18,7 @@ import java.util.Objects;
|
||||
public class ClientController {
|
||||
|
||||
/** Game Controller of the client */
|
||||
public GameController localController;
|
||||
public MiniModel miniModel;
|
||||
|
||||
/** View of the client */
|
||||
public IView view;
|
||||
@@ -31,7 +34,6 @@ public class ClientController {
|
||||
*/
|
||||
public ClientController(IView view) {
|
||||
this.view = view;
|
||||
this.localController = new GameController();
|
||||
this.client = null;
|
||||
}
|
||||
|
||||
@@ -49,9 +51,9 @@ public class ClientController {
|
||||
* Sets the model in the GameController and updates the view.
|
||||
* @param model the model to set
|
||||
*/
|
||||
public void setModel(Game model) {
|
||||
localController.setModel(model);
|
||||
view.setModel(localController.getModel());
|
||||
public void setModel(MiniModel model) {
|
||||
this.miniModel = model;
|
||||
view.setModel(miniModel);
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +74,7 @@ public class ClientController {
|
||||
*/
|
||||
public void drawUpperTribeCard(String playerUsername, int pos) {
|
||||
|
||||
if(!Objects.equals(playerUsername, localController.getModel().getCurrentState().getCurrentPlayer().getUserName()))
|
||||
if(!Objects.equals(playerUsername, miniModel.currentState.getCurrentPlayer().getUserName()))
|
||||
{
|
||||
view.showError("It's not your turn!");
|
||||
}
|
||||
@@ -94,7 +96,7 @@ public class ClientController {
|
||||
* @param pos the index of the card to draw
|
||||
*/
|
||||
public void drawLowerTribeCard(String playerUsername,int pos) {
|
||||
if(!Objects.equals(playerUsername, localController.getModel().getCurrentState().getCurrentPlayer().getUserName()))
|
||||
if(!Objects.equals(playerUsername, miniModel.currentState.getCurrentPlayer().getUserName()))
|
||||
view.showError("It's not your turn!");
|
||||
else
|
||||
try {
|
||||
@@ -112,7 +114,7 @@ public class ClientController {
|
||||
* @param pos the index of the card to draw
|
||||
*/
|
||||
public void drawUpperBuildingCard(String playerUsername,int pos) {
|
||||
if(!Objects.equals(playerUsername, localController.getModel().getCurrentState().getCurrentPlayer().getUserName()))
|
||||
if(!Objects.equals(playerUsername, miniModel.currentState.getCurrentPlayer().getUserName()))
|
||||
view.showError("It's not your turn!");
|
||||
else {
|
||||
try {
|
||||
@@ -132,7 +134,7 @@ public class ClientController {
|
||||
* @param pos the index of the card to draw
|
||||
*/
|
||||
public void drawLowerBuildingCard(String playerUsername,int pos) {
|
||||
if(!Objects.equals(playerUsername, localController.getModel().getCurrentState().getCurrentPlayer().getUserName()))
|
||||
if(!Objects.equals(playerUsername,miniModel.currentState.getCurrentPlayer().getUserName()))
|
||||
view.showError("It's not your turn!");
|
||||
else {
|
||||
try {
|
||||
@@ -150,7 +152,7 @@ public class ClientController {
|
||||
* @param playerUsername the name of the player performing the action
|
||||
*/
|
||||
public void skipTurn(String playerUsername) {
|
||||
if(!Objects.equals(playerUsername, localController.getModel().getCurrentState().getCurrentPlayer().getUserName()))
|
||||
if(!Objects.equals(playerUsername,miniModel.currentState.getCurrentPlayer().getUserName()))
|
||||
view.showError("It's not your turn!");
|
||||
else {
|
||||
try {
|
||||
@@ -171,7 +173,7 @@ public class ClientController {
|
||||
* @param pos the index of the card to draw
|
||||
*/
|
||||
public void pickOptionalTribeCard(String playerUsername,int pos) {
|
||||
if(!Objects.equals(playerUsername, localController.getModel().getCurrentState().getCurrentPlayer().getUserName()))
|
||||
if(!Objects.equals(playerUsername,miniModel.currentState.getCurrentPlayer().getUserName()))
|
||||
view.showError("It's not your turn!");
|
||||
else {
|
||||
try {
|
||||
@@ -190,7 +192,7 @@ public class ClientController {
|
||||
* @param pos the index of the card to draw
|
||||
*/
|
||||
public void pickOptionalBuildingCard(String playerUsername,int pos) {
|
||||
if(!Objects.equals(playerUsername, localController.getModel().getCurrentState().getCurrentPlayer().getUserName()))
|
||||
if(!Objects.equals(playerUsername, miniModel.currentState.getCurrentPlayer().getUserName()))
|
||||
view.showError("It's not your turn!");
|
||||
else {
|
||||
try {
|
||||
@@ -208,7 +210,7 @@ public class ClientController {
|
||||
* @param playerUsername the name of the player performing the action
|
||||
*/
|
||||
public void noOptionalCard(String playerUsername) {
|
||||
if(!Objects.equals(playerUsername, localController.getModel().getCurrentState().getCurrentPlayer().getUserName()))
|
||||
if(!Objects.equals(playerUsername, miniModel.currentState.getCurrentPlayer().getUserName()))
|
||||
view.showError("It's not your turn!");
|
||||
else {
|
||||
try {
|
||||
@@ -226,7 +228,7 @@ public class ClientController {
|
||||
* @param pos the index of the selected slot
|
||||
*/
|
||||
public void slotChoice(String playerUsername,int pos) {
|
||||
if(!Objects.equals(playerUsername, localController.getModel().getCurrentState().getCurrentPlayer().getUserName()))
|
||||
if(!Objects.equals(playerUsername, miniModel.currentState.getCurrentPlayer().getUserName()))
|
||||
view.showError("It's not your turn!");
|
||||
else {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user