namespace GrassCutter { /// /// How big Herbaria-7 is. The ball keeps its 163 830 sectors whatever its size, so a smaller ball has smaller sectors /// too: less grass all round and every sector done sooner. The host picks it for a new save, it stays with the save, /// and everyone who joins gets the host's ball. 0 is the whole planet, as every save from before there was a choice. /// public enum Difficulty : byte { Hazard = 0, HoldMyBeer = 1, Mommy = 2 } public static class Difficulties { /// Easiest first, the way the choice is offered. public static readonly Difficulty[] Order = { Difficulty.Mommy, Difficulty.HoldMyBeer, Difficulty.Hazard }; public static string Name(Difficulty d) => d == Difficulty.Mommy ? "Mommy, I'm Scared!" : d == Difficulty.HoldMyBeer ? "Hold My Beer!" : "I AM THE FUCKING HAZARD!"; public static string Tag(Difficulty d) => Loc.T(d == Difficulty.Mommy ? Loc.N("EASY") : d == Difficulty.HoldMyBeer ? Loc.N("NORMAL") : Loc.N("EXTRA HARD")); public static string Blurb(Difficulty d) => Loc.T( d == Difficulty.Mommy ? Loc.N("A sixth of the big planet, sectors to match. Earth can wait a little.") : d == Difficulty.HoldMyBeer ? Loc.N("A third of the big planet, smaller sectors. Still a lot of lawn.") : Loc.N("The big planet: the whole of Herbaria-7, every blade of it.")); /// /// Which set of sizes a save is on. 0: the first one (radius 1, 1/2, 1/3 of the whole planet), every save from /// before the planets shrank; they keep their ball, the pieces on it stand where they stood. 1: by area, the hard /// one half the whole planet, normal a third of that, easy a sixth. /// public const int NewGen = 1; /// The planet's radius against the whole one. public static float Scale(Difficulty d, int gen) => gen >= 1 ? (d == Difficulty.Mommy ? 0.288675f : d == Difficulty.HoldMyBeer ? 0.408248f : 0.707107f) : (d == Difficulty.Mommy ? 1f / 3f : d == Difficulty.HoldMyBeer ? 0.5f : 1f); /// The size set the world is built on right now. public static int Gen { get; private set; } /// Difficulty and size set in one byte, for the wire. public static byte Wire => (byte)((int)Current | (Gen << 4)); public static void ApplyWire(byte b) => Apply((Difficulty)(b & 15), b >> 4); /// What the next new save starts on: set by the menu (and `-difficulty 0..2` for the dev bots). public static Difficulty Chosen = Difficulty.Hazard; /// The ball the world is built on right now. public static Difficulty Current { get; private set; } = Difficulty.Hazard; /// Builds the world on the ball for this difficulty, if it isn't on it already. public static void Apply(Difficulty d, int gen) { if (d != Difficulty.Mommy && d != Difficulty.HoldMyBeer) d = Difficulty.Hazard; gen = gen >= 1 ? 1 : 0; if (d == Current && gen == Gen) return; Current = d; Gen = gen; Planet.Rescale(GameDefs.PlanetRadius * Scale(d, gen)); } } }