from enum import IntEnum


class GGEError(IntEnum):
    ALL_OK = 0
    GENERAL_ERROR = 1
    INVALID_PARAMETER_VALUE = 2
    MISSING_PARAMETER = 3
    INVALID_WOD_ID = 4
    INVALID_OBJECT_ID = 5
    INVALID_POSITION = 6
    FEATURE_NOT_IN_THIS_NETWORK = 7
    NOT_ENOUGH_CURRENCY1 = 10
    NOT_ENOUGH_CURRENCY2 = 11
    LEVEL_TOO_HIGH_OR_LOW = 12
    NO_PAY_USER = 14
    NO_CHANGE = 15
    CAMP_IS_OCCUPIED = 16
    WRONG_INPUT_SCREEN = 19
    INVALID_PASSWORD = 20
    PLAYER_NOT_FOUND = 21
    NAME_ALREADY_IN_USE = 22
    EMAIL_ALREADY_IN_USE = 23
    INVALID_EMAIL = 24
    ALREADY_VERIFIED_MAIL = 25
    NO_AVATAR_CREATED = 26
    IS_BANNED = 27
    INVALID_NAME = 28
    WORLD_IS_FULL = 29
    WRONG_MODE = 50
    NOT_MOVEABLE = 51
    POSITION_IS_BLOCKED = 52
    NOT_IN_OWNED_CASTLE = 53
    WOD_NOT_ACTIVE = 54
    NOT_ENOUGH_RESOURCES = 55
    NOT_UPGRADEABLE = 56
    TITLE_TOO_LOW = 57
    MOVE_FAILED = 58
    NOT_SELLABLE = 59
    NO_COLLECTABLE_OBJECT_BONUS = 60
    NOT_STOREABLE = 61
    INVALID_OBJECT_STATE = 62
    NO_FREE_CONSTRUCTION_SLOT = 63
    INVALID_NUMBER_OF_PARAMETERS = 64
    INVALID_PLAYER_ID = 65
    NO_SUCH_MESSAGE = 66
    NOT_ADDRESSED_TO_USER = 67
    INVALID_RECEIVER_ID = 68
    PLAYER_IS_IGNORED = 69
    USAGE_OF_BADWORDS = 70
    PLAYER_IS_GUEST = 80
    AREA_NOT_ATTACKABLE = 81
    ALREADY_TO_MANY_OUTPOSTS = 82
    ALREADY_COLLECTING_TAXES = 83
    TAX_COLLECTOR_NOT_FINISHED = 84
    TAX_COLLECTOR_HAS_OLD_MONEY = 85
    NOT_REPAIRABLE = 86
    MISSING_REQUIRED_BUILDING = 87
    TOO_MUCH_UNITS = 88
    PACKAGE_NOT_BOOSTABLE = 89
    CANT_START_NEW_ARMIES = 90
    INVALID_ARMY_REQUEST = 91
    NO_SELF_DESTRUCTION = 92
    EXCEEDING_MAXIMUM_COUNT = 93
    PLAYER_HAS_NOOB_PROTECTION = 94
    COOLING_DOWN = 95
    PLAYER_NOT_ON_MAP = 96
    MISSING_GENERAL = 97
    TEXT_TOO_SHORT = 98
    TEXT_TOO_LONG = 99
    MOVEMENT_HAS_NO_UNITS = 100
    MISSING_UNITS = 101
    PLAYER_ALREADY_HAS_INVITATION = 102
    TOO_MANY_FRIENDS_MY = 103
    PLAYER_ALREADY_IS_FRIEND = 104
    NOT_ENOUGH_SPIES = 105
    RUIN = 106
    TOO_MANY_FRIENDS_OTHER = 107
    UNKNOWN_MOVEMENT = 108
    MISSING_CARRIAGE = 109
    IN_OTHER_ALLI = 110
    IN_THIS_ALLI = 111
    ALLI_FULL = 112
    ALLI_NO_RIGHTS = 113
    ALLI_NOT_FOUND = 114
    ALLI_NOT_ENOUGH_C1 = 115
    ALLI_NOT_ENOUGH_C2 = 116
    ALLI_NOT_ENOUGH_RES = 117
    OTHER_LEVEL_TOO_LOW = 120
    TOO_MUCH_TRAVEL_TIME = 121
    DEFENDER_IS_IN_YOUR_ALLI = 122
    NOT_IN_SAME_ALLIANCE = 123
    JUST_JOINED_ALLIANCE = 124
    NO_SPY_DATA = 130
    TARGET_HAS_PEACE = 131
    PLAYER_HAS_PEACE = 132
    MISSING_BARON = 133
    AREA_NOT_CONQUERABLE = 134
    TAX_COLLECTOR_FINISHED = 135
    TAX_COLLECTOR_HAS_NO_MONEY = 136
    NO_FREE_RENAME = 137
    AREA_NOT_ABANDONABLE = 138
    ONLY_IN_MAIN_CASTLE = 139
    NOT_OWNED_LONG_ENOUGH = 140
    IN_ALLIED_ALLI = 141
    MAP_NOT_AVAILABLE = 142
    NOT_COMPLETED = 143
    NO_EVENT_BUILDING = 144
    NO_EVENT = 145
    LOCKED = 146
    NOTHING_TO_SKIP = 147
    ALREADY_TRANSFERING = 148
    NO_CAMP = 149
    INVALID_NODE = 150
    ALREADY_ACHIEVED_NODE = 151
    NO_SPACE = 152
    NO_PLAYER_FOUND = 153
    STORAGE_CAPACITY_REACHED = 154
    OTHER_ALLIANCE_REACHED_MAXIMUM = 155
    THIS_ALLIANCE_REACHED_MAXIMUM = 156
    REQUESTED_AMOUNT_NOT_ALLOWED = 157
    PACKAGE_NOT_IN_EVENT = 158
    PACKAGE_NOT_FOUND = 159
    ALREADY_HUNTING = 160
    OTHER_PLAYER_IN_OTHER_ALLI = 161
    ALREADY_ABANDONING_OUTPOST = 162
    ALREADY_RESEARCHING = 163
    PREREQUISITE_NOT_MATCHED = 164
    ALREADY_RESEARCHED = 165
    MAY_NOT_FORWARD = 166
    ALREADY_HAS_SPY_REPORT = 167
    ALLI_APPLICATION_EXISTS = 168
    ALLI_NOT_SEARCHING_MEMBERS = 169
    ALLI_REACHED_MAX_APLLICATIONS = 170
    ALLI_APPLICATION_NOT_EXISTS = 171
    CL_OBJECT_ALREADY_IN_LIST = 172
    MAILDOMAIN_BLOCKED = 173
    ALREADY_PURCHASED = 174
    INVALID_KINGDOM_ID = 175
    ALREADY_UNLOCKED = 176
    NOT_IN_THIS_KINGDOM = 177
    KINGDOM_NOT_AVAILABLE_FOR_USER = 178
    TARGETAREA_DOES_NOT_EXSIST = 179
    MAX_KINGDOM_GOODS_MOVEMENTS_EXCEEDED = 180
    MAX_KINGDOM_ARMY_MOVEMENTS_EXCEEDED = 181
    KINGDOM_MOVEMENTS_NOT_AVAILABLE = 182
    MULTIPLE_MOVEMENTS_AVAILABLE = 183
    VILLAGE_CAP_WOOD_REACHED = 184
    VILLAGE_CAP_STONE_REACHED = 185
    VILLAGE_CAP_FOOD_REACHED = 186
    NO_CONTOR = 187
    VILLAGE_WOULD_GET_LOST = 188
    INVALID_STARTAREA_FOR_CANCEL_MOVEMENT = 189
    CL_MOAT_ALREADY_IN = 190
    IS_ALREADY_ACHIEVED = 191
    NO_TARGET = 192
    ONLY_IN_CAPITAL = 193
    ALREADY_HAS_CAPITAL = 194
    NOT_ENOUGH_INGREDIENTS = 195
    NOT_IN_CAPITAL = 196
    IS_RELOCATING = 197
    RELOCATION_COOLDOWN_RUNNING = 198
    IS_RELOCATING_OTHER = 199
    RELOCATION_RESERVED = 200
    FACTION_ALREADY_CHOSEN = 201
    AREA_CANNOT_BUY_THIS = 202
    INVALID_AREA = 203
    SPECIALCAMP_PROTECTED = 204
    NO_MORE_TOWERS = 205
    FACTION_PLAYER_CAMP_LIMIT_REACHED = 206
    HUNTER_LEVEL_TOO_LOW = 207
    INVALID_CUSTOM_INVENTORY_OBJECT_ID = 208
    SPECIALEVENT_NOT_RUNNING = 209
    SPECIALEVENT_STILL_RUNNING = 210
    NOT_ENOUGH_POINTS = 211
    CASTLE_HAS_MOVEMENTS = 212
    ALREADY_REDEEMED = 213
    EQUIPMENT_NOT_FOUND = 214
    DIFFERENT_EQUIPMENT_RARENESS = 215
    RARENESS_TO_HIGH = 216
    BARON_IS_USED = 217
    COMMANDER_IS_USED = 218
    INVALID_LORD_ID = 219
    INVENTORY_FULL = 220
    EQUIPMENT_NOT_APPLICABLE = 221
    LORD_IN_MOVEMENT = 222
    INVALID_AMOUNT = 223
    IS_ABANDONING = 224
    MESSAGEDATA_TOO_OLD = 225
    ENCHANTMENTLEVEL_TO_HIGH = 226
    ENCHANTING_FAILED = 227
    MAX_MARKET_MOVEMENTS_TO_PLAYER_REACHED = 228
    NO_CHEST_AVAILABLE = 229
    CHEST_LOCKED = 230
    FORGE_FORBIDDEN = 231
    ALREADY_COLLECTED = 232
    TARGET_NOT_OWNED = 233
    ATTACK_IN_PROGRESS = 234
    SELECTED_FACTION_DISABLED = 235
    NOT_ENCHANTABLE = 236
    PACKAGE_MAX_BUY_REACHED = 237
    NAME_HAS_ONLY_NUMBERS = 238
    NOT_ENOUGH_KHAN_TABLETS = 239
    TOO_MANY_TOOLS = 240
    IS_NETWORK_ACCOUNT = 241
    MINE_IS_EMPTY = 242
    MINE_IS_COOLING_DOWN = 243
    PLAYER_IS_IN_OTHER_LEAGUE = 244
    TOO_MANY_MESSAGES_IN_ARCHIVE = 245
    TOPIC_NOT_FOUND = 246
    REPLY_NOT_FOUND = 247
    ALLI_IS_NOT_AUTO_JOIN_ENABLED = 248
    TOO_MANY_REPLIES = 249
    TOO_MANY_TOPICS = 250
    NOT_ENOUGH_SKULL_RELICS = 251
    ALREADY_HAS_METROPOL = 252
    NOT_IN_METROPOL = 253
    ONLY_IN_METROPOL = 254
    INVALID_ATTACK_TYPE = 255
    LORD_IS_USED = 256
    RESOURCE_CART_NOT_READY = 257
    NOT_ENOUGH_LOTTERY_TICKETS = 258
    ALLIANCE_DIFFERENCE_TOO_BIG = 259
    NOT_ENOUGH_PEARL_RELICS = 260
    FACTION_NPC_OBJECT_IS_PROTECTED = 261
    NO_MARKETPLACE = 262
    ORIENTATION_FULL = 263
    BOOSTER_REACHED_MAX_LEVEL = 264
    UNITS_WOULD_STARVE = 265
    VIP_MAX_TIME_REACHED = 266
    VIP_MAX_POINTS_REACHED = 267
    NO_RECRUITMENT = 268
    PACKAGE_NOT_HELPABLE = 269
    PLAYER_HAS_NO_ALLIANCE = 270
    NO_ALLIANCEHELP = 271
    NO_SELF_ALLIANCEHELP = 272
    NO_MULTIPLE_ALLIANCEHELP = 273
    INVALID_PRICE = 274
    NO_WORLDMAPOBJECT_FOUND = 275
    NO_FACTION_VILLAGE_FOUND = 276
    CAMPS_NOT_ATTACKABLE = 277
    PLAYER_IS_BANNED_FROM_ALLI = 278
    BOOKMARK_ALREADY_ADDED = 279
    BOOKMARK_MAX_ENTRYS = 280
    NO_SELF_TARGET = 281
    IS_OCCUPYING = 282
    IS_NOT_KING = 283
    CANNOT_ASSIGN_TO_SELF = 284
    ALREADY_HAS_TITLE = 285
    COOLING_DOWN_EQUIPMENT = 286
    NOT_IN_TIME_FOR_FREE_SKIP = 287
    NO_KAMIKAZE_CONQUER = 288
    ALLIANCE_ALREADY_HAS_PEACE_REQUEST = 289
    CAN_NOT_VOTE_IN_WORLD_CUP = 290
    NO_PLAYER_SPAWNED_YET = 291
    INVALID_EVENT_TOOL_USAGE = 292
    ALLIANCE_ALREADY_HAS_SOFT_ALLIED_REQUEST = 293
    ALLIANCE_ALREADY_HAS_REAL_ALLIED_REQUEST = 294
    BOOKMARK_IS_INVALID = 295
    IS_OCCUPIED = 296
    HAS_ALREADY_RUNNING_MISSION = 297
    GEM_NOT_FOUND = 298
    GEM_INVALID = 299
    GEM_CANNOT_BE_UPGRADED = 300
    GEM_STORAGE_FULL = 301
    GEM_ID_FULL = 302
    DID_NOT_BUY_CREST_SYMBOL = 303
    SYMBOL_NOT_UNLOCKED = 304
    PLAYER_NOT_IN_FACTION = 305
    ALLI_NOT_IN_HIGH_SCORE = 306
    CAPITAL_NOT_OWNED_LONG_ENOUGH = 307
    NOT_ENOUGH_SILVER_RUNES = 308
    NOT_ENOUGH_GOLD_RUNES = 309
    METROPOL_NOT_OWNED_LONG_ENOUGH = 310
    NOT_COOLING_DOWN = 311
    GIFT_EXPIRED = 312
    ATTACK_TOO_MANY_UNITS = 313
    NOT_ENOUGH_GREEN_SKULL_RELICS = 314
    WONT_REACH_IN_TIME = 315
    PLAYER_GIFT_STORAGE_FULL = 316
    TOO_MANY_PACKAGES_SENT_TODAY = 317
    INVALID_BOOKMARK_ID = 318
    INVALID_START_AREA = 319
    MONUMENT_REACHED_MAX_LEVEL = 320
    EMPTY_BOOKMARK = 321
    ALLIANCE_BOOKMARK_MAX_ENTRYS = 322
    RECEIVER_IS_EMPTY = 323
    INVALID_LOOT_PRIORITY = 324
    ALLI_TOO_LOW_MEMBER_BUFF = 325
    LEGEND_LEVEL_TOO_HIGH_OR_LOW = 326
    NOT_ENOUGH_SPECIAL_CURRENCY = 327
    PLAYER_NOT_IN_HIGH_SCORE = 328
    AREA_BECOMES_RUIN = 329
    ADD_LEGEND_SKILL_FAILED = 330
    ADD_LEGEND_SKILL_REQUIRED_SKILL_MISSING = 331
    ADD_LEGEND_SKILL_NOT_ENOUGH_SKILL_POINTS = 332
    ADD_LEGEND_SKILL_TIER_LOCKED = 333
    NOT_IN_WORLD_CHAT = 334
    NO_TIME_SKIP_LEFT = 335
    WRONG_AMOUNT_OF_BOUGHT_C2 = 336
    ADDITIONAL_KINGDOM_NOT_UNLOCKED = 337
    WISHING_WELL_NOT_FINISHED = 338
    NOT_ENOUGH_WISHINGWELLCOINS = 339
    STORAGE_CAPACITY_TO_LOW = 340
    LABORATORY_REACHED_MAX_LEVEL = 341
    PRIZE_CLASS_LIMIT_REACHED = 342
    MAX_MAILS_PER_DAY = 343
    MAX_MAILS_PER_MINUTE = 344
    MAX_MAILS_PER_EMAIL_PER_DAY = 345
    MAP_TIME_RAN_OUT = 346
    ALLI_TOO_LOW_MIGHT_POINTS = 347
    ALLI_LEVEL_TOO_LOW = 348
    ALLIANCE_EMBLEM_NOT_SET = 349
    ALLI_NO_NOBLE_HOUSE = 350
    EVENT_ALREADY_ENTERED = 351
    UNKNOWN_CAMP_TYPE = 352
    FACTION_LAST_MAN_STANDING_ACTIVE = 353
    ALL_SLOTS_ARE_PERMANENT = 354
    TITLE_NOT_AVAILABLE = 355
    NOT_ENOUGH_POINTS_FOR_TITLE = 356
    TITLE_SYSTEM_NOT_AVAILABLE = 357
    TITLE_ON_COOLDOWN = 358
    EXISTING_MAPPING_WRONG_SERVER = 368
    UNEXPECTED_FACEBOOK_ERROR = 369
    REGISTER_REDIRECTED_TO_LOGIN = 370
    FACEBOOK_MAPPING_NOT_ESTABLISHED = 371
    CONSTRUCTION_ITEM_NOT_FOUND = 372
    CONSTRUCTION_ITEM_COULD_NOT_BE_REMOVED = 373
    NO_FREE_CONSTRUCTION_ITEM_SLOT = 374
    LOCKED_CONSTRUCTION_ITEM_SLOT = 375
    CONSTRUCTION_ITEM_INVENTORY_FULL = 376
    CONSTRUCTION_ITEM_INVENTORY_MAX_AMOUNT_REACHED = 377
    SOME_INVERNTORY_IS_FULL = 378
    TARGET_EQUIPMENT_INVENTORY_FULL = 379
    FACEBOOK_WRONG_USER_ID = 380
    INVALID_SLOWDOWN_DURATION = 381
    STORED_DECORATION_NOT_FOUND = 382
    NOT_A_DECORATION = 383
    DECORATION_NOT_SELLABLE = 384
    ALLIANCE_TOO_LOW_REQUIRED_BUFF = 385
    INVALID_LEVEL = 388
    AB_TEST_NOT_ASSIGNED_TO_PLAYER = 389
    PLAYER_FRIEND_LIST_FULL = 390
    EVENT_ALREADY_ENDED = 391
    CONSTRUCTION_ITEM_LIMIT_FOR_TYPE_REACHED = 392
    ALREADY_CRAFTING_CONSTRUCTION_ITEM = 393
    NOT_ENOUGH_MATERIALS = 394
    NOT_ENOUGH_RAGE_POINTS = 395
    RELOCATION_PREVENTS_TAUNT = 396
    TAUNT_WONT_REACH_IN_TIME = 397
    ALLIANCE_FUNDS_FULL = 398
    CONSTRUCTION_ITEM_LOCKED = 399
    QUEST_ID_NOT_FOUND = 400
    REWARD_ID_NOT_FOUND = 401
    AREA_ALREADY_ATTACKED = 402
    AREA_BUSY = 403
    LORD_NEEDED = 404
    TICKET_NEEDED = 405
    NO_TICKET_AVAILABLE = 406
    EQUIPMENT_HAS_NO_GEM_SLOT = 407
    TROOPS_WONT_ARRIVE_IN_TIME = 408
    INVALID_LOGIN_TOKEN = 409
    INVALID_FUSION_SOURCE = 410
    INVALID_FUSION_TARGET = 411
    NOT_ENOUGH_FUSION_ENERGY = 412
    INVALID_CATALYST = 413
    MINUTESKIP_BLOCKED = 414
    PREMIUMSKIP_BLOCKED = 415
    FUSION_INVENTORY_FULL = 416
    FEATURE_NOT_ENABLED = 417
    VILLAGE_CAP_COAL_REACHED = 418
    VILLAGE_CAP_OIL_REACHED = 419
    VILLAGE_CAP_GLASS_REACHED = 420
    VILLAGE_CAP_IRON_REACHED = 421
    NOT_ENOUGH_PRIVATE_RESOURCE_VILLAGE_TOKEN = 422
    INVALID_GLOBALSERVER_LOGIN_TOKEN = 423
    REWARD_EXPIRED = 424
    LOSTANDFOUND_INVENTORY_FULL = 425
    INVALID_SLOT_ID = 426
    NO_ACTIVE_TRAINING = 427
    TARGET_SUPPORTED_BY_DIFFERENT_AREA = 428
    MAX_CONQUERABLE_ALLIANCE_LANDMARKS_REACHED = 429
    NEEDS_REPAIR = 430
    NO_DISTRICT = 431
    SCEAT_SKILL_ACTIVATION_IN_PROGRESS = 432
    INCOMPATIBLE_CIS_FOR_UPGRADE = 433
    PASSWORD_ALREADY_SET = 434
    NO_EXISTING_PASSWORD = 435
    NO_MORE_DAILY_SCORES_WILL_BE_CALCULATED = 436
    INVALID_EVENT_DIFFICULTY_ID = 437
    ALREADY_SELECTED_EVENT_DIFFICULTY_ID = 438
    LOCKED_EVENT_DIFFICULTY_ID = 439
    C2_CONFIRMATION_REQUIRED = 440
    RE_SEND_MAIL_COOLDOWN = 441
    INVALID_ABILITY_ID = 442
    TO_MANY_XP = 443
    TOO_MANY_PACKAGES = 444
    NO_SPACE_WARNING = 445
    CURRENCY_SOFT_CAP_OVERFLOW = 446
    TOO_MANY_MESSAGES = 447
    INVALID_DONATION_ITEM = 448
    DUPLICATE_ID = 449
    PASSWORD_COOLDOWN = 450
    NOT_ENOUGH_TIME = 451
    NOT_SUPPORTED = 452
    LOGIN_COOLDOWN = 453
    RESOURCE_PRODUCTION_CAP = 1001
    TOO_MANY_LEADERS = 1002
    QUICK_ATTACK_ENABLED = 1003
    IS_MINING_INFLUENCE = 1004
    MISSING_INFLUENCE_MINER = 1005
    MAX_CONQUERABLE_KINGS_TOWER_REACHED = 1006
    ALLIANCE_TOWER_NO_CHANGE = 1007
    REGISTRATION_RESTRICTED = 1008
    TOWER_DEPLETED = 1009
    INVALID_LANGUAGE = 1010
    ALLIANCE_LANGUAGE_CHANGE_NOT_ALLOWED = 1011
    NO_FREE_EMBLEM = 2000
    AGE_CHECK_FAILED_TIME_OF_DAY = 10000
    KOREA_ID_ALREADY_REGISTERED = 10001
    MISSING_KOREA_USER_DATA = 10002
    NO_KOREA_USER_DATA_AVAILABLE = 10003
    AGE_CHECK_FAILED_GAME_NOT_ALLOWED_FOR_AGE = 10004
    MISSING_KOREA_REQUEST_ID_PARAMETER = 10013
    SOCIAL_LOGIN_KEYS_INVALID = 10014

    @classmethod
    def from_code(cls, code: int) -> "GGEError":
        try:
            return cls(code)
        except ValueError:
            return cls.GENERAL_ERROR

    @property
    def is_ok(self) -> bool:
        return self == GGEError.ALL_OK

    @property
    def is_cooldown(self) -> bool:
        return self in (GGEError.COOLING_DOWN, GGEError.LOGIN_COOLDOWN)
