#ifndef Buildingtype_H
#define Buildingtype_H
// This file was generated by: extract_tileset_classes.py

#include <breeze.h>
#include <string.h>


typedef enum BuildingType {
    BUILDINGS_NONE,
    BUILDINGS_KEEP,
    BUILDINGS_GRANARY,
    BUILDINGS_ARMORY,
    BUILDINGS_WAREHOUSE,
    BUILDINGS_MINE,
    BUILDINGS_BARACKS,
    BUILDINGS_ORCHARD,
    BUILDINGS_ANIMAL_FARM,
    BUILDINGS_PLAYER_RED,
    BUILDINGS_FLETCHER,
    BUILDINGS_PLAYER_BLUE,
    BUILDINGS_SMITHY,
    BUILDINGS_WORKSHOP,
    BUILDINGS_FARM,
    BUILDINGS_ROAD,
    BUILDINGS_WALL,
    BUILDINGS_GATEHOUSE,
    BUILDINGS_TOWER,
    BUILDINGS_SMALL_TOWER,
    BUILDINGS_COUNT
} BuildingType;


static BuildingType getTileBuilding(BzTile tile) {
    switch (tile) {
        case 0:
        case 1:
        case 2:
        case 32:
        case 33:
        case 34:
        case 64:
        case 65:
        case 66:
             return BUILDINGS_KEEP;
        case 3:
             return BUILDINGS_GRANARY;
        case 4:
             return BUILDINGS_ARMORY;
        case 5:
             return BUILDINGS_WAREHOUSE;
        case 6:
        case 7:
        case 38:
        case 39:
             return BUILDINGS_MINE;
        case 8:
        case 9:
        case 40:
        case 41:
             return BUILDINGS_BARACKS;
        case 10:
        case 11:
        case 42:
        case 43:
             return BUILDINGS_ORCHARD;
        case 12:
        case 13:
        case 44:
        case 45:
             return BUILDINGS_ANIMAL_FARM;
        case 31:
             return BUILDINGS_PLAYER_RED;
        case 35:
        case 36:
             return BUILDINGS_FLETCHER;
        case 63:
             return BUILDINGS_PLAYER_BLUE;
        case 67:
        case 68:
             return BUILDINGS_SMITHY;
        case 72:
        case 73:
             return BUILDINGS_WORKSHOP;
        case 74:
             return BUILDINGS_FARM;
        case 96:
             return BUILDINGS_ROAD;
        case 97:
             return BUILDINGS_WALL;
        case 98:
             return BUILDINGS_GATEHOUSE;
        case 128:
        case 129:
        case 160:
        case 161:
             return BUILDINGS_TOWER;
        case 130:
             return BUILDINGS_SMALL_TOWER;
        default:
            return BUILDINGS_NONE;
    }
}

static BzTile getBuildingTile(BuildingType type) {
    switch (type) {
        case BUILDINGS_KEEP: return 0;
        case BUILDINGS_GRANARY: return 3;
        case BUILDINGS_ARMORY: return 4;
        case BUILDINGS_WAREHOUSE: return 5;
        case BUILDINGS_MINE: return 6;
        case BUILDINGS_BARACKS: return 8;
        case BUILDINGS_ORCHARD: return 10;
        case BUILDINGS_ANIMAL_FARM: return 12;
        case BUILDINGS_PLAYER_RED: return 31;
        case BUILDINGS_FLETCHER: return 35;
        case BUILDINGS_PLAYER_BLUE: return 63;
        case BUILDINGS_SMITHY: return 67;
        case BUILDINGS_WORKSHOP: return 72;
        case BUILDINGS_FARM: return 74;
        case BUILDINGS_ROAD: return 96;
        case BUILDINGS_WALL: return 97;
        case BUILDINGS_GATEHOUSE: return 98;
        case BUILDINGS_TOWER: return 128;
        case BUILDINGS_SMALL_TOWER: return 130;
        default: return -1;
    }
}

static BuildingType getBuildingFromStr(const char *str) {
    if (strncmp("keep", str, 4) == 0) return BUILDINGS_KEEP;
    if (strncmp("granary", str, 7) == 0) return BUILDINGS_GRANARY;
    if (strncmp("armory", str, 6) == 0) return BUILDINGS_ARMORY;
    if (strncmp("warehouse", str, 9) == 0) return BUILDINGS_WAREHOUSE;
    if (strncmp("mine", str, 4) == 0) return BUILDINGS_MINE;
    if (strncmp("baracks", str, 7) == 0) return BUILDINGS_BARACKS;
    if (strncmp("orchard", str, 7) == 0) return BUILDINGS_ORCHARD;
    if (strncmp("animal_farm", str, 11) == 0) return BUILDINGS_ANIMAL_FARM;
    if (strncmp("player_red", str, 10) == 0) return BUILDINGS_PLAYER_RED;
    if (strncmp("fletcher", str, 8) == 0) return BUILDINGS_FLETCHER;
    if (strncmp("player_blue", str, 11) == 0) return BUILDINGS_PLAYER_BLUE;
    if (strncmp("smithy", str, 6) == 0) return BUILDINGS_SMITHY;
    if (strncmp("workshop", str, 8) == 0) return BUILDINGS_WORKSHOP;
    if (strncmp("farm", str, 4) == 0) return BUILDINGS_FARM;
    if (strncmp("road", str, 4) == 0) return BUILDINGS_ROAD;
    if (strncmp("wall", str, 4) == 0) return BUILDINGS_WALL;
    if (strncmp("gatehouse", str, 9) == 0) return BUILDINGS_GATEHOUSE;
    if (strncmp("tower", str, 5) == 0) return BUILDINGS_TOWER;
    if (strncmp("small_tower", str, 11) == 0) return BUILDINGS_SMALL_TOWER;
    else return BUILDINGS_NONE;
}
static const char *getBuildingStr(BuildingType type) {
    switch (type) {
        case BUILDINGS_NONE: return "none";
        case BUILDINGS_KEEP: return "keep";
        case BUILDINGS_GRANARY: return "granary";
        case BUILDINGS_ARMORY: return "armory";
        case BUILDINGS_WAREHOUSE: return "warehouse";
        case BUILDINGS_MINE: return "mine";
        case BUILDINGS_BARACKS: return "baracks";
        case BUILDINGS_ORCHARD: return "orchard";
        case BUILDINGS_ANIMAL_FARM: return "animal_farm";
        case BUILDINGS_PLAYER_RED: return "player_red";
        case BUILDINGS_FLETCHER: return "fletcher";
        case BUILDINGS_PLAYER_BLUE: return "player_blue";
        case BUILDINGS_SMITHY: return "smithy";
        case BUILDINGS_WORKSHOP: return "workshop";
        case BUILDINGS_FARM: return "farm";
        case BUILDINGS_ROAD: return "road";
        case BUILDINGS_WALL: return "wall";
        case BUILDINGS_GATEHOUSE: return "gatehouse";
        case BUILDINGS_TOWER: return "tower";
        case BUILDINGS_SMALL_TOWER: return "small_tower";
        default: return NULL;
    }
}

static void getBuildingSize(BuildingType type, BzTile *outWidth, BzTile *outHeight) {
     switch (type) {
        case BUILDINGS_KEEP:
            if (outWidth) *outWidth = 3;
            if (outHeight) *outHeight = 3;
            break;
        case BUILDINGS_GRANARY:
            if (outWidth) *outWidth = 1;
            if (outHeight) *outHeight = 1;
            break;
        case BUILDINGS_ARMORY:
            if (outWidth) *outWidth = 1;
            if (outHeight) *outHeight = 1;
            break;
        case BUILDINGS_WAREHOUSE:
            if (outWidth) *outWidth = 1;
            if (outHeight) *outHeight = 1;
            break;
        case BUILDINGS_MINE:
            if (outWidth) *outWidth = 2;
            if (outHeight) *outHeight = 2;
            break;
        case BUILDINGS_BARACKS:
            if (outWidth) *outWidth = 2;
            if (outHeight) *outHeight = 2;
            break;
        case BUILDINGS_ORCHARD:
            if (outWidth) *outWidth = 2;
            if (outHeight) *outHeight = 2;
            break;
        case BUILDINGS_ANIMAL_FARM:
            if (outWidth) *outWidth = 2;
            if (outHeight) *outHeight = 2;
            break;
        case BUILDINGS_PLAYER_RED:
            if (outWidth) *outWidth = 1;
            if (outHeight) *outHeight = 1;
            break;
        case BUILDINGS_FLETCHER:
            if (outWidth) *outWidth = 2;
            if (outHeight) *outHeight = 1;
            break;
        case BUILDINGS_PLAYER_BLUE:
            if (outWidth) *outWidth = 1;
            if (outHeight) *outHeight = 1;
            break;
        case BUILDINGS_SMITHY:
            if (outWidth) *outWidth = 2;
            if (outHeight) *outHeight = 1;
            break;
        case BUILDINGS_WORKSHOP:
            if (outWidth) *outWidth = 2;
            if (outHeight) *outHeight = 1;
            break;
        case BUILDINGS_FARM:
            if (outWidth) *outWidth = 1;
            if (outHeight) *outHeight = 1;
            break;
        case BUILDINGS_ROAD:
            if (outWidth) *outWidth = 1;
            if (outHeight) *outHeight = 1;
            break;
        case BUILDINGS_WALL:
            if (outWidth) *outWidth = 1;
            if (outHeight) *outHeight = 1;
            break;
        case BUILDINGS_GATEHOUSE:
            if (outWidth) *outWidth = 1;
            if (outHeight) *outHeight = 1;
            break;
        case BUILDINGS_TOWER:
            if (outWidth) *outWidth = 2;
            if (outHeight) *outHeight = 2;
            break;
        case BUILDINGS_SMALL_TOWER:
            if (outWidth) *outWidth = 1;
            if (outHeight) *outHeight = 1;
            break;
        default:
            if (outWidth) *outWidth = 0;
            if (outHeight) *outHeight = 0;
            break;
    }
}

#endif //Buildingtype_H
