Commit 20839978 authored by Matyáš Latner's avatar Matyáš Latner

Fixed sync from 3.2 to 3.2.1

parent e77b107b
......@@ -74,8 +74,11 @@ public class GameRulesHelper {
return durationSeconds * 1000;
}
public static AbstractTablexiaGame.GameResult getNumberOfStarsForTime(GameDifficulty difficulty, float millis){
float seconds = millis/1000;
public static AbstractTablexiaGame.GameResult getNumberOfStarsForTime(GameDifficulty difficulty, Long millis){
if (millis == null) {
return AbstractTablexiaGame.GameResult.NO_STAR;
}
float seconds = millis / 1000;
switch (difficulty) {
case EASY:
if (seconds > EASY_ONE_STAR_DURATION) {
......
......@@ -8,6 +8,7 @@ import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.concurrent.atomic.AtomicInteger;
import cz.nic.tablexia.TablexiaSettings;
......@@ -148,16 +149,14 @@ public class GameDAO {
public static final String GAME_SELECT_COLUMNS = "id, user_id, difficulty_number, game_number, random_seed, start_time, end_time, locale, application_version_name, application_version_code, model_version_name, model_version_code, build_type, platform, hw_serial_number";
public static Game prepareGameObject(ResultSet resultSet) throws SQLException {
String startTimeStr = resultSet.getString(6);
String endTimeStr = resultSet.getString(7);
Game game = new Game(
resultSet.getLong(1), //gameId
UserDAO.selectUser(resultSet.getLong(2)), //user
resultSet.getInt(3), //difficultyNumber
resultSet.getInt(4), //gameNumber
resultSet.getLong(5), //randomSeed
startTimeStr != null ? Long.valueOf(startTimeStr) : null, //startTime
endTimeStr != null ? Long.valueOf(endTimeStr) : null, //endTime
prepareLong(resultSet.getString(6)), //startTime
prepareLong(resultSet.getString(7)), //endTime
resultSet.getInt(8), //locale
resultSet.getString(9), //applicationVersionName
resultSet.getInt(10), //applicationVersionCode
......@@ -172,6 +171,15 @@ public class GameDAO {
return game;
}
private static Long prepareLong(String longNumber) {
if (longNumber != null) {
if (new Scanner(longNumber).hasNextLong()) {
return Long.valueOf(longNumber);
}
}
return null;
}
// prepared statements
public static final String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS game (id INTEGER PRIMARY KEY AUTOINCREMENT, user_id INTEGER NOT NULL, start_time INTEGER, end_time INTEGER, difficulty_number INTEGER NOT NULL, game_number INTEGER NOT NULL, random_seed INTEGER NOT NULL, sync_at INTEGER, FOREIGN KEY(user_id) REFERENCES user(id))";
public static final String NEW_GAME_INSERT = "INSERT INTO game (user_id, difficulty_number, game_number, random_seed, locale, application_version_name, application_version_code, model_version_name, model_version_code, build_type, platform, hw_serial_number) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
......
Markdown is supported
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