inherit "/d/Seroth/std/room";
inherit "/cmd/std/command_driver";

#include "defs.h"
#define POPARCIE "poparcie_szefa"

int wstap(string str);
int poprzyj(string str);
int nie_przejdziesz();



void
create_seroth_room()
{
	set_short("Pokoj przyjec");
	set_long("Witamy w Garou\n");
	add_exit(RPATH + "srodek", "polnocny-zachod",nie_przejdziesz);
	add_exit("/d/Imperium/Nuln/library/library", "wyjscie");
}
void
init()
{
	::init();
	add_action("wstap", "wstap");
	add_action("poprzyj", "poprzyj");
}

int
nie_przejdziesz()
{
	if (MASTER_ENG->query_czlonek(TP)) return 0;
	write("Moze jednak nie?\n");
	return 1;
}

int
wstap(string str)
{
	object shadow;
	int result;
	notify_fail("Gdzie chcial" + TP->koncowka("bys", "abys") + " wstapic? Moze do Garou?\n");
	if (str != "do garou") return 0;
	notify_fail("Juz jestes wilkolakiem!\n");
//	if (MASTER_ENG->query_czlonek(TP)) return 0;
	notify_fail("Nie mzoesz byc w zadnej gildii!\n");
    if((TP->query_guild_name_occ()) ||
      (TP->query_guild_name_lay()) ||
      (TP->query_guild_name_race())) return 0;

	if (TP->query_prop(POPARCIE))
	{
            setuid();
            seteuid(getuid());
            notify_fail("Cos sie spierdolilo w nowy_czlonek()\n");
            if(!MASTER_ENG->nowy_czlonek(TP)) return 0;

		    notify_fail("Cos sie zepsulo z shadowem. Zglos to do Levisa jak najszybciej!\n");
		    shadow = clone_object(MASTER_SH);
		    if ((result = shadow->shadow_me(this_player(), "occupational",
				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->destruct();
		    	return 0;
            }
            TP->add_soul();
            write("Witaj wsrod Garou!\n");
            TP->ustaw_odmiane_rasy(({"wilkolak", "wilkolaka", "wilkolakowi", "wilkolaka", "wilkolakiem", "wilkolaku"}), ({"wilkolaki", "wilkolakow", "wilkolakom", "wilkolaki", "wilkolakami", "wilkolakach"}), PL_MESKI_NOS_ZYW);
            say(QCIMIE(this_player(), PL_MIA) + " wstapil w szeregi wilkolakow.\n");
            return 1;
    }
    else
    {
		notify_fail("Musisz miec poparcie wladcy Garou.\n");
		return 0;
	}
}

int
poprzyj( string str )
{
  object *cel = parse_this(str,"%l:"+PL_BIE);
  notify_fail("Nie jestes wladca Garou by udzielac poparc.\n");
  if (!MASTER_ENG->query_szef(TP)) return 0;
  notify_fail("Poprzyj kogo?\n");
  if (!sizeof(cel)) return 0;
  if (cel[0]->query_prop(POPARCIE))
   { TP->catch_msg(QCIMIE(cel[0],PL_MIA)+" ma juz twoje poparcie.\n");return 1; }
  this_player()->catch_msg("Popierasz "+QCIMIE(cel[0],PL_BIE)+".\n");
  cel[0]->catch_msg("Zostales poparty przez wladce Garou\n");
  cel[0]->add_prop(POPARCIE, 1);
  return 1;
}
