
inherit F_CLEAN_UP;

#include <ansi.h>
#include <7hai.h>

int telling1 (object who);
int telling2 (object who);

string name;

int main(object me, string arg)
{
	object ob;

	if( !arg ) {
		ob = me;
		name = "你";
	} else if (wizardp (me)) {
		ob = find_player(arg);
		if(!ob) ob = find_living(arg);
	
		if(!ob) ob = LOGIN_D->find_body(arg);

		if(!ob || !me->visible(ob)) return notify_fail("没有这个人。\n");

		name = ob->query("name");
	} else
		return 0;

	telling1(ob);
	telling2(ob);

	return 1;
}

int help()
{
	write(@TEXT
指令格式：7hai <某人>

显示某人波士顿神殿过关的资料。

TEXT
	);
	return 1;
}

int telling1 (object who)
{
  int size = sizeof(obstacles);
  string *names = keys(obstacles);
  string *strs = allocate (size);
  int nb = 0;
  int i;

  for (i = 0; i < size; i++)
  {
    strs[i] = "none";
  }

  for (i = 0; i < size; i++)
  {
    if (who->query("7hai/"+names[i])=="done")
    {
      strs[nb] = obstacles[names[i]];
      nb++;
    }
  }

  if (nb == 0)
  {
    write (name+"尚未开始七海过关。\n");
  }
  else
  {
    write (name+HIY"七海已过了"+chinese_number(nb)+"关：\n");
    who->set("7hai/number",nb);
    strs = (string *)sort_array (strs, 1);
    for (i = 0; i < nb; i++)
    {
      write ("    "+strs[i]+"\n");
    }
  }
  return 1;
}

int telling2 (object who)
{
  int size = sizeof(obstacles);
  string *names = keys(obstacles);
  string *strs = allocate (size);
  int nb = 0;
  int i;

  for (i = 0; i < size; i++)
  {
    strs[i] = "none";
  }

  for (i = 0; i < size; i++)
  {
    if (who->query("7hai/"+names[i])!="done")
    {
      strs[nb] = obstacles[names[i]];
      nb++;
    }
  }

  if (nb == 0)
  {
    write (name+"成功收服海皇波士顿！\n");
  }
  else
  {
    write (name+ "七海还须过"+chinese_number(nb)+"关：\n"NOR);
    strs = (string *)sort_array (strs, 1);
    for (i = 0; i < nb; i++)
    {
      write ("    "+strs[i]+"\n");
    }
  }
  return 1;
}

