tresinformal / drakkar

The tresinformal video game called 'Drakkar'
GNU General Public License v3.0
11 stars 4 forks source link

[FD] A food item eaten by a player switches back to uneaten after regeneration_time ticks #394

Closed TheoPannetier closed 3 years ago

TheoPannetier commented 3 years ago

Similar test to #255 but explicitly runs the interaction between food and player

//#define FIX_ISSUE_394
#ifdef FIX_ISSUE_394
  {
    game g;
    player p = g.get_player(0);
    food f = g.get_food()[0];
    int f_regen_time = f.get_regeneration_time();

    // Player on top of food should eat it
    assert(!nth_food_is_eaten(g, 0));    
    put_player_on_food(p, f);
    g.tick();
    assert(nth_food_is_eaten(g, 0));
    // Get player away so it does not eat food again
    put_player_near_food(p, f, f.get_radius() * 2.0);

    // Food item should not regen before the regeneration time
    for(int i = 0; i != f_regen_time - 1; i++)
      {
        g.tick();
      }
    assert(nth_food_is_eaten(g,0));
    g.tick();
    // Food item should regen on the regeneration time
    assert(!nth_food_is_eaten(g,0));
  }
#endif
TheoPannetier commented 3 years ago

Done!