
#define GUILD      ("monk" || "testmonk")
#define GUILD2          "testmonk"              /* new guild */
#define HP 14 
#define SP 13
#define HPBASE (HP * 3)
#define SPBASE (SP * 3)
#define GM      "guild/master"
#define LGF     "GUILD.JOIN"

inherit "/players/whisky/obj/guild_room";

#include "std.h"
#include "/players/whisky/guild/titles.h"
/*-------------------------------------------------------*/
/* All the Advance, Cost, List stuff here        */
/* All the pretitles, titles and exp levels for a monk.  */
/*-------------------------------------------------------*/

/* dagmar strikte_typen */

#define TO      this_object()
#define TP      this_player()
#define TPL     TP->query_level()
#define TPN     this_player()->query_name()
#define MASTER  "Whisky"
#define env     environment
#define SAY(x)      tell_room(TO,x);
#undef  EXTRA_RESET 
#define EXTRA_RESET ::reset(); extra_reset(arg);
#undef  EXTRA_INIT
#define EXTRA_INIT  ::init();
 /*
#undef  EXTRA_MOVE1
#define EXTRA_MOVE1     if(!chk_leave())
  */

int guild; 
int i, join;

TWO_EXIT("players/whisky/guild/room/c2","west",
         "players/whisky/guild/room/c6","north",
         "In the Monks Guild", room_desc(),1)


room_desc()
{
  string desc;

desc =  
"                               |  |                                   \n"+
"                               |  |               Come here for       \n"+
"                               |  |               Satisfaction  !!!!  \n"+
"                       ========    =========                          \n"+
"                       ========    =========                          \n"+
"                               |  |                                   \n"+
"                               |  |               Enjoy the Nuns      \n"+
"                               |  |               and Monks of the    \n"+
"                               |  |               Blue Order !      \n"+
"                               |  |                                   \n"+
"========================================================================\n"+
"|   This is the Monks Guild. It's a silent place where the monks       |\n" +
"|   can pray and have their calm from the hectic of this world.        |\n" +
"|   Before joining this guild you should know that it's a guild of     |\n"+
"|   dexterity and wisdom. So check your race before you join !         |\n"+
"=========================================================================\n"+
"Commands: general, cost, advance,\n" +
"          list, list [number],\n" +
"          join, about or toplist.\n"; 
  if (!i)
      return(desc);
  else 
      return ( desc + "\nBuddah Whisky is here.\n\n");
}

add_init()
{
  add_action("do_about","about");
  add_action("do_toplist","toplist");
  add_action("do_general","general");
}

int do_general()
{
    cat("/players/whisky/guild/helpdir/general");
    return 1;
}

mixed no_advance()
{
    object ob;    

    ob = present("monks_chk",this_player());

    if (!ob || (ob && (ob->query_adv_level() < this_player()->query_level())) )
    {
       return("You first have to proof if you are worth to advance\n"+
              "by winning a challenge north of the meditation room.\n"+
              "If you are there and type 'read sign' you'll get the\n"+
             "conditions.\n");
    }
    return 2;
}
int do_about(string arg)
{
    if (!arg)
    {
       cat("/players/whisky/guild/helpdir/guild");
       return 1;
    }
    if (file_size("/players/whisky/guild/helpdir/"+arg)!=-1)
    {
       cat("/players/whisky/guild/helpdir/"+arg);
       return 1;
    }
    write("Sorry no help on that topic available.\n");
    return 1;
}

int do_toplist()
{
  object ob;
    call_other("/players/whisky/guild/room/challenge","???");
   
    write("Here is the list of the most honorable nuns and monks:\n\n");
    if (ob = find_object("/players/whisky/guild/room/challenge"))
        ob->show_list();
    return 1;
}
      
 do_advance()
{
    if (no_advance()!=2)
    {
       write(no_advance());
       return 1;
    }
   if (::do_advance() == 1) 
   {
   this_player()->guild_line(
   "is NOW level "+to_string(this_player()->query_level())+" !");
   return 1;
   }
  else
   return ::do_advance();
 }
extra_reset(arg) {
  if (arg) return;
  guild=GM->query_number(GUILD);
  set_guild(guild);
} 

