#ifndef GUARD_CONSTANTS_WILD_ENCOUNTER_H
#define GUARD_CONSTANTS_WILD_ENCOUNTER_H

{{ doNotModifyHeader }}

#define NUM_ALTERING_CAVE_TABLES 9

## for wild_encounter_group in wild_encounter_groups
{% if wild_encounter_group.for_maps %}
## for wild_encounter_field in wild_encounter_group.fields
{% if not existsIn(wild_encounter_field, "groups") %}
## for encounter_rate in wild_encounter_field.encounter_rates
#define ENCOUNTER_CHANCE_{{ upper(wild_encounter_field.type) }}_SLOT_{{ loop.index }} ({% if loop.index == 0 %}{{ encounter_rate }}{% else %}ENCOUNTER_CHANCE_{{ upper(wild_encounter_field.type) }}_SLOT_{{ subtract(loop.index, 1) }} + {{ encounter_rate }}{% endif %}){{ setVarInt(wild_encounter_field.type, loop.index) }}
## endfor
#define ENCOUNTER_CHANCE_{{ upper(wild_encounter_field.type) }}_TOTAL (ENCOUNTER_CHANCE_{{ upper(wild_encounter_field.type) }}_SLOT_{{ getVar(wild_encounter_field.type) }})
{% else %}
## for field_subgroup_key, field_subgroup_subarray in wild_encounter_field.groups
{{ setVar("field_name", concat(concat(upper(wild_encounter_field.type), "_"), upper(field_subgroup_key))) }}
## for field_subgroup_index in field_subgroup_subarray
#define ENCOUNTER_CHANCE_{{ getVar("field_name") }}_SLOT_{{ field_subgroup_index }} ({% if loop.index == 0 %}{{ at(wild_encounter_field.encounter_rates, field_subgroup_index) }}{% else %}ENCOUNTER_CHANCE_{{ getVar("field_name") }}_SLOT_{{ getVar("previous_slot") }} + {{ at(wild_encounter_field.encounter_rates, field_subgroup_index) }}{% endif %}){{ setVarInt(concat(wild_encounter_field.type, field_subgroup_key), field_subgroup_index) }}{{ setVarInt("previous_slot", field_subgroup_index) }}
## endfor
#define ENCOUNTER_CHANCE_{{ getVar("field_name") }}_TOTAL (ENCOUNTER_CHANCE_{{ getVar("field_name") }}_SLOT_{{ getVar(concat(wild_encounter_field.type, field_subgroup_key)) }})
#define NUM_{{ getVar("field_name") }}_ENCOUNTER_SLOTS ({{ length(field_subgroup_subarray) }})
## endfor
{% endif %}
#define NUM_{{ upper(wild_encounter_field.type) }}_ENCOUNTER_SLOTS ({{ length(wild_encounter_field.encounter_rates) }})

## endfor
{% endif %}
## endfor

#endif // GUARD_CONSTANTS_WILD_ENCOUNTER_H
