This repository has been archived on 2022-08-05. You can view files and clone it, but cannot push or open issues or pull requests.
Lemonade/Lemonade/Weather.cs

44 lines
1.0 KiB
C#
Raw Permalink Normal View History

2020-06-12 20:02:39 +02:00
using System;
2020-06-12 20:02:04 +02:00
namespace Lemonade
{
public class Weather
{
2020-06-12 20:16:11 +02:00
private static readonly Random rnd = new Random();
2020-06-13 12:15:11 +02:00
public readonly bool Heatwave;
public readonly bool Thunderstorm;
public double Factor;
public Weather(Settings settings)
{
Factor = rnd.NextDouble();
Heatwave = W == W.Hot_and_dry && rnd.NextDouble() > settings.DifficultyFactor;
Thunderstorm = W == W.Rainy && rnd.NextDouble() < settings.DifficultyFactor;
}
2020-06-12 20:02:39 +02:00
public W W
{
get
{
if (Factor < 0.2) return W.Rainy;
if (Factor < 0.4) return W.Cloudy;
if (Factor < 0.6) return W.Warm;
if (Factor < 0.8) return W.Sunny;
return W.Hot_and_dry;
}
}
2020-06-12 20:16:11 +02:00
public override string ToString() => W.ToString().Replace('_', ' ');
2020-06-12 20:02:39 +02:00
}
public enum W
{
Rainy,
Cloudy,
Warm,
Sunny,
Hot_and_dry
2020-06-12 20:02:04 +02:00
}
}