Forms

#include "/d/Shifters/shifter.h"
object pen;
static mapping forms;
static mapping form_shapes;
static mapping durations;
static mapping advance_xp;
static mapping requirements;

create() {
 seteuid("Shifters");
 forms = ([ "feline" : ({ "basic", "cat" , "panther", "xaerre" }),
            "reptile": ({ "basic", "chameleon", "nelitos", "drakon" }),
            "forest" : ({ "basic", "flower", "tree", "treant" }),
            "earth"  : ({ "basic", "rock" , ROCK2, ROCK3}),
            "marsupial" : ({ "basic", "opossum" }),
            "amphibian" : ({ "basic", "frog" }),
            "flower"  : "forest",
            "tree"    : "forest",
            "treant"  : "forest",
            "cat"     : "feline",
            "panther" : "feline",
            "xaerre"   : "feline",
            "chameleon" : "reptile",
            "nelitos"  : "reptile",
            "drakon"  : "reptile",
            "rock"    : "earth",
            ROCK2     : "earth",
            ROCK3     : "earth",
            "opossum" : "marsupial",
            "frog"    : "amphibian" ]);

 form_shapes = ([ "opossum" : ({ "pigmy opossum", "stripy opossum", 
                                 "Kinder's opossum", "Dimwood opossum", 
                                 "ironwood opossum" }),
                  "frog"     : ({ "green tree frog", "little croaker", "bull frog",
                                  "Dog's Mouth frog", "big belcher" }),
                  "flower" : ({ "daisy", "moonflower", "saxifrage", "cactus",
                                "sunflower" }),
                  "tree"   : ({ "sapling", "yew tree", "fir tree", "oak tree",
                                "ash tree" }),
                  "treant" : ({ "softwood treant", "Syntulle treant",
                                "Ikoshian treant", "ironwood treant",
                                "forest ruler" }),
                  "cat"    : ({ "kitten","pussy cat", "alley cat", "tabby cat",
                                "feral cat" }),
                  "panther": ({ "cougar", "mountain lion", "puma", "jaguar",
                                "black panther" }),
                  "xaerre"  : ({ "xaerre recruit", "xaerre scout","xaerre warrior",
                                "xaerre leader","heroic xaerre" }),
                  "chameleon" : ({ "stunted chameleon","flat necked chameleon",
                                   "veiled chameleon", "ambanja chameleon",
                                   "rainbow chameleon" }),
                  "nelitos" : ({ "frilled neck lizard", "forked tongue lizard",
                                "goanna", "iguana", "nelitos dragon" }),
                  "drakon" : ({ "fledgling drakon","serpentine drakon",
                                "frosted drakon", "ember drakon",
                                "mystical drakon" }),
                  "rock"   : ({ "weathered lump of sandstone","ball of clay",
                                "quartz formation","block of iron",
                                "granite boulder" }),
                 ROCK2    : ({ "pile of sand", "puddle of mud",
                                "collection of crystal", "pile of magnetic balls",
                                "wall of lava" }),
                  ROCK3    : ({"amorphous "+ROCK3, "volatile "+ROCK3,
                               "established "+ROCK3,
                               "evolving "+ROCK3, "mercurial "+ROCK3 }),
                ]);

 durations = (["opossum"   :  ({  1350, 2700, 5400, 10800}),
               "frog"      :  ({  2700, 5400, 10800, 21600}),
//               "rock"      :  ({ 12600, 32400, 72000}),
               "rock"      :  ({  1800,  5400, 10800,  19800}),
               ROCK2       :  ({  5400, 14400, 28800,  52200}),
               ROCK3       :  ({ 14400, 37800, 75600, 136800}),
               "cat"       :  ({  1800,  5400, 10800,  19800}),
               "panther"   :  ({  5400, 14400, 28800,  52200}),
               "xaerre"    :  ({ 14400, 37800, 75600, 136800}),
               "flower"    :  ({  1800,  5400, 10800,  19800}),
               "tree"      :  ({  5400, 14400, 28800,  52200}),
               "treant"    :  ({ 14400, 37800, 75600, 136800}),
               "chameleon" :  ({  1800,  5400, 10800,  19800}),
               "nelitos"   :  ({  5400, 14400, 28800,  52200}),
               "drakon"    :  ({ 14400, 37800, 75600, 136800})
             ]);

 advance_xp = ([ "opossum"  : ({ 0,500,1000,2000,3500 }),
                 "frog"     : ({ 1000,2000,3500,5500,8000}),
                 "rock"     : ({  3000, 10000, 20000, 30000, 40000 }),
//                 "rock"     : ({ 10000,20000,30000,40000,50000 }),
                 ROCK2      : ({ 10000, 50000, 75000,100000,125000 }),
                 ROCK3      : ({ 10000,150000,200000,250000,300000 }),
                 "cat"      : ({  3000, 10000, 20000, 30000, 40000 }),
                 "panther"  : ({ 10000, 50000, 75000,100000,125000 }),
                 "xaerre"   : ({ 10000,150000,200000,250000,300000 }),
                 "flower"   : ({  3000, 10000, 20000, 30000, 40000 }),
                 "tree"     : ({ 10000, 50000, 75000,100000,125000 }),
                 "treant"   : ({ 10000,150000,200000,250000,300000 }),
                 "chameleon": ({  3000, 10000, 20000, 30000, 40000 }),
                 "nelitos"  : ({ 10000, 50000, 75000,100000,125000 }),
                 "drakon"   : ({ 10000,150000,200000,250000,300000 })
              ]);



 requirements = ([ "opossum" : ({ }),
                   "frog"     : ({ "opossum",3 }),
                   "rock"     : ({ "opossum",3 }),
                   ROCK2      : ({ "rock",3 }),
                   ROCK3      : ({ "rock", 5, ROCK2, 3 }),
                   "flower"   : ({ "opossum",3 }),
                   "tree"     : ({ "flower", 3 }),
                   "treant"   : ({ "flower", 5 , "tree", 3 }),
                   "cat"      : ({ "opossum", 3 }),
                   "panther"  : ({ "cat", 3 }),
                   "xaerre"    : ({ "cat", 5, "panther", 3 }),
                   "chameleon": ({ "opossum", 3 }),
                   "nelitos"   : ({ "chameleon", 3 }),
                   "drakon"   : ({ "chameleon", 5, "nelitos", 3 })
                 ]);

  pen = clone_object(OBJ+"pendant");
}

