package tins2020 type Flower struct { ID string 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 } // NewAnemoneTraits creates the traits of a anemone, a very generic flower that thrives in a moderate climate. func NewAnemoneTraits() FlowerTraits { return FlowerTraits{ Spread: 0.0004, Life: 0.99993, Resistance: FlowerResistance{ Cold: 0.7, Hot: 0.7, Dry: 0.5, 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, }, } } func NewConeflowerTraits() FlowerTraits { return FlowerTraits{ Spread: 0.0005, Life: 0.99993, Resistance: FlowerResistance{ Cold: 0.6, Hot: 0.9, Dry: 0.8, Wet: 0.5, }, } } func NewTulipTraits() FlowerTraits { return FlowerTraits{ Spread: 0.0005, Life: 0.99993, Resistance: FlowerResistance{ Cold: 0.8, Hot: 0.6, Dry: 0.5, Wet: 0.9, }, } } 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, }, } }