diff --git a/core/src/cz/nic/tablexia/game/trophy/GameTrophyDefinition.java b/core/src/cz/nic/tablexia/game/trophy/GameTrophyDefinition.java index 510b2ba9dc39fdbf7120421e1b92e42d2b7153d8..aba14d0c41947419402a7fb3c11f67abaf5a092a 100644 --- a/core/src/cz/nic/tablexia/game/trophy/GameTrophyDefinition.java +++ b/core/src/cz/nic/tablexia/game/trophy/GameTrophyDefinition.java @@ -95,7 +95,7 @@ public enum GameTrophyDefinition implements TrophyEnum { } @Override - public String getDescription() { + public String getTrophyDescription() { return trophyDescription; } diff --git a/core/src/cz/nic/tablexia/game/trophy/TrophyEnum.java b/core/src/cz/nic/tablexia/game/trophy/TrophyEnum.java index e6bc59af6577d8200e91ea0cacff597a2a0ace41..8475de59fe23f937ba911b7eaf139e66277f817f 100644 --- a/core/src/cz/nic/tablexia/game/trophy/TrophyEnum.java +++ b/core/src/cz/nic/tablexia/game/trophy/TrophyEnum.java @@ -21,6 +21,6 @@ package cz.nic.tablexia.game.trophy; public interface TrophyEnum { public String getTrophyName(); - public String getDescription(); + public String getTrophyDescription(); } diff --git a/core/src/cz/nic/tablexia/game/trophy/UserTrophyDefinition.java b/core/src/cz/nic/tablexia/game/trophy/UserTrophyDefinition.java index b8649807d33d96ef50e9c4c0c98e569b9a6f0f46..8fe2aa64e7143f7bfec481ca2d80d322c3c70166 100644 --- a/core/src/cz/nic/tablexia/game/trophy/UserTrophyDefinition.java +++ b/core/src/cz/nic/tablexia/game/trophy/UserTrophyDefinition.java @@ -22,11 +22,7 @@ package cz.nic.tablexia.game.trophy; import java.util.ArrayList; import java.util.List; -import cz.nic.tablexia.R; import cz.nic.tablexia.game.difficulty.GameDifficulty; -import cz.nic.tablexia.game.manager.GameManager; -import cz.nic.tablexia.menu.usermenu.User; -import cz.nic.tablexia.util.Utility; /** * Definitions of user trophies @@ -35,31 +31,25 @@ import cz.nic.tablexia.util.Utility; */ public enum UserTrophyDefinition implements TrophyEnum { - CONSECUTIVELY_DAYSBACK_3(UserTrophyTypeDefinition.CONSECUTIVELY_DAYSBACK, "consecutively3Days", R.drawable.trophy_user_consecutively3days_small, R.id.screen_halloffame_trophy_user_consecutively3days, R.drawable.trophy_user_consecutively3days, R.string.trophy_user_consecutively3Days_name, R.string.trophy_user_consecutively3Days_description, 3), - CONSECUTIVELY_DAYSBACK_5(UserTrophyTypeDefinition.CONSECUTIVELY_DAYSBACK, "consecutively5Days", R.drawable.trophy_user_consecutively5days_small, R.id.screen_halloffame_trophy_user_consecutively5days, R.drawable.trophy_user_consecutively5days, R.string.trophy_user_consecutively5Days_name, R.string.trophy_user_consecutively5Days_description, 5), - CONSECUTIVELY_DAYSBACK_8(UserTrophyTypeDefinition.CONSECUTIVELY_DAYSBACK, "consecutively8Days", R.drawable.trophy_user_consecutively8days_small, R.id.screen_halloffame_trophy_user_consecutively8days, R.drawable.trophy_user_consecutively8days, R.string.trophy_user_consecutively8Days_name, R.string.trophy_user_consecutively8Days_description, 8), - ONEDAYALLGAMES_0STARS(UserTrophyTypeDefinition.ONEDAYALLGAMES, "consecutivelyAllGames0Stars", R.drawable.trophy_user_consecutivelyallgames0stars_small, R.id.screen_halloffame_trophy_user_consecutivelyallgames0stars, R.drawable.trophy_user_consecutivelyallgames0stars, R.string.trophy_user_consecutivelyAllGames0Stars_name, R.string.trophy_user_consecutivelyAllGames0Stars_description, 0), - CONSECUTIVELYALLGAMES_MEDIUMDIFFICULTY(UserTrophyTypeDefinition.CONSECUTIVELY_ALLGAMES, "consecutivelyAllGames2Stars", R.drawable.trophy_user_consecutivelyallgames2stars_small, R.id.screen_halloffame_trophy_user_consecutivelyallgames2stars, R.drawable.trophy_user_consecutivelyallgames2stars, R.string.trophy_user_consecutivelyAllGames2Stars_name, R.string.trophy_user_consecutivelyAllGames2Stars_description, GameDifficulty.MEDIUM.ordinal()), - CONSECUTIVELYALLGAMES_HARDDIFFICULTY(UserTrophyTypeDefinition.CONSECUTIVELY_ALLGAMES, "consecutivelyAllGames3Stars", R.drawable.trophy_user_consecutivelyallgames3stars_small, R.id.screen_halloffame_trophy_user_consecutivelyallgames3stars, R.drawable.trophy_user_consecutivelyallgames3stars, R.string.trophy_user_consecutivelyAllGames3Stars_name, R.string.trophy_user_consecutivelyAllGames3Stars_description, GameDifficulty.HARD.ordinal()); + CONSECUTIVELY_DAYSBACK_3(UserTrophyTypeDefinition.CONSECUTIVELY_DAYSBACK, "consecutively3Days", "trophy_user_consecutively3days", "trophy_user_consecutively3days_description", 3), + CONSECUTIVELY_DAYSBACK_5(UserTrophyTypeDefinition.CONSECUTIVELY_DAYSBACK, "consecutively5Days", "trophy_user_consecutively5days", "trophy_user_consecutively5days_description", 5), + CONSECUTIVELY_DAYSBACK_8(UserTrophyTypeDefinition.CONSECUTIVELY_DAYSBACK, "consecutively8Days", "trophy_user_consecutively8days", "trophy_user_consecutively8days_description", 8), + ONEDAYALLGAMES_0STARS(UserTrophyTypeDefinition.ONEDAYALLGAMES, "consecutivelyAllGames0Stars", "trophy_user_consecutivelyallgames0stars", "trophy_user_consecutivelyallgames0stars_description", 0), + CONSECUTIVELYALLGAMES_MEDIUMDIFFICULTY(UserTrophyTypeDefinition.CONSECUTIVELY_ALLGAMES, "consecutivelyAllGames2Stars", "trophy_user_consecutivelyallgames2stars", "trophy_user_consecutivelyallgames2stars_description", GameDifficulty.MEDIUM.ordinal()), + CONSECUTIVELYALLGAMES_HARDDIFFICULTY(UserTrophyTypeDefinition.CONSECUTIVELY_ALLGAMES, "consecutivelyAllGames3Stars", "trophy_user_consecutivelyallgames3stars", "trophy_user_consecutivelyallgames2stars_description", GameDifficulty.HARD.ordinal()); private UserTrophyTypeDefinition trophyTypeDefinition; private String dbFieldName; - private int smallImageResourceId; - private int trophyImageId; + private String imageName; + private String imageDescription; private int limit; - private int nameResourceId; - private int descriptionResourceId; - private int fullImageResourceId; - private UserTrophyDefinition(UserTrophyTypeDefinition trophyTypeDefinition, String dbFieldName, int smallImageResourceId, int trophyImageId, int fullImageResourceId, int nameResourceId, int descriptionResourceId, int limit) { + private UserTrophyDefinition(UserTrophyTypeDefinition trophyTypeDefinition, String dbFieldName, String imageName, String imageDescription, int limit) { this.trophyTypeDefinition = trophyTypeDefinition; this.dbFieldName = dbFieldName; - this.smallImageResourceId = smallImageResourceId; - this.fullImageResourceId = fullImageResourceId; - this.nameResourceId = nameResourceId; - this.descriptionResourceId = descriptionResourceId; - this.trophyImageId = trophyImageId; + this.imageName = imageName; + this.imageDescription = imageDescription; this.limit = limit; } @@ -72,73 +62,59 @@ public enum UserTrophyDefinition implements TrophyEnum { } @Override - public int getSmallImageResourceId() { - return smallImageResourceId; - } - - public int getFullImageResourceId() { - return fullImageResourceId; - } - - @Override - public int getNameResourceId() { - return nameResourceId; + public String getTrophyName() { + return null; } @Override - public int getDescriptionResourceId() { - return descriptionResourceId; - } - - @Override - public int getTrophyImageId() { - return trophyImageId; + public String getTrophyDescription() { + return null; } public int getLimit() { return limit; } - public static List<TrophyEnum> processUserTrophies(User user) { - List<TrophyEnum> resultList = new ArrayList<TrophyEnum>(); - for (UserTrophyDefinition userTrophyDefinition : UserTrophyDefinition.getTrophyDefinitionByUserTrophyDefinition(UserTrophyTypeDefinition.CONSECUTIVELY_DAYSBACK)) { - if (!Utility.isSetTrophyForName(user, userTrophyDefinition.getDbFieldName())) { - boolean result = true; - for (int i = 0; i < userTrophyDefinition.getLimit(); i++) { - boolean existGame = GameManager.isGameManagerForDayBack(user.getId(), i); - result = result && existGame; - if (!existGame) { - break; - } - } - if (result) { - Utility.setTrophyForName(user, userTrophyDefinition.getDbFieldName()); - resultList.add(userTrophyDefinition); - } - } - } - - for (UserTrophyDefinition userTrophyDefinition : UserTrophyDefinition.getTrophyDefinitionByUserTrophyDefinition(UserTrophyTypeDefinition.ONEDAYALLGAMES)) { - if (!Utility.isSetTrophyForName(user, userTrophyDefinition.getDbFieldName())) { - if (GameManager.existsGameTypeManagersInOneDayWithStars(user.getId(), userTrophyDefinition.getLimit())) { - Utility.setTrophyForName(user, userTrophyDefinition.getDbFieldName()); - resultList.add(userTrophyDefinition); - } - } - } - - for (UserTrophyDefinition userTrophyDefinition : UserTrophyDefinition.getTrophyDefinitionByUserTrophyDefinition(UserTrophyTypeDefinition.CONSECUTIVELY_ALLGAMES)) { - if (!Utility.isSetTrophyForName(user, userTrophyDefinition.getDbFieldName())) { - if (GameManager.existsGameTypeManagersConsecutivelyWithStarsNumberAndDifficulty(user.getId(), userTrophyDefinition.getLimit(), 3)) { - Utility.setTrophyForName(user, userTrophyDefinition.getDbFieldName()); - resultList.add(userTrophyDefinition); - } - } - } - - user.save(); - return resultList; - } + // public static List<TrophyEnum> processUserTrophies(User user) { +// List<TrophyEnum> resultList = new ArrayList<TrophyEnum>(); +// for (UserTrophyDefinition userTrophyDefinition : UserTrophyDefinition.getTrophyDefinitionByUserTrophyDefinition(UserTrophyTypeDefinition.CONSECUTIVELY_DAYSBACK)) { +// if (!Utility.isSetTrophyForName(user, userTrophyDefinition.getDbFieldName())) { +// boolean result = true; +// for (int i = 0; i < userTrophyDefinition.getLimit(); i++) { +// boolean existGame = GameManager.isGameManagerForDayBack(user.getId(), i); +// result = result && existGame; +// if (!existGame) { +// break; +// } +// } +// if (result) { +// Utility.setTrophyForName(user, userTrophyDefinition.getDbFieldName()); +// resultList.add(userTrophyDefinition); +// } +// } +// } +// +// for (UserTrophyDefinition userTrophyDefinition : UserTrophyDefinition.getTrophyDefinitionByUserTrophyDefinition(UserTrophyTypeDefinition.ONEDAYALLGAMES)) { +// if (!Utility.isSetTrophyForName(user, userTrophyDefinition.getDbFieldName())) { +// if (GameManager.existsGameTypeManagersInOneDayWithStars(user.getId(), userTrophyDefinition.getLimit())) { +// Utility.setTrophyForName(user, userTrophyDefinition.getDbFieldName()); +// resultList.add(userTrophyDefinition); +// } +// } +// } +// +// for (UserTrophyDefinition userTrophyDefinition : UserTrophyDefinition.getTrophyDefinitionByUserTrophyDefinition(UserTrophyTypeDefinition.CONSECUTIVELY_ALLGAMES)) { +// if (!Utility.isSetTrophyForName(user, userTrophyDefinition.getDbFieldName())) { +// if (GameManager.existsGameTypeManagersConsecutivelyWithStarsNumberAndDifficulty(user.getId(), userTrophyDefinition.getLimit(), 3)) { +// Utility.setTrophyForName(user, userTrophyDefinition.getDbFieldName()); +// resultList.add(userTrophyDefinition); +// } +// } +// } +// +// user.save(); +// return resultList; + // } public static List<UserTrophyDefinition> getTrophyDefinitionByUserTrophyDefinition(UserTrophyTypeDefinition trophyTypeDefinition) { List<UserTrophyDefinition> result = new ArrayList<UserTrophyDefinition>();