#include "local.h"
inherit DHOME+"/std/room";
  /* What type of guild are we, occupational, layman, race, or minor */
#define GUILD_TYPE  "race"
  /* What style are we, fighter, magic, cleric, thief, or any other?? */
#define GUILD_STYLE "ranger"
  /* Hopefully a unique name of the guild. */
#define GUILD_NAME  "Straznicy Krainy"
  /* Name of the file the shadow is defined in */
#define SHADOW      HOME + "hobbit_s"

create_imperium_room()
{
    set_short("Hol gildii Straznikow Krainy.\n");
    set_long("Znajdujesz sie w Glownym holu gildii Straznikow Krainy"+
      " mozesz tutaj przylaczyc sie do niej jezeli taka jest twoja wola"+
      " lecz lepiej abys przeczytal wpierw na jej temat w bibliotece"+
      " mieszcacej sie pietro nizej. 
	     "here. List and leave (llll) also works.\n");

    add_exit(HOME + "fighter", "southeast");
}

init()
{
    ::init();
    add_action("join", "jjjj");
    add_action("my_leave", "llll");
    add_action("list", "list");
}

join()
{
    object shadow;
    int result;

    notify_fail("Nie nadajesz sie na Straznika Krainy.\n");
    if (!do_I_want_this_player_in_my_guild(this_player()))
	return 0;

    notify_fail("Nalezysz do gildii, ktorej czlonkow nie akceptujemy.\n");
    if (!do_I_accept_the_guilds_this_player_has_joined(this_player()))
	return 0;

    notify_fail("Z nieznanego powodu nie mozesz przylaczyc sie do gildii.\n");
    shadow = clone_object(SHADOW);
    if ((result = shadow->shadow_me(this_player(), GUILD_TYPE,
		GUILD_STYLE, GUILD_NAME)) != 1)
    {
    /* result = -1 (no name), -2 (wrong type), -3 (no style set),
                -4 (the guild the player already joined don't want this guild.)
		-5 (couldn't shadow the player, security problems. )
                Probably they have set the notify_fail() appropriate.
		0 (already member or player wasn't set properly) */

    /* This is one of the few times you destruct is OK to use... */
        shadow->remove_object();
	return 0;
    }

    write("Zostales przyjety do grona Straznikow Krainy.\n");
    return 1;
}

do_I_want_this_player_in_my_guild(player)
{

    if (player->query_guild_member(GUILD_NAME))
    {
	notify_fail("Jestes juz Straznikiem Krainy.\n");
	return 0;
    }

    if (player->query_alignment()<500)
    {
	notify_fail("Tylko prawy czlowiek moze zostaz Straznikiem Krainy.\n");
	return 0;
    }
 
    return 1;
}

do_I_accept_the_guilds_this_player_has_joined(player)
{
    if (this_player()->query_guild_member(GUILD_TYPE))
    {
	notify_fail("Jestes juz czlonkiem innej gildii rasowej.\n"); 
	return 0;
    }

    return 1;
}

list()
{
    string str;

    str = this_player()->list_mayor_guilds();
    if (str)
	write("Jestes czlonkiem nastepujacych gildii.\n" + str);
    else
	write("Nie jestes czlonkiem zadnych gildii.\n");

    return 1;
}

my_leave()
{
    notify_fail("Nie jestes Straznikiem Krainy.\n");
    if (this_player()->query_guild_name_race() != GUILD_NAME)
	return 0;

    if (this_player()->remove_guild_race())
	write("Przestales byc straznikiem Krainy.\n");
    else
	write("Nastapila bardzo dziwna sytuacja, w wyniku ktorej chwilowo\n" +
	      "nie mozesz nas opuscic. Skontaktuj sie z Sir Elvaronem .\n");

    return 1;
}

