import rebelsky.fun.balloons.Balloon;
import rebelsky.fun.balloons.Strategist;
import rebelsky.fun.balloons.Wind;

/**
 * A simple strategy for winning balloon races.  If you're still on the
 * ground, drop a sandbag with a 20% probability.
 */
public class Bagger
  extends Strategist
{
  /**
   * Decide what to do based on knowledge of the balloon status.
   * Ignore the wind.
   */
  public void decide(Balloon b, int maxheight, Wind w) 
  {
    // If we're still on the ground, drop a sandbag
    if (b.getHeight() == 0) {
      if (b.getSandbags() > 0) {
        b.drop();
      }
      else { // there are no sandbags left
        b.inflate();
      } // no sandbags left
    } // if we're on the ground

    // If we're more than half way up, deflate the balloon
    if (b.getHeight() > (maxheight / 2)) {
      b.deflate();
    }
  } // decide()
} // Bagger

