-
Notifications
You must be signed in to change notification settings - Fork 24
Smurov_Evgenij_Evgenevich RPG saga v 0.1 #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
EwvwGeN
wants to merge
4
commits into
ISUCT:Smurov_Evgenij_Evgenevich
Choose a base branch
from
EwvwGeN:RPG_Saga
base: Smurov_Evgenij_Evgenevich
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| { | ||
| // Use IntelliSense to learn about possible attributes. | ||
| // Hover to view descriptions of existing attributes. | ||
| // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
| "version": "0.2.0", | ||
| "configurations": [ | ||
| { | ||
| "name": ".NET Core Launch (console)", | ||
| "type": "coreclr", | ||
| "request": "launch", | ||
| "preLaunchTask": "build", | ||
| "program": "${workspaceFolder}/CourseApp/bin/Debug/net6.0/CourseApp.dll", | ||
| "args": [], | ||
| "cwd": "${workspaceFolder}/CourseApp", | ||
| "console": "integratedTerminal", | ||
| "stopAtEntry": false | ||
| }, | ||
| { | ||
| "name": ".NET Core Attach", | ||
| "type": "coreclr", | ||
| "request": "attach" | ||
| } | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| { | ||
| "version": "2.0.0", | ||
| "tasks": [ | ||
| { | ||
| "label": "build", | ||
| "command": "dotnet", | ||
| "type": "process", | ||
| "args": [ | ||
| "build", | ||
| "${workspaceFolder}/CourseApp/CourseApp.csproj", | ||
| "/property:GenerateFullPaths=true", | ||
| "/consoleloggerparameters:NoSummary" | ||
| ], | ||
| "problemMatcher": "$msCompile" | ||
| }, | ||
| { | ||
| "label": "publish", | ||
| "command": "dotnet", | ||
| "type": "process", | ||
| "args": [ | ||
| "publish", | ||
| "${workspaceFolder}/CourseApp/CourseApp.csproj", | ||
| "/property:GenerateFullPaths=true", | ||
| "/consoleloggerparameters:NoSummary" | ||
| ], | ||
| "problemMatcher": "$msCompile" | ||
| }, | ||
| { | ||
| "label": "watch", | ||
| "command": "dotnet", | ||
| "type": "process", | ||
| "args": [ | ||
| "watch", | ||
| "run", | ||
| "--project", | ||
| "${workspaceFolder}/CourseApp/CourseApp.csproj" | ||
| ], | ||
| "problemMatcher": "$msCompile" | ||
| } | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,152 @@ | ||
| namespace CourseApp | ||
| { | ||
| using System; | ||
| using System.Collections.Generic; | ||
|
|
||
| public class Game | ||
| { | ||
| public static void Start() | ||
| { | ||
| int p_number = AskNumber(); | ||
| List<Player> playerList = PlayerListGenerator(p_number); | ||
| PlayGame(playerList); | ||
| } | ||
|
|
||
| private static void PlayGame(List<Player> playerList) | ||
| { | ||
| for (int i = 1; playerList.Count != 1; i++) | ||
| { | ||
| Logger.WriteRound(i); | ||
| RandomizeList(playerList); | ||
| PlayRound(playerList); | ||
| } | ||
|
|
||
| Logger.WriteWinner(playerList[0]); | ||
| } | ||
|
|
||
| private static void PlayRound(List<Player> playerList) | ||
| { | ||
| for (int i = 0; i < playerList.Count / 2; i++) | ||
| { | ||
| Player[] fightMembers = { playerList[i * 2], playerList[(i * 2) + 1] }; | ||
| Logger.WriteFight(fightMembers); | ||
| playerList[i * 2] = PlayFight(fightMembers); | ||
| } | ||
|
|
||
| for (int i = 1; i < playerList.Count; i++) | ||
| { | ||
| playerList.RemoveAt(i); | ||
| } | ||
| } | ||
|
|
||
| private static Player PlayFight(Player[] fightMembers) | ||
| { | ||
| for (int i = 0; true; i++) | ||
| { | ||
| var playerStatus = fightMembers[i % 2].CheckStatus(); | ||
| Logger.WriteAction(fightMembers[i % 2], playerStatus); | ||
| bool checkDeath = fightMembers[i % 2].CheckDeath(); | ||
| if (checkDeath) | ||
| { | ||
| fightMembers[(i + 1) % 2].Update(); | ||
| return fightMembers[(i + 1) % 2]; | ||
| } | ||
|
|
||
| if (playerStatus.Contains(Tuple.Create("Заворожение", .0f))) | ||
| { | ||
| continue; | ||
| } | ||
|
|
||
| Tuple<string, float> playerAction = PlayerDoAction(fightMembers[i % 2]); | ||
| Logger.WriteAction(fightMembers[i % 2], fightMembers[(i + 1) % 2], playerAction); | ||
| if ((playerAction.Item1 != "наносит урон") && (playerAction.Item1 != "Удар возмездия")) | ||
| { | ||
| fightMembers[(i + 1) % 2].SetDebaff(playerAction.Item1); | ||
| } | ||
|
|
||
| checkDeath = fightMembers[(i + 1) % 2].GetDamage(playerAction.Item2); | ||
| if (checkDeath) | ||
| { | ||
| Logger.WriteDeath(fightMembers[(i + 1) % 2]); | ||
| fightMembers[i % 2].Update(); | ||
| return fightMembers[i % 2]; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private static Tuple<string, float> PlayerDoAction(Player inputP) | ||
| { | ||
| Random rnd = new Random(); | ||
| int chosen = rnd.Next(0, 4); | ||
| switch (chosen) | ||
| { | ||
| case 0: | ||
| return inputP.Ability(); | ||
| default: | ||
| return inputP.Attack(); | ||
| } | ||
| } | ||
|
|
||
| private static int AskNumber() | ||
| { | ||
| while (true) | ||
| { | ||
| Console.WriteLine("Введите четное количество игроков:"); | ||
| int p_number = Convert.ToInt32(Console.ReadLine()); | ||
| if (p_number <= 0) | ||
| { | ||
| Console.WriteLine("Число игроков должно быть больше 0!"); | ||
| } | ||
| else if (p_number % 2 != 0) | ||
| { | ||
| Console.WriteLine("Число игроков должно быть четным!"); | ||
| } | ||
| else | ||
| { | ||
| return p_number; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private static void RandomizeList(List<Player> input) | ||
| { | ||
| Random rnd = new Random(); | ||
| for (int i = 0; i < input.Count; i++) | ||
| { | ||
| int chosen = rnd.Next(i, input.Count); | ||
| (input[i], input[chosen]) = (input[chosen], input[i]); | ||
| } | ||
| } | ||
|
|
||
| private static List<Player> PlayerListGenerator(int count) | ||
| { | ||
| List<Player> playerList = new List<Player>(); | ||
| for (int i = 0; i < count; i++) | ||
| { | ||
| playerList.Add(PlayerGenerator()); | ||
| } | ||
|
|
||
| return playerList; | ||
| } | ||
|
|
||
| private static Player PlayerGenerator() | ||
| { | ||
| string[] names = { "Вальлиикт", "Йоророу", "Бенинэл", "Билелгар", "Вилдровер", "Бреновуд", "Труеон", "Филдис", "Грейнерэл", "Бертэам", "Ирвдес", "Франкернон", "Куртдитор" }; | ||
| Random rnd = new Random(); | ||
| int health = (int)rnd.NextInt64(1, 64); | ||
| int strength = (int)rnd.NextInt64(1, 64); | ||
| int chouse = (int)rnd.NextInt64(0, 3); | ||
| switch (chouse) | ||
| { | ||
| case 0: | ||
| return new Knight(health, strength, names[rnd.Next(names.Length)]); | ||
| case 1: | ||
| return new Mage(health, strength, names[rnd.Next(names.Length)]); | ||
| case 2: | ||
| return new Archer(health, strength, names[rnd.Next(names.Length)]); | ||
| default: | ||
| return new Knight(health, strength, names[rnd.Next(names.Length)]); | ||
| } | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| namespace CourseApp | ||
| { | ||
| using System; | ||
|
|
||
| public class Archer : Player | ||
| { | ||
| public Archer(int health, int strength, string name) | ||
| : base(health, strength, name, "Огненная стрела", 1) | ||
| { | ||
| } | ||
|
|
||
| public override string ToString() | ||
| { | ||
| return "(Лучник) " + Name; | ||
| } | ||
|
|
||
| public override Tuple<string, float> Ability() | ||
| { | ||
| if (AbilityLeft > 0) | ||
| { | ||
| AbilityLeft--; | ||
| return Tuple.Create(AbilityName, 0.0f); | ||
| } | ||
| else | ||
| { | ||
| return Attack(); | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| namespace CourseApp | ||
| { | ||
| using System; | ||
|
|
||
| public class Knight : Player | ||
| { | ||
| public Knight(int health, int strength, string name) | ||
| : base(health, strength, name, "Удар возмездия", 1) | ||
| { | ||
| } | ||
|
|
||
| public override string ToString() | ||
| { | ||
| return "(Рыцарь) " + Name; | ||
| } | ||
|
|
||
| public override Tuple<string, float> Ability() | ||
| { | ||
| if (AbilityLeft > 0) | ||
| { | ||
| AbilityLeft--; | ||
| return Tuple.Create(AbilityName, (float)Math.Round(Strength * 1.3f, 2)); | ||
| } | ||
| else | ||
| { | ||
| return Attack(); | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| namespace CourseApp | ||
| { | ||
| using System; | ||
|
|
||
| public class Mage : Player | ||
| { | ||
| public Mage(int health, int strength, string name) | ||
| : base(health, strength, name, "Заворожение", 1) | ||
| { | ||
| } | ||
|
|
||
| public override string ToString() | ||
| { | ||
| return "(Маг) " + Name; | ||
| } | ||
|
|
||
| public override Tuple<string, float> Ability() | ||
| { | ||
| if (AbilityLeft > 0) | ||
| { | ||
| AbilityLeft--; | ||
| return Tuple.Create(AbilityName, 0.0f); | ||
| } | ||
| else | ||
| { | ||
| return Attack(); | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| namespace CourseApp | ||
| { | ||
| using System; | ||
| using System.Collections.Generic; | ||
|
|
||
| public static class Logger | ||
| { | ||
| public static void WriteWinner(Player winner) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. У кого логгер копировали? |
||
| { | ||
| Console.WriteLine($"{winner.ToString()} ПОБЕДИЛ!"); | ||
| } | ||
|
|
||
| public static void WriteRound(int round) | ||
| { | ||
| Console.WriteLine($"Раунд {round}."); | ||
| } | ||
|
|
||
| public static void WriteFight(Player[] fightMembers) | ||
| { | ||
| Console.WriteLine($"{fightMembers[0].ToString()} VS {fightMembers[1].ToString()}"); | ||
| } | ||
|
|
||
| public static void WriteAction(Player firstP, Player secondP, Tuple<string, float> playerAction) | ||
| { | ||
| switch (playerAction.Item1) | ||
| { | ||
| case "наносит урон": | ||
| Console.WriteLine($"{firstP.ToString()} наносит урон {playerAction.Item2} противнику {secondP.ToString()}"); | ||
| break; | ||
| case "Удар возмездия": | ||
| Console.WriteLine($"{firstP.ToString()} применяет ({playerAction.Item1}) и наносит урон {playerAction.Item2} противнику {secondP.ToString()}"); | ||
| break; | ||
| case "Огненная стрела": | ||
| Console.WriteLine($"{firstP.ToString()} применяет ({playerAction.Item1}) по противнику {secondP.ToString()}"); | ||
| break; | ||
| case "Заворожение": | ||
| Console.WriteLine($"{firstP.ToString()} применяет ({playerAction.Item1}) по противнику {secondP.ToString()}"); | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| public static void WriteAction(Player inputP, List<Tuple<string, float>> playerStatus) | ||
| { | ||
| foreach (var debaff in playerStatus) | ||
| { | ||
| switch (debaff.Item1) | ||
| { | ||
| case "Огненная стрела": | ||
| Console.WriteLine($"{inputP.ToString()} получает периодический урон {debaff.Item2} от ({debaff.Item1})"); | ||
| break; | ||
| case "Заворожение": | ||
| Console.WriteLine($"{inputP.ToString()} пропускает ход из-за ({debaff.Item1})"); | ||
| break; | ||
| case "PlayerIsDied": | ||
| WriteDeath(inputP); | ||
| break; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| public static void WriteDeath(Player inputP) | ||
| { | ||
| Console.WriteLine($"{inputP.ToString()} погибает"); | ||
| Console.WriteLine(); | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
а зачем? может просто рэндомно из списка брать?