Quick actions

cmd+k|ctrl+k

Navigation

Languages

Randomize a Pokémon trainer

Snippet info

Language

Csharp

Visibility

public

Author

linus.aspelin

Created

2016-12-17T19:09:05Z

Updated

2016-12-17T23:57:22Z

using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;

class MainClass {
    static void Main() {
        var types = File.ReadAllLines("Types").ToList();
        var chosen = new List<int>();
        Random rand = new Random();
        Console.WriteLine("Choose two of the following types:");
        for(int i = 0; i < 4; i++)
        {
            int x;
            do {
                x = rand.Next(types.Count);
             } while(chosen.Any(y => y == x));
            chosen.Add(x);
        }
        chosen.OrderBy(x => x).ToList().ForEach(x => Console.WriteLine(types.ElementAt(x)));
        Console.WriteLine();
        
        //7 stats 3*d10
        var stats = new List<int>();
        int numStats = 7;
        while(stats.Count < numStats) {
            stats.Add(rand.Next(10)+1+3);
            if(stats.Count(stat => stat <= 4) >= 2) {
                stats.Clear();
            }
        }
        Console.WriteLine("Stats to distribute:");
        stats.ForEach(stat => Console.WriteLine(stat));
        Console.WriteLine($"(A total of {stats.Sum()} points)");
        Console.WriteLine();
        
        //money = 300*d10
        Console.WriteLine($"Your starting balance is {(rand.Next(10)+1)*300} pokécoins");
    }
}
INFO