# Food is essential and extra food makes people happier
R {
  name Food
  can_overspend 512
  decay_rate 75
  decay_when early
  decay_to
  r {
    type Happiness
    qty 20
  }
}

# Military power, recalculated each turn
R {
  name Might
  decay_rate 100
}

# If people don't have work to do, they lose Skill (or, rather, gain less),
# but are happier
R {
  name Labor
  can_overspend 1024
  influence
  r {
    type Skill
    qty 25
  }
  decay_rate 100
  decay_to
  r {
    type Skill
    qty -20
  }
  r {
    type Happiness
    qty 10
  }
}

# Conversely, if the population's Bright Thoughts aren't used for production,
# people might learn something from them
R {
  name Knowledge
  decay_rate 100
  decay_to
  r {
    type Skill
    qty 5
  }
}

# Wealth is consumed by many transactions, and any excess makes people
# happier, while a shortage makes them unhappy
R {
  name Wealth
  can_overspend 2048
  decay_rate 100
  decay_to
  r {
    type Happiness
    qty 5
  }
}

# The presence of money makes Wealth available
R {
  name Silver
  influence
  r {
    type Wealth
    qty 75
  }
}

# Define characteristics for humans - lots of 1s since they're the baseline
P {
  name Human
  food_consumption 1000
  might_production 1000
  labor_production 1000
  knowledge_production 1000
  growth_rate 50
  wanderlust 1000
}

# Before defining the Silver Mine, we need a source of ore
S {
  name Silver Vein
}

# Next, some factory templates
F {
  name Farm
  input
  r {
    type Labor
    qty 1000
  }
  output
  r {
    type Food
    qty 2000
  }
  capacity 10
  cost
  r {
    type Labor
    qty 2000
  }
  r {
    type Wealth
    qty 1000
  }
  repair_cost
  r {
    type Labor
    qty 500
  }
  r {
    type Wealth
    qty 50
  }
  depletion 10
}

F {
  name Silver Mine
  input
  r {
    type Labor
    qty 1000
  }
  r {
    type Wealth
    qty 200
  }
  output
  r {
    type Silver
    qty 20
  }
  capacity 50
  required
  s {
    type Silver Vein
  }
  cost
  r {
    type Labor
    qty 50000
  }
  r {
    type Wealth
    qty 25000
  }
  depletion 100
  # No repair_cost - when the mine runs dry, you can't do anything about it
}

# Now to finally define the Territory itself
T {
  name Shire of Hamlin
  populace
  p {
    race Human
    size 50
    happiness 0
    skill 0
  }
  
  sites
  s {
    type Silver Vein
  }

  factories
  # 5 farms and a silver mine will keep everyone busy...
  f {
    type Farm
    qty 5
    capacity 50
  }
  f {
    type Silver Mine
    # Don't forget that everything defaults to 0!
    qty 1
    capacity 50
  }
  
  resources
  # Starting quantities of food and silver - everything else decays completely
  r {
    type Food
    qty 125000
  }
  r {
    type Silver
    qty 10000
  }
}
