diff --git a/.editorconfig b/.editorconfig index 1f75e836..e87a51e1 100644 --- a/.editorconfig +++ b/.editorconfig @@ -16,4 +16,16 @@ dotnet_diagnostic.CA1050.severity = none dotnet_diagnostic.IDE0028.severity = none # RS0030: Do not used banned APIs -dotnet_diagnostic.RS0030.severity = error \ No newline at end of file +dotnet_diagnostic.RS0030.severity = error + +# CA1510: Use ArgumentNullException throw helper +dotnet_diagnostic.CA1510.severity = none + +# CA1512: Use ArgumentOutOfRangeException throw helper +dotnet_diagnostic.CA1512.severity = none + +# IDE0290: Use primary constructor +dotnet_diagnostic.IDE0290.severity = none + +# IDE0270: Use coalesce expression +dotnet_diagnostic.IDE0270.severity = none \ No newline at end of file diff --git a/Projects/2048/Program.cs b/Projects/2048/Program.cs index c743cb4e..58bef7a8 100644 --- a/Projects/2048/Program.cs +++ b/Projects/2048/Program.cs @@ -4,7 +4,7 @@ using static Direction; ConsoleColor[] Colors = -{ +[ ConsoleColor.DarkBlue, ConsoleColor.DarkGreen, ConsoleColor.DarkCyan, @@ -14,7 +14,7 @@ ConsoleColor.Blue, ConsoleColor.Red, ConsoleColor.Magenta, -}; +]; try { diff --git a/Projects/Beep Pad/Program.cs b/Projects/Beep Pad/Program.cs index d4b4abfc..a5b9bdd8 100644 --- a/Projects/Beep Pad/Program.cs +++ b/Projects/Beep Pad/Program.cs @@ -9,8 +9,8 @@ (int X, int Y) Position = default; // C major scale, starting with middle C -int[] frequencies = new int[] -{ +int[] frequencies = +[ 262, 294, 330, @@ -20,7 +20,7 @@ 494, 523, 587, -}; +]; if (!OperatingSystem.IsWindows()) { @@ -165,7 +165,7 @@ void ShuffleFrequencies() int[] GetRandomCode() { - int[] possibilities = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + int[] possibilities = [1, 2, 3, 4, 5, 6, 7, 8, 9]; for (int i = 0; i < CodeLength; i++) { int randomIndex = Random.Shared.Next(possibilities.Length - i); diff --git a/Projects/Blackjack/Program.cs b/Projects/Blackjack/Program.cs index 7d715d50..da7e9603 100644 --- a/Projects/Blackjack/Program.cs +++ b/Projects/Blackjack/Program.cs @@ -556,8 +556,8 @@ public string[] Render() { if (!FaceUp) { - return new string[] - { + return + [ $"┌───────┐", $"│███████│", $"│███████│", @@ -565,7 +565,7 @@ public string[] Render() $"│███████│", $"│███████│", $"└───────┘", - }; + ]; } char suit = Suit.ToString()[0]; @@ -581,8 +581,8 @@ public string[] Render() string card = $"{value}{suit}"; string a = card.Length < 3 ? $"{card} " : card; string b = card.Length < 3 ? $" {card}" : card; - return new[] - { + return + [ $"┌───────┐", $"│{a} │", $"│ │", @@ -590,7 +590,7 @@ public string[] Render() $"│ │", $"│ {b}│", $"└───────┘", - }; + ]; } } diff --git a/Projects/Bound/Program.cs b/Projects/Bound/Program.cs index 58727a8b..e65ecc1a 100644 --- a/Projects/Bound/Program.cs +++ b/Projects/Bound/Program.cs @@ -4,7 +4,7 @@ Exception? exception = null; ((int Left, int Top) StartPosition, (string Map, TimeSpan Delay)[])[] levels = -{ +[ #region level 00 ((15, 16), new (string Map, TimeSpan Delay)[] @@ -1816,7 +1816,7 @@ """, TimeSpan.FromSeconds(.5)), }), #endregion -}; +]; try { diff --git a/Projects/Clicker/Program.cs b/Projects/Clicker/Program.cs index af1e7aef..e90ec0fa 100644 --- a/Projects/Clicker/Program.cs +++ b/Projects/Clicker/Program.cs @@ -3,11 +3,11 @@ using System.Numerics; char[] keys = -{ +[ 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', -}; +]; MainMenu: Console.Clear(); diff --git a/Projects/Console Monsters/Bases/MapBase.cs b/Projects/Console Monsters/Bases/MapBase.cs index 68158526..bf8488b6 100644 --- a/Projects/Console Monsters/Bases/MapBase.cs +++ b/Projects/Console Monsters/Bases/MapBase.cs @@ -14,10 +14,7 @@ public static (int I, int J) WorldToTile(int i, int j) public void SpawnCharacterOn(char c) { (int I, int J)? tile = FindTileInMap(c); - if (tile is null) - { - throw new InvalidOperationException("Attempting to spawn the player on a non-existing tile."); - } + if (tile is null) throw new InvalidOperationException("Attempting to spawn the player on a non-existing tile."); character.I = tile.Value.I * Sprites.Width; character.J = tile.Value.J * Sprites.Height; } diff --git a/Projects/Console Monsters/Characters/Camper.cs b/Projects/Console Monsters/Characters/Camper.cs index 501a8ef6..a4624f87 100644 --- a/Projects/Console Monsters/Characters/Camper.cs +++ b/Projects/Console Monsters/Characters/Camper.cs @@ -6,11 +6,11 @@ public Camper() { Sprite = IdleFront; - Dialogue = new string[] - { + Dialogue = + [ "Camper:", "Nothing better than warming up by a fire.", - }; + ]; } public override string? Name => "Camper"; diff --git a/Projects/Console Monsters/Characters/ChineseMan.cs b/Projects/Console Monsters/Characters/ChineseMan.cs index c94fa08c..7b1f3779 100644 --- a/Projects/Console Monsters/Characters/ChineseMan.cs +++ b/Projects/Console Monsters/Characters/ChineseMan.cs @@ -6,11 +6,11 @@ public ChineseMan() { Sprite = IdleFront; - Dialogue = new string[] - { + Dialogue = + [ "Chinese Man says:" + "I'm a copy paste file" - }; + ]; } public override string? Name => "Chinese Man"; diff --git a/Projects/Console Monsters/Characters/CopyPaste.cs b/Projects/Console Monsters/Characters/CopyPaste.cs index a9b0c8fe..9e815859 100644 --- a/Projects/Console Monsters/Characters/CopyPaste.cs +++ b/Projects/Console Monsters/Characters/CopyPaste.cs @@ -1,24 +1,24 @@ namespace Console_Monsters.Characters; -public class name : CharacterBase -{ - public name() - { - Sprite = IdleFront; +//public class name : CharacterBase +//{ +// public name() +// { +// Sprite = IdleFront; - Dialogue = new string[] - { - "name says:" + - "I'm a copy paste file" - }; - } +// Dialogue = +// [ +// "name says:" + +// "I'm a copy paste file" +// ]; +// } - public override string? Name => "name"; +// public override string? Name => "name"; - public static readonly string IdleFront = - @"COPY" + '\n' + - @"COPY" + '\n' + - @"COPY" + '\n' + - @"COPY" + '\n' + - @"COPY"; -} +// public static readonly string IdleFront = +// @"COPY" + '\n' + +// @"COPY" + '\n' + +// @"COPY" + '\n' + +// @"COPY" + '\n' + +// @"COPY"; +//} diff --git a/Projects/Console Monsters/Characters/LittleGirl.cs b/Projects/Console Monsters/Characters/LittleGirl.cs index aa265078..ceafe557 100644 --- a/Projects/Console Monsters/Characters/LittleGirl.cs +++ b/Projects/Console Monsters/Characters/LittleGirl.cs @@ -6,11 +6,11 @@ public LittleGirl() { Sprite = IdleFront; - Dialogue = new string[] - { + Dialogue = + [ "Little Girl says:" + "I'm a copy paste file" - }; + ]; } public override string? Name => "Little Girl"; diff --git a/Projects/Console Monsters/Characters/MartialArtist.cs b/Projects/Console Monsters/Characters/MartialArtist.cs index 983f2d44..f77d19e7 100644 --- a/Projects/Console Monsters/Characters/MartialArtist.cs +++ b/Projects/Console Monsters/Characters/MartialArtist.cs @@ -6,11 +6,11 @@ public MartialArtist() { Sprite = IdleFront; - Dialogue = new string[] - { + Dialogue = + [ "Martial Artist says:" + "Wanna learn some martial arts?" - }; + ]; } public override string? Name => "Martial Artist"; diff --git a/Projects/Console Monsters/Characters/Monk.cs b/Projects/Console Monsters/Characters/Monk.cs index 7c3e9636..18934a80 100644 --- a/Projects/Console Monsters/Characters/Monk.cs +++ b/Projects/Console Monsters/Characters/Monk.cs @@ -6,11 +6,11 @@ public Monk() { Sprite = IdleFront; - Dialogue = new string[] - { + Dialogue = + [ "Monk Says:", "Hello! I am a Danish Monk. :P", - }; + ]; } public override string? Name => "Scientist"; diff --git a/Projects/Console Monsters/Characters/Nurse.cs b/Projects/Console Monsters/Characters/Nurse.cs index 35cec56f..c4bdb828 100644 --- a/Projects/Console Monsters/Characters/Nurse.cs +++ b/Projects/Console Monsters/Characters/Nurse.cs @@ -6,11 +6,11 @@ public Nurse() { Sprite = Idle1; - Dialogue = new string[] - { + Dialogue = + [ "Nurse Says:", "Hello! I have healed your monsters:P", - }; + ]; } public override string? Name => "Nurse"; diff --git a/Projects/Console Monsters/Characters/Samurai.cs b/Projects/Console Monsters/Characters/Samurai.cs index 5a7524d8..4a9cf709 100644 --- a/Projects/Console Monsters/Characters/Samurai.cs +++ b/Projects/Console Monsters/Characters/Samurai.cs @@ -6,11 +6,11 @@ public Samurai() { Sprite = IdleFront; - Dialogue = new string[] - { + Dialogue = + [ "Samurai says:" + "I'm a copy paste file" - }; + ]; } public override string? Name => "Samurai"; diff --git a/Projects/Console Monsters/Characters/Scientist.cs b/Projects/Console Monsters/Characters/Scientist.cs index 81a7cd14..40236b87 100644 --- a/Projects/Console Monsters/Characters/Scientist.cs +++ b/Projects/Console Monsters/Characters/Scientist.cs @@ -6,11 +6,11 @@ public Scientist() { Sprite = IdleFront; - Dialogue = new string[] - { + Dialogue = + [ "Scientist Says:", "Hello! I am a scientist. :P", - }; + ]; } public override string? Name => "Scientist"; diff --git a/Projects/Console Monsters/Maps/Center1.cs b/Projects/Console Monsters/Maps/Center1.cs index 8c5a4382..963bf5e6 100644 --- a/Projects/Console Monsters/Maps/Center1.cs +++ b/Projects/Console Monsters/Maps/Center1.cs @@ -13,15 +13,15 @@ public Center1() littleGirl = new(); } - private static readonly char[][] spriteSheet = new char[][] - { + private static readonly char[][] spriteSheet = + [ "affffifffffjffffb".ToCharArray(), "go gttktths oh".ToCharArray(), "g mplllrnq h".ToCharArray(), "g h".ToCharArray(), "go oh".ToCharArray(), "ceeeeee000eeeeeed".ToCharArray(), - }; + ]; public override char[][] SpriteSheet => spriteSheet; @@ -89,29 +89,29 @@ public override void InteractWithMapTile(int i, int j) switch (SpriteSheet[j][i]) { case 'k': - PromptText = new string[] - { + PromptText = + [ " Hello and welcome to the monster center.", " I will heal all your monsters.", - }; + ]; for (int p = 0; p < partyMonsters.Count; p++) { partyMonsters[p].CurrentHP = partyMonsters[p].MaximumHP; } break; case 's': - PromptText = new string[] - { + PromptText = + [ "You picked up a MonsterBox", - }; + ]; PlayerInventory.TryAdd(MonsterBox.Instance); spriteSheet[j][i] = ' '; break; case 'q': - PromptText = new string[] - { + PromptText = + [ "...", - }; + ]; break; } } } diff --git a/Projects/Console Monsters/Maps/House1.cs b/Projects/Console Monsters/Maps/House1.cs index cd91bfb1..b7c8e86a 100644 --- a/Projects/Console Monsters/Maps/House1.cs +++ b/Projects/Console Monsters/Maps/House1.cs @@ -4,15 +4,15 @@ public class House1 : MapBase { public override string? AudioFile => AudioController.CoDA_Lullaby; - private static readonly char[][] spriteSheet = new char[][] - { + private static readonly char[][] spriteSheet = + [ "afffffffffffffffb".ToCharArray(), "hpmn wvwkijg".ToCharArray(), "hmq kijg".ToCharArray(), "h k12g".ToCharArray(), "hssss uuu g".ToCharArray(), "cllllll000lllllld".ToCharArray(), - }; + ]; public override char[][] SpriteSheet => spriteSheet; @@ -80,19 +80,19 @@ public override void InteractWithMapTile(int i, int j) switch (SpriteSheet[j][i]) { case 'q': - PromptText = new string[] - { + PromptText = + [ "Mozin0's Mum:", "Welcome to my house, My son always gifts guests.", "He's Upstairs, go talk to him to recieve your gift.", - }; + ]; break; case 'v': - PromptText = new string[] - { + PromptText = + [ "Funky:", "Slurp Slurp", - }; + ]; break; } } diff --git a/Projects/Console Monsters/Maps/House1SecondFloor.cs b/Projects/Console Monsters/Maps/House1SecondFloor.cs index 8b165b38..5c329c1d 100644 --- a/Projects/Console Monsters/Maps/House1SecondFloor.cs +++ b/Projects/Console Monsters/Maps/House1SecondFloor.cs @@ -4,15 +4,15 @@ public class House1SecondFloor : MapBase { public override string? AudioFile => AudioController.CoDA_Lullaby; - private static readonly char[][] spriteSheet = new char[][] - { + private static readonly char[][] spriteSheet = + [ "afffffffffffffffb".ToCharArray(), "hpq! uv - g".ToCharArray(), "hno kemg".ToCharArray(), "h yy xkemg".ToCharArray(), "hrrr wzkijg".ToCharArray(), "cllllllllllllllld".ToCharArray(), - }; + ]; public override char[][] SpriteSheet => spriteSheet; @@ -85,26 +85,26 @@ public override void InteractWithMapTile(int i, int j) switch (SpriteSheet[j][i]) { case 'r': - PromptText = new string[] - { + PromptText = + [ "Mozin0:", "ZzzZzzZzz...", "MonsterBox...", "ZzzZzzZzz...", - }; + ]; break; case 'w': - PromptText = new string[] - { + PromptText = + [ "Penguin:", "BrrrRRRrrr!", - }; + ]; break; case '!': - PromptText = new string[] - { + PromptText = + [ "You picked up a MonsterBox", - }; + ]; PlayerInventory.TryAdd(MonsterBox.Instance); spriteSheet[j][i] = ' '; break; diff --git a/Projects/Console Monsters/Maps/PaletTown.cs b/Projects/Console Monsters/Maps/PaletTown.cs index 95a752e7..401336b3 100644 --- a/Projects/Console Monsters/Maps/PaletTown.cs +++ b/Projects/Console Monsters/Maps/PaletTown.cs @@ -13,8 +13,8 @@ public PaletTown() public override string? AudioFile => AudioController.CoDA_Lullaby; - private readonly static char[][] spriteSheet = new char[][] - { + private readonly static char[][] spriteSheet = + [ "tttttgggggggfgggggf11fgggggfgggggttttt".ToCharArray(), "tttttggggffffffffff ffffffffggggttttt".ToCharArray(), "tttttggggfg gfggggttttt".ToCharArray(), @@ -37,7 +37,7 @@ public PaletTown() "tttttggggffffWwwWffffffffffffggggttttt".ToCharArray(), "tttttggggggggWwwWggggggfgggggggggttttt".ToCharArray(), "tttttggggggggWwwWggggggfgggggggggttttt".ToCharArray(), - }; + ]; public override char[][] SpriteSheet => spriteSheet; @@ -111,26 +111,26 @@ public override void InteractWithMapTile(int i, int j) switch (SpriteSheet[j][i]) { case 's' or 'a': - PromptText = new string[] - { + PromptText = + [ "Sign Says:", "Hello! I am sign. :P", - }; + ]; break; case 'o': PromptText = scientist.Dialogue; break; case 'p' or 'n': - PromptText = new string[] - { + PromptText = + [ "...", - }; + ]; break; case 'e': - PromptText = new string[] - { + PromptText = + [ "You picked up a MonsterBox", - }; + ]; PlayerInventory.TryAdd(MonsterBox.Instance); spriteSheet[j][i] = 'g'; break; diff --git a/Projects/Console Monsters/Maps/Route1.cs b/Projects/Console Monsters/Maps/Route1.cs index 7e14d69b..ab8d3597 100644 --- a/Projects/Console Monsters/Maps/Route1.cs +++ b/Projects/Console Monsters/Maps/Route1.cs @@ -2,8 +2,8 @@ class Route1 : MapBase { - private static readonly char[][] spriteSheet = new char[][] - { + private static readonly char[][] spriteSheet = + [ "ggggggggggggfgggggf11fgggggfgggggggggg".ToCharArray(), "ggggggggggggfgggggf fgggggfgggggggggg".ToCharArray(), "ggggggggggggfgggggf fgggggfgggggggggg".ToCharArray(), @@ -45,7 +45,7 @@ class Route1 : MapBase "ggggggggggggTgggggfGGfgggggTgggggggggg".ToCharArray(), "ggggggggggggfgggggf00fgggggfgggggggggg".ToCharArray(), - }; + ]; public override char[][] SpriteSheet => spriteSheet; @@ -96,11 +96,11 @@ public override void InteractWithMapTile(int i, int j) switch (SpriteSheet[j][i]) { case 's': - PromptText = new string[] - { + PromptText = + [ "Sign Says:", "Hello! I am a sign. :P", - }; + ]; break; } } diff --git a/Projects/Console Monsters/Maps/Route2.cs b/Projects/Console Monsters/Maps/Route2.cs index ded7a032..41fff232 100644 --- a/Projects/Console Monsters/Maps/Route2.cs +++ b/Projects/Console Monsters/Maps/Route2.cs @@ -9,8 +9,8 @@ public Route2() camper = new(); } - private static readonly char[][] spriteSheet = new char[][] - { + private static readonly char[][] spriteSheet = + [ "TTTTTTTTTTTTT ".ToCharArray(), "TTTTTTTTTTTTT ".ToCharArray(), "TTTTaaaaaaaaa ".ToCharArray(), @@ -28,7 +28,7 @@ public Route2() " fggggggggggggggTTTTTTTTTs GGGGGGGGgggggggTTTTTTTTf".ToCharArray(), " fggggggggggggggggggggggT TTTTTTTTgggggggggggggggf".ToCharArray(), " fffffffffffffffffffffffff00fffffffffffffffffffffffff".ToCharArray(), - }; + ]; public override char[][] SpriteSheet => spriteSheet; @@ -80,11 +80,11 @@ public override void InteractWithMapTile(int i, int j) PromptText = camper.Dialogue; break; case 's': - PromptText = new string[] - { + PromptText = + [ "Sign Says:", "Vejle Town <----- -----> Aalborg City", - }; + ]; break; } } diff --git a/Projects/Console Monsters/Maps/Western.cs b/Projects/Console Monsters/Maps/Western.cs index 5b9feab2..ac465c2c 100644 --- a/Projects/Console Monsters/Maps/Western.cs +++ b/Projects/Console Monsters/Maps/Western.cs @@ -2,8 +2,8 @@ namespace Console_Monsters.Maps; class Western : MapBase { - private static readonly char[][] spriteSheet = new char[][] - { + private static readonly char[][] spriteSheet = + [ "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb".ToCharArray(), "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb".ToCharArray(), "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb".ToCharArray(), @@ -12,7 +12,7 @@ class Western : MapBase "0aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa!".ToCharArray(), "0aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa!".ToCharArray(), "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa".ToCharArray(), - }; + ]; public override char[][] SpriteSheet => spriteSheet; diff --git a/Projects/Console Monsters/Player.cs b/Projects/Console Monsters/Player.cs index 8af463b6..562d944f 100644 --- a/Projects/Console Monsters/Player.cs +++ b/Projects/Console Monsters/Player.cs @@ -47,8 +47,8 @@ public class Player #region Player Sprites - public static readonly string[] RunRight = new[] - { + public static readonly string[] RunRight = + [ // 0 @" ╭══╮ " + '\n' + @" │ '│ " + '\n' + @@ -85,10 +85,10 @@ public class Player @" ╰──╯ " + '\n' + @" │||│ " + '\n' + @" └─_│ ", - }; + ]; - public static readonly string[] RunLeft = new[] - { + public static readonly string[] RunLeft = + [ // 0 @" ╭══╮ " + '\n' + @" │' │ " + '\n' + @@ -125,10 +125,10 @@ public class Player @" ╰──╯ " + '\n' + @" │||│ " + '\n' + @" └─_│ ", - }; + ]; - public static readonly string[] RunDown = new[] - { + public static readonly string[] RunDown = + [ // 0 @" ╭═══╮ " + '\n' + @" │'_'│ " + '\n' + @@ -165,10 +165,10 @@ public class Player @"╭╰───╯╮" + '\n' + @"│├───┤│" + '\n' + @" │_├─┘ ", - }; + ]; - public static readonly string[] RunUp = new[] - { + public static readonly string[] RunUp = + [ // 0 @" ╭═══╮ " + '\n' + @" │ │ " + '\n' + @@ -205,7 +205,7 @@ public class Player @"╭╰───╯╮" + '\n' + @"│├───┤│" + '\n' + @" │_├─┘ ", - }; + ]; public static readonly string IdleLeft1 = @" ╭══╮ " + '\n' + diff --git a/Projects/Console Monsters/Screens/BattleTransition.cs b/Projects/Console Monsters/Screens/BattleTransition.cs index ccb9ddc6..ada368e9 100644 --- a/Projects/Console Monsters/Screens/BattleTransition.cs +++ b/Projects/Console Monsters/Screens/BattleTransition.cs @@ -4,14 +4,14 @@ public static class BattleTransition { private static readonly TimeSpan Delay = TimeSpan.FromTicks(7500); - private static readonly Action[] Transitions = new[] - { + private static readonly Action[] Transitions = + [ LeftToRight, RightToLeft, LeftToRightBlocks, RightToLeftBlocks, Swirl, - }; + ]; public static void Random() { diff --git a/Projects/Console Monsters/Screens/Menus/ColorsScreen.cs b/Projects/Console Monsters/Screens/Menus/ColorsScreen.cs index 784cd146..ed663b97 100644 --- a/Projects/Console Monsters/Screens/Menus/ColorsScreen.cs +++ b/Projects/Console Monsters/Screens/Menus/ColorsScreen.cs @@ -4,15 +4,15 @@ public static class ColorsScreen { public static void Show() { - string[] bigHeader = new[] - { + string[] bigHeader = + [ " ██████╗ ██████╗ ██╗ ██████╗ ██████╗ ███████╗ ██████╗██╗ ██╗███████╗███╗ ███╗███████╗", "██╔════╝██╔═══██╗██║ ██╔═══██╗██╔══██╗ ██╔════╝██╔════╝██║ ██║██╔════╝████╗ ████║██╔════╝", "██║ ██║ ██║██║ ██║ ██║██████╔╝ ███████╗██║ ███████║█████╗ ██╔████╔██║█████╗ ", "██║ ██║ ██║██║ ██║ ██║██╔══██╗ ╚════██║██║ ██╔══██║██╔══╝ ██║╚██╔╝██║██╔══╝ ", "╚██████╗╚██████╔╝███████╗╚██████╔╝██║ ██║ ███████║╚██████╗██║ ██║███████╗██║ ╚═╝ ██║███████╗", " ╚═════╝ ╚═════╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝ ╚═════╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚══════╝", - }; + ]; int bigHeaderWidth = bigHeader.Max(line => line.Length); const int bigHeaderPadding = 2; const int optionPadding = 1; @@ -33,8 +33,8 @@ public static void Show() StringBuilder? buffer = null; if (consoleWidth - 1 >= bigHeaderWidth) { - string[][] options = new[] - { + string[][] options = + [ AsciiGenerator.ToAscii((selectedOption is 0 ? "■" : "□") + " black"), AsciiGenerator.ToAscii((selectedOption is 1 ? "■" : "□") + " green"), AsciiGenerator.ToAscii((selectedOption is 2 ? "■" : "□") + " red"), @@ -43,7 +43,7 @@ public static void Show() AsciiGenerator.ToAscii((selectedOption is 5 ? "■" : "□") + " invert"), AsciiGenerator.ToAscii((selectedOption is 6 ? "■" : "□") + " reset"), AsciiGenerator.ToAscii((selectedOption is 7 ? "■" : "□") + " back"), - }; + ]; int optionsWidth = options.Max(o => o.Max(l => l.Length)); int bigRenderHeight = bigHeader.Length + options.Sum(o => o.Length) + bigHeaderPadding + optionPadding * options.Length; if (consoleHeight - 1 >= bigRenderHeight && consoleWidth - 1 >= optionsWidth) @@ -70,8 +70,8 @@ public static void Show() } if (buffer is null) { - string[] render = new[] - { + string[] render = + [ $@"Color Scheme", $@"{(selectedOption is 0 ? ">" : " ")} Black", $@"{(selectedOption is 1 ? ">" : " ")} Green", @@ -81,7 +81,7 @@ public static void Show() $@"{(selectedOption is 5 ? ">" : " ")} Invert", $@"{(selectedOption is 6 ? ">" : " ")} Reset", $@"{(selectedOption is 7 ? ">" : " ")} Back", - }; + ]; buffer = ScreenHelpers.Center(render, (consoleHeight - 1, consoleWidth - 1)); } Console.SetCursorPosition(0, 0); diff --git a/Projects/Console Monsters/Screens/Menus/ControlsScreen.cs b/Projects/Console Monsters/Screens/Menus/ControlsScreen.cs index c3e79090..f24aa0fe 100644 --- a/Projects/Console Monsters/Screens/Menus/ControlsScreen.cs +++ b/Projects/Console Monsters/Screens/Menus/ControlsScreen.cs @@ -4,15 +4,15 @@ public static class ControlsScreen { public static void ControlsMenu() { - string[] bigHeader = new[] - { + string[] bigHeader = + [ "██╗ ██╗███████╗██╗ ██╗ ███╗ ███╗ █████╗ ██████╗ ██████╗ ██╗███╗ ██╗ ██████╗ ", "██║ ██╔╝██╔════╝╚██╗ ██╔╝ ████╗ ████║██╔══██╗██╔══██╗██╔══██╗██║████╗ ██║██╔════╝ ", "█████╔╝ █████╗ ╚████╔╝ ██╔████╔██║███████║██████╔╝██████╔╝██║██╔██╗ ██║██║ ███╗", "██╔═██╗ ██╔══╝ ╚██╔╝ ██║╚██╔╝██║██╔══██║██╔═══╝ ██╔═══╝ ██║██║╚██╗██║██║ ██║", "██║ ██╗███████╗ ██║ ██║ ╚═╝ ██║██║ ██║██║ ██║ ██║██║ ╚████║╚██████╔╝", "╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝ ", - }; + ]; int bigHeaderWidth = bigHeader.Max(line => line.Length); const int bigHeaderPadding = 2; const int optionPadding = 1; @@ -20,8 +20,8 @@ public static void ControlsMenu() Console.Clear(); int selectedOption = 0; bool needToRender = true; - string[] spacingSmall = {"\n"}; - string[] spacingLarge = {"\n","\n"}; + string[] spacingSmall = ["\n"]; + string[] spacingLarge = ["\n","\n"]; Console.CursorVisible = false; while (true) { @@ -35,8 +35,8 @@ public static void ControlsMenu() StringBuilder? buffer = null; if (consoleWidth - 1 >= bigHeaderWidth) { - string[][] options = new[] - { + string[][] options = + [ AsciiGenerator.ToAscii((selectedOption is 0 ? "■" : "□") + " up: "+ reverseKeyMappings[UserKeyPress.Up].ToDisplayString() ), spacingSmall, AsciiGenerator.ToAscii((selectedOption is 1 ? "■" : "□") + " down: "+ reverseKeyMappings[UserKeyPress.Down].ToDisplayString() ), spacingSmall, AsciiGenerator.ToAscii((selectedOption is 2 ? "■" : "□") + " left: "+ reverseKeyMappings[UserKeyPress.Left].ToDisplayString() ), spacingSmall, @@ -48,7 +48,7 @@ public static void ControlsMenu() spacingLarge, //NEEDS FULL SCREEN TO SHOW ALL AsciiGenerator.ToAscii((selectedOption is 8 ? "■" : "□") + " restore defaults"), AsciiGenerator.ToAscii((selectedOption is 9 ? "■" : "□") + " back"), - }; + ]; int optionsWidth = options.Max(o => o.Max(l => l.Length)); int bigRenderHeight = bigHeader.Length + options.Sum(o => o.Length) + bigHeaderPadding + optionPadding * options.Length; if (consoleHeight - 1 >= bigRenderHeight && consoleWidth - 1 >= optionsWidth) @@ -75,8 +75,8 @@ public static void ControlsMenu() } if (buffer is null) { - string[] render = new[] - { + string[] render = + [ $@"Key Mapping", $@"{(selectedOption is 0 ? ">" : " ")} Up: {reverseKeyMappings[UserKeyPress.Up].ToDisplayString() } ", $@"{(selectedOption is 1 ? ">" : " ")} Down: {reverseKeyMappings[UserKeyPress.Down].ToDisplayString() } ", @@ -88,7 +88,7 @@ public static void ControlsMenu() $@"{(selectedOption is 7 ? ">" : " ")} Pause: {reverseKeyMappings[UserKeyPress.Escape].ToDisplayString() } ", $@"{(selectedOption is 8 ? ">" : " ")} Restore Defaults", $@"{(selectedOption is 9 ? ">" : " ")} Back", - }; + ]; buffer = ScreenHelpers.Center(render, (consoleHeight - 1, consoleWidth - 1)); } Console.SetCursorPosition(0, 0); @@ -136,14 +136,14 @@ private static void PerformKeyMap(UserKeyPress userInput) Console.Clear(); Console.Write($"Press a key to use for the Main {userInput} input..."); ConsoleKey main = Console.ReadKey(true).Key; - if (keyMappings.ContainsKey(main) && keyMappings[main] is UserKeyPress.Escape) + if (keyMappings.TryGetValue(main, out UserKeyPress possibleEscapeKey1) && possibleEscapeKey1 is UserKeyPress.Escape) { return; } Console.Clear(); Console.Write($"Press a key to use for the Alternate {userInput} input or [{reverseKeyMappings[UserKeyPress.Escape].ToDisplayString()}] to leave empty..."); ConsoleKey? alternate = Console.ReadKey(true).Key; - if (keyMappings.ContainsKey(alternate.Value) && keyMappings[alternate.Value] is UserKeyPress.Escape) + if (keyMappings.TryGetValue(alternate.Value, out UserKeyPress possibleEscapeKey2) && possibleEscapeKey2 is UserKeyPress.Escape) { alternate = null; } @@ -161,7 +161,7 @@ private static void PerformKeyMap(UserKeyPress userInput) while (true) { ConsoleKey key = Console.ReadKey(true).Key; - if (keyMappings.ContainsKey(key) && keyMappings[key] is UserKeyPress.Confirm) + if (keyMappings.TryGetValue(key, out UserKeyPress possibleConfirmKey) && possibleConfirmKey is UserKeyPress.Confirm) { break; } diff --git a/Projects/Console Monsters/Screens/Menus/OptionsScreen.cs b/Projects/Console Monsters/Screens/Menus/OptionsScreen.cs index a389b9e6..fb2614a0 100644 --- a/Projects/Console Monsters/Screens/Menus/OptionsScreen.cs +++ b/Projects/Console Monsters/Screens/Menus/OptionsScreen.cs @@ -4,15 +4,15 @@ public static class OptionsScreen { public static void Show() { - string[] bigHeader = new[] - { + string[] bigHeader = + [ " ██████╗ ██████╗ ████████╗██╗ ██████╗ ███╗ ██╗███████╗", "██╔═══██╗██╔══██╗╚══██╔══╝██║██╔═══██╗████╗ ██║██╔════╝", "██║ ██║██████╔╝ ██║ ██║██║ ██║██╔██╗ ██║███████╗", "██║ ██║██╔═══╝ ██║ ██║██║ ██║██║╚██╗██║╚════██║", "╚██████╔╝██║ ██║ ██║╚██████╔╝██║ ╚████║███████║", " ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝", - }; + ]; int bigHeaderWidth = bigHeader.Max(line => line.Length); const int bigHeaderPadding = 2; const int optionPadding = 1; @@ -22,33 +22,33 @@ public static void Show() bool needToRender = true; Console.CursorVisible = false; - string[] movementAnimation = new[] - { + string[] movementAnimation = + [ " ", " Movement Animation ", " ", - }; + ]; - string[] battleTransition = new[] - { + string[] battleTransition = + [ " ", " Battle Transition ", " ", - }; + ]; - string[] battles = new[] - { + string[] battles = + [ " ", " Battles ", " ", - }; + ]; - string[] audioEnabled = new[] - { + string[] audioEnabled = + [ " ", " Audio Enabled ", " ", - }; + ]; while (true) { @@ -62,8 +62,8 @@ public static void Show() StringBuilder? buffer = null; if (consoleWidth - 1 >= bigHeaderWidth) { - string[][] options = new[] - { + string[][] options = + [ AsciiGenerator.Concat(AsciiGenerator.ToAscii(selectedOption is 0 ? "■ " : "□ "), movementAnimation, AsciiGenerator.ToAscii(DisableMovementAnimation ? "○" : "●")), AsciiGenerator.Concat(AsciiGenerator.ToAscii(selectedOption is 1 ? "■ " : "□ "), battleTransition, AsciiGenerator.ToAscii(DisableBattleTransition ? "○" : "●")), AsciiGenerator.Concat(AsciiGenerator.ToAscii(selectedOption is 2 ? "■ " : "□ "), battles, AsciiGenerator.ToAscii(DisableBattle ? "○" : "●")), @@ -71,7 +71,7 @@ public static void Show() AsciiGenerator.Concat(AsciiGenerator.ToAscii((selectedOption is 4 ? "■" : "□") + " colors")), AsciiGenerator.Concat(AsciiGenerator.ToAscii((selectedOption is 5 ? "■" : "□") + " controls")), AsciiGenerator.Concat(AsciiGenerator.ToAscii((selectedOption is 6 ? "■" : "□") + " back")), - }; + ]; int optionsWidth = options.Max(o => o.Max(l => l.Length)); int bigRenderHeight = bigHeader.Length + options.Sum(o => o.Length) + bigHeaderPadding + optionPadding * options.Length; if (consoleHeight - 1 >= bigRenderHeight && consoleWidth - 1 >= optionsWidth) @@ -98,8 +98,8 @@ public static void Show() } if (buffer is null) { - string[] render = new[] - { + string[] render = + [ $@"Options", $@"{(selectedOption is 0 ? ">" : " ")} Movement Animation {(DisableMovementAnimation ? "□" : "■")}", $@"{(selectedOption is 1 ? ">" : " ")} Battle Transition {(DisableBattleTransition ? "□" : "■")}", @@ -108,7 +108,7 @@ public static void Show() $@"{(selectedOption is 4 ? ">" : " ")} Colors", $@"{(selectedOption is 5 ? ">" : " ")} Controls", $@"{(selectedOption is 6 ? ">" : " ")} Exit", - }; + ]; buffer = ScreenHelpers.Center(render, (consoleHeight - 1, consoleWidth - 1)); } Console.SetCursorPosition(0, 0); diff --git a/Projects/Console Monsters/Screens/Menus/StartScreen.cs b/Projects/Console Monsters/Screens/Menus/StartScreen.cs index 8703bc84..4ba06416 100644 --- a/Projects/Console Monsters/Screens/Menus/StartScreen.cs +++ b/Projects/Console Monsters/Screens/Menus/StartScreen.cs @@ -4,15 +4,15 @@ public static class StartScreen { public static void Show() { - string[] bigHeader = new[] - { + string[] bigHeader = + [ " ██████╗ ██████╗ ███╗ ██╗███████╗ ██████╗ ██╗ ███████╗ ███╗ ███╗ ██████╗ ███╗ ██╗███████╗████████╗███████╗██████╗ ███████╗", "██╔════╝██╔═══██╗████╗ ██║██╔════╝██╔═══██╗██║ ██╔════╝ ████╗ ████║██╔═══██╗████╗ ██║██╔════╝╚══██╔══╝██╔════╝██╔══██╗██╔════╝", "██║ ██║ ██║██╔██╗ ██║███████╗██║ ██║██║ █████╗ ██╔████╔██║██║ ██║██╔██╗ ██║███████╗ ██║ █████╗ ██████╔╝███████╗", "██║ ██║ ██║██║╚██╗██║╚════██║██║ ██║██║ ██╔══╝ ██║╚██╔╝██║██║ ██║██║╚██╗██║╚════██║ ██║ ██╔══╝ ██╔══██╗╚════██║", "╚██████╗╚██████╔╝██║ ╚████║███████║╚██████╔╝███████╗███████╗ ██║ ╚═╝ ██║╚██████╔╝██║ ╚████║███████║ ██║ ███████╗██║ ██║███████║", " ╚═════╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚══════╝╚══════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝ ╚═╝ ╚══════╝╚═╝ ╚═╝╚══════╝", - }; + ]; int bigHeaderWidth = bigHeader.Max(line => line.Length); const int bigHeaderPadding = 2; const int optionPadding = 1; @@ -33,12 +33,12 @@ public static void Show() StringBuilder? buffer = null; if (consoleWidth - 1 >= bigHeaderWidth) { - string[][] options = new[] - { + string[][] options = + [ AsciiGenerator.ToAscii((selectedOption is 0 ? "■" : "□") + (FirstTimeLaunching ? " start" : " resume")), AsciiGenerator.ToAscii((selectedOption is 1 ? "■" : "□") + " options"), AsciiGenerator.ToAscii((selectedOption is 2 ? "■" : "□") + " exit"), - }; + ]; int optionsWidth = options.Max(o => o.Max(l => l.Length)); int bigRenderHeight = bigHeader.Length + options.Sum(o => o.Length) + bigHeaderPadding + optionPadding * options.Length; if (consoleHeight - 1 >= bigRenderHeight && consoleWidth - 1 >= optionsWidth) @@ -65,13 +65,13 @@ public static void Show() } if (buffer is null) { - string[] render = new[] - { + string[] render = + [ $@"Console Monsters", $@"{(selectedOption is 0 ? ">" : " ")} {(FirstTimeLaunching ? "Start" : "Resume")}", $@"{(selectedOption is 1 ? ">" : " ")} Options", $@"{(selectedOption is 2 ? ">" : " ")} Exit", - }; + ]; buffer = ScreenHelpers.Center(render, (consoleHeight - 1, consoleWidth - 1)); } Console.SetCursorPosition(0, 0); diff --git a/Projects/Console Monsters/Utilities/AsciiGenerator.cs b/Projects/Console Monsters/Utilities/AsciiGenerator.cs index cda8fdb0..fcc04feb 100644 --- a/Projects/Console Monsters/Utilities/AsciiGenerator.cs +++ b/Projects/Console Monsters/Utilities/AsciiGenerator.cs @@ -25,7 +25,7 @@ public static string[] ToAscii(string @string) first = false; } - return new[] { a.ToString(), b.ToString(), c.ToString() }; + return [a.ToString(), b.ToString(), c.ToString()]; } /// Generates medium sized uppercase ascii text art from a char. @@ -274,6 +274,6 @@ public static string[] Concat(params string[][] sprites) } } - return new[] { a.ToString(), b.ToString(), c.ToString() }; + return [a.ToString(), b.ToString(), c.ToString()]; } } \ No newline at end of file diff --git a/Projects/Darts/Program.cs b/Projects/Darts/Program.cs index c58a247a..4c08e10b 100644 --- a/Projects/Darts/Program.cs +++ b/Projects/Darts/Program.cs @@ -302,8 +302,8 @@ void Render() return; } - string[] board = new string[] - { + string[] board = + [ "╔═══════╤═══════╤═══════╤═══════╤═══════╗", "║ │ │ │ │ ║", "║ 1 │ 2 │ 3 │ 2 │ 1 ║", @@ -321,7 +321,7 @@ void Render() "║ 1 │ 2 │ 3 │ 2 │ 1 ║", "║ │ │ │ │ ║", "╚═══════╧═══════╧═══════╧═══════╧═══════╝", - }; + ]; for (int i = 0; i < board.Length; i++) { for (int j = 0; j < board[i].Length; j++) @@ -440,8 +440,8 @@ void Render() (int PlayerScore, int ComputerScore) CalculateScores() { - string[] scoreBoard = new string[] - { + string[] scoreBoard = + [ "111111112222222233333332222222211111111", "111111112222222233333332222222211111111", "111111112222222233333332222222211111111", @@ -457,7 +457,7 @@ void Render() "111111112222222233333332222222211111111", "111111112222222233333332222222211111111", "111111112222222233333332222222211111111", - }; + ]; int playerScore = 0; int computerScore = 0; diff --git a/Projects/Duck Hunt/Program.cs b/Projects/Duck Hunt/Program.cs index de1737a7..87895032 100644 --- a/Projects/Duck Hunt/Program.cs +++ b/Projects/Duck Hunt/Program.cs @@ -702,7 +702,7 @@ public static class Enviroment public static class Bird { public static char[][] LeftSprites = - { ( @" _(nn)_ " + NEWLINE_CHAR + + [ ( @" _(nn)_ " + NEWLINE_CHAR + @"<(o----_)=" + NEWLINE_CHAR + @" (UU) ").ToCharArray(), @@ -723,9 +723,9 @@ public static class Bird @"(--(-)--)" + NEWLINE_CHAR + @"(__(_)__)" + NEWLINE_CHAR + @" _/ \_ " ).ToCharArray() - }; + ]; public static char[][] RightSprites = - { ( @" _(nn)_ " + NEWLINE_CHAR + + [ ( @" _(nn)_ " + NEWLINE_CHAR + @"=(_----o)>" + NEWLINE_CHAR + @" (UU) ").ToCharArray(), @@ -746,7 +746,7 @@ public static class Bird @"(--(-)--)" + NEWLINE_CHAR + @"(__(_)__)" + NEWLINE_CHAR + @" _/ \_ " ).ToCharArray() - }; + ]; public static int Height = 3; public static int Width = 10; #endregion diff --git a/Projects/Fighter/Program.cs b/Projects/Fighter/Program.cs index a3355d87..417803ea 100644 --- a/Projects/Fighter/Program.cs +++ b/Projects/Fighter/Program.cs @@ -577,8 +577,8 @@ static class Ascii public static class Player { - public static readonly string[] IdleAnimation = new string[] - { + public static readonly string[] IdleAnimation = + [ // 0 @" " + '\n' + @" " + '\n' + @@ -593,10 +593,10 @@ public static class Player @" ((L " + '\n' + @" | " + '\n' + @" / ) ", - }; + ]; - public static readonly string[] BlockAnimation = new string[] - { + public static readonly string[] BlockAnimation = + [ // 0 @" " + '\n' + @" " + '\n' + @@ -604,10 +604,10 @@ public static class Player @" |-' " + '\n' + @" | " + '\n' + @" / / ", - }; + ]; - public static readonly string[] PunchAnimation = new string[] - { + public static readonly string[] PunchAnimation = + [ // 0 @" " + '\n' + @" " + '\n' + @@ -650,10 +650,10 @@ public static class Player @" (|) " + '\n' + @" | " + '\n' + @" / \ ", - }; + ]; - public static readonly string[] JumpKickAnimation = new string[] - { + public static readonly string[] JumpKickAnimation = + [ // 0 @" " + '\n' + @" " + '\n' + @@ -710,10 +710,10 @@ public static class Player @" o " + '\n' + @" > ", - }; + ]; - public static readonly string[] OwnedAnimation = new string[] - { + public static readonly string[] OwnedAnimation = + [ // 0 @" " + '\n' + @" " + '\n' + @@ -742,10 +742,10 @@ public static class Player @" " + '\n' + @" " + '\n' + @" o___/\ ", - }; + ]; - public static readonly string[] GroundAnimation = new string[] - { + public static readonly string[] GroundAnimation = + [ // 0 @" " + '\n' + @" " + '\n' + @@ -753,10 +753,10 @@ public static class Player @" " + '\n' + @" " + '\n' + @" o___/\ ", - }; + ]; - public static readonly string[] GetUpAnimation = new string[] - { + public static readonly string[] GetUpAnimation = + [ // 0 @" " + '\n' + @" " + '\n' + @@ -813,13 +813,13 @@ public static class Player @" o " + '\n' + @" > ", - }; + ]; } public static class Enemy { - public static readonly string[] IdleAnimation = new string[] - { + public static readonly string[] IdleAnimation = + [ // 0 @" " + '\n' + @" " + '\n' + @@ -834,10 +834,10 @@ public static class Enemy @" J)) " + '\n' + @" | " + '\n' + @" ( \ ", - }; + ]; - public static readonly string[] BlockAnimation = new string[] - { + public static readonly string[] BlockAnimation = + [ // 0 @" " + '\n' + @" " + '\n' + @@ -845,10 +845,10 @@ public static class Enemy @" '-| " + '\n' + @" | " + '\n' + @" \ \ ", - }; + ]; - public static readonly string[] PunchAnimation = new string[] - { + public static readonly string[] PunchAnimation = + [ // 0 @" " + '\n' + @" " + '\n' + @@ -891,10 +891,10 @@ public static class Enemy @" (|) " + '\n' + @" | " + '\n' + @" / \ ", - }; + ]; - public static readonly string[] JumpKickAnimation = new string[] - { + public static readonly string[] JumpKickAnimation = + [ // 0 @" " + '\n' + @" " + '\n' + @@ -951,10 +951,10 @@ public static class Enemy @" o " + '\n' + @" >\> " + '\n' + @" << ", - }; + ]; - public static readonly string[] OwnedAnimation = new string[] - { + public static readonly string[] OwnedAnimation = + [ // 0 @" " + '\n' + @" " + '\n' + @@ -983,10 +983,10 @@ public static class Enemy @" " + '\n' + @" " + '\n' + @" /\___o ", - }; + ]; - public static readonly string[] GroundAnimation = new string[] - { + public static readonly string[] GroundAnimation = + [ // 0 @" " + '\n' + @" " + '\n' + @@ -994,10 +994,10 @@ public static class Enemy @" " + '\n' + @" " + '\n' + @" /\___o ", - }; + ]; - public static readonly string[] GetUpAnimation = new string[] - { + public static readonly string[] GetUpAnimation = + [ // 0 @" " + '\n' + @" " + '\n' + @@ -1054,7 +1054,7 @@ public static class Enemy @" o " + '\n' + @" >\> " + '\n' + @" << ", - }; + ]; } #endregion diff --git a/Projects/Flash Cards/Program.cs b/Projects/Flash Cards/Program.cs index a862de4e..3d921fe0 100644 --- a/Projects/Flash Cards/Program.cs +++ b/Projects/Flash Cards/Program.cs @@ -62,7 +62,7 @@ Press [enter] to continue or [escape] to quit... Console.Write($" {array[index].Letter}? "); string input = Console.ReadLine()!; Console.WriteLine(); - if (input.Trim().ToUpper() == array[index].CodeWord.ToUpper()) + if (input.Trim().Equals(array[index].CodeWord, StringComparison.CurrentCultureIgnoreCase)) { Console.WriteLine(" Correct! :)"); } diff --git a/Projects/Hangman/Program.cs b/Projects/Hangman/Program.cs index 17dfa0ae..f580a72e 100644 --- a/Projects/Hangman/Program.cs +++ b/Projects/Hangman/Program.cs @@ -6,7 +6,7 @@ using System.Linq; string[] Renders = -{ +[ #region Frames // 0 @" ╔═══╗ " + '\n' + @@ -65,10 +65,10 @@ @" ███ ║ " + '\n' + @" ══════╩═══", #endregion -}; +]; string[] DeathAnimation = -{ +[ #region Frames // @" ╔═══╗ " + '\n' + @@ -359,7 +359,7 @@ @" _ ║ " + '\n' + @" __/══════╩═══", #endregion -}; +]; const string wordsResource = "Hangman.Words.txt"; Assembly assembly = Assembly.GetExecutingAssembly(); @@ -381,7 +381,7 @@ words.Add(word); } } -string[] wordarray = words.ToArray(); +string[] wordarray = [.. words]; PlayAgain: Console.CursorVisible = false; Console.Clear(); diff --git a/Projects/Helicopter/Program.cs b/Projects/Helicopter/Program.cs index 7215dd8f..5ef0d573 100644 --- a/Projects/Helicopter/Program.cs +++ b/Projects/Helicopter/Program.cs @@ -22,16 +22,16 @@ #region Ascii Renders -string[] bulletRenders = new string[] -{ +string[] bulletRenders = +[ " ", // 0 "-", // 1 "~", // 2 "█", // 3 -}; +]; -string[] helicopterRenders = new string[] -{ +string[] helicopterRenders = +[ // 0 @" " + '\n' + @" " + '\n' + @@ -44,10 +44,10 @@ @" -----+-----" + '\n' + @"*\===<[_]L) " + '\n' + @" -'-`- ", -}; +]; -string[] ufoRenders = new string[] -{ +string[] ufoRenders = +[ // 0 @" __O__ " + '\n' + @"-=<_‗_‗_>=-", @@ -67,10 +67,10 @@ @" _!_ " + '\n' + @"(_o_)" + '\n' + @" ^^^ ", -}; +]; -string[] explosionRenders = new string[] -{ +string[] explosionRenders = +[ // 0 @" " + '\n' + @" █████ " + '\n' + @@ -119,7 +119,7 @@ @"* *" + '\n' + @" * * " + '\n' + @" * * ", -}; +]; #endregion diff --git a/Projects/Hurdles/Program.cs b/Projects/Hurdles/Program.cs index 4f060654..24b9f535 100644 --- a/Projects/Hurdles/Program.cs +++ b/Projects/Hurdles/Program.cs @@ -1,8 +1,8 @@ using System; using System.Threading; -string[] runningAnimation = new string[] -{ +string[] runningAnimation = +[ #region Frames // 0 @" " + '\n' + @@ -54,10 +54,10 @@ @" /-- " + '\n' + @" / |", #endregion -}; +]; -string[] jumpingAnimation = new string[] -{ +string[] jumpingAnimation = +[ #region Frames // 0 @" " + '\n' + @@ -122,7 +122,7 @@ @" |_ " + '\n' + @" / | ", #endregion -}; +]; string hurdleFrame = #region Frame diff --git a/Projects/Oligopoly/Program.cs b/Projects/Oligopoly/Program.cs index 0541c561..ffcd9fe2 100644 --- a/Projects/Oligopoly/Program.cs +++ b/Projects/Oligopoly/Program.cs @@ -85,12 +85,11 @@ private static void MainMenuScreen() prompt.AppendLine(); prompt.Append("Use up and down arrow keys and enter to select an option:"); int selectedIndex = HandleMenuWithOptions(prompt.ToString(), - new string[] - { + [ "Play", "About", "Exit", - }); + ]); switch (selectedIndex) { case 0: IntroductionScreen(); break; @@ -120,13 +119,13 @@ private static void GameLoop() StringBuilder prompt = RenderCompanyStocksTable(); prompt.AppendLine(); prompt.Append("Use up and down arrow keys and enter to select an option:"); - selectedOption = HandleMenuWithOptions(prompt.ToString(), new string[] - { + selectedOption = HandleMenuWithOptions(prompt.ToString(), + [ "Wait For Market Change", "Buy", "Sell", "Information About Companies", - }); + ]); switch (selectedOption) { case 1: BuyOrSellStockScreen(true); break; diff --git a/Projects/PacMan/Program.cs b/Projects/PacMan/Program.cs index f87fccfe..0978d8b1 100644 --- a/Projects/PacMan/Program.cs +++ b/Projects/PacMan/Program.cs @@ -107,12 +107,12 @@ " "; string[] PacManAnimations = -{ +[ "\"' '\"", "n. .n", ")>- ->", "(<- -<", -}; +]; #endregion @@ -175,7 +175,7 @@ d.FramesToUpdate = 12; d.Update = () => UpdateGhost(d); - Ghosts = new Ghost[] { a, b, c, d, }; + Ghosts = [a, b, c, d,]; RenderWalls(); RenderGate(); @@ -576,7 +576,7 @@ void UpdateGhost(Ghost ghost) x++; } } - return list.ToArray(); + return [.. list]; } (int X, int Y) GetRandomLocation() => Random.Shared.Choose(Locations); diff --git a/Projects/Role Playing Game/Maps.cs b/Projects/Role Playing Game/Maps.cs index 2e885a7a..986d9d76 100644 --- a/Projects/Role Playing Game/Maps.cs +++ b/Projects/Role Playing Game/Maps.cs @@ -59,8 +59,8 @@ public static bool IsValidCharacterMapTile(char[][] map, int tileI, int tileJ) }; } - public static readonly char[][] Town = new char[][] - { + public static readonly char[][] Town = + [ " WWWWWWWWWWWWWWWWW111WWWWWWWWWWWWWWWWW ".ToCharArray(), "wwwWbbbfbbbB Bbffbffbffb cWwww".ToCharArray(), "wwwW Wwww".ToCharArray(), @@ -72,10 +72,10 @@ public static bool IsValidCharacterMapTile(char[][] map, int tileI, int tileJ) "wwwW cWwww".ToCharArray(), "wwwWbffbfbffbfbfbbfb bbfbfbffbfbbfbfbWwww".ToCharArray(), " WWWWWWWWWWWWWWWWW111WWWWWWWWWWWWWWWWW ".ToCharArray(), - }; + ]; - public static readonly char[][] Field = new char[][] - { + public static readonly char[][] Field = + [ "mmmpmmmmpmmmmmpmmmmmpmmmmmpmmmpmmmpmmmpmm".ToCharArray(), "mmpppppppmmmpppmmmpppppmmppmmmpmmmmpppmmm".ToCharArray(), "mmpmmpmmpmppmmpmpmmpmmpmmmmmmpppmmpmpmmmp".ToCharArray(), @@ -91,10 +91,10 @@ public static bool IsValidCharacterMapTile(char[][] map, int tileI, int tileJ) "wwwwwwwwwwwwwwwwwwwwwTTTTTTTTTTTTmmmmmmmm".ToCharArray(), "wwwwwwwwwwwwwwwwwwwwTTTTTTTTTTTTTTmmmmmmm".ToCharArray(), "wwwwwwwwwwwwwwwwwwwTTTTTTTTTTTTTTTTmmmmmm".ToCharArray(), - }; + ]; - public static readonly char[][] Castle = new char[][] - { + public static readonly char[][] Castle = + [ "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW".ToCharArray(), "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW".ToCharArray(), "WWc WkW cWW".ToCharArray(), @@ -111,5 +111,5 @@ public static bool IsValidCharacterMapTile(char[][] map, int tileI, int tileJ) "WWc cWW".ToCharArray(), "WWWWWWWWWWWWWWWWWWW WWWWWWWWWWWWWWWWWWW".ToCharArray(), "WWWWWWWWWWWWWWWWWWW111WWWWWWWWWWWWWWWWWWW".ToCharArray(), - }; + ]; } diff --git a/Projects/Role Playing Game/Program.cs b/Projects/Role Playing Game/Program.cs index 4fdb3b43..47ee8637 100644 --- a/Projects/Role Playing Game/Program.cs +++ b/Projects/Role Playing Game/Program.cs @@ -30,19 +30,19 @@ static char[][] Map set => _map = value; } - private static readonly string[] maptext = new[] - { + private static readonly string[] maptext = + [ "Move: arrow keys or (w, a, s, d)", "Check Status: [enter]", "Quit: [escape]", - }; + ]; - private static readonly string[] defaultCombatText = new string[] - { + private static readonly string[] defaultCombatText = + [ "1) attack", "2) run", "3) check status", - }; + ]; private static string[]? _combatText; @@ -421,19 +421,19 @@ static void Battle(EnemyType enemyType, out bool ranAway) switch (enemyType) { case EnemyType.Boar: - CombatText = new string[] - { + CombatText = + [ "You were attacked by a wild boar!", "1) attack", "2) run", "3) check status", - }; + ]; break; case EnemyType.GuardBoss: if (Character.Level < 2) { - CombatText = new string[] - { + CombatText = + [ "You approached the castle guard.", "He looks tough. You should probably", "run away and come back when you are", @@ -441,33 +441,33 @@ static void Battle(EnemyType enemyType, out bool ranAway) "1) attack", "2) run", "3) check status", - }; + ]; } else { - CombatText = new string[] - { + CombatText = + [ "You approached the castle guard.", "1) attack", "2) run", "3) check status", - }; + ]; } break; case EnemyType.Guard: - CombatText = new string[] - { + CombatText = + [ "You were attacked by a castle guard!", "1) attack", "2) run", "3) check status", - }; + ]; break; case EnemyType.FinalBoss: if (Character.Level < 3) { - CombatText = new string[] - { + CombatText = + [ "You approached the evil king.", "He looks tough. You should probably", "run away and come back when you are", @@ -475,17 +475,17 @@ static void Battle(EnemyType enemyType, out bool ranAway) "1) attack", "2) run", "3) check status", - }; + ]; } else { - CombatText = new string[] - { + CombatText = + [ "You approached the evil king.", "1) attack", "2) run", "3) check status", - }; + ]; } break; } @@ -500,7 +500,7 @@ static void Battle(EnemyType enemyType, out bool ranAway) EnemyType.Guard => Sprites.IdleLeft, EnemyType.GuardBoss => Sprites.IdleLeft, EnemyType.FinalBoss => Sprites.IdleLeft, - _ => new[] { Sprites.Error }, + _ => [Sprites.Error], }; bool pendingConfirmation = false; @@ -532,24 +532,24 @@ static void Battle(EnemyType enemyType, out bool ranAway) case 0: frameLeft = 0; animationLeft = Sprites.PunchRight; - CombatText = new string[] - { + CombatText = + [ "You attacked and did damage!", "", "Press [enter] to continue...", - }; + ]; enemyHealth -= Character.Damage; break; case 1: frameLeft = 0; animationLeft = Sprites.FallLeft; - CombatText = new string[] - { + CombatText = + [ "You attacked, but the enemy was", "faster and you took damage!", "", "Press [enter] to continue...", - }; + ]; Character.Health--; break; } @@ -580,14 +580,14 @@ static void Battle(EnemyType enemyType, out bool ranAway) { frameLeft = 0; animationLeft = Sprites.FallLeft; - CombatText = new string[] - { + CombatText = + [ "You tried to run away but the enemy", "attacked you from behind and you took", "damage.", "", "Press [enter] to continue...", - }; + ]; Character.Health--; pendingConfirmation = true; } diff --git a/Projects/Role Playing Game/Sprites.cs b/Projects/Role Playing Game/Sprites.cs index 0cc60bc1..e40c8f20 100644 --- a/Projects/Role Playing Game/Sprites.cs +++ b/Projects/Role Playing Game/Sprites.cs @@ -210,8 +210,8 @@ public static class Sprites @"║error║" + "\n" + @"╚═════╝"; - public static readonly string[] RunRight = new[] - { + public static readonly string[] RunRight = + [ // 0 @" O " + '\n' + @" |_ " + '\n' + @@ -247,10 +247,10 @@ public static class Sprites @" \> " + '\n' + @" / " + '\n' + @" |\ ", - }; + ]; // would be nice to give up/down their own animations, but // for now they are just copies of left/right @@ -328,8 +328,8 @@ public static class Sprites public static readonly string[] IdleDown = (string[])IdleRight.Clone(); public static readonly string[] IdleUp = (string[])IdleLeft.Clone(); - public static readonly string[] FallLeft = new string[] - { + public static readonly string[] FallLeft = + [ // 0 @" O___ " + '\n' + @" \`- " + '\n' + @@ -370,10 +370,10 @@ public static class Sprites @" " + '\n' + @" " + '\n' + @" o___/\", - }; + ]; - public static readonly string[] PunchRight = new string[] - { + public static readonly string[] PunchRight = + [ // 0 @" _o_. " + '\n' + @" (| " + '\n' + @@ -429,10 +429,10 @@ public static class Sprites @" (|) " + '\n' + @" | " + '\n' + @" / \ ", - }; + ]; - public static readonly string[] IdleBoar = new[] - { + public static readonly string[] IdleBoar = + [ // 0 @" " + '\n' + @"^..^ " + '\n' + @@ -573,10 +573,10 @@ public static class Sprites @"^..^ " + '\n' + @"(oo) )~" + '\n' + @" ,, ,, ", - }; + ]; - public static readonly string[] GetUpAnimationRight = new string[] - { + public static readonly string[] GetUpAnimationRight = + [ // 0 @" " + '\n' + @" " + '\n' + @@ -657,5 +657,5 @@ public static class Sprites @" o " + '\n' + @" > ", - }; + ]; } diff --git a/Projects/Roll And Move/Program.cs b/Projects/Roll And Move/Program.cs index 37f5bdfb..d7ac7323 100644 --- a/Projects/Roll And Move/Program.cs +++ b/Projects/Roll And Move/Program.cs @@ -66,21 +66,21 @@ Your opponent circled the board before you. ConsoleColor color_a = ConsoleColor.Blue; (int Top, int Left)[] spots_a = -{ +[ /* top */ (02, 04), (02, 10), (02, 14), (02, 18), (02, 22), (02, 26), (02, 30), (02, 34), (02, 38), /* right */ (02, 44), (05, 44), (07, 44), (09, 44), (11, 44), (13, 44), (15, 44), (17, 44), /* bottom */ (20, 44), (20, 38), (20, 34), (20, 30), (20, 26), (20, 22), (20, 18), (20, 14), (20, 10), /* left */ (20, 04), (17, 04), (15, 04), (13, 04), (11, 04), (09, 04), (07, 04), (05, 04), (02, 04), -}; +]; ConsoleColor color_b = ConsoleColor.Red; (int Top, int Left)[] spots_b = -{ +[ /* top */ (03, 06), (03, 10), (03, 14), (03, 18), (03, 22), (03, 26), (03, 30), (03, 34), (03, 38), /* right */ (03, 42), (05, 42), (07, 42), (09, 42), (11, 42), (13, 42), (15, 42), (17, 42), /* bottom */ (19, 42), (19, 38), (19, 34), (19, 30), (19, 26), (19, 22), (19, 18), (19, 14), (19, 10), /* left */ (19, 06), (17, 06), (15, 06), (13, 06), (11, 06), (09, 06), (07, 06), (05, 06), (03, 06), -}; +]; bool escape = false; while (!escape) diff --git a/Projects/Rythm/Program.cs b/Projects/Rythm/Program.cs index 3d0f3407..5e60a90f 100644 --- a/Projects/Rythm/Program.cs +++ b/Projects/Rythm/Program.cs @@ -2,8 +2,8 @@ using System.Collections.Generic; using System.Threading; -string[] frames = { "▌", "▐", }; -string[] deathFrames = { "X", "X", "X", "X", "X", }; +string[] frames = ["▌", "▐",]; +string[] deathFrames = ["X", "X", "X", "X", "X",]; List notes; List deadNotes; TimeSpan delayTime = TimeSpan.FromMilliseconds(34); @@ -12,12 +12,12 @@ int targetLeft = 5; int remainingMisses = 5; (int Top, ConsoleKey Key)[] tracks = -{ +[ (4, ConsoleKey.UpArrow), (7, ConsoleKey.LeftArrow), (10, ConsoleKey.DownArrow), (13, ConsoleKey.RightArrow), -}; +]; try { diff --git a/Projects/Shmup/Enemies/Helicopter.cs b/Projects/Shmup/Enemies/Helicopter.cs index 8da54076..aceb12ad 100644 --- a/Projects/Shmup/Enemies/Helicopter.cs +++ b/Projects/Shmup/Enemies/Helicopter.cs @@ -15,18 +15,18 @@ internal class Helicopter : IEnemy private string[] Sprite = Random.Shared.Next(2) is 0 ? spriteA : spriteB; static readonly string[] spriteA = - { + [ @" ~~~~~+~~~~~", @"'\===<[_]L) ", @" -'-`- ", - }; + ]; static readonly string[] spriteB = - { + [ @" -----+-----", @"*\===<[_]L) ", @" -'-`- ", - }; + ]; internal static int XMax = Math.Max(spriteA.Max(s => s.Length), spriteB.Max(s => s.Length)); internal static int YMax = Math.Max(spriteA.Length, spriteB.Length); diff --git a/Projects/Shmup/Enemies/Tank.cs b/Projects/Shmup/Enemies/Tank.cs index f9372ef6..840684e8 100644 --- a/Projects/Shmup/Enemies/Tank.cs +++ b/Projects/Shmup/Enemies/Tank.cs @@ -14,32 +14,32 @@ internal class Tank : IEnemy private string[] Sprite = spriteDown; static readonly string[] spriteDown = - { + [ @" ___ ", @"|_O_|", @"[ooo]", - }; + ]; static readonly string[] spriteUp = - { + [ @" _^_ ", @"|___|", @"[ooo]", - }; + ]; static readonly string[] spriteLeft = - { + [ @" __ ", @"=|__|", @"[ooo]", - }; + ]; static readonly string[] spriteRight = - { + [ @" __ ", @"|__|=", @"[ooo]", - }; + ]; internal static int XMax = new[] { spriteDown.Max(s => s.Length), spriteUp.Max(s => s.Length), spriteLeft.Max(s => s.Length), spriteRight.Max(s => s.Length), }.Max(); internal static int YMax = new[] { spriteDown.Length, spriteUp.Length, spriteLeft.Length, spriteRight.Length, }.Max(); diff --git a/Projects/Shmup/Enemies/UFO1.cs b/Projects/Shmup/Enemies/UFO1.cs index 2e7b04d1..677ee47d 100644 --- a/Projects/Shmup/Enemies/UFO1.cs +++ b/Projects/Shmup/Enemies/UFO1.cs @@ -12,11 +12,11 @@ internal class UFO1 : IEnemy public float XVelocity = 1f / 8f; public float YVelocity = 1f / 8f; private static readonly string[] Sprite = - { + [ @" _!_ ", @"(_o_)", @" ''' ", - }; + ]; internal static int XMax = Sprite.Max(s => s.Length); internal static int YMax = Sprite.Length; diff --git a/Projects/Shmup/Enemies/UFO2.cs b/Projects/Shmup/Enemies/UFO2.cs index e5350b9e..1bfc393f 100644 --- a/Projects/Shmup/Enemies/UFO2.cs +++ b/Projects/Shmup/Enemies/UFO2.cs @@ -13,11 +13,11 @@ internal class UFO2 : IEnemy public int TeleportFrequency = 360; private static readonly string[] Sprite = - { + [ @" _!_ ", @" /_O_\ ", @"-==<_‗_‗_>==-", - }; + ]; internal static int XMax = Sprite.Max(s => s.Length); internal static int YMax = Sprite.Length; diff --git a/Projects/Shmup/Player.cs b/Projects/Shmup/Player.cs index a172db92..5a74d3aa 100644 --- a/Projects/Shmup/Player.cs +++ b/Projects/Shmup/Player.cs @@ -19,88 +19,88 @@ internal enum States public States State; static readonly string[] Sprite = - { + [ @" ╱‾╲ ", @" ╱╱‾╲╲ ", @" ╱'╲O╱'╲ ", @"╱ / ‾ \ ╲", @"╲_╱───╲_╱", - }; + ]; static readonly string[] SpriteUp = - { + [ @" ╱‾╲ ", @" ╱╱‾╲╲ ", @" ╱'╲O╱'╲ ", @"╱ / ‾ \ ╲", @"╲_╱───╲_╱", @"/V\ /V\", - }; + ]; static readonly string[] SpriteDown = - { + [ @" ╱‾╲ ", @" ╱╱‾╲╲ ", @"-╱'╲O╱'╲-", @"╱-/ ‾ \-╲", @"╲_╱───╲_╱", - }; + ]; static readonly string[] SpriteLeft = - { + [ @" ╱╲ ", @" ╱‾╲╲ ", @" ╱╲O╱'╲ ", @"╱/ ‾ \ ╲", @"╲╱───╲_╱", - }; + ]; static readonly string[] SpriteRight = - { + [ @" ╱╲ ", @" ╱╱‾╲ ", @" ╱'╲O╱╲ ", @"╱ / ‾ \╲", @"╲_╱───╲╱", - }; + ]; static readonly string[] SpriteUpLeft = - { + [ @" ╱╲ ", @" ╱‾╲╲ ", @" ╱╲O╱'╲ ", @"╱/ ‾ \ ╲", @"╲╱───╲_╱", @"/\ /V\", - }; + ]; static readonly string[] SpriteUpRight = - { + [ @" ╱╲ ", @" ╱╱‾╲ ", @" ╱'╲O╱╲ ", @"╱ / ‾ \╲", @"╲_╱───╲╱", @"/V\ /\", - }; + ]; static readonly string[] SpriteDownLeft = - { + [ @" ╱╲ ", @" ╱‾╲╲ ", @"-╱╲O╱'╲-", @"-/ ‾ \-╲", @"╲╱───╲_╱", - }; + ]; static readonly string[] SpriteDownRight = - { + [ @" ╱╲ ", @" ╱╱‾╲ ", @"-╱'╲O╱╲-", @"╱-/ ‾ \-", @"╲_╱───╲╱", - }; + ]; public void Render() { diff --git a/Projects/Shmup/Program.cs b/Projects/Shmup/Program.cs index cb01be5b..78a177d3 100644 --- a/Projects/Shmup/Program.cs +++ b/Projects/Shmup/Program.cs @@ -8,7 +8,7 @@ namespace Shmup; -internal static class Program +internal static partial class Program { internal static bool closeRequested = false; internal static Stopwatch stopwatch = new(); @@ -210,7 +210,7 @@ internal static void Update() { PlayerBullet bullet = playerBullets[i]; bool exploded = false; - IEnemy[] enemiesClone = enemies.ToArray(); + IEnemy[] enemiesClone = [.. enemies]; for (int j = 0; j < enemiesClone.Length; j++) { if (enemiesClone[j].CollidingWith(bullet.X, bullet.Y)) @@ -387,9 +387,9 @@ internal static void SleepAfterRender() stopwatch.Restart(); } - internal static class User32_dll + internal static partial class User32_dll { - [DllImport("user32.dll")] - internal static extern short GetAsyncKeyState(int vKey); + [LibraryImport("user32.dll")] + internal static partial short GetAsyncKeyState(int vKey); } } diff --git a/Projects/Shmup/Shmup.csproj b/Projects/Shmup/Shmup.csproj index 26137b7e..cd79c600 100644 --- a/Projects/Shmup/Shmup.csproj +++ b/Projects/Shmup/Shmup.csproj @@ -4,5 +4,6 @@ net8.0 disable enable + true diff --git a/Projects/Simon/Program.cs b/Projects/Simon/Program.cs index 35f7b42e..019bc230 100644 --- a/Projects/Simon/Program.cs +++ b/Projects/Simon/Program.cs @@ -7,8 +7,8 @@ int score = 0; List pattern = new(); -string[] Renders = new string[] -{ +string[] Renders = +[ #region Frames // 0 @" ╔══════╗ " + '\n' + @@ -71,7 +71,7 @@ @" ║ ║ " + '\n' + @" ╚══════╝ ", #endregion -}; +]; try { diff --git a/Projects/Snake/Program.cs b/Projects/Snake/Program.cs index a2853914..6e602f5f 100644 --- a/Projects/Snake/Program.cs +++ b/Projects/Snake/Program.cs @@ -19,9 +19,9 @@ Console.Write(prompt); } } -int[] velocities = { 100, 70, 50 }; +int[] velocities = [100, 70, 50]; int velocity = velocities[speedInput - 1]; -char[] DirectionChars = { '^', 'v', '<', '>', }; +char[] DirectionChars = ['^', 'v', '<', '>',]; TimeSpan sleep = TimeSpan.FromMilliseconds(velocity); int width = Console.WindowWidth; int height = Console.WindowHeight; diff --git a/Projects/Tanks/Program.cs b/Projects/Tanks/Program.cs index e22e4104..a761c448 100644 --- a/Projects/Tanks/Program.cs +++ b/Projects/Tanks/Program.cs @@ -2,8 +2,8 @@ using System.Collections.Generic; using System.Threading; -string[] Tank = new string[] -{ +string[] Tank = +[ #region Frames null, // Up @@ -23,10 +23,10 @@ @"|__|=" + "\n" + @"[ooo]" + "\n", #endregion -}; +]; -string[] TankShooting = new string[] -{ +string[] TankShooting = +[ #region Frames null, // Up @@ -46,10 +46,10 @@ @"|__|█" + "\n" + @"[ooo]" + "\n", #endregion -}; +]; -string[] TankExploding = new string[] -{ +string[] TankExploding = +[ #region Frames // Ka... @" ___ " + "\n" + @@ -64,10 +64,10 @@ @" " + "\n" + @" " + "\n", #endregion -}; +]; -char[] Bullet = new char[] -{ +char[] Bullet = +[ #region Frames default, '^', // Up @@ -75,7 +75,7 @@ '<', // Left '>', // Right #endregion -}; +]; string Map = #region Frames diff --git a/Projects/Tetris/Program.cs b/Projects/Tetris/Program.cs index 05646a0e..3e6a4630 100644 --- a/Projects/Tetris/Program.cs +++ b/Projects/Tetris/Program.cs @@ -14,8 +14,8 @@ } emptyField[^1] = "╰──────────────────────────────╯"; -string[] nextTetrominoBorder = new[] -{ +string[] nextTetrominoBorder = +[ "╭─────────╮", "│ │", "│ │", @@ -26,28 +26,28 @@ "│ │", "│ │", "╰─────────╯" -}; +]; -string[] scoreBorder = new[] -{ +string[] scoreBorder = +[ "╭─────────╮", "│ │", "╰─────────╯" -}; +]; -string[] pauseRender = new[] -{ +string[] pauseRender = +[ "█████╗ ███╗ ██╗██╗█████╗█████╗", "██╔██║██╔██╗██║██║██╔══╝██╔══╝", "█████║█████║██║██║ ███╗ █████╗", "██╔══╝██╔██║██║██║ ██╗██╔══╝", "██║ ██║██║█████║█████║█████╗", "╚═╝ ╚═╝╚═╝╚════╝╚════╝╚════╝", -}; +]; -string[][] tetrominos = new[] -{ - new[]{ +string[][] tetrominos = +[ + [ "╭─╮", "╰─╯", "x─╮", @@ -56,44 +56,44 @@ "╰─╯", "╭─╮", "╰─╯" - }, - new[]{ + ], + [ "╭─╮ ", "╰─╯ ", "╭─╮x─╮╭─╮", "╰─╯╰─╯╰─╯" - }, - new[]{ + ], + [ " ╭─╮", " ╰─╯", "╭─╮x─╮╭─╮", "╰─╯╰─╯╰─╯" - }, - new[]{ + ], + [ "╭─╮╭─╮", "╰─╯╰─╯", "x─╮╭─╮", "╰─╯╰─╯" - }, - new[]{ + ], + [ " ╭─╮╭─╮", " ╰─╯╰─╯", "╭─╮x─╮ ", "╰─╯╰─╯ " - }, - new[]{ + ], + [ " ╭─╮ ", " ╰─╯ ", "╭─╮x─╮╭─╮", "╰─╯╰─╯╰─╯" - }, - new[]{ + ], + [ "╭─╮╭─╮ ", "╰─╯╰─╯ ", " x─╮╭─╮", " ╰─╯╰─╯" - }, -}; + ], +]; const int borderSize = 1; @@ -403,7 +403,7 @@ void DrawFrame() // Next for (int y = 0; y < nextTetrominoBorder.Length; y++) { - frame[y] = frame[y].Concat(nextTetrominoBorder[y]).ToArray(); + frame[y] = [.. frame[y], .. nextTetrominoBorder[y]]; } for (int y = 0; y < tetromino.Next.Length; y++) { @@ -424,7 +424,7 @@ void DrawFrame() for (int y = 0; y < scoreBorder.Length; y++) { int sY = nextTetrominoBorder.Length + y; - frame[sY] = frame[sY].Concat(scoreBorder[y]).ToArray(); + frame[sY] = [.. frame[sY], .. scoreBorder[y]]; } char[] scoreRender = score.ToString(CultureInfo.InvariantCulture).ToCharArray(); for (int scoreX = scoreRender.Length - 1; scoreX >= 0; scoreX--) diff --git a/Projects/Tower Of Hanoi/Program.cs b/Projects/Tower Of Hanoi/Program.cs index 29f4f47e..86274518 100644 --- a/Projects/Tower Of Hanoi/Program.cs +++ b/Projects/Tower Of Hanoi/Program.cs @@ -68,7 +68,7 @@ Restart: state = State.ChooseSource; minimumNumberOfMoves = (int)Math.Pow(2, disks) - 1; - stacks = new List[] { new(), new(), new() }; + stacks = [new(), new(), new()]; for (int i = disks; i > 0; i--) { stacks[0].Add(i); diff --git a/Projects/Type/Program.cs b/Projects/Type/Program.cs index b22a2410..e5da5caf 100644 --- a/Projects/Type/Program.cs +++ b/Projects/Type/Program.cs @@ -17,11 +17,11 @@ DateTime WordStart; ConsoleColor[] Colors = -{ +[ ConsoleColor.White, ConsoleColor.Gray, ConsoleColor.DarkGray, -}; +]; #region Loading @@ -44,7 +44,7 @@ words.Add(word); } } -WordPool = words.ToArray(); +WordPool = [.. words]; #endregion diff --git a/Projects/Website/BlazorConsole.cs b/Projects/Website/BlazorConsole.cs index 53e248ee..48e0d3d3 100644 --- a/Projects/Website/BlazorConsole.cs +++ b/Projects/Website/BlazorConsole.cs @@ -24,9 +24,9 @@ public struct Pixel public static bool operator !=(Pixel a, Pixel b) => !(a == b); - public override bool Equals(object? obj) => obj is Pixel pixel && this == pixel; + public override readonly bool Equals(object? obj) => obj is Pixel pixel && this == pixel; - public override int GetHashCode() => HashCode.Combine(Char, ForegroundColor, BackgroundColor); + public override readonly int GetHashCode() => HashCode.Combine(Char, ForegroundColor, BackgroundColor); } #pragma warning disable CA2211 // Non-constant fields should not be visible diff --git a/Projects/Website/Games/2048/2048.cs b/Projects/Website/Games/2048/2048.cs index 04421f95..2a4a875c 100644 --- a/Projects/Website/Games/2048/2048.cs +++ b/Projects/Website/Games/2048/2048.cs @@ -13,7 +13,7 @@ public class _2048 public async Task Run() { ConsoleColor[] Colors = - { + [ ConsoleColor.DarkBlue, ConsoleColor.DarkGreen, ConsoleColor.DarkCyan, @@ -23,7 +23,7 @@ public async Task Run() ConsoleColor.Blue, ConsoleColor.Red, ConsoleColor.Magenta, - }; + ]; try { diff --git a/Projects/Website/Games/Blackjack/Blackjack.cs b/Projects/Website/Games/Blackjack/Blackjack.cs index 3d90fd1d..ac89fdf0 100644 --- a/Projects/Website/Games/Blackjack/Blackjack.cs +++ b/Projects/Website/Games/Blackjack/Blackjack.cs @@ -567,8 +567,8 @@ public string[] Render() { if (!FaceUp) { - return new string[] - { + return + [ $"┌───────┐", $"│███████│", $"│███████│", @@ -576,7 +576,7 @@ public string[] Render() $"│███████│", $"│███████│", $"└───────┘", - }; + ]; } char suit = Suit.ToString()[0]; @@ -592,8 +592,8 @@ public string[] Render() string card = $"{value}{suit}"; string a = card.Length < 3 ? $"{card} " : card; string b = card.Length < 3 ? $" {card}" : card; - return new[] - { + return + [ $"┌───────┐", $"│{a} │", $"│ │", @@ -601,7 +601,7 @@ public string[] Render() $"│ │", $"│ {b}│", $"└───────┘", - }; + ]; } } diff --git a/Projects/Website/Games/Bound/Bound.cs b/Projects/Website/Games/Bound/Bound.cs index 500f1038..cc33682f 100644 --- a/Projects/Website/Games/Bound/Bound.cs +++ b/Projects/Website/Games/Bound/Bound.cs @@ -12,7 +12,7 @@ public async Task Run() { ((int Left, int Top) StartPosition, (string Map, TimeSpan Delay)[])[] levels = - { + [ #region level 00 ((15, 16), new (string Map, TimeSpan Delay)[] @@ -1824,7 +1824,7 @@ public async Task Run() """, TimeSpan.FromSeconds(.5)), }), #endregion - }; + ]; try { diff --git a/Projects/Website/Games/Clicker/Clicker.cs b/Projects/Website/Games/Clicker/Clicker.cs index 40c6703f..9b407703 100644 --- a/Projects/Website/Games/Clicker/Clicker.cs +++ b/Projects/Website/Games/Clicker/Clicker.cs @@ -12,11 +12,11 @@ public class Clicker public async Task Run() { char[] keys = - { + [ 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', - }; + ]; MainMenu: await Console.Clear(); diff --git a/Projects/Website/Games/Console Monsters/Characters/MartialArtist.cs b/Projects/Website/Games/Console Monsters/Characters/MartialArtist.cs index d80db9cc..9020b73a 100644 --- a/Projects/Website/Games/Console Monsters/Characters/MartialArtist.cs +++ b/Projects/Website/Games/Console Monsters/Characters/MartialArtist.cs @@ -9,11 +9,11 @@ public MartialArtist() { Sprite = IdleFront; - Dialogue = new string[] - { + Dialogue = + [ "Martial Artist says:" + "Wanna learn some martial arts?" - }; + ]; } public override string? Name => "Martial Artist"; diff --git a/Projects/Website/Games/Console Monsters/Characters/Monk.cs b/Projects/Website/Games/Console Monsters/Characters/Monk.cs index 0b85a239..3c4f363e 100644 --- a/Projects/Website/Games/Console Monsters/Characters/Monk.cs +++ b/Projects/Website/Games/Console Monsters/Characters/Monk.cs @@ -9,11 +9,11 @@ public Monk() { Sprite = IdleFront; - Dialogue = new string[] - { + Dialogue = + [ "Monk Says:", "Hello! I am a Danish Monk. :P", - }; + ]; } public override string? Name => "Scientist"; diff --git a/Projects/Website/Games/Console Monsters/Characters/Nurse.cs b/Projects/Website/Games/Console Monsters/Characters/Nurse.cs index 80e23f6f..b88ac49c 100644 --- a/Projects/Website/Games/Console Monsters/Characters/Nurse.cs +++ b/Projects/Website/Games/Console Monsters/Characters/Nurse.cs @@ -9,11 +9,11 @@ public Nurse() { Sprite = Idle1; - Dialogue = new string[] - { + Dialogue = + [ "Nurse Says:", "Hello! I have healed your monsters:P", - }; + ]; } public override string? Name => "Nurse"; diff --git a/Projects/Website/Games/Console Monsters/Characters/Scientist.cs b/Projects/Website/Games/Console Monsters/Characters/Scientist.cs index 73f22f23..95596bc0 100644 --- a/Projects/Website/Games/Console Monsters/Characters/Scientist.cs +++ b/Projects/Website/Games/Console Monsters/Characters/Scientist.cs @@ -9,11 +9,11 @@ public Scientist() { Sprite = IdleFront; - Dialogue = new string[] - { + Dialogue = + [ "Scientist Says:", "Hello! I am a scientist. :P", - }; + ]; } public override string? Name => "Scientist"; diff --git a/Projects/Website/Games/Console Monsters/Console Monsters.cs b/Projects/Website/Games/Console Monsters/Console Monsters.cs index 6f2ab585..f9e412c2 100644 --- a/Projects/Website/Games/Console Monsters/Console Monsters.cs +++ b/Projects/Website/Games/Console Monsters/Console Monsters.cs @@ -49,11 +49,11 @@ public async Task Run() } await StartScreen.StartMenu(); - while (gameRunning) + while (GameRunning) { await UpdateCharacter(); await HandleMapUserInput(); - if (gameRunning) + if (GameRunning) { await MapScreen.Render(); await SleepAfterRender(); @@ -91,7 +91,7 @@ static async Task UpdateCharacter() (character.Animation == Player.RunRight && character.AnimationFrame >= Sprites.Width)) { var (i, j) = MapBase.WorldToTile(character.I, character.J); - await map.PerformTileAction(i, j); + await Map.PerformTileAction(i, j); character.Animation = character.Animation == Player.RunUp ? Player.IdleUp : character.Animation == Player.RunDown ? Player.IdleDown : @@ -133,7 +133,7 @@ ConsoleKey.LeftArrow or ConsoleKey.A or ConsoleKey.RightArrow or ConsoleKey.D => (i + 1, j), _ => throw new Exception("bug"), }; - if (map.IsValidCharacterMapTile(i, j)) + if (Map.IsValidCharacterMapTile(i, j)) { if (DisableMovementAnimation) { @@ -145,7 +145,7 @@ ConsoleKey.LeftArrow or ConsoleKey.A or case ConsoleKey.RightArrow or ConsoleKey.D: character.I += Sprites.Width; character.Animation = Player.IdleRight; break; } var (i2, j2) = MapBase.WorldToTile(character.I, character.J); - await map.PerformTileAction(i2, j2); + await Map.PerformTileAction(i2, j2); } else { @@ -180,13 +180,13 @@ ConsoleKey.LeftArrow or ConsoleKey.A or //#warning TODO: this is temporary population of monsters during developemnt partyMonsters.Clear(); Turtle turtle = new(); - for (int i = 0; i < (maxPartySize - GameRandom.Next(0, 3)); i++) + for (int i = 0; i < (MaxPartySize - GameRandom.Next(0, 3)); i++) { partyMonsters.Add(turtle); } - inInventory = true; - while (inInventory) + InInventory = true; + while (InInventory) { await InventoryScreen.Render(); @@ -212,7 +212,7 @@ ConsoleKey.LeftArrow or ConsoleKey.A or SelectedPlayerInventoryItem = 0; } break; - case ConsoleKey.Escape: inInventory = false; break; + case ConsoleKey.Escape: InInventory = false; break; } } break; @@ -228,7 +228,7 @@ ConsoleKey.LeftArrow or ConsoleKey.A or if (character.IsIdle) { var (i, j) = character.InteractTile; - map.InteractWithMapTile(i, j); + Map.InteractWithMapTile(i, j); } break; case ConsoleKey.Escape: @@ -242,7 +242,7 @@ public async Task SleepAfterRender() { // frame rate control targeting 30 frames per second DateTime now = DateTime.Now; - TimeSpan sleep = TimeSpan.FromMilliseconds(33) - (now - previoiusRender); + TimeSpan sleep = TimeSpan.FromMilliseconds(33) - (now - PrevioiusRender); if (sleep > TimeSpan.Zero) { await Console.RefreshAndDelay(sleep); @@ -251,6 +251,6 @@ public async Task SleepAfterRender() { await Console.Refresh(); } - previoiusRender = DateTime.Now; + PrevioiusRender = DateTime.Now; } } diff --git a/Projects/Website/Games/Console Monsters/Maps/Center1.cs b/Projects/Website/Games/Console Monsters/Maps/Center1.cs index 3c895255..e53c5b60 100644 --- a/Projects/Website/Games/Console Monsters/Maps/Center1.cs +++ b/Projects/Website/Games/Console Monsters/Maps/Center1.cs @@ -8,15 +8,15 @@ namespace Website.Games.Console_Monsters.Maps; public class Center1 : MapBase { - private readonly char[][] spriteSheet = new char[][] - { + private readonly char[][] spriteSheet = + [ "affffifffffjffffb".ToCharArray(), "go gttktth oh".ToCharArray(), "g mplllrnq h".ToCharArray(), "g h".ToCharArray(), "go oh".ToCharArray(), "ceeeeee000eeeeeed".ToCharArray(), - }; + ]; public override char[][] SpriteSheet => spriteSheet; @@ -75,11 +75,11 @@ public override void InteractWithMapTile(int i, int j) { if (SpriteSheet[j][i] is 'k') { - promptText = new string[] - { + promptText = + [ " Hello and welcome to the monster center.", " I will heal all your monsters.", - }; + ]; for(int p = 0; p < partyMonsters.Count; p++) { partyMonsters[p].CurrentHP = partyMonsters[p].MaximumHP; @@ -117,8 +117,8 @@ public override async Task PerformTileAction(int i, int j) switch (SpriteSheet[j][i]) { case '0': - map = new PaletTown(); - map.SpawnCharacterOn('0'); + Map = new PaletTown(); + Map.SpawnCharacterOn('0'); break; } } diff --git a/Projects/Website/Games/Console Monsters/Maps/House1.cs b/Projects/Website/Games/Console Monsters/Maps/House1.cs index b114a132..774d1619 100644 --- a/Projects/Website/Games/Console Monsters/Maps/House1.cs +++ b/Projects/Website/Games/Console Monsters/Maps/House1.cs @@ -12,15 +12,15 @@ namespace Website.Games.Console_Monsters.Maps; public class House1 : MapBase { - private readonly char[][] spriteSheet = new char[][] - { + private readonly char[][] spriteSheet = + [ "afffffffffffffffb".ToCharArray(), "hpmn wvwkijg".ToCharArray(), "hmq kijg".ToCharArray(), "h k12g".ToCharArray(), "hssss uuu g".ToCharArray(), "cllllll000lllllld".ToCharArray(), - }; + ]; public override char[][] SpriteSheet => spriteSheet; @@ -84,12 +84,12 @@ public override void InteractWithMapTile(int i, int j) switch (SpriteSheet[j][i]) { case 'q': - promptText = new string[] - { + promptText = + [ "Mozin0's Mum:", "Welcome to my house, My son always gifts guests.", "He's Upstairs, go talk to him to recieve your gift.", - }; + ]; break; } } @@ -126,16 +126,16 @@ public override async Task PerformTileAction(int i, int j) switch (SpriteSheet[j][i]) { case '0': - map = new PaletTown(); - map.SpawnCharacterOn('2'); + Map = new PaletTown(); + Map.SpawnCharacterOn('2'); break; case 'i': - map = new House1SecondFloor(); - map.SpawnCharacterOn('i'); + Map = new House1SecondFloor(); + Map.SpawnCharacterOn('i'); break; case 'j': - map = new House1SecondFloor(); - map.SpawnCharacterOn('j'); + Map = new House1SecondFloor(); + Map.SpawnCharacterOn('j'); break; } diff --git a/Projects/Website/Games/Console Monsters/Maps/House1SecondFloor.cs b/Projects/Website/Games/Console Monsters/Maps/House1SecondFloor.cs index 0b072bae..43e8c36b 100644 --- a/Projects/Website/Games/Console Monsters/Maps/House1SecondFloor.cs +++ b/Projects/Website/Games/Console Monsters/Maps/House1SecondFloor.cs @@ -12,15 +12,15 @@ namespace Website.Games.Console_Monsters.Maps; public class House1SecondFloor : MapBase { - private readonly char[][] spriteSheet = new char[][] - { + private readonly char[][] spriteSheet = + [ "afffffffffffffffb".ToCharArray(), "hpq uv - g".ToCharArray(), "hno kemg".ToCharArray(), "h yy xkemg".ToCharArray(), "hrrr wzkijg".ToCharArray(), "cllllllllllllllld".ToCharArray(), - }; + ]; public override char[][] SpriteSheet => spriteSheet; @@ -86,20 +86,20 @@ public override void InteractWithMapTile(int i, int j) switch (SpriteSheet[j][i]) { case 'r': - promptText = new string[] - { + promptText = + [ "Mozin0:", "ZzzZzzZzz...", "MonsterBoz...", "ZzzZzzZzz...", - }; + ]; break; case 'w': - promptText = new string[] - { + promptText = + [ "Penguin:", "BrrrRRRrrr!", - }; + ]; break; } } @@ -134,12 +134,12 @@ public override async Task PerformTileAction(int i, int j) switch (SpriteSheet[j][i]) { case 'i': - map = new House1(); - map.SpawnCharacterOn('1'); + Map = new House1(); + Map.SpawnCharacterOn('1'); break; case 'j': - map = new House1(); - map.SpawnCharacterOn('2'); + Map = new House1(); + Map.SpawnCharacterOn('2'); break; } } diff --git a/Projects/Website/Games/Console Monsters/Maps/PaletTown.cs b/Projects/Website/Games/Console Monsters/Maps/PaletTown.cs index 887aa168..f5a76683 100644 --- a/Projects/Website/Games/Console Monsters/Maps/PaletTown.cs +++ b/Projects/Website/Games/Console Monsters/Maps/PaletTown.cs @@ -20,8 +20,8 @@ public PaletTown() scientist = new(); } - private readonly char[][] spriteSheet = new char[][] - { + private readonly char[][] spriteSheet = + [ "tttttgggggggfgggggf11fgggggfgggggttttt".ToCharArray(), "tttttggggffffffffff ffffffffggggttttt".ToCharArray(), "tttttggggfg gfggggttttt".ToCharArray(), @@ -44,7 +44,7 @@ public PaletTown() "tttttggggffffWwwWffffffffffffggggttttt".ToCharArray(), "tttttggggggggWwwWggggggfgggggggggttttt".ToCharArray(), "tttttggggggggWwwWggggggfgggggggggttttt".ToCharArray(), - }; + ]; public override char[][] SpriteSheet => spriteSheet; @@ -113,18 +113,18 @@ public override void InteractWithMapTile(int i, int j) switch (SpriteSheet[j][i]) { case 's' or 'a': - promptText = new string[] - { + promptText = + [ "Sign Says:", "Hello! I am sign. :P", - }; + ]; break; case 'ś': - promptText = new string[] - { + promptText = + [ "Sign #2 Says:", "Hello! I am sign #2. :P", - }; + ]; break; case 'o': promptText = scientist.Dialogue; @@ -163,16 +163,16 @@ public override async Task PerformTileAction(int i, int j) switch (SpriteSheet[j][i]) { case '0': - map = new Center1(); - map.SpawnCharacterOn('0'); + Map = new Center1(); + Map.SpawnCharacterOn('0'); break; case '1': - map = new Route1(); - map.SpawnCharacterOn('0'); + Map = new Route1(); + Map.SpawnCharacterOn('0'); break; case '2': - map = new House1(); - map.SpawnCharacterOn('0'); + Map = new House1(); + Map.SpawnCharacterOn('0'); break; } } diff --git a/Projects/Website/Games/Console Monsters/Maps/Route1.cs b/Projects/Website/Games/Console Monsters/Maps/Route1.cs index f16dd595..fe9693da 100644 --- a/Projects/Website/Games/Console Monsters/Maps/Route1.cs +++ b/Projects/Website/Games/Console Monsters/Maps/Route1.cs @@ -10,8 +10,8 @@ namespace Website.Games.Console_Monsters.Maps; class Route1 : MapBase { - private readonly char[][] spriteSheet = new char[][] - { + private readonly char[][] spriteSheet = + [ "ggggggggggggfgggggf11fgggggfgggggggggg".ToCharArray(), "ggggggggggggfgggggf fgggggfgggggggggg".ToCharArray(), "ggggggggggggfgggggf fgggggfgggggggggg".ToCharArray(), @@ -53,7 +53,7 @@ class Route1 : MapBase "ggggggggggggTgggggfGGfgggggTgggggggggg".ToCharArray(), "ggggggggggggfgggggf00fgggggfgggggggggg".ToCharArray(), - }; + ]; public override char[][] SpriteSheet => spriteSheet; @@ -104,11 +104,11 @@ public override void InteractWithMapTile(int i, int j) switch (SpriteSheet[j][i]) { case 's': - promptText = new string[] - { + promptText = + [ "Sign Says:", "Hello! I am a sign. :P", - }; + ]; break; } } @@ -142,12 +142,12 @@ public override async Task PerformTileAction(int i, int j) switch (SpriteSheet[j][i]) { case '0': - map = new PaletTown(); - map.SpawnCharacterOn('1'); + Map = new PaletTown(); + Map.SpawnCharacterOn('1'); break; case '1': - map = new Route2(); - map.SpawnCharacterOn('0'); + Map = new Route2(); + Map.SpawnCharacterOn('0'); break; case 'G': if (!DisableBattle && Random.Shared.Next(2) is 0) // BATTLE CHANCE diff --git a/Projects/Website/Games/Console Monsters/Maps/Route2.cs b/Projects/Website/Games/Console Monsters/Maps/Route2.cs index f7aa2f35..cc3616d8 100644 --- a/Projects/Website/Games/Console Monsters/Maps/Route2.cs +++ b/Projects/Website/Games/Console Monsters/Maps/Route2.cs @@ -10,8 +10,8 @@ namespace Website.Games.Console_Monsters.Maps; class Route2 : MapBase { - private readonly char[][] spriteSheet = new char[][] - { + private readonly char[][] spriteSheet = + [ "ffffffffffffffffffffffffffffffffffffffffffffffffffff".ToCharArray(), "fggggggggggggggggggggggg ggggggggg GGGGGGGf".ToCharArray(), "!ggggggggggggggggggggggg ggggggggg GGGGGGGf".ToCharArray(), @@ -24,7 +24,7 @@ class Route2 : MapBase "fggggggggggggggTTTTTTTTTs GGGGGGGGgggggggTTTTTTTTf".ToCharArray(), "fggggggggggggggggggggggT TTTTTTTTgggggggggggggggf".ToCharArray(), "fffffffffffffffffffffffff00fffffffffffffffffffffffff".ToCharArray(), - }; + ]; public override char[][] SpriteSheet => spriteSheet; @@ -69,11 +69,11 @@ public override void InteractWithMapTile(int i, int j) switch (SpriteSheet[j][i]) { case 's': - promptText = new string[] - { + promptText = + [ "Sign Says:", "Vejle Town <----- -----> Aalborg City", - }; + ]; break; } } @@ -105,8 +105,8 @@ public override async Task PerformTileAction(int i, int j) switch (SpriteSheet[j][i]) { case '0': - map = new Route1(); - map.SpawnCharacterOn('1'); + Map = new Route1(); + Map.SpawnCharacterOn('1'); break; case 'G': if (!DisableBattle && Random.Shared.Next(2) is 0) // BATTLE CHANCE diff --git a/Projects/Website/Games/Console Monsters/Player.cs b/Projects/Website/Games/Console Monsters/Player.cs index b8f5cee3..0cf8d1d7 100644 --- a/Projects/Website/Games/Console Monsters/Player.cs +++ b/Projects/Website/Games/Console Monsters/Player.cs @@ -54,8 +54,8 @@ public class Player #region Player Sprites - public static readonly string[] RunRight = new[] - { + public static readonly string[] RunRight = + [ // 0 @" ╭══╮ " + '\n' + @" │ '│ " + '\n' + @@ -92,10 +92,10 @@ public class Player @" ╰──╯ " + '\n' + @" │||│ " + '\n' + @" └─_│ ", - }; + ]; - public static readonly string[] RunLeft = new[] - { + public static readonly string[] RunLeft = + [ // 0 @" ╭══╮ " + '\n' + @" │' │ " + '\n' + @@ -132,10 +132,10 @@ public class Player @" ╰──╯ " + '\n' + @" │||│ " + '\n' + @" └─_│ ", - }; + ]; - public static readonly string[] RunDown = new[] - { + public static readonly string[] RunDown = + [ // 0 @" ╭═══╮ " + '\n' + @" │'_'│ " + '\n' + @@ -172,10 +172,10 @@ public class Player @"╭╰───╯╮" + '\n' + @"│├───┤│" + '\n' + @" │_├─┘ ", - }; + ]; - public static readonly string[] RunUp = new[] - { + public static readonly string[] RunUp = + [ // 0 @" ╭═══╮ " + '\n' + @" │ │ " + '\n' + @@ -212,7 +212,7 @@ public class Player @"╭╰───╯╮" + '\n' + @"│├───┤│" + '\n' + @" │_├─┘ ", - }; + ]; #region IdleLeft public static readonly string IdleLeft1 = diff --git a/Projects/Website/Games/Console Monsters/Screens/BattleTransition.cs b/Projects/Website/Games/Console Monsters/Screens/BattleTransition.cs index 2722757a..2462fe4d 100644 --- a/Projects/Website/Games/Console Monsters/Screens/BattleTransition.cs +++ b/Projects/Website/Games/Console Monsters/Screens/BattleTransition.cs @@ -10,14 +10,14 @@ public static class BattleTransition { private static readonly TimeSpan Delay = TimeSpan.FromMilliseconds(1); - private static readonly Func[] Transitions = new Func[] - { + private static readonly Func[] Transitions = + [ LeftToRight, RightToLeft, LeftToRightBlocks, RightToLeftBlocks, Swirl, - }; + ]; public static async Task Random() { diff --git a/Projects/Website/Games/Console Monsters/Screens/MapScreen.cs b/Projects/Website/Games/Console Monsters/Screens/MapScreen.cs index a432f8f2..aeb3b2d3 100644 --- a/Projects/Website/Games/Console Monsters/Screens/MapScreen.cs +++ b/Projects/Website/Games/Console Monsters/Screens/MapScreen.cs @@ -149,7 +149,7 @@ public static async Task Render() int pixelJ = mapJ < 0 ? (Sprites.Height - 1) + ((mapJ + 1) % Sprites.Height) : (mapJ % Sprites.Height); // render pixel from map tile - string tileRender = map.GetMapTileRender(tileI, tileJ); + string tileRender = Map.GetMapTileRender(tileI, tileJ); char c = tileRender[pixelJ * (Sprites.Width + 1) + pixelI]; sb.Append(char.IsWhiteSpace(c) ? ' ' : c); } diff --git a/Projects/Website/Games/Console Monsters/Screens/Menus/StartScreen.cs b/Projects/Website/Games/Console Monsters/Screens/Menus/StartScreen.cs index ce063ab5..19cd5101 100644 --- a/Projects/Website/Games/Console Monsters/Screens/Menus/StartScreen.cs +++ b/Projects/Website/Games/Console Monsters/Screens/Menus/StartScreen.cs @@ -64,7 +64,7 @@ public static async Task StartMenu() await Statics.Console.Clear(); goto ReDraw; // To not run "arrowOption" so it stays on "Options" after going back case 3: - gameRunning = false; + GameRunning = false; break; } break; diff --git a/Projects/Website/Games/Console Monsters/Sprites.cs b/Projects/Website/Games/Console Monsters/Sprites.cs index 7994ef5c..8edacfc5 100644 --- a/Projects/Website/Games/Console Monsters/Sprites.cs +++ b/Projects/Website/Games/Console Monsters/Sprites.cs @@ -829,77 +829,77 @@ public static class Sprites //WASD public static readonly string[] W = - { + [ "▄ ▄", "█ ▄ █", "█▀ ▀█" - }; + ]; public static readonly string[] A = - { + [ " ▄▄▄ ", "█▄▄▄█", "█ █" - }; + ]; public static readonly string[] S = - { + [ "▄▄▄▄▄", "█▄▄▄▄", "▄▄▄▄█" - }; + ]; public static readonly string[] D = - { + [ "▄▄▄▄ ", "█ █", "█▄▄▄▀" - }; + ]; //ARROWS public static readonly string[] UpArrow = - { + [ " ▄█▄ ", "▀ █ ▀", " █ " - }; + ]; public static readonly string[] LeftArrow = - { + [ " ▄ ", "■█■■■", " ▀ " - }; + ]; public static readonly string[] DownArrow = - { + [ " █ ", "▄ █ ▄", " ▀█▀ " - }; + ]; public static readonly string[] RightArrow = - { + [ " ▄ ", "■■■█■", " ▀ " - }; + ]; //INTERACT public static readonly string[] E = - { + [ "▄▄▄▄▄", "█▄▄▄ ", "█▄▄▄▄" - }; + ]; public static readonly string[] Enter = - { + [ " ▄ ▄", "▄█▄▄█", " ▀▄ " //" ", //"◄──┘", //" " - }; + ]; //Status public static readonly string[] B = - { + [ "▄▄▄▄ ", "█▄▄▄▀", "█▄▄▄▀" - }; + ]; #endregion public const string FullBlock = diff --git a/Projects/Website/Games/Console Monsters/Statics.cs b/Projects/Website/Games/Console Monsters/Statics.cs index 0900a2c3..cda1f28f 100644 --- a/Projects/Website/Games/Console Monsters/Statics.cs +++ b/Projects/Website/Games/Console Monsters/Statics.cs @@ -7,8 +7,11 @@ namespace Website.Games.Console_Monsters; +#pragma warning disable CA2211 // Non-constant fields should not be visible + public static class Statics { + public static BlazorConsole Console = null!; public static BlazorConsole OperatingSystem = null!; @@ -25,30 +28,30 @@ public static class Statics public readonly static Random GameRandom = new(7); public readonly static Random BattleRandom = new(7); public readonly static Player character = new(); - public readonly static List ownedMonsters = new(); - public readonly static List partyMonsters = new(); - - public static MapBase map = new PaletTown(); - public static DateTime previoiusRender = DateTime.Now; - public static int maxPartySize = 6; - public static bool gameRunning { get; set; } = true; - public static bool startMenu { get; set; } = true; - public static bool inInventory { get; set; } = false; - - public static readonly string[] defaultMaptext = new[] - { + public readonly static List ownedMonsters = new(); + public readonly static List partyMonsters = new(); + + public static MapBase Map = new PaletTown(); + public static DateTime PrevioiusRender = DateTime.Now; + public static int MaxPartySize = 6; + public static bool GameRunning { get; set; } = true; + public static bool StartMenu { get; set; } = true; + public static bool InInventory { get; set; } = false; + + public static readonly string[] defaultMaptext = + [ "[↑, W, ←, A, ↓, S, →, D]: Move, [B]: Status, [Escape]: Menu", - }; + ]; - public static readonly string[] defaultMaptextWithInteract = new[] - { + public static readonly string[] defaultMaptextWithInteract = + [ "[↑, W, ←, A, ↓, S, →, D]: Move, [B]: Status, [Escape]: Menu, [E]: Interact", - }; + ]; - public static readonly string[] mapTextPressEnter = new string[] - { + public static readonly string[] mapTextPressEnter = + [ "[E, Enter]: Continue, [Escape]: Menu", - }; + ]; public static string[] MapText { @@ -61,7 +64,7 @@ public static string[] MapText if (character.IsIdle) { var interactTile = character.InteractTile; - if (map.CanInteractWithMapTile(interactTile.I, interactTile.J)) + if (Map.CanInteractWithMapTile(interactTile.I, interactTile.J)) { return defaultMaptextWithInteract; } @@ -70,13 +73,13 @@ public static string[] MapText } } - public static readonly string[] battletext = new[] - { + public static readonly string[] battletext = + [ //"[↑, W, ←, A, ↓, S, →, D]: Move Selection, [E]: Select, [Escape]: Back", "Battles are still in development.", "We are just showing two random monsters at the moment.", "[Enter]: exit battle" - }; + ]; public static string[]? promptText = null; @@ -89,8 +92,8 @@ static Statics() { Animation = Player.IdleDown, }; - map = new PaletTown(); - map.SpawnCharacterOn('X'); + Map = new PaletTown(); + Map.SpawnCharacterOn('X'); PlayerInventory.TryAdd(ExperienceBerries.Instance); PlayerInventory.TryAdd(HealthPotionLarge.Instance); PlayerInventory.TryAdd(HealthPotionMedium.Instance); @@ -105,3 +108,5 @@ static Statics() [System.Diagnostics.DebuggerHidden] public static (int, int) Subtract((int, int) a, (int, int) b) => (a.Item1 - b.Item1, a.Item2 - b.Item2); } + +#pragma warning restore CA2211 // Non-constant fields should not be visible diff --git a/Projects/Website/Games/Console Monsters/Utilities/AsciiGenerator.cs b/Projects/Website/Games/Console Monsters/Utilities/AsciiGenerator.cs index 2e968655..1a1e2439 100644 --- a/Projects/Website/Games/Console Monsters/Utilities/AsciiGenerator.cs +++ b/Projects/Website/Games/Console Monsters/Utilities/AsciiGenerator.cs @@ -29,7 +29,7 @@ public static string[] ToAscii(string @string) first = false; } - return new[] { a.ToString(), b.ToString(), c.ToString() }; + return [a.ToString(), b.ToString(), c.ToString()]; } /// Generates medium sized uppercase ascii text art from a char. diff --git a/Projects/Website/Games/Darts/Darts.cs b/Projects/Website/Games/Darts/Darts.cs index aabb8b95..b9e04064 100644 --- a/Projects/Website/Games/Darts/Darts.cs +++ b/Projects/Website/Games/Darts/Darts.cs @@ -310,8 +310,8 @@ async Task Render() return; } - string[] board = new string[] - { + string[] board = + [ "╔═══════╤═══════╤═══════╤═══════╤═══════╗", "║ │ │ │ │ ║", "║ 1 │ 2 │ 3 │ 2 │ 1 ║", @@ -329,7 +329,7 @@ async Task Render() "║ 1 │ 2 │ 3 │ 2 │ 1 ║", "║ │ │ │ │ ║", "╚═══════╧═══════╧═══════╧═══════╧═══════╝", - }; + ]; for (int i = 0; i < board.Length; i++) { for (int j = 0; j < board[i].Length; j++) @@ -448,8 +448,8 @@ async Task Render() (int PlayerScore, int ComputerScore) CalculateScores() { - string[] scoreBoard = new string[] - { + string[] scoreBoard = + [ "111111112222222233333332222222211111111", "111111112222222233333332222222211111111", "111111112222222233333332222222211111111", @@ -465,7 +465,7 @@ async Task Render() "111111112222222233333332222222211111111", "111111112222222233333332222222211111111", "111111112222222233333332222222211111111", - }; + ]; int playerScore = 0; int computerScore = 0; diff --git a/Projects/Website/Games/Duck Hunt/Duck Hunt.cs b/Projects/Website/Games/Duck Hunt/Duck Hunt.cs index 2804af36..5ee97c21 100644 --- a/Projects/Website/Games/Duck Hunt/Duck Hunt.cs +++ b/Projects/Website/Games/Duck Hunt/Duck Hunt.cs @@ -734,7 +734,7 @@ public static class Enviroment public static class Bird { public static char[][] LeftSprites = - { ( @" _(nn)_ " + NEWLINE_CHAR + + [ ( @" _(nn)_ " + NEWLINE_CHAR + @"<(o----_)=" + NEWLINE_CHAR + @" (UU) ").ToCharArray(), @@ -755,9 +755,9 @@ public static class Bird @"(--(-)--)" + NEWLINE_CHAR + @"(__(_)__)" + NEWLINE_CHAR + @" _/ \_ " ).ToCharArray() - }; + ]; public static char[][] RightSprites = - { ( @" _(nn)_ " + NEWLINE_CHAR + + [ ( @" _(nn)_ " + NEWLINE_CHAR + @"=(_----o)>" + NEWLINE_CHAR + @" (UU) ").ToCharArray(), @@ -778,7 +778,7 @@ public static class Bird @"(--(-)--)" + NEWLINE_CHAR + @"(__(_)__)" + NEWLINE_CHAR + @" _/ \_ " ).ToCharArray() - }; + ]; public static int Height = 3; public static int Width = 10; #endregion diff --git a/Projects/Website/Games/Fighter/Fighter.cs b/Projects/Website/Games/Fighter/Fighter.cs index f81f18ee..6eb94f17 100644 --- a/Projects/Website/Games/Fighter/Fighter.cs +++ b/Projects/Website/Games/Fighter/Fighter.cs @@ -575,8 +575,8 @@ static class Ascii public static class Player { - public static readonly string[] IdleAnimation = new string[] - { + public static readonly string[] IdleAnimation = + [ // 0 @" " + '\n' + @" " + '\n' + @@ -591,10 +591,10 @@ public static class Player @" ((L " + '\n' + @" | " + '\n' + @" / ) ", - }; + ]; - public static readonly string[] BlockAnimation = new string[] - { + public static readonly string[] BlockAnimation = + [ // 0 @" " + '\n' + @" " + '\n' + @@ -602,10 +602,10 @@ public static class Player @" |-' " + '\n' + @" | " + '\n' + @" / / ", - }; + ]; - public static readonly string[] PunchAnimation = new string[] - { + public static readonly string[] PunchAnimation = + [ // 0 @" " + '\n' + @" " + '\n' + @@ -648,10 +648,10 @@ public static class Player @" (|) " + '\n' + @" | " + '\n' + @" / \ ", - }; + ]; - public static readonly string[] JumpKickAnimation = new string[] - { + public static readonly string[] JumpKickAnimation = + [ // 0 @" " + '\n' + @" " + '\n' + @@ -708,10 +708,10 @@ public static class Player @" o " + '\n' + @" > ", - }; + ]; - public static readonly string[] OwnedAnimation = new string[] - { + public static readonly string[] OwnedAnimation = + [ // 0 @" " + '\n' + @" " + '\n' + @@ -740,10 +740,10 @@ public static class Player @" " + '\n' + @" " + '\n' + @" o___/\ ", - }; + ]; - public static readonly string[] GroundAnimation = new string[] - { + public static readonly string[] GroundAnimation = + [ // 0 @" " + '\n' + @" " + '\n' + @@ -751,10 +751,10 @@ public static class Player @" " + '\n' + @" " + '\n' + @" o___/\ ", - }; + ]; - public static readonly string[] GetUpAnimation = new string[] - { + public static readonly string[] GetUpAnimation = + [ // 0 @" " + '\n' + @" " + '\n' + @@ -811,13 +811,13 @@ public static class Player @" o " + '\n' + @" > ", - }; + ]; } public static class Enemy { - public static readonly string[] IdleAnimation = new string[] - { + public static readonly string[] IdleAnimation = + [ // 0 @" " + '\n' + @" " + '\n' + @@ -832,10 +832,10 @@ public static class Enemy @" J)) " + '\n' + @" | " + '\n' + @" ( \ ", - }; + ]; - public static readonly string[] BlockAnimation = new string[] - { + public static readonly string[] BlockAnimation = + [ // 0 @" " + '\n' + @" " + '\n' + @@ -843,10 +843,10 @@ public static class Enemy @" '-| " + '\n' + @" | " + '\n' + @" \ \ ", - }; + ]; - public static readonly string[] PunchAnimation = new string[] - { + public static readonly string[] PunchAnimation = + [ // 0 @" " + '\n' + @" " + '\n' + @@ -889,10 +889,10 @@ public static class Enemy @" (|) " + '\n' + @" | " + '\n' + @" / \ ", - }; + ]; - public static readonly string[] JumpKickAnimation = new string[] - { + public static readonly string[] JumpKickAnimation = + [ // 0 @" " + '\n' + @" " + '\n' + @@ -949,10 +949,10 @@ public static class Enemy @" o " + '\n' + @" >\> " + '\n' + @" << ", - }; + ]; - public static readonly string[] OwnedAnimation = new string[] - { + public static readonly string[] OwnedAnimation = + [ // 0 @" " + '\n' + @" " + '\n' + @@ -981,10 +981,10 @@ public static class Enemy @" " + '\n' + @" " + '\n' + @" /\___o ", - }; + ]; - public static readonly string[] GroundAnimation = new string[] - { + public static readonly string[] GroundAnimation = + [ // 0 @" " + '\n' + @" " + '\n' + @@ -992,10 +992,10 @@ public static class Enemy @" " + '\n' + @" " + '\n' + @" /\___o ", - }; + ]; - public static readonly string[] GetUpAnimation = new string[] - { + public static readonly string[] GetUpAnimation = + [ // 0 @" " + '\n' + @" " + '\n' + @@ -1052,7 +1052,7 @@ public static class Enemy @" o " + '\n' + @" >\> " + '\n' + @" << ", - }; + ]; } #endregion diff --git a/Projects/Website/Games/Flash Cards/Flash Cards.cs b/Projects/Website/Games/Flash Cards/Flash Cards.cs index 896c99ce..7c2c3c79 100644 --- a/Projects/Website/Games/Flash Cards/Flash Cards.cs +++ b/Projects/Website/Games/Flash Cards/Flash Cards.cs @@ -72,7 +72,7 @@ Press [enter] to continue or [escape] to quit... await Console.Write($" {array[index].Letter}? "); string input = await Console.ReadLine()!; await Console.WriteLine(); - if (input.Trim().ToUpper() == array[index].CodeWord.ToUpper()) + if (input.Trim().Equals(array[index].CodeWord, StringComparison.CurrentCultureIgnoreCase)) { await Console.WriteLine(" Correct! :)"); } diff --git a/Projects/Website/Games/Hangman/Hangman.cs b/Projects/Website/Games/Hangman/Hangman.cs index 7b4960c3..ce9923a9 100644 --- a/Projects/Website/Games/Hangman/Hangman.cs +++ b/Projects/Website/Games/Hangman/Hangman.cs @@ -11,7 +11,7 @@ public class Hangman public async Task Run() { string[] Renders = - { + [ #region Frames // 0 @" ╔═══╗ " + '\n' + @@ -70,10 +70,10 @@ public async Task Run() @" ███ ║ " + '\n' + @" ══════╩═══", #endregion - }; + ]; string[] DeathAnimation = - { + [ #region Frames // @" ╔═══╗ " + '\n' + @@ -364,7 +364,7 @@ public async Task Run() @" _ ║ " + '\n' + @" __/══════╩═══", #endregion - }; + ]; if (Resources.Words is null || Resources.Words.Length is 0) { diff --git a/Projects/Website/Games/Helicopter/Helicopter.cs b/Projects/Website/Games/Helicopter/Helicopter.cs index 46f8fe06..da382b01 100644 --- a/Projects/Website/Games/Helicopter/Helicopter.cs +++ b/Projects/Website/Games/Helicopter/Helicopter.cs @@ -30,16 +30,16 @@ public async Task Run() #region Ascii Renders - string[] bulletRenders = new string[] - { + string[] bulletRenders = + [ " ", // 0 "-", // 1 "~", // 2 "█", // 3 - }; + ]; - string[] helicopterRenders = new string[] - { + string[] helicopterRenders = + [ // 0 @" " + '\n' + @" " + '\n' + @@ -52,10 +52,10 @@ public async Task Run() @" -----+-----" + '\n' + @"*\===<[_]L) " + '\n' + @" -'-`- ", - }; + ]; - string[] ufoRenders = new string[] - { + string[] ufoRenders = + [ // 0 @" __O__ " + '\n' + @"-=<_‗_‗_>=-", @@ -75,10 +75,10 @@ public async Task Run() @" _!_ " + '\n' + @"(_o_)" + '\n' + @" ^^^ ", - }; + ]; - string[] explosionRenders = new string[] - { + string[] explosionRenders = + [ // 0 @" " + '\n' + @" █████ " + '\n' + @@ -127,7 +127,7 @@ public async Task Run() @"* *" + '\n' + @" * * " + '\n' + @" * * ", - }; + ]; #endregion diff --git a/Projects/Website/Games/Hurdles/Hurdles.cs b/Projects/Website/Games/Hurdles/Hurdles.cs index 4e92cb88..6b427de6 100644 --- a/Projects/Website/Games/Hurdles/Hurdles.cs +++ b/Projects/Website/Games/Hurdles/Hurdles.cs @@ -9,8 +9,8 @@ public class Hurdles public async Task Run() { - string[] runningAnimation = new string[] - { + string[] runningAnimation = + [ #region Frames // 0 @" " + '\n' + @@ -62,10 +62,10 @@ public async Task Run() @" /-- " + '\n' + @" / |", #endregion - }; + ]; - string[] jumpingAnimation = new string[] - { + string[] jumpingAnimation = + [ #region Frames // 0 @" " + '\n' + @@ -130,7 +130,7 @@ public async Task Run() @" |_ " + '\n' + @" / | ", #endregion - }; + ]; string hurdleFrame = #region Frame diff --git a/Projects/Website/Games/Oligopoly/Oligopoly.cs b/Projects/Website/Games/Oligopoly/Oligopoly.cs index 5258cb19..5c7cb944 100644 --- a/Projects/Website/Games/Oligopoly/Oligopoly.cs +++ b/Projects/Website/Games/Oligopoly/Oligopoly.cs @@ -13,12 +13,10 @@ public class Oligopoly public async Task Run() { bool CloseRequested = false; -#pragma warning disable IDE0059 // Unnecessary assignment of a value List Companies = null!; List Events = null!; Event CurrentEvent = null!; decimal Money = 10000.00m; -#pragma warning restore IDE0059 // Unnecessary assignment of a value const decimal LosingNetWorth = 2000.00m; const decimal WinningNetWorth = 50000.00m; @@ -55,12 +53,11 @@ async Task MainMenuScreen() prompt.AppendLine(); prompt.Append("Use up and down arrow keys and enter to select an option:"); int selectedIndex = await HandleMenuWithOptions(prompt.ToString(), - new string[] - { + [ "Play", "About", "Exit", - }); + ]); switch (selectedIndex) { case 0: await IntroductionScreen(); break; @@ -94,13 +91,13 @@ async Task GameLoop() StringBuilder prompt = RenderCompanyStocksTable(); prompt.AppendLine(); prompt.Append("Use up and down arrow keys and enter to select an option:"); - selectedOption = await HandleMenuWithOptions(prompt.ToString(), new string[] - { + selectedOption = await HandleMenuWithOptions(prompt.ToString(), + [ "Wait For Market Change", "Buy", "Sell", "Information About Companies", - }); + ]); switch (selectedOption) { case 1: await BuyOrSellStockScreen(true); break; diff --git a/Projects/Website/Games/PacMan/PacMan.cs b/Projects/Website/Games/PacMan/PacMan.cs index d01ab71c..b28a0c51 100644 --- a/Projects/Website/Games/PacMan/PacMan.cs +++ b/Projects/Website/Games/PacMan/PacMan.cs @@ -115,12 +115,12 @@ public async Task Run() " "; string[] PacManAnimations = - { + [ "\"' '\"", "n. .n", ")>- ->", "(<- -<", - }; + ]; #endregion @@ -183,7 +183,7 @@ public async Task Run() d.FramesToUpdate = 12; d.Update = () => UpdateGhost(d); - Ghosts = new Ghost[] { a, b, c, d, }; + Ghosts = [a, b, c, d,]; await RenderWalls(); await RenderGate(); @@ -569,7 +569,7 @@ async Task UpdateGhost(Ghost ghost) x++; } } - return list.ToArray(); + return [.. list]; } (int X, int Y) GetRandomLocation() => Random.Shared.Choose(Locations); diff --git a/Projects/Website/Games/Role Playing game/Maps.cs b/Projects/Website/Games/Role Playing game/Maps.cs index 222fb8ee..01695493 100644 --- a/Projects/Website/Games/Role Playing game/Maps.cs +++ b/Projects/Website/Games/Role Playing game/Maps.cs @@ -59,8 +59,8 @@ public static bool IsValidCharacterMapTile(char[][] map, int tileI, int tileJ) }; } - public static readonly char[][] Town = new char[][] - { + public static readonly char[][] Town = + [ " WWWWWWWWWWWWWWWWW111WWWWWWWWWWWWWWWWW ".ToCharArray(), "wwwWbbbfbbbB Bbffbffbffb cWwww".ToCharArray(), "wwwW Wwww".ToCharArray(), @@ -72,10 +72,10 @@ public static bool IsValidCharacterMapTile(char[][] map, int tileI, int tileJ) "wwwW cWwww".ToCharArray(), "wwwWbffbfbffbfbfbbfb bbfbfbffbfbbfbfbWwww".ToCharArray(), " WWWWWWWWWWWWWWWWW111WWWWWWWWWWWWWWWWW ".ToCharArray(), - }; + ]; - public static readonly char[][] Field = new char[][] - { + public static readonly char[][] Field = + [ "mmmpmmmmpmmmmmpmmmmmpmmmmmpmmmpmmmpmmmpmm".ToCharArray(), "mmpppppppmmmpppmmmpppppmmppmmmpmmmmpppmmm".ToCharArray(), "mmpmmpmmpmppmmpmpmmpmmpmmmmmmpppmmpmpmmmp".ToCharArray(), @@ -91,10 +91,10 @@ public static bool IsValidCharacterMapTile(char[][] map, int tileI, int tileJ) "wwwwwwwwwwwwwwwwwwwwwTTTTTTTTTTTTmmmmmmmm".ToCharArray(), "wwwwwwwwwwwwwwwwwwwwTTTTTTTTTTTTTTmmmmmmm".ToCharArray(), "wwwwwwwwwwwwwwwwwwwTTTTTTTTTTTTTTTTmmmmmm".ToCharArray(), - }; + ]; - public static readonly char[][] Castle = new char[][] - { + public static readonly char[][] Castle = + [ "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW".ToCharArray(), "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW".ToCharArray(), "WWc WkW cWW".ToCharArray(), @@ -111,5 +111,5 @@ public static bool IsValidCharacterMapTile(char[][] map, int tileI, int tileJ) "WWc cWW".ToCharArray(), "WWWWWWWWWWWWWWWWWWW WWWWWWWWWWWWWWWWWWW".ToCharArray(), "WWWWWWWWWWWWWWWWWWW111WWWWWWWWWWWWWWWWWWW".ToCharArray(), - }; + ]; } diff --git a/Projects/Website/Games/Role Playing game/Role Playing Game.cs b/Projects/Website/Games/Role Playing game/Role Playing Game.cs index 9610d2a0..7f4a8c6d 100644 --- a/Projects/Website/Games/Role Playing game/Role Playing Game.cs +++ b/Projects/Website/Games/Role Playing game/Role Playing Game.cs @@ -20,19 +20,19 @@ public async Task Run() const double randomBattleChance = 1d / 10d; const int movesBeforeRandomBattle = 4; - string[] maptext = new[] - { + string[] maptext = + [ "Move: arrow keys or (w, a, s, d)", "Check Status: [enter]", "Quit: [escape]", - }; + ]; - string[] defaultCombatText = new string[] - { + string[] defaultCombatText = + [ "1) attack", "2) run", "3) check status", - }; + ]; string[] combatText = defaultCombatText; @@ -402,19 +402,19 @@ async Task Battle(EnemyType enemyType)//, out bool ranAway) switch (enemyType) { case EnemyType.Boar: - combatText = new string[] - { + combatText = + [ "You were attacked by a wild boar!", "1) attack", "2) run", "3) check status", - }; + ]; break; case EnemyType.GuardBoss: if (character.Level < 2) { - combatText = new string[] - { + combatText = + [ "You approached the castle guard.", "He looks tough. You should probably", "run away and come back when you are", @@ -422,33 +422,33 @@ async Task Battle(EnemyType enemyType)//, out bool ranAway) "1) attack", "2) run", "3) check status", - }; + ]; } else { - combatText = new string[] - { + combatText = + [ "You approached the castle guard.", "1) attack", "2) run", "3) check status", - }; + ]; } break; case EnemyType.Guard: - combatText = new string[] - { + combatText = + [ "You were attacked by a castle guard!", "1) attack", "2) run", "3) check status", - }; + ]; break; case EnemyType.FinalBoss: if (character.Level < 3) { - combatText = new string[] - { + combatText = + [ "You approached the evil king.", "He looks tough. You should probably", "run away and come back when you are", @@ -456,17 +456,17 @@ async Task Battle(EnemyType enemyType)//, out bool ranAway) "1) attack", "2) run", "3) check status", - }; + ]; } else { - combatText = new string[] - { + combatText = + [ "You approached the evil king.", "1) attack", "2) run", "3) check status", - }; + ]; } break; } @@ -481,7 +481,7 @@ async Task Battle(EnemyType enemyType)//, out bool ranAway) EnemyType.Guard => Sprites.IdleLeft, EnemyType.GuardBoss => Sprites.IdleLeft, EnemyType.FinalBoss => Sprites.IdleLeft, - _ => new[] { Sprites.Error }, + _ => [Sprites.Error], }; bool pendingConfirmation = false; @@ -513,24 +513,24 @@ async Task Battle(EnemyType enemyType)//, out bool ranAway) case 0: frameLeft = 0; animationLeft = Sprites.PunchRight; - combatText = new string[] - { + combatText = + [ "You attacked and did damage!", "", "Press [enter] to continue...", - }; + ]; enemyHealth -= character.Damage; break; case 1: frameLeft = 0; animationLeft = Sprites.FallLeft; - combatText = new string[] - { + combatText = + [ "You were attacked, but the enemy was", "faster and you took damage!", "", "Press [enter] to continue...", - }; + ]; character.Health--; break; } @@ -561,14 +561,14 @@ async Task Battle(EnemyType enemyType)//, out bool ranAway) { frameLeft = 0; animationLeft = Sprites.FallLeft; - combatText = new string[] - { + combatText = + [ "You tried to run away but the enemy", "attacked you from behind and you took", "damage.", "", "Press [enter] to continue...", - }; + ]; character.Health--; pendingConfirmation = true; } diff --git a/Projects/Website/Games/Role Playing game/Sprites.cs b/Projects/Website/Games/Role Playing game/Sprites.cs index 6776cb96..8b126455 100644 --- a/Projects/Website/Games/Role Playing game/Sprites.cs +++ b/Projects/Website/Games/Role Playing game/Sprites.cs @@ -210,8 +210,8 @@ public static class Sprites @"║error║" + "\n" + @"╚═════╝"; - public static readonly string[] RunRight = new[] - { + public static readonly string[] RunRight = + [ // 0 @" O " + '\n' + @" |_ " + '\n' + @@ -247,10 +247,10 @@ public static class Sprites @" \> " + '\n' + @" / " + '\n' + @" |\ ", - }; + ]; // would be nice to give up/down their own animations, but // for now they are just copies of left/right @@ -328,8 +328,8 @@ public static class Sprites public static readonly string[] IdleDown = (string[])IdleRight.Clone(); public static readonly string[] IdleUp = (string[])IdleLeft.Clone(); - public static readonly string[] FallLeft = new string[] - { + public static readonly string[] FallLeft = + [ // 0 @" O___ " + '\n' + @" \`- " + '\n' + @@ -370,10 +370,10 @@ public static class Sprites @" " + '\n' + @" " + '\n' + @" o___/\", - }; + ]; - public static readonly string[] PunchRight = new string[] - { + public static readonly string[] PunchRight = + [ // 0 @" _o_. " + '\n' + @" (| " + '\n' + @@ -429,10 +429,10 @@ public static class Sprites @" (|) " + '\n' + @" | " + '\n' + @" / \ ", - }; + ]; - public static readonly string[] IdleBoar = new[] - { + public static readonly string[] IdleBoar = + [ // 0 @" " + '\n' + @"^..^ " + '\n' + @@ -573,10 +573,10 @@ public static class Sprites @"^..^ " + '\n' + @"(oo) )~" + '\n' + @" ,, ,, ", - }; + ]; - public static readonly string[] GetUpAnimationRight = new string[] - { + public static readonly string[] GetUpAnimationRight = + [ // 0 @" " + '\n' + @" " + '\n' + @@ -657,5 +657,5 @@ public static class Sprites @" o " + '\n' + @" > ", - }; + ]; } diff --git a/Projects/Website/Games/Roll And Move/Roll And Move.cs b/Projects/Website/Games/Roll And Move/Roll And Move.cs index 3f10b1bf..8774c2cd 100644 --- a/Projects/Website/Games/Roll And Move/Roll And Move.cs +++ b/Projects/Website/Games/Roll And Move/Roll And Move.cs @@ -75,21 +75,21 @@ Your opponent circled the board before you. ConsoleColor color_a = ConsoleColor.Blue; (int Top, int Left)[] spots_a = - { + [ /* top */ (02, 04), (02, 10), (02, 14), (02, 18), (02, 22), (02, 26), (02, 30), (02, 34), (02, 38), /* right */ (02, 44), (05, 44), (07, 44), (09, 44), (11, 44), (13, 44), (15, 44), (17, 44), /* bottom */ (20, 44), (20, 38), (20, 34), (20, 30), (20, 26), (20, 22), (20, 18), (20, 14), (20, 10), /* left */ (20, 04), (17, 04), (15, 04), (13, 04), (11, 04), (09, 04), (07, 04), (05, 04), (02, 04), - }; + ]; ConsoleColor color_b = ConsoleColor.Red; (int Top, int Left)[] spots_b = - { + [ /* top */ (03, 06), (03, 10), (03, 14), (03, 18), (03, 22), (03, 26), (03, 30), (03, 34), (03, 38), /* right */ (03, 42), (05, 42), (07, 42), (09, 42), (11, 42), (13, 42), (15, 42), (17, 42), /* bottom */ (19, 42), (19, 38), (19, 34), (19, 30), (19, 26), (19, 22), (19, 18), (19, 14), (19, 10), /* left */ (19, 06), (17, 06), (15, 06), (13, 06), (11, 06), (09, 06), (07, 06), (05, 06), (03, 06), - }; + ]; bool escape = false; while (!escape) diff --git a/Projects/Website/Games/Rythm/Rythm.cs b/Projects/Website/Games/Rythm/Rythm.cs index 0efefa29..0a7934c9 100644 --- a/Projects/Website/Games/Rythm/Rythm.cs +++ b/Projects/Website/Games/Rythm/Rythm.cs @@ -10,8 +10,8 @@ public class Rythm public async Task Run() { - string[] frames = { "▌", "▐", }; - string[] deathFrames = { "X", "X", "X", "X", "X", }; + string[] frames = ["▌", "▐",]; + string[] deathFrames = ["X", "X", "X", "X", "X",]; List notes; List deadNotes; TimeSpan delayTime = TimeSpan.FromMilliseconds(34); @@ -20,12 +20,12 @@ public async Task Run() int targetLeft = 5; int remainingMisses = 5; (int Top, ConsoleKey Key)[] tracks = - { + [ (4, ConsoleKey.UpArrow), (7, ConsoleKey.LeftArrow), (10, ConsoleKey.DownArrow), (13, ConsoleKey.RightArrow), - }; + ]; try { diff --git a/Projects/Website/Games/Shmup/Shmup.cs b/Projects/Website/Games/Shmup/Shmup.cs index aa6d83f7..d5efee27 100644 --- a/Projects/Website/Games/Shmup/Shmup.cs +++ b/Projects/Website/Games/Shmup/Shmup.cs @@ -236,7 +236,7 @@ async Task Update() { PlayerBullet bullet = playerBullets[i]; bool exploded = false; - IEnemy[] enemiesClone = enemies.ToArray(); + IEnemy[] enemiesClone = [.. enemies]; for (int j = 0; j < enemiesClone.Length; j++) { if (enemiesClone[j].CollidingWith(bullet.X, bullet.Y)) @@ -431,88 +431,88 @@ internal enum States public States State; static readonly string[] Sprite = - { + [ @" ╱‾╲ ", @" ╱╱‾╲╲ ", @" ╱'╲O╱'╲ ", @"╱ / ‾ \ ╲", @"╲_╱───╲_╱", - }; + ]; static readonly string[] SpriteUp = - { + [ @" ╱‾╲ ", @" ╱╱‾╲╲ ", @" ╱'╲O╱'╲ ", @"╱ / ‾ \ ╲", @"╲_╱───╲_╱", @"/V\ /V\", - }; + ]; static readonly string[] SpriteDown = - { + [ @" ╱‾╲ ", @" ╱╱‾╲╲ ", @"-╱'╲O╱'╲-", @"╱-/ ‾ \-╲", @"╲_╱───╲_╱", - }; + ]; static readonly string[] SpriteLeft = - { + [ @" ╱╲ ", @" ╱‾╲╲ ", @" ╱╲O╱'╲ ", @"╱/ ‾ \ ╲", @"╲╱───╲_╱", - }; + ]; static readonly string[] SpriteRight = - { + [ @" ╱╲ ", @" ╱╱‾╲ ", @" ╱'╲O╱╲ ", @"╱ / ‾ \╲", @"╲_╱───╲╱", - }; + ]; static readonly string[] SpriteUpLeft = - { + [ @" ╱╲ ", @" ╱‾╲╲ ", @" ╱╲O╱'╲ ", @"╱/ ‾ \ ╲", @"╲╱───╲_╱", @"/\ /V\", - }; + ]; static readonly string[] SpriteUpRight = - { + [ @" ╱╲ ", @" ╱╱‾╲ ", @" ╱'╲O╱╲ ", @"╱ / ‾ \╲", @"╲_╱───╲╱", @"/V\ /\", - }; + ]; static readonly string[] SpriteDownLeft = - { + [ @" ╱╲ ", @" ╱‾╲╲ ", @"-╱╲O╱'╲-", @"-/ ‾ \-╲", @"╲╱───╲_╱", - }; + ]; static readonly string[] SpriteDownRight = - { + [ @" ╱╲ ", @" ╱╱‾╲ ", @"-╱'╲O╱╲-", @"╱-/ ‾ \-", @"╲_╱───╲╱", - }; + ]; public void Render() { @@ -584,18 +584,18 @@ internal class Helicopter : IEnemy private string[] Sprite = Random.Shared.Next(2) is 0 ? spriteA : spriteB; static readonly string[] spriteA = - { + [ @" ~~~~~+~~~~~", @"'\===<[_]L) ", @" -'-`- ", - }; + ]; static readonly string[] spriteB = - { + [ @" -----+-----", @"*\===<[_]L) ", @" -'-`- ", - }; + ]; internal static int XMax = Math.Max(spriteA.Max(s => s.Length), spriteB.Max(s => s.Length)); internal static int YMax = Math.Max(spriteA.Length, spriteB.Length); @@ -676,32 +676,32 @@ internal class Tank : IEnemy private string[] Sprite = spriteDown; static readonly string[] spriteDown = - { + [ @" ___ ", @"|_O_|", @"[ooo]", - }; + ]; static readonly string[] spriteUp = - { + [ @" _^_ ", @"|___|", @"[ooo]", - }; + ]; static readonly string[] spriteLeft = - { + [ @" __ ", @"=|__|", @"[ooo]", - }; + ]; static readonly string[] spriteRight = - { + [ @" __ ", @"|__|=", @"[ooo]", - }; + ]; internal static int XMax = new[] { spriteDown.Max(s => s.Length), spriteUp.Max(s => s.Length), spriteLeft.Max(s => s.Length), spriteRight.Max(s => s.Length), }.Max(); internal static int YMax = new[] { spriteDown.Length, spriteUp.Length, spriteLeft.Length, spriteRight.Length, }.Max(); @@ -781,11 +781,11 @@ internal class UFO1 : IEnemy public float XVelocity = 1f / 8f; public float YVelocity = 1f / 8f; private static readonly string[] Sprite = - { + [ @" _!_ ", @"(_o_)", @" ''' ", - }; + ]; internal static int XMax = Sprite.Max(s => s.Length); internal static int YMax = Sprite.Length; @@ -873,11 +873,11 @@ internal class UFO2 : IEnemy public int TeleportFrequency = 360; private static readonly string[] Sprite = - { + [ @" _!_ ", @" /_O_\ ", @"-==<_‗_‗_>==-", - }; + ]; internal static int XMax = Sprite.Max(s => s.Length); internal static int YMax = Sprite.Length; diff --git a/Projects/Website/Games/Simon/Simon.cs b/Projects/Website/Games/Simon/Simon.cs index e229fedd..0c7c680f 100644 --- a/Projects/Website/Games/Simon/Simon.cs +++ b/Projects/Website/Games/Simon/Simon.cs @@ -15,8 +15,8 @@ public async Task Run() int score = 0; List pattern = new(); - string[] Renders = new string[] - { + string[] Renders = + [ #region Frames // 0 @" ╔══════╗ " + '\n' + @@ -79,7 +79,7 @@ public async Task Run() @" ║ ║ " + '\n' + @" ╚══════╝ ", #endregion - }; + ]; try { diff --git a/Projects/Website/Games/Snake/Snake.cs b/Projects/Website/Games/Snake/Snake.cs index 16d0442a..5279f62e 100644 --- a/Projects/Website/Games/Snake/Snake.cs +++ b/Projects/Website/Games/Snake/Snake.cs @@ -28,9 +28,9 @@ public async Task Run() await Console.Write(prompt); } } - int[] velocities = { 50, 35, 20 }; + int[] velocities = [50, 35, 20]; int velocity = velocities[speedInput - 1]; - char[] DirectionChars = { '^', 'v', '<', '>', }; + char[] DirectionChars = ['^', 'v', '<', '>',]; TimeSpan sleep = TimeSpan.FromMilliseconds(velocity); int width = Console.WindowWidth; int height = Console.WindowHeight; diff --git a/Projects/Website/Games/Tanks/Tanks.cs b/Projects/Website/Games/Tanks/Tanks.cs index 25b97983..ee7531d3 100644 --- a/Projects/Website/Games/Tanks/Tanks.cs +++ b/Projects/Website/Games/Tanks/Tanks.cs @@ -10,8 +10,8 @@ public class Tanks public async Task Run() { - string[] Tank = new string[] - { + string[] Tank = + [ #region Frames null!, // Up @@ -31,10 +31,10 @@ public async Task Run() @"|__|=" + "\n" + @"[ooo]" + "\n", #endregion - }; + ]; - string[] TankShooting = new string[] - { + string[] TankShooting = + [ #region Frames null!, // Up @@ -54,10 +54,10 @@ public async Task Run() @"|__|█" + "\n" + @"[ooo]" + "\n", #endregion - }; + ]; - string[] TankExploding = new string[] - { + string[] TankExploding = + [ #region Frames // Ka... @" ___ " + "\n" + @@ -72,10 +72,10 @@ public async Task Run() @" " + "\n" + @" " + "\n", #endregion - }; + ]; - char[] Bullet = new char[] - { + char[] Bullet = + [ #region Frames default, '^', // Up @@ -83,7 +83,7 @@ public async Task Run() '<', // Left '>', // Right #endregion - }; + ]; string Map = #region Frames diff --git a/Projects/Website/Games/Tetris/Tetris.cs b/Projects/Website/Games/Tetris/Tetris.cs index 5648224f..99411e2f 100644 --- a/Projects/Website/Games/Tetris/Tetris.cs +++ b/Projects/Website/Games/Tetris/Tetris.cs @@ -23,8 +23,8 @@ public async Task Run() } emptyField[^1] = "╰──────────────────────────────╯"; - string[] nextTetrominoBorder = new[] - { + string[] nextTetrominoBorder = + [ "╭─────────╮", "│ │", "│ │", @@ -35,28 +35,28 @@ public async Task Run() "│ │", "│ │", "╰─────────╯" - }; + ]; - string[] scoreBorder = new[] - { + string[] scoreBorder = + [ "╭─────────╮", "│ │", "╰─────────╯" - }; + ]; - string[] pauseRender = new[] - { + string[] pauseRender = + [ "█████╗ ███╗ ██╗██╗█████╗█████╗", "██╔██║██╔██╗██║██║██╔══╝██╔══╝", "█████║█████║██║██║ ███╗ █████╗", "██╔══╝██╔██║██║██║ ██╗██╔══╝", "██║ ██║██║█████║█████║█████╗", "╚═╝ ╚═╝╚═╝╚════╝╚════╝╚════╝", - }; + ]; - string[][] tetrominos = new[] - { - new[]{ + string[][] tetrominos = + [ + [ "╭─╮", "╰─╯", "x─╮", @@ -65,44 +65,44 @@ public async Task Run() "╰─╯", "╭─╮", "╰─╯" - }, - new[]{ + ], + [ "╭─╮ ", "╰─╯ ", "╭─╮x─╮╭─╮", "╰─╯╰─╯╰─╯" - }, - new[]{ + ], + [ " ╭─╮", " ╰─╯", "╭─╮x─╮╭─╮", "╰─╯╰─╯╰─╯" - }, - new[]{ + ], + [ "╭─╮╭─╮", "╰─╯╰─╯", "x─╮╭─╮", "╰─╯╰─╯" - }, - new[]{ + ], + [ " ╭─╮╭─╮", " ╰─╯╰─╯", "╭─╮x─╮ ", "╰─╯╰─╯ " - }, - new[]{ + ], + [ " ╭─╮ ", " ╰─╯ ", "╭─╮x─╮╭─╮", "╰─╯╰─╯╰─╯" - }, - new[]{ + ], + [ "╭─╮╭─╮ ", "╰─╯╰─╯ ", " x─╮╭─╮", " ╰─╯╰─╯" - }, - }; + ], + ]; const int borderSize = 1; @@ -413,7 +413,7 @@ async Task DrawFrame() // Next for (int y = 0; y < nextTetrominoBorder.Length; y++) { - frame[y] = frame[y].Concat(nextTetrominoBorder[y]).ToArray(); + frame[y] = [.. frame[y], .. nextTetrominoBorder[y]]; } for (int y = 0; y < tetromino.Next.Length; y++) { @@ -434,7 +434,7 @@ async Task DrawFrame() for (int y = 0; y < scoreBorder.Length; y++) { int sY = nextTetrominoBorder.Length + y; - frame[sY] = frame[sY].Concat(scoreBorder[y]).ToArray(); + frame[sY] = [.. frame[sY], .. scoreBorder[y]]; } char[] scoreRender = score.ToString(CultureInfo.InvariantCulture).ToCharArray(); for (int scoreX = scoreRender.Length - 1; scoreX >= 0; scoreX--) diff --git a/Projects/Website/Games/Tower Of Hanoi/Tower Of Hanoi.cs b/Projects/Website/Games/Tower Of Hanoi/Tower Of Hanoi.cs index 73c4c23d..1fe65809 100644 --- a/Projects/Website/Games/Tower Of Hanoi/Tower Of Hanoi.cs +++ b/Projects/Website/Games/Tower Of Hanoi/Tower Of Hanoi.cs @@ -77,7 +77,7 @@ public async Task Run() Restart: state = State.ChooseSource; minimumNumberOfMoves = (int)Math.Pow(2, disks) - 1; - stacks = new List[] { new(), new(), new() }; + stacks = [new(), new(), new()]; for (int i = disks; i > 0; i--) { stacks[0].Add(i); diff --git a/Projects/Website/Games/Type/Type.cs b/Projects/Website/Games/Type/Type.cs index 96b33a4c..94d40e45 100644 --- a/Projects/Website/Games/Type/Type.cs +++ b/Projects/Website/Games/Type/Type.cs @@ -38,11 +38,11 @@ public async Task Run() DateTime WordStart; ConsoleColor[] Colors = - { + [ ConsoleColor.White, ConsoleColor.Gray, ConsoleColor.DarkGray, - }; + ]; try { diff --git a/Projects/Website/Games/Wordle/Wordle.cs b/Projects/Website/Games/Wordle/Wordle.cs index dcc18a8c..34e17108 100644 --- a/Projects/Website/Games/Wordle/Wordle.cs +++ b/Projects/Website/Games/Wordle/Wordle.cs @@ -48,7 +48,7 @@ await Console.WriteLine(@" Wordle int guess = 0; int cursor = 0; string word = Resources.FiveLetterWords[Random.Shared.Next(Resources.FiveLetterWords.Length)].ToUpperInvariant(); - char[] letters = { ' ', ' ', ' ', ' ', ' ' }; + char[] letters = [' ', ' ', ' ', ' ', ' ']; GetInput: await Console.SetCursorPosition(3 + cursor * 4, 2 + guess * 2); ConsoleKey key = (await Console.ReadKey(true)).Key; @@ -113,7 +113,7 @@ await Console.WriteLine(@" Wordle } else { - letters = new char[] { ' ', ' ', ' ', ' ', ' ' }; + letters = [' ', ' ', ' ', ' ', ' ']; guess++; cursor = 0; } diff --git a/Projects/Website/Games/Yahtzee/Yahtzee.cs b/Projects/Website/Games/Yahtzee/Yahtzee.cs index feeafecc..e441383a 100644 --- a/Projects/Website/Games/Yahtzee/Yahtzee.cs +++ b/Projects/Website/Games/Yahtzee/Yahtzee.cs @@ -119,7 +119,7 @@ Play again [enter] or quit [escape]? const int minWidth = 50; const int minHeight = 32; - int[] dice = { 1, 2, 3, 4, 5 }; + int[] dice = [1, 2, 3, 4, 5]; bool[] locked = new bool[dice.Length]; int diceSelection = 0; int scoreSelection = 0; diff --git a/Projects/Website/Resources.cs b/Projects/Website/Resources.cs index 27ab3883..5e4b3ccc 100644 --- a/Projects/Website/Resources.cs +++ b/Projects/Website/Resources.cs @@ -26,7 +26,7 @@ static Resources() string word = streamReader.ReadLine()!; words.Add(word); } - Words = words.ToArray(); + Words = [.. words]; } } { @@ -42,7 +42,7 @@ static Resources() string word = streamReader.ReadLine()!; words.Add(word); } - FiveLetterWords = words.ToArray(); + FiveLetterWords = [.. words]; } } { diff --git a/Projects/Wordle/Program.cs b/Projects/Wordle/Program.cs index d4c14872..d85e5510 100644 --- a/Projects/Wordle/Program.cs +++ b/Projects/Wordle/Program.cs @@ -54,7 +54,7 @@ int guess = 0; int cursor = 0; string word = words[Random.Shared.Next(words.Count)].ToUpperInvariant(); - char[] letters = { ' ', ' ', ' ', ' ', ' ' }; + char[] letters = [' ', ' ', ' ', ' ', ' ']; GetInput: Console.SetCursorPosition(3 + cursor * 4, 2 + guess * 2); ConsoleKey key = Console.ReadKey(true).Key; @@ -119,7 +119,7 @@ } else { - letters = new char[] { ' ', ' ', ' ', ' ', ' ' }; + letters = [' ', ' ', ' ', ' ', ' ']; guess++; cursor = 0; } diff --git a/Projects/Yahtzee/Program.cs b/Projects/Yahtzee/Program.cs index 30c2f9eb..ef84f1ea 100644 --- a/Projects/Yahtzee/Program.cs +++ b/Projects/Yahtzee/Program.cs @@ -110,7 +110,7 @@ Play again [enter] or quit [escape]? const int minWidth = 50; const int minHeight = 32; -int[] dice = { 1, 2, 3, 4, 5 }; +int[] dice = [1, 2, 3, 4, 5]; bool[] locked = new bool[dice.Length]; int diceSelection = 0; int scoreSelection = 0;