import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Supply a ship with stronger guns (i. e. increase the guns' level), but remove all but the center gun in exchange.
 * 
 * @author Jannis Andrija Schnitzer, Martin Schend
 * @version 2011-01-20
 */
public class StrongerGuns  extends Collectible
{
    public void act()
    {
        super.act();
    }
    
    public boolean hit(ManuallyControlledSpaceship ship)
    {
        int n_guns = ship.getNumberOfGuns();
        // penalty for stronger guns: remove all existing ones except one; reset its speed
        for (int i = n_guns-1; i > 0; i--)
        {
            ship.removeGun(i);
        }
        ship.setLevel(ship.getLevel()+1);
        ship.guns[0].setRecovery(ship.guns[0].getInitialRecovery());
        ship.reorderGuns();
        return false;
    }
}
