Exemplo n.º 1
0
void test_cases(void)
{
   struct monster l= create_monster(2,3,4.5,6);
   
   checkit_int(l.numEyes, 2);
   checkit_int(l.numArms,3);
   checkit_double(l.height, 4.5);
   checkit_int(l.numTails, 6);
}
Exemplo n.º 2
0
int main()
{
	initscr();
	raw();
	keypad(stdscr, TRUE);
	noecho();
	curs_set(0);
	start_color();
	use_default_colors();

	init_pair(1, COLOR_BLUE, 144);/*COLOR_BLACK); */
	init_pair(2, COLOR_BLUE, 186);/*238); */
	init_pair(3, COLOR_BLUE, 187);/*245); */
	init_pair(4, COLOR_BLUE, COLOR_WHITE);


	init_pair(5, TREECOLOR, 144);/*COLOR_BLACK); */
	init_pair(6, TREECOLOR, 186);/*238); */
	init_pair(7, TREECOLOR, 187);/*245); */
	init_pair(8, TREECOLOR, COLOR_WHITE);

	init_pair(9, -1, COLOR_BLUE);
	init_pair(10, -1, COLOR_RED);

	assume_default_colors(COLOR_WHITE, COLOR_BLACK);

	srand(time(NULL));

	map = make_level(1000,1000);
	player = create_monster(PLAYER);
	player->x = 500;
	player->y = 500;
	player->hp = 100;
	snow_count = 10;

	offset_x = 0;
	offset_y = 0;

	messages = al_makenull(NULL);

	ninterface();

	endwin();

	return 0;
}
Exemplo n.º 3
0
Arquivo: main.c Projeto: Zleub/IDLE
void	play_round(t_heros *heros)
{
	t_monster *monster;
	int 	enter;

	write (1, "auto-battling\n", 15);
	monster = malloc(sizeof(t_monster));
	monster = create_monster(monster);
	ft_putstr(heros->name);
	write (1, " [", 2);
	ft_putnbr(heros->level);
	write (1, "][", 2);
	ft_putnbr(heros->xp);
	write (1, "] encounters a ", 15);
	ft_putstr(monster->name);
	write (1, "\n", 1);
	free (monster);
	write(1, "Press Enter", 11);
	enter = fgetc(fdopen(0, "r"));
	if (enter == 10)
		play_round(heros);
}
Exemplo n.º 4
0
void
read_scroll(void)
{
	short ch;
	object *obj;
	char msg[DCOLS];

	ch = pack_letter("read what?", SCROL);

	if (ch == CANCEL) {
		return;
	}
	if (!(obj = get_letter_object(ch))) {
		message("no such item.", 0);
		return;
	}
	if (obj->what_is != SCROL) {
		message("you can't read that", 0);
		return;
	}
	switch(obj->which_kind) {
		case SCARE_MONSTER:
			message("you hear a maniacal laughter in the distance",
			0);
			break;
		case HOLD_MONSTER:
			hold_monster();
			break;
		case ENCH_WEAPON:
			if (rogue.weapon) {
				if (rogue.weapon->what_is == WEAPON) {
					sprintf(msg, "your %sglow%s %sfor a moment",
					name_of(rogue.weapon),
					((rogue.weapon->quantity <= 1) ? "s" : ""),
					get_ench_color());
					message(msg, 0);
					if (coin_toss()) {
						rogue.weapon->hit_enchant++;
					} else {
						rogue.weapon->d_enchant++;
					}
				}
				rogue.weapon->is_cursed = 0;
			} else {
				message("your hands tingle", 0);
			}
			break;
		case ENCH_ARMOR:
			if (rogue.armor) {
				sprintf(msg, "your armor glows %sfor a moment",
				get_ench_color());
				message(msg, 0);
				rogue.armor->d_enchant++;
				rogue.armor->is_cursed = 0;
				print_stats(STAT_ARMOR);
			} else {
				message("your skin crawls", 0);
			}
			break;
		case IDENTIFY:
			message("this is a scroll of identify", 0);
			obj->identified = 1;
			id_scrolls[obj->which_kind].id_status = IDENTIFIED;
			idntfy();
			break;
		case TELEPORT:
			tele();
			break;
		case SLEEP:
			message("you fall asleep", 0);
			take_a_nap();
			break;
		case PROTECT_ARMOR:
			if (rogue.armor) {
				message( "your armor is covered by a shimmering gold shield",0);
				rogue.armor->is_protected = 1;
				rogue.armor->is_cursed = 0;
			} else {
				message("your acne seems to have disappeared", 0);
			}
			break;
		case REMOVE_CURSE:
				message((!halluc) ?
					"you feel as though someone is watching over you" :
					"you feel in touch with the universal oneness", 0);
			uncurse_all();
			break;
		case CREATE_MONSTER:
			create_monster();
			break;
		case AGGRAVATE_MONSTER:
			aggravate();
			break;
		case MAGIC_MAPPING:
			message("this scroll seems to have a map on it", 0);
			draw_magic_map();
			break;
		case CON_MON:
			con_mon = 1;
			sprintf(msg, "your hands glow %sfor a moment", get_ench_color());
			message(msg, 0);
			break;
	}
	if (id_scrolls[obj->which_kind].id_status != CALLED) {
		id_scrolls[obj->which_kind].id_status = IDENTIFIED;
	}
	vanish(obj, (obj->which_kind != SLEEP), &rogue.pack);
}
Exemplo n.º 5
0
Arquivo: monster.c Projeto: xxx/cdlib
/*
 * Function name: create_npc
 * Description:   Create the inherited npc object. (constructor)
 */
