/*
Work in progress
 */

class StyleSheet {

    build(builder) {

        this.addTerrainColors(builder);

        builder.style("#water").color("map.water").useBiomeWaterColor();        
        builder.style("#lava").color("map.lava");
        builder.style("#tar").color("map.tar");

        builder.style("#grass").color("map.grass").useBiomeGrassColor().adjustLightness(1.15);

        builder.style("#deco").color("map.deco");
        builder.style("#cloth").color("map.cloth");
        builder.style("#furniture").color("map.furniture");

        builder.style("Plant_*").color("map.plant");
        builder.style("Plant_Vine, Plant_Vine_*").color("map.vine");        
        builder.style("Plant_Leaves_*").color("map.leaves");        
        builder.style("Plant_Leaves_Ash").color("map.leaves.ash");
        builder.style("Plant_Leaves_Autumn").color("map.leaves.autumn");
        builder.style("Plant_Leaves_Oak").color("map.leaves.oak");
        builder.style("Plant_Leaves_Burnt").color("map.leaves.burnt");
        builder.style("Plant_Leaves_Fire").color("map.leaves.fire");
        builder.style("Plant_Leaves_Beech").color("map.leaves.beech");
        builder.style("Plant_Leaves_Birch").color("map.leaves.birch");
        builder.style("Plant_Leaves_Bottle").color("map.leaves.bottle");
        builder.style("Plant_Leaves_Maple").color("map.leaves.maple");
        builder.style("Plant_Leaves_Aspen").color("map.leaves.aspen");
        builder.style("Plant_Leaves_Azure").color("map.leaves.azure");
        builder.style("Plant_Leaves_Petrified").color("map.leaves.petrified");
        builder.style("Plant_Leaves_Dead").color("map.leaves.dead");
        builder.style("Plant_Leaves_Dry").color("map.leaves.dry");
        builder.style("Plant_Leaves_*_Snow").color("map.leaves.snow");
        builder.style("Plant_Leaves_Palo").color("map.leaves.palo");

        builder.style("Wood_*").color("map.wood");
        builder.style("Wood_Ash_*").color("map.wood.ash");
        builder.style("Wood_Azure_*").color("map.wood.azure");
        builder.style("Wood_Fire_*").color("map.wood.fire");
        builder.style("Wood_Blackwood_*").color("map.wood.blackwood");
        builder.style("Wood_Burnt_*").color("map.wood.burnt");
        builder.style("Wood_Deadwood_Roof**").color("map.wood.deadwood.roof");

        builder.style("Plant_Moss_*_Green").color("map.moss.green");
        builder.style("Plant_Moss_*_Blue").color("map.moss.blue");
        builder.style("Plant_Moss_*_Yellow").color("map.moss.yellow");

        builder.style("Plant_Bush_Dead, Plant_Bush_Dead_*").color("map.bush.dead");
        builder.style("Plant_Bush_Lush, Plant_Bush_Lush_*").color("map.bush.lush");

        builder.style("Plant_Bush_Arid_Red").color("map.bush.arid.red");
        builder.style("Plant_Bush_Winter").color("map.bush.winter");
        builder.style("Plant_Bush_Crystal").color("map.bush.crystal");

        builder.style("Plant_Crop_*_Burnt").color("map.leaves.burnt");

        builder.style("Plant_Fruit_Azure").color("map.fruit.azure");

        builder.style("Plant_Moss_Rug_Blue").color("map.moss.blue");

        builder.style("Plant_Crop_Mushroom_Glowing_Blue").color("map.mushroom.glowing.blue");
        builder.style("Plant_Crop_Mushroom_Common_Blue").color("map.mushroom.blue");
        builder.style("Plant_Crop_Mushroom_Glowing_Violet").color("map.mushroom.glowing.violet");
        builder.style("Plant_Crop_Mushroom_Common_Violet").color("map.mushroom.violet");

        builder.style("Plant_Flower_*_Blue").color("map.flower.blue");

        builder.style("Plant_Bramble_Moss_Twisted").color("map.bramble.moss");
        builder.style("Plant_Bramble_Dead_Lavathorn").color("map.bramble.lavathorn");
        
        


        builder.style("#rubble").color("map.rubble");

        builder.style("Rock_*").color("map.rock");
        builder.style("Rock_Stone**").color("map.rock.stone");
        builder.style("Rock_Stone_Mossy").color("map.rock.stone.mossy");
        builder.style("Rock_Basalt**, Rubble_Basalt**").color("map.rock.basalt");
        builder.style("Rock_Ice").color("map.rock.ice");
        builder.style("Rock_Magma_Cooled").color("map.rock.magmacooled");
        builder.style("Rock_Sandstone**").color("map.rock.sandstone");
        builder.style("Rock_Sandstone_Red**").color("map.rock.sandstone.red");
        builder.style("Rock_Slate**, Rubble_Slate**").color("map.rock.slate");
        builder.style("Rock_Volcanic**, Rubble_Volcanic**").color("map.rock.volcanic");
        builder.style("Rock_Volcanic_Cracked_Lava").color("map.rock.volcanic.crackedlava");
        builder.style("Rock_Marble**").color("map.rock.marble");
        builder.style("Rock_Chalk**").color("map.rock.chalk");
        builder.style("Rock_Crystal_Cyan**").color("map.crystal.cyan");

        builder.style("Soil_*").color("map.soil");
        builder.style("Soil_Ash").color("map.soil.ash");
        builder.style("Soil_Dirt").color("map.soil.dirt");
        builder.style("Soil_Dirt_Burnt").color("map.soil.dirt.burnt");
        builder.style("Soil_Dirt_Dry").color("map.soil.dirt.dry");
        builder.style("Soil_Dirt_Poisoned").color("map.soil.dirt.poisoned");
        builder.style("Soil_Dirt_Cold").color("map.soil.dirt.cold");

        builder.style("#soil.mud").color("map.soil.mud");
        builder.style("#soil.mud.dry").color("map.soil.mud.dry");
        builder.style("#soil.hive").color("map.soil.hive");
        
        builder.style("Soil_Leaves").color("map.soil.grass").useBiomeGrassColor();        
        builder.style("Soil_Gravel").color("map.soil.gravel");
        builder.style("Soil_Gravel_Sand").color("map.soil.gravel.sand");
        builder.style("Soil_Pebbles").color("map.soil.pebbles");        
        builder.style("Soil_Snow").color("map.soil.snow");

        builder.style("#soil.grass").color("map.soil.grass").useBiomeGrassColor();        
        builder.style("#soil.grass.dry").color("map.soil.grass.dry");        
        builder.style("Soil_Grass_Burnt").color("map.soil.grass.burnt");
        builder.style("Soil_Grass_Cold").color("map.soil.grass.cold");

        builder.style("#soil.sand").color("map.soil.sand");
        builder.style("#soil.sand.ashen").color("map.soil.sand.ashen");
        builder.style("#soil.sand.red").color("map.soil.sand.red");
        builder.style("#soil.sand.white").color("map.soil.sand.white");

        builder.style("Soil_Gravel_Sand_White").color("map.soil.gravel.sand.white");
        builder.style("Soil_Gravel_Sand_Red").color("map.soil.gravel.sand.red");
        builder.style("Soil_Clay").color("map.soil.clay");
        builder.style("Soil_Clay_Red").color("map.soil.clay.red");

        builder.style("#ore.adamantite").color("map.ore.adamantite");
        builder.style("#ore.cobalt").color("map.ore.cobalt");
        builder.style("#ore.copper").color("map.ore.copper");
        builder.style("#ore.gold").color("map.ore.gold");
        builder.style("#ore.iron").color("map.ore.iron");
        builder.style("#ore.silver").color("map.ore.silver");
        builder.style("#ore.thorium").color("map.ore.thorium");

        

        builder.style("Deco_Fire").color("map.fire");
        builder.style("Rail").color("map.rail");

        
        
    }

