Ejemplo n.º 1
0
void test_cycle() {
	monster_descr * rat_test = malloc(sizeof(monster_descr));
	rat_test->pic = '$';
	rat_test->name = "Rat";
	rat_test->max_hp = 10;
	rat_test->dodge = 20;
	rat_test->max_roll = 100;
	rat_test->max_dmg = 10;
	rat_test->min_dmg = 1;
	
	//TEST//fix
	player_descr * player = malloc(sizeof(player_descr));
	player->max_hp = 20;
	player->hp = 20;		
	player->dodge = 20;
	player->max_roll = 100;
	player->max_dmg = 20;
	player->min_dmg = 5;	

	monster * rat1;
	rat1 = make_monster(rat_test);
		
	player_hit(player, rat1);
	monster_hit(rat1, player);
	// TODO: add test
}
Ejemplo n.º 2
0
/*
  Interacts with the tile at players feet. This will usually change
  the tile to an identical-looking but functionally inert tile.
*/
int interact()
{
  int tile;
  char line[DEFLEN];

  tile = gtile(player->y, player->x);

  if (tile == TL_P_CHEST || tile == TL_P_UWCHEST)
  {
    loot_chest(player->y, player->x);
  }
  else if (tile == TL_P_NPC1)
  {
    shop_chef();
  }
  else if (tile == TL_P_NPC3)
  {
    shop_train();
  }
  else if (tile == TL_P_NPC4)
  {
    shop_map();
  }
  else if (tile == TL_P_NPC_ARMOR)
  {
    shop_armor();
  }
  else if (tile == TL_P_NPC_RANGED)
  {
    shop_weapons(1);
  }
  else if (tile == TL_P_NPC_WEAPONS)
  {
    shop_weapons(0);
  }
  else if (tile == TL_P_NPC_CLOSED)
  {
    pwait("SORRY WE ARE CLOSED FOR RENOVATION");
  }
  else if (tile == TL_P_NPC_SCUBA)
  {
    shop_scuba();
  }
  else if (tile == TL_P_NPC_BAR)
  {
    ye_olde_bar();
  }
  else if (tile == TL_P_NPC_SUSHI)
  {
    shop_sushi();
  }
  else if (tile == TL_P_COFFIN)
  {
    stile(player->y, player->x, TL_COFFIN_HL);
    stile(player->y - 1, player->x, TL_VOID);
    stile(player->y - 1, player->x - 1, TL_VOID);
    stile(player->y - 1, player->x + 1, TL_VOID);
    stile(player->y - 2, player->x, TL_VOID);

    if (player->flip)
    {
      stile(player->y, player->x + 4, TL_COFFIN_LID_R);
      stile(player->y - 1, player->x + 3, TL_COFFIN_LID_R);
      stile(player->y - 2, player->x + 2, TL_COFFIN_LID_R);
    }
    else
    {
      stile(player->y, player->x - 4, TL_COFFIN_LID_L);
      stile(player->y - 1, player->x - 3, TL_COFFIN_LID_L);
      stile(player->y - 2, player->x - 2, TL_COFFIN_LID_L);
    }

    strcpy(line, "YOU OPEN THE COFFIN\n\n");

    if (rand() % 5 == 0)
    {
      strcat(line, "A GHOUL ESCAPES!");

      if (rand() % 2 == 0)
	make_monster(player->y, player->x - 5, MOB_GHOUL);
      else
	make_monster(player->y, player->x + 5, MOB_GHOUL);

      draw_board();

      pwait(line);
    }
    else if (rand() % 5 == 0)
    {
      draw_board();
      find_random_armor(line);
    }
    else
    {
      draw_board_norefresh();
      give_item(line, 10 + rand() % COFFIN_GOLD, LOOT_NORMAL);
    }
  }
  else if (tile == TL_P_FOUNTAIN || tile == TL_P_BLOOD_FOUNTAIN)
  {
    fountain();
  }
  else if (tile == TL_P_SWSTONE)
  {
    sword_in_stone();
  }
  else if (tile == TL_P_ORB)
  {
    gaze_orb();
  }
  else if (tile == TL_P_TABLET)
  {
    stone_tablet();
  }
  else if (tile == TL_P_HELL)
  {
    stile(player->y, player->x, TL_VOID);
    pwait("YOU ARE IN HELL");
    draw_board();
  }
  else if (tile == TL_P_PORTAL)
  {
    portal_travel();
  }
  else if (tile == TL_P_IDOL)
  {
    idol();
  }
  else if (tile == TL_P_MUSHROOMS)
  {
    mushrooms();
  }
  else if (tile == TL_P_BOOKSHELF)
  {
    bookshelf();
  }
  else if (tile == TL_P_CAMP)
  {
    if (anything_near())
    {
      pwait("YOU CANNOT REST NOW!\nENEMIES ARE NEAR");
      return false;
    }

    camp();
  }
  else if (tile == TL_P_DISCO)
  {
    if (anything_near())
    {
      pwait("YOU CANNOT DANCE WHILE\nSOMEONE IS WATCHING");
      return false;
    }

    disco();
  }
  else if (tile == TL_P_ALTAR)
  {
    altar();
  }
  else if (tile == TL_P_CORPSE || tile == TL_P_SKELETON)
  {
    if (tile == TL_P_CORPSE)
    {
      stile(player->y, player->x, TL_VOID);
      strcpy(line, "YOU FIND A DECAYING CORPSE\n\n");
    }
    else
    {
      stile(player->y, player->x, TL_VOID);
      strcpy(line, "YOU FIND A LONG-DEAD SKELETON\n\n");
    }

    switch(rand() % 10)
    {
    case 0:
    case 1:
    case 2:
      find_random_armor(line);
      break;

    case 3:
    case 4:
    case 5:
      find_random_weapon(line);
      break;

    default:
      if (tile == TL_P_SKELETON)
	give_item(line, 5 + rand() % 25, LOOT_BONES);
      else
	give_item(line, 5 + rand() % 25, LOOT_NORMAL);
      break;
    }

    //pwait(line);

    return true;
  }

  return true;
}