nomask void
create_npc() { create_monster(); }
Exemplo n.º 6
0
/* p[0] = map, p[1] = &player, p[2] = bmap */
task_func floor_load(LPTCB t)
{
	int i, x, y, monscnt, id, bosscnt[2];
	struct _list *room_list;
	LPSPLAYER pl;
	LPSMONSTER mo;
	
	/* floor設定 */
	room_list = init_floor(t->p[0], t->p[2]);
	set_object(&x, &y, room_list, t->p[0], STAIRS);
	set_bmap_smell(t->p[2], x, y, SMELL_ST);
//	show_map2(t->p[2]);
	
	/* player設定 */
	pl = (LPSPLAYER)t->p[1];
	set_object(&x, &y, room_list, t->p[0], PLAYER);
	pl->x = x;
	pl->y = y;
	pl->fturn = 1;
	set_bmap_smell(t->p[2], x, y, SMELL_PL);
	
	/* monster設定 */
	chose_monscnt();
	monscnt = get_monscnt();
//	printf("monscnt: %d\n", monscnt);
	mo = get_mo_p();
	if(read_monster_area(floor_cnt, moarray) == 0){
		int chk;
		LPTCB mt;
		
		bosscnt[0] = bosscnt[1] = 0;
		for(i = 0; i < ENEMY_MAX; i++){
//			printf("%d: %d\n", i, moarray[i]);
			if(moarray[i] > 990000) bosscnt[0]++;
			else if(moarray[i] == 0) break;
			bosscnt[1]++;
		}
		
		/* ボス設定 */
		for(i = 0; i < bosscnt[0]; i++){
			if((chk = read_monster(moarray[i], mo+i)) == -1){
				list_free(room_list);
				game_end();
				return;
			}
			mt = create_monster(create_boss_monster(moarray[i]), get_des(moarray[i]), chk);
			mt->p[1] = t->p[1];
			mt->p[2] = t->p[2];
			
			set_object(&x, &y, room_list, t->p[0], MO_BOSS);
			(mo+i)->x = x;
			(mo+i)->y = y;
			set_bmap_smell(t->p[2], x, y, SMELL_BOSS);
		}
		
		/* 標準/Level monster設定 */
		for(i = bosscnt[0]; i < monscnt; i++){
			id = bosscnt[0] + get_random_range(0, bosscnt[1] - bosscnt[0]);
			if((chk = read_monster(moarray[id], mo+i)) == -1){
				list_free(room_list);
				game_end();
				return;
			}
			mt = create_monster(monster_move1, NULL, chk);
			mt->p[1] = t->p[1];
			mt->p[2] = t->p[2];
/*			printf("id: %d, name: %s, hp: %d, mp: %d, p: %d, d: %d\n",
				id, (mo+i)->name,(mo+i)->hp,(mo+i)->mp,(mo+i)->p,(mo+i)->d);
*/
			set_object(&x, &y, room_list, t->p[0], MONSTER);
			(mo+i)->x = x;
			(mo+i)->y = y;
			set_bmap_smell(t->p[2], x, y, SMELL_MO);
		}
	}
	
	/* キノコ設定 */
	init_mush(t->p[0], room_list);
	
	list_free(room_list);
	t->state = TASK_SLEEP;
}
Exemplo n.º 7
0
void
read_scroll(void)
{
    short ch;
    object *obj;
    char msg[ROGUE_COLUMNS];

    ch = pack_letter(mesg[245], SCROL);

    if (ch == CANCEL) {
	return;
    }
    if (!(obj = get_letter_object(ch))) {
	message(mesg[246], 0);
	return;
    }
    if (obj->what_is != SCROL) {
	message(mesg[247], 0);
	return;
    }
    switch (obj->which_kind) {
    case SCARE_MONSTER:
	message(mesg[248], 0);
	break;
    case HOLD_MONSTER:
	hold_monster();
	break;
    case ENCH_WEAPON:
	if (rogue.weapon) {
	    if (rogue.weapon->what_is == WEAPON) {
		sprintf(msg, mesg[249],
			name_of(rogue.weapon), get_ench_color());
		message(msg, 0);
		if (coin_toss()) {
		    rogue.weapon->hit_enchant++;
		} else {
		    rogue.weapon->d_enchant++;
		}
	    }
	    rogue.weapon->is_cursed = 0;
	} else {
	    message(mesg[250], 0);
	}
	break;
    case ENCH_ARMOR:
	if (rogue.armor) {
	    sprintf(msg, mesg[251], get_ench_color());
	    message(msg, 0);
	    rogue.armor->d_enchant++;
	    rogue.armor->is_cursed = 0;
	    print_stats(STAT_ARMOR);
	} else {
	    message(mesg[252], 0);
	}
	break;
    case IDENTIFY:
	message(mesg[253], 0);
	obj->identified = 1;
	id_scrolls[obj->which_kind].id_status = IDENTIFIED;
	idntfy();
	break;
    case TELEPORT:
	tele();
	break;
    case SLEEP:
	message(mesg[254], 0);
	take_a_nap();
	break;
    case PROTECT_ARMOR:
	if (rogue.armor) {
	    message(mesg[255], 0);
	    rogue.armor->is_protected = 1;
	    rogue.armor->is_cursed = 0;
	} else {
	    message(mesg[256], 0);
	}
	break;
    case REMOVE_CURSE:
	message((!halluc) ? mesg[257] : mesg[258], 0);
	uncurse_all();
	break;
    case CREATE_MONSTER:
	create_monster();
	break;
    case AGGRAVATE_MONSTER:
	aggravate();
	break;
    case MAGIC_MAPPING:
	message(mesg[259], 0);
	draw_magic_map();
	break;
    }
#if !defined( ORIGINAL )
    id_scrolls[obj->which_kind].id_status = IDENTIFIED;
#else /* ORIGINAL */
    if (id_scrolls[obj->which_kind].id_status != CALLED) {
	id_scrolls[obj->which_kind].id_status = IDENTIFIED;
    }
#endif /* ORIGINAL */
    vanish(obj, (obj->which_kind != SLEEP), &rogue.pack);
}
Exemplo n.º 8
0
void read_scroll(void)
{
	short ch;
	object *obj;
	char msg[DCOLS];

	if(blind)
	{
		message("You can't see to read the scroll.",0);
		return;
	}

	ch = pack_letter("Read what?", SCROLL);

	if (ch == ROGUE_KEY_CANCEL)
	{
		return;
	}
	if (!(obj = get_letter_object(ch)))
	{
		message("No such item.", 0);
		return;
	}
	if (obj->what_is != SCROLL)
	{
		message("You can't read that!", 0);
		return;
	}
	switch(obj->which_kind)
	{
		case SCARE_MONSTER:
			message("You hear a maniacal laughter in the distance.", 0);
			break;
		case HOLD_MONSTER:
			hold_monster();
			break;
		case ENCH_WEAPON:
			if (rogue.weapon)
			{
				if (rogue.weapon->what_is == WEAPON)
				{
					sprintf(msg, "Your %sglow%s %sfor a moment.",
					name_of(rogue.weapon),
					((rogue.weapon->quantity <= 1) ? "s" : ""),
					get_ench_color());
					message(msg, 0);
					if (coin_toss())
					{
						rogue.weapon->hit_enchant++;
					}
					else
					{
						rogue.weapon->d_enchant++;
					}
				}
				rogue.weapon->is_cursed = 0;
			}
			else
			{
				message("Your hands tingle.", 0);
			}
			break;
		case ENCH_ARMOR:
			if (rogue.armor)
			{
				sprintf(msg, "Your armor glows %sfor a moment.",
				get_ench_color());
				message(msg, 0);
				rogue.armor->d_enchant++;
				rogue.armor->is_cursed = 0;
				print_stats(STAT_ARMOR);
			}
			else
			{
				message("Your skin crawls.", 0);
			}
			break;
		case IDENTIFY:
			message("This is a scroll of identify.", 0);
			obj->identified = 1;
			id_scrolls[obj->which_kind].id_status = IDENTIFIED;
			identify_item(0) ;
			break;
		case TELEPORT:
			tele();
			/* (zerogue 0.4.0) The first time a rogue uses this scroll,
			 * he is briefly confused.
			 */
			if( ! obj->identified && id_scrolls[obj->which_kind].id_status != IDENTIFIED )
				confused += get_rand(0,5) ;
			break;
		case SLEEP:
			sleepify(obj) ;
			break ;
		case PROTECT_ARMOR:
			if (rogue.armor)
			{
				message("Your armor is covered by a shimmering gold shield.", 0);
				rogue.armor->is_protected = 1;
				rogue.armor->is_cursed = 0;
			}
			else
			{
				message("Your acne seems to have disappeared.", 0);
			}
			break;
		case REMOVE_CURSE:
				message((!halluc) ?
					"You feel as though someone is watching over you." :
					"You feel in touch with the universal oneness.", 0);
			uncurse_all();
			break;
		case CREATE_MONSTER:
			/* (zerogue 0.4.0) A summoned monster is briefly confused. */
			create_monster(1) ;
			break;
		case AGGRAVATE_MONSTER:
			aggravate();
			break;
		case MAGIC_MAPPING:
			message("This scroll seems to have a map on it.", 0);
			draw_magic_map();
			break;
	}
	if (id_scrolls[obj->which_kind].id_status != CALLED)
	{
		id_scrolls[obj->which_kind].id_status = IDENTIFIED;
	}
	vanish(obj, (obj->which_kind != SLEEP), &rogue.pack);
}