package eu.smoser.dungeongenerator.dungeon.objects;

import eu.smoser.dungeongenerator.util.Dice;

/**
 * Stores information about a treasure
 * @author MrMcX
 */
public class Treasure extends ADungeonObject{
    /**
     * Constructs a random treasure
     */
    public Treasure(){
        descString = "";
        switch(Dice.Roll(20, 1)){
            case 1: 
                descString = Dice.Roll(20, 1) + " Kreuzer";
                break;
            case 2: 
                descString = Dice.Roll(20, 1) + " Heller";
                break;
            case 3: 
                descString = Dice.Roll(20, 1) + " Silbertaler";
                break;
            case 4: 
                descString = Dice.Roll(20, 1) + " Dukaten";
                break;
            case 5:
            case 6:
            case 7: 
                descString = DetailedTreasure();
                break;
            case 8:
            case 9: 
                descString = DetailedTreasure() + "; außerdem " + DetailedTreasure();
                break;
            case 10:
                descString = "uralte Waffe/Rüstung";        
                break;
            case 11: 
                descString = "ziemlich neue Waffe/Rüstung";
                break;
            case 12: 
                descString = "hervorragende Waffe/Rüstung";
                break;
            case 13: 
                descString = Dice.Roll(6, 1) + " goldene Trinkpokale mit jeweils 5 kleinen Rubinen";
                break;
            case 14: 
                descString = "Skelett mit einer kompletten Höhlenforscherausrüstung (Q7 127)";
                break;
            case 15: 
                descString = "ein paar Holz-/Knochenwürfel";
                break;
            case 16: 
                descString = "eine zerbrochene Phiole";
                break;
            case 17: 
                switch(Dice.Roll(6, 1)){
                    case 1:
                    case 2:
                    case 3: 
                        descString = "eine Phiole mit einem Heiltrank darin";
                        break;
                    case 4: 
                        descString = "eine Phiole mit einem Astraltrank darin";
                        break;
                    case 5: 
                        descString = "eine Phiole mit einem Eigenschaftselixier darin";
                        break;
                    case 6: 
                        descString = "eine Phiole mit einem Halbgift darin";
                        break;
                }
                break;
            case 18: 
                descString = "Götterstatue/-amulett";
                break;
            case 19: 
                descString = "magisches Artefakt, dessen Ladungen alle verbraucht sind";
                break;
            case 20: 
                descString = "magisches Artefakt";
                break;
        }
    }
    
    /**
     * Generates a handfull of treasures
     * @return description of tresure
     */
    public static String DetailedTreasure(){
        switch(Dice.Roll(20,1)){
            case 1:
            case 2:
            case 3:
            case 4: return Coins();
            case 5:
            case 6:
            case 7:
            case 8:
            case 9: return Jewelry();
            case 10:
            case 11:
            case 12:
            case 13:
            case 14: return Gem();
            case 15:
            case 16: return Coins() + "; " + Jewelry();
            case 17:
            case 18: return Coins() + "; " + Gem();
            case 19: return Jewelry() + "; " + Gem();
            case 20: return Coins() + "; " + Jewelry() + "; " + Gem();
        }
        return "";
    }
    
    private static String Coins(){
        switch(Dice.Roll(20,1)){
            case 1:
            case 2: return Dice.Roll(20, 2) + " Kreuzer";
            case 3:
            case 4: return Dice.Roll(20, 2) + " Heller";
            case 5:
            case 6: return Dice.Roll(20, 2) + " Silbertaler";
            case 7:
            case 8: return Dice.Roll(20, 2) + " Dukaten";
            case 9: 
            case 10: return "Je " + Dice.Roll(20, 1) + " Kreuzer und Heller";
            case 11:
            case 12: return "Je " + Dice.Roll(20, 1) + " Kreuzer, Heller und Silbertaler";
            case 13:
            case 14: return "Je " + Dice.Roll(20, 1) + " Kreuzer, Heller, Silbertaler und Dukaten";
            case 15:
            case 16: return "Je " + Dice.Roll(20, 2) + " Silbertaler und Dukaten";
            case 17:
            case 18: return "Je " + Dice.Roll(20, 1) + " Kreuzer, Heller, Silbertaler und Dukaten";
            case 19: 
            case 20: return Dice.Roll(20, 3) + " Dukaten";
        }
        return "";
    }
    
