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/ResultScreen.cs

56 lines
2.0 KiB
C#
Raw Permalink Normal View History

2020-06-12 20:02:39 +02:00
using System;
using System.Collections.Generic;
using System.Drawing;
using CC_Functions.Commandline;
using CC_Functions.Commandline.TUI;
2020-06-13 12:51:14 +02:00
using static System.Environment;
2020-06-12 20:02:39 +02:00
namespace Lemonade
2020-06-12 20:02:04 +02:00
{
2020-06-12 20:02:39 +02:00
public class ResultScreen : CenteredScreen
{
public delegate void OkDelegate();
2020-06-12 20:16:11 +02:00
private readonly Label lab;
2020-06-12 20:02:39 +02:00
public ResultScreen(Settings settings) : base(200, 20, ConsoleColor.Black, settings.Color)
{
ContentPanel.ForeColor = ConsoleColor.DarkGray;
Title = "Lemonade - Daily financial report";
lab = new Label("");
ContentPanel.Controls.Add(lab);
Input += (screen, args) => Ok?.Invoke();
Close += (screen, args) => Ok?.Invoke();
}
2020-06-12 20:16:11 +02:00
public event OkDelegate Ok;
2020-06-13 12:15:11 +02:00
public void Setup(IEnumerable<PlayerState> players, Weather weather)
2020-06-12 20:02:39 +02:00
{
2020-06-13 12:15:11 +02:00
if (weather.Heatwave)
lab.Content = "There was a heatwave";
else if (weather.Thunderstorm)
lab.Content = "Lightning struck your table while you were setting it up. Nothing was sold";
else
lab.Content = $"The weather was {weather}. Nothing out of the ordinary happened";
2020-06-13 12:51:14 +02:00
lab.Content += NewLine + NewLine + players.ToStringTable(
2020-06-12 20:16:11 +02:00
new[]
{
2020-06-13 12:51:14 +02:00
"Player", "Glasses made", "Earnings per glass",
"Glasses sold", "Signs made", "Income",
"Expenses", "Profit", "Budget"
2020-06-12 20:16:11 +02:00
},
s => s.Number,
s => s.Glasses,
2020-06-13 12:51:14 +02:00
s => s.GlassPrice.ToDollar(),
2020-06-12 20:16:11 +02:00
s => s.Sales,
s => s.Signs,
2020-06-13 12:51:14 +02:00
s => s.Earnings.ToDollar(),
s => s.Expenses.ToDollar(),
s => (s.Earnings - s.Expenses).ToDollar(),
s => s.Budget.ToDollar());
2020-06-12 20:02:39 +02:00
lab.Render();
ActualSize = new Size(lab.Size.Width, lab.Size.Height);
}
}
2020-06-12 20:02:04 +02:00
}