area/
build/testing/
log/
player/
player/backup/
#include <glib.h>
#include <check.h>
#include <sys/types.h>
#include <sys/time.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <merc.h>
#include <recycle.h>
#include <player.h>
#include "lurfcheck.h"

ROOM_INDEX_DATA *create_room1(){
	ROOM_INDEX_DATA *pRoomIndex;
	
	pRoomIndex			= g_new0(ROOM_INDEX_DATA,1);
	
	pRoomIndex->vnum 	= 100;
	
	return pRoomIndex;
}

CHAR_DATA *setup_avatar(int class, int obf_level){
	CHAR_DATA *ch;
	
	ch = new_char();
	clear_char( ch );
	ch->pcdata = new_pcdata();
	ch->in_room = create_room1();
	ch->plane = 1;
	
	ch->level = LEVEL_AVATAR;
	
	SET_BIT(ch->act,PLR_WIZINVIS);
		
	switch (class){
		default:
			break;
		case CLASS_MAGE:
			ch->pcdata->discipline[SPHERE_CORRESPONDENCE] = obf_level;
			break;
		case CLASS_VAMPIRE:
			ch->pcdata->disc[DISC_OBFUSCATE] = obf_level;
			break;
		case CLASS_SWWF:
			ch->pcdata->auspice[AUSPICE_RAGABASH] = obf_level;
			break;
	}
	return ch;
}

CHAR_DATA *setup_mortal(){
	
	CHAR_DATA *ch;
	
	ch = new_char();
	clear_char( ch );
	ch->pcdata = new_pcdata();
	ch->in_room = create_room1();
	ch->plane = 1;
	
	ch->level = LEVEL_MORTAL;
	
	return ch;
}

void tear_down_char(CHAR_DATA *ch)
{
	g_free(ch->in_room);
	free_pcdata(ch->pcdata);
	free_char(ch);
	return;
}

START_TEST(avatar_unclassed_vanish_test)
{
	CHAR_DATA *unclassed,*mage,*wwf,*vamp;
	bool fCanSee;

	mage = setup_avatar(CLASS_MAGE,6);
	wwf = setup_avatar(CLASS_SWWF,6);
	vamp = setup_avatar(CLASS_VAMPIRE,6);

	unclassed = setup_mortal();	

	fCanSee = can_see(unclassed,mage);
	fail_unless( fCanSee == FALSE,"Unclassed Avatar seen Mage!");
	
	fCanSee = can_see(unclassed,wwf);
	fail_unless( fCanSee == FALSE,"Unclassed Avatar seen Werewolf!");
	
	fCanSee = can_see(unclassed,vamp);
	fail_unless( fCanSee == FALSE,"Unclassed Avatar seen Vampire!");
	
	tear_down_char(mage);
	tear_down_char(wwf);
	tear_down_char(vamp);
	tear_down_char(unclassed);
	
	return;	
}
END_TEST

START_TEST(avatar_o_immortal_wizinvs_test) 
{ 
	CHAR_DATA *mortal,*avatar;
	bool fCanSee = FALSE;
	
	avatar = setup_avatar(CLASS_MAGE,6);
	mortal = setup_mortal();	
	
	avatar->level = LEVEL_AVATAR;
	mortal->level = LEVEL_IMPLEMENTOR;
	
	SET_BIT(mortal->act,PLR_WIZINVIS);
	mortal->invis_level = LEVEL_IMPLEMENTOR;
	
	avatar->trust = LEVEL_AVATAR;
	mortal->trust = LEVEL_IMPLEMENTOR;
	
	fCanSee = can_see(avatar,mortal);
	
	fail_unless( fCanSee == FALSE,"Avatar cannot see mortal!");
	
	tear_down_char(avatar);
	tear_down_char(mortal);
	return;			
}
END_TEST

Suite *sighttest_suite (void) 
{ 
  Suite *Sight_Test = suite_create ("Lurking Fear"); 
  TCase *tc_core = tcase_create ("Sight");
 
  suite_add_tcase (Sight_Test, tc_core);
 
  tcase_add_test (tc_core, avatar_unclassed_vanish_test); 
  tcase_add_test (tc_core, avatar_o_immortal_wizinvs_test); 
  return Sight_Test; 
}