From ce45f4135e363f9027258615058cc203d49c4a69 Mon Sep 17 00:00:00 2001 From: Rokas Puzonas Date: Thu, 28 Apr 2022 01:32:20 +0300 Subject: [PATCH] preliminarily solve `L4.LD_24` --- L4/L4.sln | 25 +++++ L4/LD_24/App_Data/Actors1.txt | 5 + L4/LD_24/App_Data/Actors2.txt | 12 +++ L4/LD_24/App_Data/Actors3.txt | 6 ++ L4/LD_24/App_Data/Klasės.csv | 4 + L4/LD_24/App_Data/Riktine.csv | 8 ++ L4/LD_24/App_Data/Trūkstami.csv | 2 + L4/LD_24/Code/Actor.cs | 33 ++++++ L4/LD_24/Code/Hero.cs | 38 +++++++ L4/LD_24/Code/InOutUtils.cs | 148 +++++++++++++++++++++++++++ L4/LD_24/Code/NPC.cs | 32 ++++++ L4/LD_24/Code/TaskUtils.cs | 111 ++++++++++++++++++++ L4/LD_24/Forma1.aspx | 33 ++++++ L4/LD_24/Forma1.aspx.cs | 72 +++++++++++++ L4/LD_24/Forma1.aspx.designer.cs | 107 ++++++++++++++++++++ L4/LD_24/Forma1Utils.cs | 68 +++++++++++++ L4/LD_24/LD_24.csproj | 150 ++++++++++++++++++++++++++++ L4/LD_24/Properties/AssemblyInfo.cs | 35 +++++++ L4/LD_24/Styles/main.css | 11 ++ L4/LD_24/Web.Debug.config | 30 ++++++ L4/LD_24/Web.Release.config | 31 ++++++ L4/LD_24/Web.config | 18 ++++ L4/LD_24/packages.config | 5 + 23 files changed, 984 insertions(+) create mode 100644 L4/L4.sln create mode 100644 L4/LD_24/App_Data/Actors1.txt create mode 100644 L4/LD_24/App_Data/Actors2.txt create mode 100644 L4/LD_24/App_Data/Actors3.txt create mode 100644 L4/LD_24/App_Data/Klasės.csv create mode 100644 L4/LD_24/App_Data/Riktine.csv create mode 100644 L4/LD_24/App_Data/Trūkstami.csv create mode 100644 L4/LD_24/Code/Actor.cs create mode 100644 L4/LD_24/Code/Hero.cs create mode 100644 L4/LD_24/Code/InOutUtils.cs create mode 100644 L4/LD_24/Code/NPC.cs create mode 100644 L4/LD_24/Code/TaskUtils.cs create mode 100644 L4/LD_24/Forma1.aspx create mode 100644 L4/LD_24/Forma1.aspx.cs create mode 100644 L4/LD_24/Forma1.aspx.designer.cs create mode 100644 L4/LD_24/Forma1Utils.cs create mode 100644 L4/LD_24/LD_24.csproj create mode 100644 L4/LD_24/Properties/AssemblyInfo.cs create mode 100644 L4/LD_24/Styles/main.css create mode 100644 L4/LD_24/Web.Debug.config create mode 100644 L4/LD_24/Web.Release.config create mode 100644 L4/LD_24/Web.config create mode 100644 L4/LD_24/packages.config diff --git a/L4/L4.sln b/L4/L4.sln new file mode 100644 index 0000000..46eaa1a --- /dev/null +++ b/L4/L4.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.1.32328.378 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LD_24", "LD_24\LD_24.csproj", "{4B4C2BFE-C41E-4EA1-BC86-979E2CA1D27B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4B4C2BFE-C41E-4EA1-BC86-979E2CA1D27B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4B4C2BFE-C41E-4EA1-BC86-979E2CA1D27B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4B4C2BFE-C41E-4EA1-BC86-979E2CA1D27B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4B4C2BFE-C41E-4EA1-BC86-979E2CA1D27B}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {311CB727-13E2-47BB-8B1B-0C68CF29441E} + EndGlobalSection +EndGlobal diff --git a/L4/LD_24/App_Data/Actors1.txt b/L4/LD_24/App_Data/Actors1.txt new file mode 100644 index 0000000..2a02e69 --- /dev/null +++ b/L4/LD_24/App_Data/Actors1.txt @@ -0,0 +1,5 @@ +Orc +Amandatown +Mercedes;Warrior;24;18;13;17;Cummings, Lehner and Wilkinson +Kelvin;Warrior;5;4;17;11;Waelchi, Kulas and Bruen +Domenico;Archer;24;10;3;25;Jacobi Group diff --git a/L4/LD_24/App_Data/Actors2.txt b/L4/LD_24/App_Data/Actors2.txt new file mode 100644 index 0000000..3b706d3 --- /dev/null +++ b/L4/LD_24/App_Data/Actors2.txt @@ -0,0 +1,12 @@ +Halfling +Leifberg +Clare;Warrior;17;2;7;23;14;23;19;6 +Drake;Hunter;10;15;18;3;Will - Yost +Mike;Necromancer;18;24;3;11;23;11;22;9 +Cathryn;Warrior;20;1;14;9;2;22;6;18 +Tobin;Necromancer;12;14;21;18;Hermann, Cole and Gislason +Yasmine;Archer;6;24;3;4;O'Keefe and Sons +Shanna;Necromancer;3;5;15;14;Mraz, Jenkins and Bosco +Otha;Warrior;24;22;13;15;2;13;17;13 +Cletus;Necromancer;4;8;20;16;Moen - Roberts +Katelynn;Hunter;2;24;9;9;Feil Inc diff --git a/L4/LD_24/App_Data/Actors3.txt b/L4/LD_24/App_Data/Actors3.txt new file mode 100644 index 0000000..8af34a3 --- /dev/null +++ b/L4/LD_24/App_Data/Actors3.txt @@ -0,0 +1,6 @@ +Fairy +Celestineville +Alec;Hunter;20;14;13;4;9;6;21;23 +Summer;Warrior;6;11;23;7;19;12;19;24 +Rylan;Archer;13;17;23;20;10;10;17;7 +Gisselle;Warrior;11;10;11;5;6;16;6;12 diff --git a/L4/LD_24/App_Data/Klasės.csv b/L4/LD_24/App_Data/Klasės.csv new file mode 100644 index 0000000..bbc2a53 --- /dev/null +++ b/L4/LD_24/App_Data/Klasės.csv @@ -0,0 +1,4 @@ +Warrior +Archer +Hunter +Necromancer diff --git a/L4/LD_24/App_Data/Riktine.csv b/L4/LD_24/App_Data/Riktine.csv new file mode 100644 index 0000000..77ad195 --- /dev/null +++ b/L4/LD_24/App_Data/Riktine.csv @@ -0,0 +1,8 @@ +Halfling;Leifberg;Clare;Warrior;17;2;7;23;14;23;19;6 +Fairy;Celestineville;Summer;Warrior;6;11;23;7;19;12;19;24 +Fairy;Celestineville;Alec;Hunter;20;14;13;4;9;6;21;23 +Halfling;Leifberg;Mike;Necromancer;18;24;3;11;23;11;22;9 +Orc;Amandatown;Domenico;Archer;24;10;3;25;Jacobi Group +Halfling;Leifberg;Yasmine;Archer;6;24;3;4;O'Keefe and Sons +Halfling;Leifberg;Katelynn;Hunter;2;24;9;9;Feil Inc +Orc;Amandatown;Mercedes;Warrior;24;18;13;17;Cummings, Lehner and Wilkinson diff --git a/L4/LD_24/App_Data/Trūkstami.csv b/L4/LD_24/App_Data/Trūkstami.csv new file mode 100644 index 0000000..1d684be --- /dev/null +++ b/L4/LD_24/App_Data/Trūkstami.csv @@ -0,0 +1,2 @@ +Orc +Fairy diff --git a/L4/LD_24/Code/Actor.cs b/L4/LD_24/Code/Actor.cs new file mode 100644 index 0000000..9f94814 --- /dev/null +++ b/L4/LD_24/Code/Actor.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace LD_24.Code +{ + public abstract class Actor + { + public string Race { get; set; } + public string StartingTown { get; set; } + public string Name { get; set; } + public string Class { get; set; } + public int Health { get; set; } + public int Mana { get; set; } + public int Attack { get; set; } + public int Defense { get; set; } + + public Actor(string race, string startingTown, string name, string @class, int health, int mana, int attack, int defense) + { + Race = race; + StartingTown = startingTown; + Name = name; + Class = @class; + Health = health; + Mana = mana; + Attack = attack; + Defense = defense; + } + + public abstract string ToCSVLine(); + } +} \ No newline at end of file diff --git a/L4/LD_24/Code/Hero.cs b/L4/LD_24/Code/Hero.cs new file mode 100644 index 0000000..ada81ef --- /dev/null +++ b/L4/LD_24/Code/Hero.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace LD_24.Code +{ + public class Hero : Actor, IComparable, IEquatable + { + public int Power { get; set; } + public int Agility { get; set; } + public int Intellect { get; set; } + public int Special { get; set; } + + public Hero(string race, string startingTown, string name, string @class, int health, int mana, int attack, int defense, int power, int agility, int intellect, int special) : base(race, startingTown, name, @class, health, mana, attack, defense) + { + Power = power; + Agility = agility; + Intellect = intellect; + Special = special; + } + + public int CompareTo(Hero other) + { + return Intellect.CompareTo(other.Intellect); + } + + public bool Equals(Hero other) + { + return Intellect.Equals(other.Intellect); + } + + public override string ToCSVLine() + { + return string.Join(";", Race, StartingTown, Name, Class, Health, Mana, Attack, Defense, Power, Agility, Intellect, Special); + } + } +} \ No newline at end of file diff --git a/L4/LD_24/Code/InOutUtils.cs b/L4/LD_24/Code/InOutUtils.cs new file mode 100644 index 0000000..b424f0a --- /dev/null +++ b/L4/LD_24/Code/InOutUtils.cs @@ -0,0 +1,148 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.IO; +using System.Diagnostics; +using Bogus; +using System.Text; + +namespace LD_24.Code +{ + public static class InOutUtils + { + private static readonly List Races = new List { "Human", "Orc", "Elf", "Dwarf", "Fairy", "Halfling" }; + private static readonly List Classess = new List { "Warrior", "Hunter", "Archer", "Mage", "Necromancer" }; + private static readonly Faker faker = new Faker(); + + public static IEnumerable ReadLines(string filename) + { + using (var reader = new StreamReader(filename)) + { + string line; + while ((line = reader.ReadLine()) != null) + { + // This check is for ignoring empty lines + if (line.Length > 0) + { + yield return line; + } + } + } + } + + public static List ReadActors(string filename) + { + var actors = new List(); + var lines = ReadLines(filename); + var race = lines.First().Trim(); + var startingTown = lines.Skip(1).First().Trim(); + foreach (var line in lines.Skip(2)) + { + string[] parts = line.Split(';'); + if (parts.Length != 7 && parts.Length != 10) + { + throw new Exception($"Invalid number of values given: '{line}'"); + } + + string name = parts[0].Trim(); + string @class = parts[1].Trim(); + int health = int.Parse(parts[2]); + int mana = int.Parse(parts[3]); + int attack = int.Parse(parts[4]); + int defense = int.Parse(parts[5]); + if (parts.Length == 7) + { + string guild = parts[6].Trim(); + actors.Add(new NPC(race, startingTown, name, @class, health, mana, attack, defense, guild)); + } + else if (parts.Length == 10) + { + int power = int.Parse(parts[6]); + int agility = int.Parse(parts[7]); + int intellect = int.Parse(parts[8]); + int special = int.Parse(parts[9]); + actors.Add(new Hero(race, startingTown, name, @class, health, mana, attack, defense, power, agility, intellect, special)); + } + } + return actors; + } + + public static void GenerateFakeActors(string filename) + { + using (var writer = new StreamWriter(filename)) + { + writer.WriteLine(faker.PickRandom(Races)); + writer.WriteLine(faker.Address.City()); + int count = faker.Random.Number(2, 10); + for (int i = 0; i < count; i++) + { + string name = faker.Name.FirstName(); + string @class = faker.PickRandom(Classess); + int health = faker.Random.Number(1, 25); + int mana = faker.Random.Number(1, 25); + int attack = faker.Random.Number(1, 25); + int defense = faker.Random.Number(1, 25); + writer.Write($"{name};{@class};{health};{mana};{attack};{defense};"); + if (faker.Random.Number(100) < 60) + { + string guild = faker.Company.CompanyName(); + writer.WriteLine($"{guild}"); + } else + { + int power = faker.Random.Number(1, 25); + int agility = faker.Random.Number(1, 25); + int intellect = faker.Random.Number(1, 25); + int special = faker.Random.Number(1, 25); + writer.WriteLine($"{power};{agility};{intellect};{special}"); + } + } + } + } + + public static List ReadActorsDir(string directory, string pattern = "*.txt") + { + if (!Directory.Exists(directory)) + { + throw new Exception(string.Format("Directory '{0}' not found", directory)); + } + var merged = new List(); + foreach (var filename in Directory.GetFiles(directory, pattern)) + { + merged.AddRange(ReadActors(filename)); + } + return merged; + } + + public static void PrintClassesCSV(string filename, List classes) + { + using (var writer = new StreamWriter(filename, false, Encoding.UTF8)) + { + foreach (var @class in classes) + { + writer.WriteLine(@class); + } + } + } + + public static void PrintMissingActors(string filename, Tuple, List> missingActors) + { + using (var writer = new StreamWriter(filename, false, Encoding.UTF8)) + { + writer.WriteLine(string.Join(";", missingActors.Item1)); + writer.WriteLine(string.Join(";", missingActors.Item2)); + } + } + + public static void PrintTeam(string filename, List team) + { + using (var writer = new StreamWriter(filename, false, Encoding.UTF8)) + { + foreach (var actor in team) + { + writer.WriteLine(actor.ToCSVLine()); + } + } + } + } +} \ No newline at end of file diff --git a/L4/LD_24/Code/NPC.cs b/L4/LD_24/Code/NPC.cs new file mode 100644 index 0000000..e0d37f4 --- /dev/null +++ b/L4/LD_24/Code/NPC.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace LD_24.Code +{ + public class NPC : Actor, IComparable, IEquatable + { + public string Guild { get; set; } + + public NPC(string race, string startingTown, string name, string @class, int health, int mana, int attack, int defense, string guild) : base(race, startingTown, name, @class, health, mana, attack, defense) + { + Guild = guild; + } + + public int CompareTo(NPC other) + { + return Attack.CompareTo(other.Attack); + } + + public bool Equals(NPC other) + { + return Attack.Equals(other.Attack); + } + + public override string ToCSVLine() + { + return string.Join(";", Race, StartingTown, Name, Class, Health, Mana, Attack, Defense, Guild); + } + } +} \ No newline at end of file diff --git a/L4/LD_24/Code/TaskUtils.cs b/L4/LD_24/Code/TaskUtils.cs new file mode 100644 index 0000000..f22742e --- /dev/null +++ b/L4/LD_24/Code/TaskUtils.cs @@ -0,0 +1,111 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace LD_24.Code +{ + public static class TaskUtils + { + public static Dictionary FindMostHealthByClass(List actors) + { + Dictionary mostHealth = new Dictionary(); + foreach (var actor in actors) + { + if (mostHealth.ContainsKey(actor.Class)) + { + mostHealth[actor.Class] = Math.Max(mostHealth[actor.Class], actor.Health); + } else + { + mostHealth.Add(actor.Class, actor.Health); + } + } + return mostHealth; + } + + public static List FindAllClasses(List actors) + { + List result = new List(); + foreach (var actor in actors) + { + if (!result.Contains(actor.Class)) + { + result.Add(actor.Class); + } + } + return result; + } + + public static List FindAllRaces(List actors) + { + List races = new List(); + foreach (var actor in actors) + { + if (!races.Contains(actor.Race)) + { + races.Add(actor.Race); + } + } + return races; + } + + public static Tuple, List> FindMissingActors(List actors) + { + var races = FindAllRaces(actors); + var missingHeroes = races; + var missingNPCs = new List(races); + foreach (var actor in actors) + { + if (actor is Hero) + { + missingHeroes.Remove(actor.Race); + } else if (actor is NPC) + { + missingNPCs.Remove(actor.Race); + } + } + + return Tuple.Create(missingHeroes, missingNPCs); + } + + public static List FilterMostHealthByClass(List actors) + { + List filtered = new List(); + var mostHealths = FindMostHealthByClass(actors); + foreach (var actor in actors) + { + if (mostHealths[actor.Class] == actor.Health) + { + filtered.Add(actor); + } + } + return filtered; + } + + public static List FilterHeroesByIntellect(List actors, int minIntellect) + { + List filtered = new List(); + foreach (var actor in actors) + { + if (actor is Hero && (actor as Hero).Intellect > minIntellect) + { + filtered.Add(actor as Hero); + } + } + return filtered; + } + + public static List FilterNPCsByAttack(List actors, int maxAttack) + { + List filtered = new List(); + foreach (var actor in actors) + { + if (actor is NPC && actor.Attack < maxAttack) + { + filtered.Add(actor as NPC); + } + } + return filtered; + } + } +} \ No newline at end of file diff --git a/L4/LD_24/Forma1.aspx b/L4/LD_24/Forma1.aspx new file mode 100644 index 0000000..6355674 --- /dev/null +++ b/L4/LD_24/Forma1.aspx @@ -0,0 +1,33 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Forma1.aspx.cs" Inherits="LD_24.Forma1" %> + + + + + + + + +
+
+ +
+ +
+ +
+ +
+
+ +
+
+ + + + + + +
+
+ + diff --git a/L4/LD_24/Forma1.aspx.cs b/L4/LD_24/Forma1.aspx.cs new file mode 100644 index 0000000..898b3f7 --- /dev/null +++ b/L4/LD_24/Forma1.aspx.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; +using System.IO; +using LD_24.Code; +using System.Diagnostics; + +namespace LD_24 +{ + public partial class Forma1 : System.Web.UI.Page + { + private List actors = null; + + protected void Page_Load(object sender, EventArgs e) + { + string[] actorFiles = { "Actors1.txt", "Actors2.txt", "Actors3.txt" }; + foreach (string name in actorFiles) + { + string filename = Server.MapPath($"App_Data/{name}"); + if (!File.Exists(filename)) + { + InOutUtils.GenerateFakeActors(filename); + } + } + + try + { + actors = InOutUtils.ReadActorsDir(Server.MapPath("App_Data")); + } catch (Exception ex) + { + Debug.WriteLine("Oops an error occured:"); + Debug.WriteLine(ex); + throw ex; + } + + Label1.Visible = false; + Label2.Visible = false; + } + + protected void Button1_Click(object sender, EventArgs e) + { + Label1.Visible = true; + Label2.Visible = true; + + int minHeroIntellect = int.Parse(TextBox1.Text); + int maxNPCAttack = int.Parse(TextBox2.Text); + + ShowActors(Table1, actors); + + var heatlhyActors = TaskUtils.FilterMostHealthByClass(actors); + ShowHealthyActors(Table2, heatlhyActors); + + var allClasses = TaskUtils.FindAllClasses(actors); + InOutUtils.PrintClassesCSV(Server.MapPath("App_Data/Klasės.csv"), allClasses); + + var missingActors = TaskUtils.FindMissingActors(actors); + InOutUtils.PrintMissingActors(Server.MapPath("App_Data/Trūkstami.csv"), missingActors); + + var intellectHeroes = TaskUtils.FilterHeroesByIntellect(actors, minHeroIntellect); + var strengthNPCs = TaskUtils.FilterNPCsByAttack(actors, maxNPCAttack); + intellectHeroes.Sort(); + strengthNPCs.Sort(); + var team = new List(); + team.AddRange(intellectHeroes); + team.AddRange(strengthNPCs); + InOutUtils.PrintTeam(Server.MapPath("App_Data/Riktine.csv"), team); + } + } +} \ No newline at end of file diff --git a/L4/LD_24/Forma1.aspx.designer.cs b/L4/LD_24/Forma1.aspx.designer.cs new file mode 100644 index 0000000..f1ffbbb --- /dev/null +++ b/L4/LD_24/Forma1.aspx.designer.cs @@ -0,0 +1,107 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace LD_24 +{ + + + public partial class Forma1 + { + + /// + /// form1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.HtmlControls.HtmlForm form1; + + /// + /// Label3 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label Label3; + + /// + /// TextBox1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox TextBox1; + + /// + /// Label4 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label Label4; + + /// + /// TextBox2 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox TextBox2; + + /// + /// Button1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Button Button1; + + /// + /// Label1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label Label1; + + /// + /// Table1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Table Table1; + + /// + /// Label2 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label Label2; + + /// + /// Table2 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Table Table2; + } +} diff --git a/L4/LD_24/Forma1Utils.cs b/L4/LD_24/Forma1Utils.cs new file mode 100644 index 0000000..d07ce12 --- /dev/null +++ b/L4/LD_24/Forma1Utils.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI.WebControls; +using LD_24.Code; + +namespace LD_24 +{ + public partial class Forma1 : System.Web.UI.Page + { + public static IEnumerable> ShowTable(Table table, IEnumerable list, params string[] columns) + { + TableHeaderRow header = new TableHeaderRow(); + foreach (string column in columns) + { + header.Cells.Add(new TableHeaderCell { Text = column }); + } + table.Rows.Add(header); + + bool noRows = true; + foreach (T item in list) + { + TableRow row = new TableRow(); + yield return Tuple.Create(item, row); + table.Rows.Add(row); + noRows = false; + } + + if (noRows) + { + TableRow row = new TableRow(); + row.Cells.Add(new TableCell { Text = "Nėra", ColumnSpan = columns.Length }); + table.Rows.Add(row); + } + } + + public static void ShowActors(Table table, IEnumerable actors) + { + foreach (var tuple in ShowTable(table, actors, "Rasė", "Miestas", "Vardas", "Klasė", "Gyvybė", "Mana", "Žala", "Šarvai")) + { + Actor actor = tuple.Item1; + TableRow row = tuple.Item2; + row.Cells.Add(new TableCell { Text = actor.Race }); + row.Cells.Add(new TableCell { Text = actor.StartingTown }); + row.Cells.Add(new TableCell { Text = actor.Name }); + row.Cells.Add(new TableCell { Text = actor.Class }); + row.Cells.Add(new TableCell { Text = actor.Health.ToString() }); + row.Cells.Add(new TableCell { Text = actor.Mana.ToString() }); + row.Cells.Add(new TableCell { Text = actor.Attack.ToString() }); + row.Cells.Add(new TableCell { Text = actor.Defense.ToString() }); + } + } + + public static void ShowHealthyActors(Table table, IEnumerable actors) + { + foreach (var tuple in ShowTable(table, actors, "Vardas", "Rasė", "Klasė", "Gyvybė")) + { + Actor actor = tuple.Item1; + TableRow row = tuple.Item2; + row.Cells.Add(new TableCell { Text = actor.Name }); + row.Cells.Add(new TableCell { Text = actor.Race }); + row.Cells.Add(new TableCell { Text = actor.Class }); + row.Cells.Add(new TableCell { Text = actor.Health.ToString() }); + } + } + } +} \ No newline at end of file diff --git a/L4/LD_24/LD_24.csproj b/L4/LD_24/LD_24.csproj new file mode 100644 index 0000000..0b2d286 --- /dev/null +++ b/L4/LD_24/LD_24.csproj @@ -0,0 +1,150 @@ + + + + + Debug + AnyCPU + + + 2.0 + {4B4C2BFE-C41E-4EA1-BC86-979E2CA1D27B} + {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} + Library + Properties + LD_24 + LD_24 + v4.6 + true + + + + + + + + + + + + true + full + false + bin\ + DEBUG;TRACE + prompt + 4 + + + true + pdbonly + true + bin\ + TRACE + prompt + 4 + + + + ..\packages\Bogus.34.0.2\lib\net40\Bogus.dll + + + + + + + + + + + + + + + + + + + + + + ..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll + + + + + + + + + + + + + + + + + + Forma1.aspx + ASPXCodeBehind + + + Forma1.aspx + + + ASPXCodeBehind + + + + + + + + + + Web.config + + + Web.config + + + + + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + + + + + + True + True + 50285 + / + http://localhost:44308/ + False + False + + + False + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + \ No newline at end of file diff --git a/L4/LD_24/Properties/AssemblyInfo.cs b/L4/LD_24/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..e19cb50 --- /dev/null +++ b/L4/LD_24/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("LD_24")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("LD_24")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("4b4c2bfe-c41e-4ea1-bc86-979e2ca1d27b")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/L4/LD_24/Styles/main.css b/L4/LD_24/Styles/main.css new file mode 100644 index 0000000..562696f --- /dev/null +++ b/L4/LD_24/Styles/main.css @@ -0,0 +1,11 @@ +table, th, td { + border: 1px solid black; + padding: 0.5rem; + border-collapse: collapse; +} + +table { + margin-bottom: 1em; + background-color: #FFFFCC; +} + diff --git a/L4/LD_24/Web.Debug.config b/L4/LD_24/Web.Debug.config new file mode 100644 index 0000000..fae9cfe --- /dev/null +++ b/L4/LD_24/Web.Debug.config @@ -0,0 +1,30 @@ + + + + + + + + + + \ No newline at end of file diff --git a/L4/LD_24/Web.Release.config b/L4/LD_24/Web.Release.config new file mode 100644 index 0000000..da6e960 --- /dev/null +++ b/L4/LD_24/Web.Release.config @@ -0,0 +1,31 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/L4/LD_24/Web.config b/L4/LD_24/Web.config new file mode 100644 index 0000000..db443c3 --- /dev/null +++ b/L4/LD_24/Web.config @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/L4/LD_24/packages.config b/L4/LD_24/packages.config new file mode 100644 index 0000000..bceeb8b --- /dev/null +++ b/L4/LD_24/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file