    addTerrainColors(builder) {

        var waterSaturation = 80;
        var waterLightness = 50;
        builder.color("map.water", 222, waterSaturation, waterLightness);

        builder.color("map.tar", 19, 25, 18);

        builder.color("map.snow", 0, 0, 90);        
        builder.color("map.lava", 18, 90, 50);
        
        builder.color("map.rock", 0, 0, 70);
        builder.color("map.rock.stone", 54, 15, 35);
        builder.color("map.rock.stone.mossy", 75, 30, 35);
        builder.color("map.rock.basalt", 54, 17, 24);
        builder.color("map.rock.ice", 204, 50, 70);
        builder.color("map.rock.magmacooled", 330, 9, 9);
        builder.color("map.rock.sandstone", 33, 45, 50);
        builder.color("map.rock.sandstone.red", 24, 45, 35);
        builder.color("map.rock.slate", 210, 3, 16);
        builder.color("map.rock.volcanic", 7, 9, 19);
        builder.color("map.rock.volcanic.crackedlava", 4, 15, 19);
        builder.color("map.rock.marble", 60, 7, 70);
        builder.color("map.rock.chalk", 42, 13, 70);

        builder.color("map.crystal.cyan", 192, 55, 60);

        builder.color("map.rubble", 0, 0, 60);

        builder.color("map.soil", 87, 36, 47);
        builder.color("map.soil.ash", 180, 1, 23);
        builder.color("map.soil.grass", 87, 36, 47);
        builder.color("map.soil.grass.cold", 196, 45, 94);
        builder.color("map.soil.grass.burnt", 27, 35, 21);
        builder.color("map.soil.grass.dry", 24, 60, 90);
        builder.color("map.soil.gravel", 54, 20, 38);
        builder.color("map.soil.gravel.sand.white", 42, 50, 53);
        builder.color("map.soil.snow", 192, 57, 91);
        builder.color("map.soil.dirt", 37, 52, 36);
        builder.color("map.soil.dirt.burnt", 27, 32, 24);
        builder.color("map.soil.dirt.cold", 33, 12, 25);
        builder.color("map.soil.dirt.dry", 36, 43, 44);
        builder.color("map.soil.dirt.poisoned", 0, 18, 23);
        builder.color("map.soil.gravel", 54, 20, 38);
        builder.color("map.soil.gravel.sand", 42, 50, 50);
        builder.color("map.soil.gravel.sand.red", 27, 50, 45);
        builder.color("map.soil.hive", 24, 35, 30);        
        builder.color("map.soil.pebbles", 48, 14, 60);
        builder.color("map.soil.mud", 18, 42, 22);
        builder.color("map.soil.mud.dry", 24, 45, 30);
        builder.color("map.soil.clay", 27, 45, 50);
        builder.color("map.soil.clay.red", 15, 45, 30);

        builder.color("map.soil.sand", 42, 60, 54);
        builder.color("map.soil.sand.ashen", 60, 6, 60);
        builder.color("map.soil.sand.red", 30, 50, 46);
        builder.color("map.soil.sand.white", 45, 65, 65);

        builder.color("map.ore.adamantite", 354, 70, 24);
        builder.color("map.ore.cobalt", 208, 37, 24);
        builder.color("map.ore.copper", 24, 54, 38);
        builder.color("map.ore.gold", 42, 82, 42);
        builder.color("map.ore.iron", 69, 3, 50);
        builder.color("map.ore.silver", 290, 4, 72);
        builder.color("map.ore.thorium", 112, 54, 22);

        
        builder.color("map.grass", 87, 36, 48);

        builder.color("map.plant", 96, 60, 60);

        //const leavesLightness = 26;
        const leavesLightness = 24;

        builder.color("map.vine", 112, 44, leavesLightness);

        builder.color("map.moss.green", 90, 60, leavesLightness * 1.25);
        builder.color("map.moss.blue", 160, 70, leavesLightness);
        builder.color("map.moss.yellow", 60, 75, leavesLightness);

        builder.color("map.leaves", 102, 80, leavesLightness);
        

        builder.color("map.leaves.ash", 138, 60, leavesLightness);
        builder.color("map.leaves.aspen", 42, 85, leavesLightness * 1.5);

        builder.color("map.leaves.azure", 204, 70, leavesLightness);
        builder.color("map.leaves.autumn", 23, 75, leavesLightness * 1.5);
        builder.color("map.leaves.burnt", 240, 1, leavesLightness * 0.65);
        builder.color("map.leaves.fire", 6, 45, leavesLightness * 0.65);
        builder.color("map.leaves.dead", 9, 23, leavesLightness * 0.65);
        builder.color("map.leaves.dry", 54, 60, leavesLightness * 1.25);
        builder.color("map.leaves.bottle", 66, 60, leavesLightness * 1.25);

        builder.color("map.fruit.azure", 204, 70, leavesLightness * 1.25);


        builder.color("map.leaves.beech", 90, 70, leavesLightness);
        builder.color("map.leaves.birch", 72, 75, leavesLightness * 1.5);
        builder.color("map.leaves.maple", 6, 60, leavesLightness * 1.5);
        builder.color("map.leaves.palo", 36, 65, leavesLightness * 2);

        builder.color("map.leaves.oak", 96, 70, leavesLightness);
        builder.color("map.leaves.petrified", 236, 8, leavesLightness);

        builder.color("map.leaves.snow", 0, 0, 85);

        builder.color("map.bush.dead", 9, 23, leavesLightness * 0.65);
        builder.color("map.bush.lush", 141, 50, leavesLightness);
        builder.color("map.bush.arid.red", 9, 70, leavesLightness * 2);
        builder.color("map.bush.winter", 213, 6, leavesLightness * 1.5);
        builder.color("map.bush.crystal", 24, 100, leavesLightness * 2);

        builder.color("map.bramble.moss", 81, 50, leavesLightness * 1.5);
        builder.color("map.bramble.lavathorn", 225, 25, leavesLightness * 0.65);

        builder.color("map.moss.blue", 160, 65, 30);

        builder.color("map.mushroom.blue", 186, 95, 34);
        builder.color("map.mushroom.glowing.blue", 186, 95, 75);
        builder.color("map.mushroom.violet", 240, 42, 34);
        builder.color("map.mushroom.glowing.violet", 240, 42, 75);

        builder.color("map.flower.blue", 198, 55, 45);

        builder.color("map.wood", 42, 50, 50);
        builder.color("map.wood.ash", 15, 30, 20);
        builder.color("map.wood.azure", 348, 25, 30);
        builder.color("map.wood.burnt", 0, 0, 17);
        builder.color("map.wood.fire", 12, 70, 25);
        builder.color("map.wood.blackwood", 42, 10, 12);
        builder.color("map.wood.deadwood.roof", 39, 30, 42);

        builder.color("map.deco", 0, 0, 80);
        builder.color("map.cloth", 0, 0, 75);
        builder.color("map.furniture", 0, 0, 70);
        builder.color("map.fire", 24, 100, 60);

        builder.color("map.rail", 42, 100, 50);
    }

}



