Commit 939a049c authored by Peining Li's avatar Peining Li
Browse files

Merge branch 'develop' into 'ihm-main/develop'

Develop

See merge request !132
parents 0006b9e1 275c3e94
......@@ -216,7 +216,7 @@ public class ComFacade {
* @param id is the UID of the player demanding to join the game
* @param game is the game in question
*/
public void joinGameResponse(boolean success, String id, Game game) {
public void joinGameResponse(boolean success, String id, StatGame game) {
M_JoinGameResponse m_joingameresponse = new M_JoinGameResponse(iDataCom.getMyPublicUserProfile(), success, game);
if (success) {
for (Inet4Address ip : kIpCtrl.getHashMap().values()) {
......
......@@ -23,15 +23,16 @@ import java.util.logging.Logger;
public class M_JoinGameResponse extends Message {
private final boolean success;
private final Game game;
private final StatGame game;
/**
* Constructor.
*
* @param user is the message's sender
* @param success is the response
* @param game
*/
public M_JoinGameResponse(PublicUser user, boolean success, Game game) {
public M_JoinGameResponse(PublicUser user, boolean success, StatGame game) {
super(user);
this.success = success;
this.game = game;
......@@ -41,7 +42,7 @@ public class M_JoinGameResponse extends Message {
public void callback(IDataCom iDataCom) {
if (success) {
try {
iDataCom.receptionGame(game);
iDataCom.receptionGame(game.getRealGame());
} catch (DataException ex) {
Logger.getLogger(M_JoinGameResponse.class.getName()).log(Level.SEVERE, null, ex);
}
......
......@@ -5,6 +5,7 @@
*/
package com.utclo23.data.module;
import com.utclo23.data.structure.SerializableEntity;
import java.util.ArrayList;
import java.util.List;
......@@ -13,7 +14,7 @@ import java.util.List;
* store mementos and reload it into game
* @author Davy
*/
public class Caretaker {
public class Caretaker extends SerializableEntity{
/**
* list of memento
*/
......
......@@ -295,6 +295,7 @@ public class GameMediator {
* @param role role of the new user
*/
public void updateGameList(LightPublicUser user, String id, String role) throws DataException {
System.out.println("id "+id);
if(user == null)
{
System.out.println("user is null");
......@@ -309,11 +310,13 @@ public class GameMediator {
System.out.println("add Urole "+role);
System.out.println("add Urole "+role);
this.getCurrentGame().addUser(user, role);
if (this.dataFacade.getComfacade() != null) {
this.dataFacade.getComfacade().joinGameResponse(true, user.getId(), this.currentGame);
System.out.println("data join game resp");
this.dataFacade.getComfacade().joinGameResponse(true, user.getId(), this.currentGame.getStatGame());
}
} else {
......
......@@ -6,6 +6,7 @@
package com.utclo23.data.module;
import com.utclo23.data.structure.Event;
import com.utclo23.data.structure.SerializableEntity;
import java.util.List;
/**
......@@ -13,7 +14,7 @@ import java.util.List;
* Keep a state of a game
* @author Davy
*/
public class Memento {
public class Memento extends SerializableEntity{
/**
* list of events (messages, ships)
*/
......
......@@ -37,13 +37,12 @@ public abstract class Game extends SerializableEntity {
public Game(StatGame statGame, List<Player> players, List<LightPublicUser> spectators, List<Message> messages) {
this.statGame = statGame;
this.statGame.setRealGame(this);
this.players = players;
this.spectators = spectators;
this.messages = messages;
this.currentPlayer = players.get(0);
/* creation of caretaker */
this.caretaker = new Caretaker();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment