Skip to content

Instantly share code, notes, and snippets.

@Theoistic
Created May 14, 2020 17:44
Show Gist options
  • Save Theoistic/3f3ba5d6dde646e23ddfbb1c27da8141 to your computer and use it in GitHub Desktop.
Save Theoistic/3f3ba5d6dde646e23ddfbb1c27da8141 to your computer and use it in GitHub Desktop.
This is some weird game.
public class Player
{
public string Username;
public int Score;
public Player(string name)
{
this.Username = name;
}
}
public class Program
{
static void Main(string[] args)
{
List<Player> Players = new List<Player>() { new Player("Neo"), new Player("RainbowDash") };
Random rnd = new Random();
Action<Player> runEntry = (x) =>
{
int score = 0;
int d1 = rnd.Next(1, 6);
int d2 = rnd.Next(1, 6);
// do some logic for even and odd. and add scores.
score = d1 + d2;
if (d1 % 2 == 0)
score += 10;
else
score += 5;
x.Score += score;
Console.WriteLine($"{x.Username} rolled a {d1} and {d2} and has {x.Score} points now.");
};
for (int i = 1; i < 5; i++)
{
foreach (var player in Players)
{
runEntry(player);
}
}
if (Players[0].Score == Players[1].Score)
{
Console.WriteLine("Wow, score is even we need to fix that.");
}
while(Players[0].Score == Players[1].Score)
{
foreach (var player in Players)
{
runEntry(player);
}
}
Player winner = Players.First(x => x.Score == Players.Max(z => z.Score));
Console.WriteLine($"Yaay, {winner.Username} won the game with {winner.Score} points");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment