mirror of
https://github.com/2OOP/pism.git
synced 2026-02-04 19:04:49 +00:00
Fixes
This commit is contained in:
@@ -100,7 +100,7 @@ public class Server implements GameServer {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (user.games().length > 0) {
|
||||
if (user.game() != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -119,7 +119,8 @@ public class ServerHandler extends SimpleChannelInboundHandler<String> {
|
||||
}
|
||||
|
||||
private void handleMove(ParsedMessage p) {
|
||||
// TODO
|
||||
if(!allowedArgs(p.args())) return;
|
||||
|
||||
}
|
||||
|
||||
private ParsedMessage parse(String msg) {
|
||||
|
||||
@@ -3,9 +3,9 @@ package org.toop.framework.networking.server;
|
||||
public interface ServerUser {
|
||||
long id();
|
||||
String name();
|
||||
Game[] games();
|
||||
Game game();
|
||||
void addGame(Game game);
|
||||
void removeGame(Game game);
|
||||
void removeGame();
|
||||
void setName(String name);
|
||||
void sendMessage(String message);
|
||||
}
|
||||
|
||||
@@ -2,13 +2,10 @@ package org.toop.framework.networking.server;
|
||||
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class User implements ServerUser {
|
||||
final private long id;
|
||||
private String name;
|
||||
private final List<Game> games = new ArrayList<>();
|
||||
private Game game;
|
||||
private ChannelHandlerContext connectionContext;
|
||||
|
||||
public User(long userId, String name) {
|
||||
@@ -30,17 +27,19 @@ public class User implements ServerUser {
|
||||
|
||||
@Override
|
||||
public void addGame(Game game) {
|
||||
games.add(game);
|
||||
if (this.game == null) {
|
||||
this.game = game;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeGame(Game game) {
|
||||
games.remove(game);
|
||||
public void removeGame() {
|
||||
this.game = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Game[] games() {
|
||||
return games.toArray(new Game[0]);
|
||||
public Game game() {
|
||||
return this.game;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user