contract CardConfig {
    enum Type {Monster, Spell} // More could come!

    enum Race {Dragon, Spiderling, Demon, Humanoid, Beast, Undead, Elemental, Vampire, Serpent, Mech, Golem, Parasite}
    uint16 constant numRaces = 12;

    enum Trait {Normal, Fire, Poison, Lightning, Ice, Divine, Shadow, Arcane, Cursed, Void}
    uint16 constant numTraits = 10;

    function getType(uint32 randomSeed) public constant returns (uint8) {
        if (randomSeed % 5 > 0) { // 80% chance for monster (spells are less fun so make up for it in rarity)
            return uint8(Type.Monster);
        } else {
            return uint8(Type.Spell);
        }
    }
    
    function getRace(uint32 randomSeed) public constant returns (uint8) {
        return uint8(Race(randomSeed % numRaces));
    }

    function getTrait(uint32 randomSeed) public constant returns (uint8) {
        return uint8(Trait(randomSeed % numTraits));
    }

    SpellAbilities spellAbilities = new SpellAbilities();
    SharedNeutralMutations neutralMutations = new SharedNeutralMutations();
    DragonMutations dragonMutations = new DragonMutations();
    SpiderlingMutations spiderlingMutations = new SpiderlingMutations();
    DemonMutations demonMutations = new DemonMutations();
    HumanoidMutations humanoidMutations = new HumanoidMutations();
    BeastMutations beastMutations = new BeastMutations();
    UndeadMutations undeadMutations = new UndeadMutations();
    ElementalMutations elementalMutations = new ElementalMutations();
    VampireMutations vampireMutations = new VampireMutations();
    SerpentMutations serpentMutations = new SerpentMutations();
    MechMutations mechMutations = new MechMutations();
    GolemMutations golemMutations = new GolemMutations();
    ParasiteMutations parasiteMutations = new ParasiteMutations();
    

    // The powerful schema that will allow the Workshop (crystal) prices to fluctuate based on performance, keeping the game fresh & evolve over time!
    
    function getCostForRace(uint8 race) public constant returns (uint8 cost) {
        return 0; // born equal (under current config)
    }
    
    function getCostForTrait(uint8 trait) public constant returns (uint24 cost) {
        if (trait == uint8(CardConfig.Trait.Normal)) {
            return 0;
        }
        return 40000;
    }
    
    function getSpellAbility(uint32 randomSeed) public constant returns (uint24 cost, uint8 spell) {
        spell = uint8(spellAbilities.getSpell(randomSeed)) + 1;
        return (getSpellAbilityCost(spell), spell);
    }
    
    function getSpellAbilityCost(uint8 spell) public constant returns (uint24 cost) {
        return 100000;
    }

    function getNeutralMutation(uint32 randomSeed) public constant returns (uint24 cost, uint8 mutation) {
        mutation = uint8(neutralMutations.getMutation(randomSeed)) + 1;
        return (getNeutralMutationCost(mutation), mutation);
    }
    
    function getNeutralMutationCost(uint8 mutation) public constant returns (uint24 cost) {
        if (mutation == 0) {
            return 0;   
        }
        return 40000;
    }

    function getMutationForRace(Race race, uint32 randomSeed) public constant returns (uint24 cost, uint8 mutation) {
        if (race == Race.Dragon) {
            mutation = uint8(dragonMutations.getRaceMutation(randomSeed)) + 1;
        } else if (race == Race.Spiderling) {
            mutation = uint8(spiderlingMutations.getRaceMutation(randomSeed)) + 1;
        } else if (race == Race.Demon) {
            mutation = uint8(demonMutations.getRaceMutation(randomSeed)) + 1;
        } else if (race == Race.Humanoid) {
            mutation = uint8(humanoidMutations.getRaceMutation(randomSeed)) + 1;
        } else if (race == Race.Beast) {
            mutation = uint8(beastMutations.getRaceMutation(randomSeed)) + 1;
        } else if (race == Race.Undead) {
            mutation = uint8(undeadMutations.getRaceMutation(randomSeed)) + 1;
        } else if (race == Race.Elemental) {
            mutation = uint8(elementalMutations.getRaceMutation(randomSeed)) + 1;
        } else if (race == Race.Vampire) {
            mutation = uint8(vampireMutations.getRaceMutation(randomSeed)) + 1;
        } else if (race == Race.Serpent) {
            mutation = uint8(serpentMutations.getRaceMutation(randomSeed)) + 1;
        } else if (race == Race.Mech) {
            mutation = uint8(mechMutations.getRaceMutation(randomSeed)) + 1;
        } else if (race == Race.Golem) {
            mutation = uint8(golemMutations.getRaceMutation(randomSeed)) + 1;
        } else if (race == Race.Parasite) {
            mutation = uint8(parasiteMutations.getRaceMutation(randomSeed)) + 1;
        }
        return (getRaceMutationCost(race, mutation), mutation);
    }
    
    function getRaceMutationCost(Race race, uint8 mutation) public constant returns (uint24 cost) {
        if (mutation == 0) {
            return 0;   
        }
        return 40000;
    }
    
    function getCostForHealth(uint8 health) public constant returns (uint24 cost) {
        return health * uint24(2000);
    }
    
    function getHealthForCost(uint32 cost) public constant returns (uint32 health) {
        health = cost / 2000;
        if (health > 98) { // 1+[0-98] (gotta have [1-99] health)
            health = 98;
        }
        return health;
    }
    
    function getCostForAttack(uint8 attack) public constant returns (uint24 cost) {
        return attack * uint24(2000);
    }
    
    function getAttackForCost(uint32 cost) public constant returns (uint32 attack) {
       attack = cost / 2000;
        if (attack > 99) {
            attack = 99;
        }
        return attack;
    }
    
}
function getCostForRace(uint8 race) public constant returns (uint8 cost) {
        return 0; // born equal (under current config)
    }
// The powerful schema that will allow the Workshop (crystal) prices to fluctuate based on performance, keeping the game fresh & evolve over time!