do_join() 
{
  string quests;

   ::do_join();
  
  if (i)
  {
    write("Whisky whispers: You have to wait someone, is just joining.\n");
    say("Whisky whispers something to "+TPN+".\n");
    return 1;
  }
  i = 1; 
  call_out("my_now",1);
  SAY("Whisky steps in front of the altar.\n\n");
  if (TP->query_race()=="troll" || TP->query_race()=="orc" || TP->query_race()=="giant")
  {
      write("Whisky whispers to you: Sorry but you are not the proper race.\n");
      SAY("Whisky whispers something to "+TPN+".\n");
   }
  else if (((!TP->query_quests() || 
            !(member_array("millquest",explode(TP->query_quests(),"#"))+1)))) 
  {
      write("Whisky whispers to you: Please, help Hobbe the poor miller.\n"+
            "He has problems with his watermill. This will show me then\n"+
            "that you are worth to join our powerful guild.\n");
      say("Whisky whispers something to "+TPN+".\n");
  }
  else if ( TP->query_money() < ( 200 * TPL * (TPL/4+1)) ) 
  {
      write("Whisky whispers to you: Hmmm, you first need to gather "
            +(200*TP->query_level()*(TP->query_level()/4+1))+" coins\n"+
            "for the maintenance costs of our community.\n");
      say("Whisky whispers something to "+TPN+".\n");
  }
  else if (TP->query_gender()==2) 
  {
  write("Whisky whispers to you: Welcome, sister. Now you are now a\n"+
        "sweet member of the BLUE ORDER. You have joined a community, where\n"+
        "love and friendship with your ** grin ** brothers, and sisters\n"+
        "are high values. So be just nice to force this cummunity of love.\n");
        say("Whisky whispers something to "+TPN+".\n");
        ok_now();
        return 1;  
  } 
  else if (TP->query_gender()==1) 
 {
  write("Whisky whispers to you: Welcome, brother. Now you are a\n"+
        "sweet member of the BLUE ORDER. You have joined a community, where\n"+
        "love and friendship with your ** grin ** brothers, and sisters\n"+
        "are high values. So be just nice to force this cummunity of love.\n");
        say("Whisky whispers something to "+TPN+".\n");
        ok_now();
        return 1;
  } else 
     SAY("Whisky shrugs helplessly.\n");         
 call_out("do_wave",4);
 call_out("do_vanish",8); 
 return ( 1 );
}

my_now()
{
   i = 0;
}
do_wave()
{
  SAY("Whisky waves happily.\n");
}

do_vanish()
{
  SAY("Whisky turns a pentagram and vanishes.\n");
  i = 0;
}


ok_now() 
{
  
  TP->add_money( - ( 200 * TP->query_level() * (TP->query_level()/4+1) ) );
  log_file("whisky.join",TPN+" joined "+ctime(time())+".\n");  
  TP->set_guild(guild);

  tell_all();
  give_hat();
  write("Whisky hugs you.\n"); 
  say("Whisky hugs "+TPN+".\n");
  call_out("do_wave",4);
  call_out("do_vanish",8);
  say(TPN+" has joined the monks guild.\n");
  log_file(LGF,TPN+" joins the "+GUILD+"'s guild at "+
  ctime(time())+"\n");
             
   return ( 1 );
}

  
tell_all() 
{
     object *member;
     int i;
     
     member=users();
     
     for (i=1;i<sizeof(member);i++) {
       if ( member[i]->query_guild()==guild && member[i]!=TP) {
       tell_object(member[i],
          "[*Buddah Whisky*]: Hi, brothers and sisters :*) "+
           TPN+" has joined our GREAT guild !\n");
     }
    } 
    return ( 1 );
   }
   
  give_hat() {
    object hat;
     
     hat=clone_object("obj/armour");
     hat->set_name("hat");
     hat->set_alias("party hat");
     hat->set_short("A party hat");
     hat->set_long("This is a blue party hat. It shell show your\n"+
                   "brothers and sisters, that you are ready for a\n"+
                   "party to gather some experience !\n");
     hat->set_weight(1);
     hat->set_value(20);
     hat->set_type("helmet");
     hat->set_ac(0);
     
     move_object(hat,TP);
     
     write("Whisky smiles at you and gives you a small gift.\n");
     SAY("Whisky happily smiles at "+TPN+".\n");
     
    return ( 1 );
    }
     

 query_maxsp(lvl) 
 {
  return (SPBASE + lvl * SP);
 }
                       
 query_maxhp(lvl) 
{
  return (HPBASE + lvl * HP);
}
  
