Fixed random token assigning and realisation

Token class now has two functions: assignRandomType and realiseRandomType
The former can be used to assign any random type to the token including the random type
The latter can be used to assign a concrete random type to the token (not the random type)

#story[1245]
This commit is contained in:
William Muir
2017-09-20 12:02:12 +12:00
parent 52d3cea592
commit 6cde016401
4 changed files with 39 additions and 19 deletions
@@ -283,10 +283,9 @@ public class GameState implements Runnable {
Random random = new Random();
tokensInPlay.clear();
//Get a random token location
//Get a random token location with random type
Token token = allTokens.get(random.nextInt(allTokens.size()));
//Set a random type to this token
token.setTokenType(TokenType.values()[random.nextInt(TokenType.values().length)]);
token.assignRandomType();
tokensInPlay.add(token);
}
@@ -389,6 +388,7 @@ public class GameState implements Runnable {
//Yacht Collision
ServerYacht collidedYacht = checkYachtCollision(serverYacht);
Mark collidedMark = checkMarkCollision(serverYacht);
Token collidedToken = checkTokenPickUp(serverYacht);
if (collidedYacht != null) {
GeoPoint originalLocation = serverYacht.getLocation();
@@ -433,8 +433,10 @@ public class GameState implements Runnable {
}
//Token Collision
Token collidedToken = checkTokenPickUp(serverYacht);
if (collidedToken != null) {
if (collidedToken.getTokenType() == TokenType.RANDOM) {
collidedToken.realiseRandom();
}
sendServerMessage(serverYacht.getSourceId(),
serverYacht.getBoatName() + " has picked up a " + collidedToken.getTokenType()
.getName() + " token");