    private static String Jewelry(){
        switch(Dice.Roll(20,1)){
            case 1:
            case 2: return Material() + "-Amulett";
            case 3:
            case 4: return Material() + "-Armreif";
            case 5:
            case 6: return Material() + "-Brosche";
            case 7:
            case 8: return Material() + "-Diadem";
            case 9: 
            case 10: return Material() + "-Kette";
            case 11:
            case 12: return Material() + "-Ohrring";
            case 13:
            case 14: return Material() + "-Ring";
            case 15: return Material() + "-Armreif mit eingearbeitetem " + Gem();
            case 16: return Material() + "-Brosche besetzt mit " + Dice.Roll(6, 1) + " " + Gem();
            case 17: return Material() + "-Diadem besetzt mit " + Dice.Roll(6, 1) + " " + Gem();
            case 18: return Material() + "-Kette mit Anhänger mit einem " + Gem();
            case 19: return Material() + "-Ohrring mit einem " + Gem();
            case 20: return Material() + "-Ring mit einem " + Gem();
        }
        return "";
    }
    
    private static String Material(){
        switch(Dice.Roll(20,1)){
            case 1: return "rostige(s/r) Eisen";
            case 2: return "Eisen";
            case 3: return "Zinn";
            case 4:
            case 5: return "Messing";
            case 6:
            case 7: return "Bronze";
            case 8:
            case 9: return "Kupfer";
            case 10:
            case 11:
            case 12:
            case 13:
            case 14: return "Silber";
            case 15:
            case 16:
            case 17: return "Gold";
            case 18:
            case 19: return "Elektrum";
            case 20: return (Dice.Roll(6,1)==6 ? "Mindorium" : "Mondsilber");
        }
        return "";
    }
    
    private static String Gem(){
        switch(Dice.Roll(20,1)){
            case 1: 
            case 2: return "Speckstein (weiß/braun/rot, " + Karat() + ")";
            case 3: 
            case 4: return "Obsidian (schwarz, " + Karat() + ")";
            case 5: 
            case 6: return "Malachit (dunkelgrün, " + Karat() + ")";
            case 7: 
            case 8: return "Achat (rot/braun/grün, " + Karat() + ")";
            case 9: return "Türkis (grün-blau, " + Karat() + ")";
            case 10: return "Aventurin (grünlich, " + Karat() + ")";
            case 11: return "Turmalin (farblos, " + Karat() + ")";
            case 12: return "Obsidian (rot, " + Karat() + ")";
            case 13: return "Jade (grün, " + Karat() + ")";
            case 14: return "Topas (farblos, " + Karat() + ")";
            case 15: return "Opal (milchig, " + Karat() + ")";
            case 16: return "Feueropal (rot schimmernd, " + Karat() + ")";
            case 17: return "Smaragd (grün, " + Karat() + ")";
            case 18: return "Saphir (blau, " + Karat() + ")";
            case 19: return "Rubin (rot, " + Karat() + ")";
            case 20: return "Diamant (durchsichtig, " + Karat() + ")";
        }
        return "";
    }
    
    private static String Karat(){
        switch(Dice.Roll(6,2)){
            case 2: return Dice.Roll(20, 2) + " Karat";
            case 3: 
            case 4: return Dice.Roll(6, 2) + " Karat";
            case 5: 
            case 6: return Dice.Roll(6, 1) + " Karat";
            case 7:
            case 8:
            case 9: return (int) Math.ceil(Dice.Roll(6, 1)/2f) + " Karat";
            case 10: return (Dice.Roll(6, 3)+3) + " Karat";
            case 11: return Dice.Roll(6, 5) + " Karat";
            case 12: return (Dice.Roll(20, 1)+10) + " Karat";
        }
        return "";
    }
    
    //TODO: other items (p. 188)
}
