2020-05-09 17:34:43 +00:00
|
|
|
package tins2020
|
|
|
|
|
|
|
|
type Flower struct {
|
2020-05-10 21:00:19 +00:00
|
|
|
ID string
|
2020-05-09 17:34:43 +00:00
|
|
|
Traits FlowerTraits
|
|
|
|
}
|
|
|
|
|
|
|
|
type FlowerTraits struct {
|
|
|
|
Spread float32
|
|
|
|
Life float32
|
|
|
|
LifeModifier float32
|
|
|
|
Resistance FlowerResistance
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *FlowerTraits) UpdateModifier(temp, humid float32) {
|
|
|
|
mod := float32(1)
|
|
|
|
cold := temp * 2
|
|
|
|
mod *= Min32(1, Sqrt32(t.Resistance.Cold*t.Resistance.Cold+cold*cold))
|
|
|
|
hot := (1 - temp) * 2
|
|
|
|
mod *= Min32(1, Sqrt32(t.Resistance.Hot*t.Resistance.Hot+hot*hot))
|
|
|
|
dry := humid * 2
|
|
|
|
mod *= Min32(1, Sqrt32(t.Resistance.Dry*t.Resistance.Dry+dry*dry))
|
|
|
|
wet := (1 - humid) * 2
|
|
|
|
mod *= Min32(1, Sqrt32(t.Resistance.Wet*t.Resistance.Wet+wet*wet))
|
|
|
|
t.LifeModifier = mod
|
|
|
|
}
|
|
|
|
|
|
|
|
type FlowerResistance struct {
|
|
|
|
Cold float32 // 0 will die almost instantly, 1 is completely resistant.
|
|
|
|
Hot float32
|
|
|
|
Dry float32
|
|
|
|
Wet float32
|
|
|
|
}
|
|
|
|
|
2020-05-10 22:46:26 +00:00
|
|
|
// NewAnemoneTraits creates the traits of a anemone, a very generic flower that thrives in a moderate climate.
|
|
|
|
func NewAnemoneTraits() FlowerTraits {
|
2020-05-09 17:34:43 +00:00
|
|
|
return FlowerTraits{
|
2020-05-10 21:00:19 +00:00
|
|
|
Spread: 0.0004,
|
2020-05-10 10:21:51 +00:00
|
|
|
Life: 0.99993,
|
2020-05-09 17:34:43 +00:00
|
|
|
Resistance: FlowerResistance{
|
2020-05-10 22:00:35 +00:00
|
|
|
Cold: 0.7,
|
2020-05-10 21:00:19 +00:00
|
|
|
Hot: 0.7,
|
2020-05-10 10:21:51 +00:00
|
|
|
Dry: 0.5,
|
2020-05-10 22:00:35 +00:00
|
|
|
Wet: 0.5,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewLoosestrifeTraits() FlowerTraits {
|
|
|
|
return FlowerTraits{
|
|
|
|
Spread: 0.0005,
|
|
|
|
Life: 0.99993,
|
|
|
|
Resistance: FlowerResistance{
|
|
|
|
Cold: 0.7,
|
|
|
|
Hot: 0.6,
|
|
|
|
Dry: 0.5,
|
|
|
|
Wet: 0.8,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-10 22:46:26 +00:00
|
|
|
func NewConeflowerTraits() FlowerTraits {
|
2020-05-10 22:00:35 +00:00
|
|
|
return FlowerTraits{
|
|
|
|
Spread: 0.0005,
|
|
|
|
Life: 0.99993,
|
|
|
|
Resistance: FlowerResistance{
|
2020-05-10 22:46:26 +00:00
|
|
|
Cold: 0.7,
|
|
|
|
Hot: 0.8,
|
|
|
|
Dry: 0.8,
|
|
|
|
Wet: 0.5,
|
2020-05-10 22:00:35 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-10 22:46:26 +00:00
|
|
|
func NewTulipTraits() FlowerTraits {
|
2020-05-10 22:00:35 +00:00
|
|
|
return FlowerTraits{
|
|
|
|
Spread: 0.0005,
|
|
|
|
Life: 0.99993,
|
|
|
|
Resistance: FlowerResistance{
|
2020-05-10 22:46:26 +00:00
|
|
|
Cold: 0.8,
|
|
|
|
Hot: 0.6,
|
|
|
|
Dry: 0.5,
|
|
|
|
Wet: 0.9,
|
2020-05-10 22:00:35 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewAjugaTraits() FlowerTraits {
|
|
|
|
return FlowerTraits{
|
|
|
|
Spread: 0.0007,
|
|
|
|
Life: 0.99991,
|
|
|
|
Resistance: FlowerResistance{
|
|
|
|
Cold: 0.9,
|
|
|
|
Hot: 0.5,
|
|
|
|
Dry: 0.75,
|
|
|
|
Wet: 0.75,
|
2020-05-09 17:34:43 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|