diff --git a/RPG/Archer.cs b/RPG/Archer.cs new file mode 100644 index 0000000..6208b59 --- /dev/null +++ b/RPG/Archer.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace RPG +{ + public class Archer : Player + { + public Archer() + : this("Незадано") + { + } + public Archer(string name) + : base(name) + { + Skills.Add(new ArcherSkill()); + Class = "Archer"; + } + + } +} diff --git a/RPG/ArcherSkill.cs b/RPG/ArcherSkill.cs new file mode 100644 index 0000000..2f96bf4 --- /dev/null +++ b/RPG/ArcherSkill.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace RPG +{ + public class ArcherSkill : IUseSkill + { + public int TimesUsedSkill = 0; + public void UseSkill(Player user) + { + if (TimesUsedSkill < 1) + { + user.Opponent.Effects.Add(new FireArrow()); + Logger.LogText($"({user.Class}) {user.Name} использует (Огненные стрелы) на ({user.Opponent.Class}) {user.Opponent.Name}."); + TimesUsedSkill++; + } + else + { + user.Usingskill = new Attack(); + user.UseSkill(); + } + } + } +} diff --git a/RPG/Attack.cs b/RPG/Attack.cs new file mode 100644 index 0000000..cc6de44 --- /dev/null +++ b/RPG/Attack.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace RPG +{ + public class Attack : IUseSkill + { + public void UseSkill(Player user) + { + user.Opponent.HP -= user.Strength; + Logger.LogText($"({user.Class}) {user.Name} наносит урон {user.Strength} противнику ({user.Opponent.Class}) {user.Opponent.Name}."); + } + } +} diff --git a/RPG/Battle.cs b/RPG/Battle.cs new file mode 100644 index 0000000..cda857a --- /dev/null +++ b/RPG/Battle.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace RPG +{ + public static class ClassBattle + { + public static Player Battle(Player w) + { + Random rnd = new Random(); + while (w.HP > 0 && w.Opponent.HP > 0) + { + int RandomSkill1 = rnd.Next(0, w.Skills.Count); + int RandomSkill2 = rnd.Next(0, w.Opponent.Skills.Count); + w.ProcEffects(); + if (w.isStunned == false) + { + w.Usingskill = w.Skills[RandomSkill1]; + w.UseSkill(); + } + else + { + w.isStunned = false; + for (int i = 0; i < w.Effects.Count; i++) + { + if (w.Effects[i] is Skip) + { + w.Effects.RemoveAt(i); + i--; + } + } + } + w.Opponent.ProcEffects(); + if (w.Opponent.HP > 0) + { + if (w.Opponent.isStunned == false) + { + w.Opponent.Usingskill = w.Opponent.Skills[RandomSkill2]; + w.Opponent.UseSkill(); + } + else + { + w.Opponent.isStunned = false; + for (int i = 0; i < w.Effects.Count; i++) + { + if (w.Opponent.Effects[i] is Skip) + { + w.Opponent.Effects.RemoveAt(i); + i--; + } + } + } + } + } + if (w.HP < 1) + { + Logger.LogText($"({w.Class}) {w.Name} погиб!\n"); + w.Opponent.HP = rnd.Next(1, 100); + w.Opponent.Effects.Clear(); + return w; + } + else if (w.Opponent.HP < 1) + { + Logger.LogText($"({w.Opponent.Class}) {w.Opponent.Name} погиб!\n"); + w.HP = rnd.Next(1, 100); + w.Effects.Clear(); + return w.Opponent; + } + throw new Exception("Fatal error"); + + } + } +} diff --git a/RPG/FireArrow.cs b/RPG/FireArrow.cs new file mode 100644 index 0000000..a358964 --- /dev/null +++ b/RPG/FireArrow.cs @@ -0,0 +1,16 @@ + using System; +using System.Collections.Generic; +using System.Text; + +namespace RPG +{ + public class FireArrow : IEffect + { + public const int DamageFireArrow = 2; + public void Proc(Player owner) + { + owner.HP -= DamageFireArrow; + Logger.LogText($"({owner.Class}) {owner.Name} получает урон {DamageFireArrow} от эффекта Fire Arrow."); + } + } +} diff --git a/RPG/Game.cs b/RPG/Game.cs new file mode 100644 index 0000000..c20e907 --- /dev/null +++ b/RPG/Game.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +namespace RPG +{ + class Game + { + static void Main(string[] args) + { + string[] names = { "WhiteCat", "Vaxei", "Alumetri", "idke", "Micca", "FlyingTuna", "Karthy", "RyuK", "Varvalian", + "Mathi", "FGSky", "fieryrage", "firebat92", "chocomint", "Abyssal", "Aireu"}; + int n = 0; + try + { + Console.Write($"Введите кол-во игроков(1-16):"); + string nString = Console.ReadLine(); + n = Convert.ToInt32(nString); + } + catch (System.FormatException) + { + Console.Write($"Введите кол-во игроков(1-16):"); + string nString = Console.ReadLine(); + n = Convert.ToInt32(nString); + } + while (n % 2 != 0 || n <= 0) + { + Console.Write($"Введите кол-во игроков(1-16):"); + n = Convert.ToInt32(Console.ReadLine()); + } + Random rnd = new Random(); + List players = new List(); + List winners = new List(); + int k = 0; + int kon = 1; + while (players.Count < n) + { + int c1 = rnd.Next(0, 3); + switch (c1) + { + case 0: + players.Add(new Knight(names[k])); + break; + case 1: + players.Add(new Archer(names[k])); + break; + case 2: + players.Add(new Mage(names[k])); + break; + } + k++; + } + Logger.LogText($"{kon++}-й Кон\n"); + while (players.Count + winners.Count > 1) + { + if (players.Count >=2) + { + Player tempPlayer = ClassBattle.Battle(players[PickPlayers.PickOp(players)]); + winners.Add(tempPlayer.Opponent); + players.Remove(tempPlayer.Opponent); + players[players.IndexOf(tempPlayer)].Opponent.Opponent = null; + players.Remove(tempPlayer); + } + else + { + Logger.LogText($"{kon}-й Кон\n"); + players.AddRange(winners); + winners.Clear(); + kon++; + } + } + Logger.LogText($"({winners[0].Class}) {winners[0].Name} WINNER!!!"); + } + } +} diff --git a/RPG/IEffect.cs b/RPG/IEffect.cs new file mode 100644 index 0000000..334d59c --- /dev/null +++ b/RPG/IEffect.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace RPG +{ + public interface IEffect + { + void Proc(Player owner); + } +} \ No newline at end of file diff --git a/RPG/IUseSkill.cs b/RPG/IUseSkill.cs new file mode 100644 index 0000000..118db41 --- /dev/null +++ b/RPG/IUseSkill.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace RPG +{ + public interface IUseSkill + { + void UseSkill(Player user); + } +} diff --git a/RPG/Knight.cs b/RPG/Knight.cs new file mode 100644 index 0000000..d03279d --- /dev/null +++ b/RPG/Knight.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace RPG +{ + public class Knight : Player + { + public Knight() + : this("Незадано") + { + } + public Knight(string name) + :base(name) + { + Skills.Add(new KnightSkill()); + Class = "Knight"; + } + + } +} diff --git a/RPG/KnightSkill.cs b/RPG/KnightSkill.cs new file mode 100644 index 0000000..1b39698 --- /dev/null +++ b/RPG/KnightSkill.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace RPG +{ + public class KnightSkill : IUseSkill + { + public void UseSkill(Player user) + { + user.Opponent.HP -= user.Strength * 1.3; + Logger.LogText($"({user.Class}) {user.Name} использует (Удар возмездия) и наносит урон {user.Strength * 1.3} противнику ({user.Opponent.Class}){user.Opponent.Name}."); + } + } +} diff --git a/RPG/Logger.cs b/RPG/Logger.cs new file mode 100644 index 0000000..0c3b4f6 --- /dev/null +++ b/RPG/Logger.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace RPG +{ + public static class Logger + { + public static void LogVS(Player player1) + { + Console.WriteLine($"{player1.Class} {player1.Name} vs {player1.Opponent.Class} {player1.Opponent.Name}."); + } + public static void LogText(string message) + { + Console.WriteLine(message); + } + } +} diff --git a/RPG/Mage.cs b/RPG/Mage.cs new file mode 100644 index 0000000..d6d1977 --- /dev/null +++ b/RPG/Mage.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace RPG +{ + public class Mage : Player + { + public Mage() + : this("Незадано") + { + } + public Mage(string name) + : base(name) + { + Class = "Mage"; + Skills.Add(new MageSkill()); + } + + } +} diff --git a/RPG/MageSkill.cs b/RPG/MageSkill.cs new file mode 100644 index 0000000..5a2524d --- /dev/null +++ b/RPG/MageSkill.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Linq; + +namespace RPG +{ + public class MageSkill : IUseSkill + { + public void UseSkill(Player user) + { + user.Opponent.Effects.Add(new Skip()); + Logger.LogText($"({user.Class}) {user.Name} использует (Заворожение) на ({user.Opponent.Class}) {user.Opponent.Name}."); + + } + } +} diff --git a/RPG/PickPlayers.cs b/RPG/PickPlayers.cs new file mode 100644 index 0000000..c1e4f02 --- /dev/null +++ b/RPG/PickPlayers.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace RPG +{ + public class PickPlayers + { + public static int PickOp(List players) + { + Random rnd = new Random(); + int randomplayer1 = rnd.Next(0, players.Count); + int randomplayer2 = rnd.Next(0, players.Count); + while(randomplayer1 == randomplayer2) + { + randomplayer2 = rnd.Next(0, players.Count); + } + players[randomplayer1].Opponent = players[randomplayer2]; + players[randomplayer2].Opponent = players[randomplayer1]; + return randomplayer1; + } + } +} diff --git a/RPG/Player.cs b/RPG/Player.cs new file mode 100644 index 0000000..84fa3a8 --- /dev/null +++ b/RPG/Player.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; + +namespace RPG +{ + + public abstract class Player + { + private static readonly Random rnd = new Random(); + public Player() + : this("Незадано") + { + } + public Player(string name) + { + Name = name; + HP = rnd.Next(1, 100); + Strength = rnd.Next(1, 99); + Skills.Add(new Attack()); + } + public string Class { get; protected set; } + public string Name { get; set; } + public Player Opponent { get; set; } = null; + public double HP { get; set; } + public int Strength { get; } + public bool isStunned { get; set; } + public IUseSkill Usingskill { get; set; } + + public List Skills = new List(); + + public List Effects = new List(); + + public void UseSkill() + { + Usingskill.UseSkill(this); + } + public void ProcEffects() + { + for(int i=0;i + + + Exe + netcoreapp2.1 + + + diff --git a/RPG/RPG.sln b/RPG/RPG.sln new file mode 100644 index 0000000..1510808 --- /dev/null +++ b/RPG/RPG.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29609.76 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RPG", "RPG.csproj", "{FB5E5FE5-EAAD-4CC3-A9D9-DF22DEEF4B73}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {FB5E5FE5-EAAD-4CC3-A9D9-DF22DEEF4B73}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FB5E5FE5-EAAD-4CC3-A9D9-DF22DEEF4B73}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FB5E5FE5-EAAD-4CC3-A9D9-DF22DEEF4B73}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FB5E5FE5-EAAD-4CC3-A9D9-DF22DEEF4B73}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {9A8D6197-8DF4-45DA-A169-89422F723F9A} + EndGlobalSection +EndGlobal diff --git a/RPG/Skip.cs b/RPG/Skip.cs new file mode 100644 index 0000000..22c8147 --- /dev/null +++ b/RPG/Skip.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace RPG +{ + public class Skip : IEffect + { + public void Proc(Player owner) + { + owner.isStunned = true; + Logger.LogText($"({owner.Class}) {owner.Name} пропускает ход."); + } + } +} diff --git a/site/images/png.jpg b/site/images/png.jpg new file mode 100644 index 0000000..4f2382f Binary files /dev/null and b/site/images/png.jpg differ diff --git a/site/index.html b/site/index.html new file mode 100644 index 0000000..69409ff --- /dev/null +++ b/site/index.html @@ -0,0 +1,31 @@ + + + + + + + +
+
Технологии программирования
+ +
+ +
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Etiam dignissim diam quis enim lobortis scelerisque fermentum dui. Faucibus nisl tincidunt eget nullam non nisi. Rhoncus dolor purus non enim praesent elementum facilisis leo. Feugiat nibh sed pulvinar proin gravida hendrerit lectus. Neque egestas congue quisque egestas diam in. Diam quam nulla porttitor massa id neque aliquam vestibulum. Posuere ac ut consequat semper viverra nam. Elementum sagittis vitae et leo duis ut diam. Nunc sed blandit libero volutpat sed cras ornare. Netus et malesuada fames ac. Facilisis mauris sit amet massa vitae tortor. Nibh sit amet commodo nulla facilisi nullam vehicula ipsum. +Viverra accumsan in nisl nisi. Pretium fusce id velit ut tortor. Faucibus turpis in eu mi. Id volutpat lacus laoreet non. Commodo quis imperdiet massa tincidunt nunc pulvinar sapien et. Gravida arcu ac tortor dignissim convallis. Et odio pellentesque diam volutpat commodo sed egestas. Enim sed faucibus turpis in. Non tellus orci ac auctor augue mauris augue neque gravida. Tempor orci eu lobortis elementum nibh tellus molestie nunc non. Suspendisse ultrices gravida dictum fusce ut placerat. Malesuada fames ac turpis egestas integer eget aliquet. Aliquam eleifend mi in nulla posuere sollicitudin aliquam ultrices sagittis. Neque ornare aenean euismod elementum nisi quis. Vitae auctor eu augue ut. Dolor morbi non arcu risus quis varius quam quisque. Sed velit dignissim sodales ut eu. Amet consectetur adipiscing elit ut aliquam purus. Auctor augue mauris augue neque. +
+ + + + + + + + +
ФИО
Возраст
+
+ +
+ + + diff --git a/site/styles/style.css b/site/styles/style.css new file mode 100644 index 0000000..5d60baa --- /dev/null +++ b/site/styles/style.css @@ -0,0 +1,34 @@ +.leftimg +{ + float:left; + margin: 7px 7px 7px 0; + width: 279px; + height: 246px; +} +.textdiv +{ + font-family: 'Courier New', Courier, monospace; + min-height: 251px; +} +table +{ + margin-top: 10px; + margin-left: 10px; +} +.bg +{ + background: #00b0d8 +} +.button +{ + margin-top: 10px; + margin-left: 120px; +} +.title +{ + font-size: 36px; + padding-top: 10px; + text-align: center; + display: block; + background: #00b0d8; +} \ No newline at end of file