68 lines
1.8 KiB
C#
68 lines
1.8 KiB
C#
|
using System;
|
|||
|
|
|||
|
namespace Utility
|
|||
|
{
|
|||
|
public enum Difficulty
|
|||
|
{
|
|||
|
Easy,
|
|||
|
Medium,
|
|||
|
Hard
|
|||
|
}
|
|||
|
|
|||
|
public abstract class DifficultySettings
|
|||
|
{
|
|||
|
public Difficulty Difficulty { get; protected set; }
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// Faktor, wie viel mehr Zeit man halt als die Entwickler bei 100% effizienz benötigen.
|
|||
|
/// </summary>
|
|||
|
public double DaysUntilReleaseFactor { get; protected set; }
|
|||
|
}
|
|||
|
|
|||
|
public class EasyDifficulty : DifficultySettings
|
|||
|
{
|
|||
|
public EasyDifficulty()
|
|||
|
{
|
|||
|
Difficulty = Difficulty.Easy;
|
|||
|
DaysUntilReleaseFactor = 2.0;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public class MediumDifficulty : DifficultySettings
|
|||
|
{
|
|||
|
public MediumDifficulty()
|
|||
|
{
|
|||
|
Difficulty = Difficulty.Medium;
|
|||
|
DaysUntilReleaseFactor = 1.5;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public class HardDifficulty : DifficultySettings
|
|||
|
{
|
|||
|
public HardDifficulty()
|
|||
|
{
|
|||
|
Difficulty = Difficulty.Hard;
|
|||
|
DaysUntilReleaseFactor = 1.0;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public static class DifficultyExtensions
|
|||
|
{
|
|||
|
public static DifficultySettings GetSettings(this Difficulty difficulty) => difficulty switch
|
|||
|
{
|
|||
|
Difficulty.Easy => new EasyDifficulty(),
|
|||
|
Difficulty.Medium => new MediumDifficulty(),
|
|||
|
Difficulty.Hard => new HardDifficulty(),
|
|||
|
_ => throw new ArgumentOutOfRangeException(nameof(difficulty), difficulty, null)
|
|||
|
};
|
|||
|
|
|||
|
public static string GetName(this Difficulty difficulty) =>
|
|||
|
difficulty switch
|
|||
|
{
|
|||
|
Difficulty.Easy => "Entspannt",
|
|||
|
Difficulty.Medium => "Normal",
|
|||
|
Difficulty.Hard => "Stressig",
|
|||
|
_ => "Unbekannt"
|
|||
|
};
|
|||
|
}
|
|||
|
}
|