### Persefone.jl - a model of agricultural landscapes and ecosystems in Europe.
###
### Daniel Vedder <daniel.vedder@idiv.de>
### Guy Pe'er <guy.peer@idiv.de>
### https://git.idiv.de/persefone/persefone-model
### (c) 2022-2023, licensed under the terms of the MIT license
###
### This file defines the module/package for the Persefone model.
### To run the model, either execute `run.jl` from the commandline,
### or import the module using your own wrapper script or software.
###

module Persefone

## define dependencies
using
    Agents,
    ArgParse,
    CSV,
    Dates,
    DataFrames,
    DataFramesMeta,
    Distributed,
    FileIO,
    #FIXME an upstream update broke GeoArrays for TableTransforms > 1.15.0
    GeoArrays, #XXX this is a big dependency - can we get rid of it?
    Logging,
    LoggingExtras,
    CairoMakie, #XXX this is a very big dependency :-(
    Random,
    Serialization,
    StableRNGs,
    TOML

## Packages that may be useful later on:
# MacroTools, http://fluxml.ai/MacroTools.jl/stable/utilities/
# Debugger, https://github.com/JuliaDebug/Debugger.jl
# PackageCompiler, https://julialang.github.io/PackageCompiler.jl/stable/
# SpatialEcology, https://github.com/EcoJulia/SpatialEcology.jl
# OmniScape, https://circuitscape.org/
# PlantSimEngine, https://virtualplantlab.github.io/PlantSimEngine.jl/stable/
# Overseer, https://juliapackages.com/p/overseer -> ECS

## define exported functions and variables
export
    #types
    Pixel,
    Weather,
    FarmEvent,
    FarmPlot,
    Animal,
    Farmer,
    DataOutput,
    #macros
    @param,
    @species,
    @initialise,
    @phase,
    @trait,
    @setphase,
    @respond,
    @here,
    @kill,
    @reproduce,
    @neighbours,
    @habitat,
    @landcover,
    @cropheight,
    @cropname,
    @distanceto,
    @distancetoedge,
    @countanimals,
    @rand,
    @shuffle!,
    #functions
    simulate,
    simulate!,
    initialise,
    stepsimulation!,
    createevent!,
    finalise!,
    visualisemap,
    populationtrends,
    visualiseoutput,
    savemodelobject,
    loadmodelobject

## include all module files (note that the order matters - if file
## b references something from file a, it must be included later)
include("core/input.jl")
include("core/output.jl")
include("analysis/makieplots.jl")

include("world/landscape.jl")
include("world/weather.jl")

include("crop/crops.jl")
include("crop/farmplot.jl")
include("farm/farm.jl")

include("nature/insects.jl")
include("nature/energy.jl")
include("nature/nature.jl")
include("nature/populations.jl")
include("nature/ecologicaldata.jl")
#TODO loop over files in nature/species directory
# (the below doesn't work yet)
# for f in readdir("nature/species", join=true)
#     endswith(f, ".jl") && include(f)
# end
#include("nature/species/skylark.jl")
include("nature/species/wolpertinger.jl")
include("nature/species/wyvern.jl")

include("core/simulation.jl") #this must be last

end