/* _disband.c  -  Zeus  (13/01/1993)
// command to allow players to leave a team or disband a team
// if he/she/it is leader.
*/

inherit "/std/cmd_m";

int help();

int cmd_disband(string str) {
	object ob;
	string name;

	if(!this_player()->query("leader")) {
		notify_fail("You are not in a team.\n");
		return 0;
	}

	if(!str) {
		if(this_player()->query("cap_name") == this_player()->query("leader")) {
			this_player()->disband_team();
			write("Your team is disbanded.\n");
			return 1;
		}
		name = lower_case((string)this_player()->query("leader"));
		ob = find_living(name);
		if(!ob) {
			notify_fail("Your leader is gone....PLEASE NOTIFY A WIZ.\n");
			return 0;
		}
		ob->disband_member(this_player());
		tell_object(ob, this_player()->query("cap_name")+" is disbanded from your team.\n");
		write("You are disbanded from "+ob->query("cap_name")+"'s team.\n");
		return 1;
	}

	if(this_player()->query("cap_name") != this_player()->query("leader")) {
		notify_fail("You are not the leader.\n");
		return 0;
	}

	ob = find_living(lower_case(str));
	if(!ob) {
		notify_fail("No such player.\n");
		return 0;
	}
	this_player()->disband_member(ob);
	tell_object(ob, "You are disbanded from "+this_player()->query("cap_name")+
		    "'s team.\n");
	write(ob->query("cap_name")+" is disbanded from your team.\n");
	return 1;
}

int help() {
	write("Syntax :  disband <member>\n"+
              "          disband\n");
	write("This command allows you to disband your entire team or a\n"+
              "member of your team if you are the leader. If you are just a\n"+
              "member of a team, you can disband yourself by just typing\n"+
              "disband.\n");
	return 1;
}