### Persephone - a socio-economic-ecological model of European agricultural landscapes.
###
### This file holds the code for the Eurasian Skylark (Alauda arvensis).
###

##XXX At the moment, this is just a skeleton to show what I want to be able to interpret
## with the @species, @phase, and @habitat macros (and their helper macros)

"""
    Skylark

*Alauda arvensis* is a common and charismatic species of agricultural landscapes.
At the moment, this implementation is still in development.
"""
@species Skylark begin

    popsize = Int(round(1/10000*reduce(*, size(model.landscape))))
    lifeexpectancy = 365*5

    eggharvestmortality = 0.9
    eggpredationmortality = 0.1
    
    initialise! = initrandompopulation(popsize)
    phase = "egg"

    habitats = @habitat((@landcover() == grass || 
                         (@landcover() == agriculture && @croptype() != maize &&
                          @cropheight() < 10)) &&
                        @distanceto(forest) > 20)
    
    @phase egg begin
        @kill(@trait(eggpredationmortality), "predation")

        #TODO dies if parents die
        
        @respond harvest @kill(@trait(eggharvestmortality), "harvest")

        if @trait(age) == 14
            @trait(phase) = "nestling"
        end
    end

    @phase nestling begin
        #TODO
    end

    #TODO
end