Skip to content

Commit f49f175

Browse files
committed
Hunting the bug
1 parent 84f1a42 commit f49f175

File tree

5 files changed

+24
-9
lines changed

5 files changed

+24
-9
lines changed

META-INF/MANIFEST.MF

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Manifest-Version: 1.0
2+
Main-Class: com.apporelbotna.gameserver.pongserver.Main

src/main/java/com/apporelbotna/gameserver/pongserver/model/MatchmakerQueue.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@
88
import org.slf4j.Logger;
99
import org.slf4j.LoggerFactory;
1010

11+
import com.apporelbotna.gameserver.persistencewsclient.GameDAO;
1112
import com.apporelbotna.gameserver.pongserver.properties.ApplicationProperties;
1213
import com.apporelbotna.gameserver.pongserver.stubs.model.Player;
1314
import com.apporelbotna.gameserver.pongserver.stubs.net.SocketConnection;
15+
import com.apporelbotna.gameserver.stubs.Token;
16+
import com.apporelbotna.gameserver.stubs.User;
1417

1518
/**
1619
* This is the PongServer's main thread, which accepts connections from players and starts a new
@@ -28,6 +31,8 @@ public class MatchmakerQueue implements Matchmaker
2831

2932
private static ServerSocket serverSocket;
3033

34+
private GameDAO gameDAO;
35+
3136
public MatchmakerQueue()
3237
{
3338
try
@@ -40,6 +45,7 @@ public MatchmakerQueue()
4045
}
4146
playerQueue = new LinkedList<>();
4247
logger.info("Server is running");
48+
gameDAO = new GameDAO();
4349
}
4450

4551
@Override
@@ -57,7 +63,9 @@ public PlayerConnection acceptPlayer()
5763
playerListener = new SocketConnection(serverSocket.accept());
5864
String playerEmail = playerListener.readLine();
5965
String playerToken = playerListener.readLine();
60-
return new PlayerConnection(new Player(playerEmail, playerToken), playerListener);
66+
gameDAO = new GameDAO();
67+
User user = gameDAO.getUserInformation(playerEmail);
68+
return new PlayerConnection(new Player(user, new Token(playerToken)), playerListener);
6169
}
6270
catch (IOException e)
6371
{

src/main/java/com/apporelbotna/gameserver/pongserver/properties/application.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version=1.0.9
1+
version=1.0.10
22
name=PongServer
33

44
server.ip=localhost

src/main/java/com/apporelbotna/gameserver/pongserver/stubs/model/Ball.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ public void spawnAtCenter()
3737
this.position = new Vector2(INITIAL_X, INITIAL_Y);
3838

3939
// FIXME el random no se genera bien
40-
int initialVelocityX = random.nextInt(2) - 1;
41-
while (initialVelocityX == 0)
42-
initialVelocityX = random.nextInt(2) - 1;
43-
int initialVelocityY = random.nextInt(2) - 1;
44-
while (initialVelocityY == 0)
45-
initialVelocityY = random.nextInt(2) - 1;
46-
this.velocity = new Vector2(initialVelocityX, initialVelocityY);
40+
// int initialVelocityX = random.nextInt(2) - 1;
41+
// while (initialVelocityX == 0)
42+
// initialVelocityX = random.nextInt(2) - 1;
43+
// int initialVelocityY = random.nextInt(2) - 1;
44+
// while (initialVelocityY == 0)
45+
// initialVelocityY = random.nextInt(2) - 1;
46+
this.velocity = new Vector2(1, 1);
4747
}
4848

4949
public Ball mirrorPositionX()

src/main/java/com/apporelbotna/gameserver/pongserver/stubs/model/Player.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ public Player(String email, String tokenKey)
2424
this(new UserWrapper(new User(email), new Token(tokenKey)));
2525
}
2626

27+
public Player(User user, Token token)
28+
{
29+
this(new UserWrapper(user, token));
30+
}
31+
2732
public UserWrapper getUserWrapper()
2833
{
2934
return userWrapper;

0 commit comments

Comments
 (0)