query_forms() {
  if (!check_previous()) return 0;
  return forms;
}

query_form(string form) {  // checks to see of form is valid
  return forms[form];
}

query_form_shapes() {
  if (!check_previous()) return 0;
  return form_shapes;
}

query_form_shape(string type,int size) {
 if (!check_previous()) return 0;
 if (size && form_shapes[type]) {
   return form_shapes[type][size-1];
 }
 return type;
}

query_duration(string type,int pos,int size, string who) {
  int mod;
  if (!check_previous()) return -1;
  if (!durations[type]) return -1;
// if (type == "general")
//   return durations[type][pos][size];
  if (who)
    if (find_player(who))
      return CLASSOB(find_player(who))->query_duration_modifier(who,type,durations[type][size]);
    else
      if (pen)
        return pen->query_duration_modifier(who,type,durations[type][size]);
      else {
        pen = clone_object(OBJ+"pendant");
        return pen->query_duration_modifier(who,type,durations[type][size]);
      }
 return durations[type][size];
}

query_advance_xp(string what, int pos, int size, string who) {
 if (!check_previous()) return -1;
 if (!advance_xp[what]) return -2;
// if (what == "general") {
//  return advance_xp["general"][pos][size];
// } else {
  if (who)
    if (find_player(who))
      return CLASSOB(find_player(who))->query_exp_modifier(who,what,advance_xp[what][size]);
    else
      if (pen)
        return pen->query_exp_modifier(who,what,advance_xp[what][size]);
      else {
        pen = clone_object(OBJ+"pendant");
        return pen->query_exp_modifier(who,what,advance_xp[what][size]);
      }
  return advance_xp[what][size];
// }
}

query_requirements(string shape) {
 if (!check_previous()) return 0;
 return requirements[shape];
}

int check_previous() {
 if (geteuid(previous_object()) != "Shifters" &&
     geteuid(previous_object()) != "paldin" &&
     geteuid(previous_object()) != "serf") return 0;
 return 1;
}