Skip to content
Snippets Groups Projects
Commit 9d1f005f authored by Petter Selfors Rølvåg's avatar Petter Selfors Rølvåg
Browse files

Merge branch 'dev' into 'dev2'

# Conflicts:
#   CheckersClient/core/src/com/mygdx/game/controllers/PlayerController.java
parents 3defe1c5 a187b8b8
Branches
No related tags found
2 merge requests!8Dev,!6added notification feature to commants
...@@ -58,6 +58,7 @@ public class NetworkController { ...@@ -58,6 +58,7 @@ public class NetworkController {
kryo.register(cLobbyLeave.class, 22); kryo.register(cLobbyLeave.class, 22);
kryo.register(cLobbyDelete.class, 23); kryo.register(cLobbyDelete.class, 23);
kryo.register(cLobbyGetList.class, 24); kryo.register(cLobbyGetList.class, 24);
kryo.register(cSetIndexAvatar.class, 25);
} }
public Client getClient() { return client; } public Client getClient() { return client; }
......
...@@ -30,12 +30,6 @@ public class PlayerController { ...@@ -30,12 +30,6 @@ public class PlayerController {
connectPlayer(0); connectPlayer(0);
} }
public void issueACommand(String commandString) {
if (commandString.equals("W")){
cPlayerPieceMove newCommand = new cPlayerPieceMove();
net.sendToServer(newCommand);
}
}
public void lobbyGetList(){ net.sendToServer(new cLobbyGetList()); } public void lobbyGetList(){ net.sendToServer(new cLobbyGetList()); }
...@@ -64,4 +58,5 @@ public class PlayerController { ...@@ -64,4 +58,5 @@ public class PlayerController {
public PlayerController getPlayerController(){ return this; } public PlayerController getPlayerController(){ return this; }
public NetworkController getNetWorkController() { return net; } public NetworkController getNetWorkController() { return net; }
} }
...@@ -19,6 +19,7 @@ public class Command{ ...@@ -19,6 +19,7 @@ public class Command{
this.data = "None"; this.data = "None";
} }
public void execute(PlayerController playerController, Connection connection){} public void execute(PlayerController playerController, Connection connection){}
public String getText(){ return text; } public String getText(){ return text; }
......
...@@ -9,7 +9,9 @@ public class cLobbyJoin extends Command{ ...@@ -9,7 +9,9 @@ public class cLobbyJoin extends Command{
public cLobbyJoin() { super("cLobbyJoin"); } public cLobbyJoin() { super("cLobbyJoin"); }
public cLobbyJoin(int id) { super("cLobbyJoin", (Integer) id); } public cLobbyJoin(int id) {
super("cLobbyJoin", (Integer) id);
}
@Override @Override
public void execute(PlayerController playerController, Connection connection){ public void execute(PlayerController playerController, Connection connection){
......
package com.mygdx.game.controllers.commands;
import com.esotericsoftware.kryonet.Connection;
import com.mygdx.game.controllers.NetworkController;
import com.mygdx.game.controllers.PlayerController;
import com.mygdx.game.model.Lobby;
public class cSetIndexAvatar extends Command {
public cSetIndexAvatar() { super("cLobbyJoin"); }
public cSetIndexAvatar(int indexAvatar) {
super("cSetIndexAvatar", indexAvatar);
}
@Override
public void execute(PlayerController playerController, Connection connection){
if(data instanceof Integer){
int indexAvatar = (int) data;
if (indexAvatar == -1) System.out.println("Failed to set indexAvatar.");
else {
playerController.getPlayer().setIndexAvatar(indexAvatar);
}
}
}
}
\ No newline at end of file
...@@ -237,7 +237,7 @@ public class MenuView extends View{ ...@@ -237,7 +237,7 @@ public class MenuView extends View{
transitionAudio.play(0.50f); transitionAudio.play(0.50f);
startFadeFromBlankToWhite = true; startFadeFromBlankToWhite = true;
whiteImage.setZIndex(stage.getActors().size); whiteImage.setZIndex(stage.getActors().size);
playerController.getPlayer().setIndexAvatar(currentIndexAvatar); playerController.updateIndexAvatar(currentIndexAvatar);
} }
return true; return true;
} }
......
...@@ -126,6 +126,8 @@ public class NetworkController { ...@@ -126,6 +126,8 @@ public class NetworkController {
public ArrayList<Lobby> getLobbies(){ return lobbies; } public ArrayList<Lobby> getLobbies(){ return lobbies; }
public ArrayList<Player> getPlayers(){ return players; }
public void registerClasses(){ public void registerClasses(){
kryo.register(ArrayList.class, 100); kryo.register(ArrayList.class, 100);
kryo.register(Lobby.class, 5); kryo.register(Lobby.class, 5);
...@@ -138,6 +140,7 @@ public class NetworkController { ...@@ -138,6 +140,7 @@ public class NetworkController {
kryo.register(cLobbyLeave.class, 22); kryo.register(cLobbyLeave.class, 22);
kryo.register(cLobbyDelete.class, 23); kryo.register(cLobbyDelete.class, 23);
kryo.register(cLobbyGetList.class, 24); kryo.register(cLobbyGetList.class, 24);
kryo.register(cSetIndexAvatar.class, 25);
} }
public NetworkController getNetworkController() { return this; } public NetworkController getNetworkController() { return this; }
......
package com.mygdx.game.controller.commands;
import com.esotericsoftware.kryonet.Connection;
import com.mygdx.game.controller.NetworkController;
import com.mygdx.game.model.Player;
import java.util.HashSet;
public class cSetIndexAvatar extends Command {
public cSetIndexAvatar() { super("cLobbyJoin"); }
public cSetIndexAvatar(int indexAvatar) {
super("cSetIndexAvatar", indexAvatar);
}
@Override
public void execute(NetworkController net, Connection connection){
if(data instanceof Integer){
int indexAvatar = (int) data;
if (indexAvatar == -1) System.out.println("Failed to set index avatar.");
else {
for (Player p : net.getPlayers()) {
if(p.getID() == connection.getID()){
p.setIndexAvatar(indexAvatar);
connection.sendTCP(this);
}
else{
connection.sendTCP(new cSetIndexAvatar(-1));
}
}
}
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment