-
Notifications
You must be signed in to change notification settings - Fork 24
RPG Saga #10
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
base: Beljakov_Aleksej_Vasilevich
Are you sure you want to change the base?
RPG Saga #10
Changes from all commits
05e6679
f096ca8
221d163
ed0bbb8
bed1c70
a90f815
aa31022
c95b681
5f80cbc
a6deebf
a8af3c2
0c276eb
92d56f9
2fff9c2
612e935
8eb9e56
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
// Use IntelliSense to find out which attributes exist for C# debugging | ||
// Use hover for the description of the existing attributes | ||
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md | ||
"name": ".NET Core Launch (console)", | ||
"type": "coreclr", | ||
"request": "launch", | ||
"preLaunchTask": "build", | ||
// If you have changed target frameworks, make sure to update the program path. | ||
"program": "${workspaceFolder}/RpgSaga/bin/Debug/net6.0/RpgSaga.dll", | ||
"args": [], | ||
"cwd": "${workspaceFolder}/RpgSaga", | ||
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console | ||
"console": "integratedTerminal", | ||
"stopAtEntry": false | ||
}, | ||
{ | ||
"name": ".NET Core Attach", | ||
"type": "coreclr", | ||
"request": "attach" | ||
} | ||
] | ||
} |
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}/RpgSaga/RpgSaga.csproj", | ||
"/property:GenerateFullPaths=true", | ||
"/consoleloggerparameters:NoSummary" | ||
], | ||
"problemMatcher": "$msCompile" | ||
}, | ||
{ | ||
"label": "publish", | ||
"command": "dotnet", | ||
"type": "process", | ||
"args": [ | ||
"publish", | ||
"${workspaceFolder}/RpgSaga/RpgSaga.csproj", | ||
"/property:GenerateFullPaths=true", | ||
"/consoleloggerparameters:NoSummary" | ||
], | ||
"problemMatcher": "$msCompile" | ||
}, | ||
{ | ||
"label": "watch", | ||
"command": "dotnet", | ||
"type": "process", | ||
"args": [ | ||
"watch", | ||
"run", | ||
"--project", | ||
"${workspaceFolder}/RpgSaga/RpgSaga.csproj" | ||
], | ||
"problemMatcher": "$msCompile" | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
namespace BinaryTree | ||
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. только давайте все же в подкаталог с CourseApp - или stylecop нфдо настравивать |
||
{ | ||
internal class Node<T> where T : IComparable | ||
{ | ||
public Node<T>? Left { get; set; } | ||
public Node<T>? Right { get; set; } | ||
public T? Data { get; set; } | ||
public int Index { get; set; } | ||
|
||
public Node() | ||
{ | ||
Left = null; | ||
Right = null; | ||
Data = default(T); | ||
} | ||
|
||
public void Add(T value) | ||
{ | ||
if (Data == null || Data.CompareTo(default(T)) == 0 || value.CompareTo(Data) == 0) | ||
{ | ||
Data = value; | ||
return; | ||
} | ||
|
||
if (value.CompareTo(Data) < 0) | ||
{ | ||
if (Left == null) | ||
{ | ||
Left = new Node<T>(); | ||
} | ||
|
||
Left.Add(value); | ||
return; | ||
} | ||
|
||
if (value.CompareTo(Data) > 0) | ||
{ | ||
if (Right == null) | ||
{ | ||
Right = new Node<T>(); | ||
} | ||
|
||
Right.Add(value); | ||
return; | ||
} | ||
} | ||
|
||
public Node<T>? GetNode(int index) | ||
{ | ||
if (Index == index) | ||
{ | ||
return this; | ||
} | ||
|
||
if (Left != null && Left.GetNode(index) != null) | ||
{ | ||
return Left.GetNode(index); | ||
} | ||
|
||
if (Right != null && Right.GetNode(index) != null) | ||
{ | ||
return Right.GetNode(index); | ||
} | ||
|
||
return null; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
namespace BinaryTree | ||
{ | ||
public class BinaryTree<T> where T : IComparable | ||
{ | ||
Queue<Node<T>> nodeQueue; | ||
Node<T> Root { get; set; } | ||
public BinaryTree() | ||
{ | ||
Root = new Node<T>(); | ||
nodeQueue = new Queue<Node<T>>(); | ||
} | ||
|
||
public void Insert(T value) | ||
{ | ||
Root.Add(value); | ||
} | ||
|
||
public void IndexNodes() | ||
{ | ||
nodeQueue.Enqueue(Root); | ||
int index = 1; | ||
while (nodeQueue.Count > 0) | ||
{ | ||
var node = nodeQueue.Dequeue(); | ||
|
||
node.Index = index; | ||
index++; | ||
|
||
if (node.Left != null) | ||
{ | ||
nodeQueue.Enqueue(node.Left); | ||
} | ||
|
||
if (node.Right != null) | ||
{ | ||
nodeQueue.Enqueue(node.Right); | ||
} | ||
} | ||
} | ||
|
||
public void ShowNodes() | ||
{ | ||
nodeQueue.Enqueue(Root); | ||
while (nodeQueue.Count > 0) | ||
{ | ||
var node = nodeQueue.Dequeue(); | ||
System.Console.WriteLine(node.Index + " - " + node.Data); | ||
if (node.Left != null) | ||
{ | ||
nodeQueue.Enqueue(node.Left); | ||
} | ||
|
||
if (node.Right != null) | ||
{ | ||
nodeQueue.Enqueue(node.Right); | ||
} | ||
} | ||
} | ||
|
||
public void GetByIndex(int index) | ||
{ | ||
var node = Root.GetNode(index); | ||
if (node != null) | ||
{ | ||
System.Console.WriteLine($"{index} - {node.Data}"); | ||
return; | ||
} | ||
|
||
System.Console.WriteLine($"Node with index {index} not found"); | ||
} | ||
|
||
public void EditByIndex(int index, T value) | ||
{ | ||
var node = Root.GetNode(index); | ||
if (node != null) | ||
{ | ||
node.Data = value; | ||
System.Console.WriteLine($"{node.Index} - {node.Data}"); | ||
return; | ||
} | ||
|
||
System.Console.WriteLine($"Node with {index} index not found"); | ||
} | ||
|
||
public void Remove(T value) | ||
{ | ||
|
||
} | ||
|
||
public void Remove(int Index) | ||
{ | ||
|
||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
</Project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
| ||
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. аналогично - или в 1 каталог с CourseApp или надо настроить gh actions и stylecop |
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.30114.105 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BinaryTree", "BinaryTree\BinaryTree.csproj", "{F94BD8BF-37A9-4F69-A2D6-E233C6C1C4DA}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RpgSaga", "RpgSaga\RpgSaga.csproj", "{B2051BB6-8AAC-418B-9863-DD0189D3D58D}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{F94BD8BF-37A9-4F69-A2D6-E233C6C1C4DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{F94BD8BF-37A9-4F69-A2D6-E233C6C1C4DA}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{F94BD8BF-37A9-4F69-A2D6-E233C6C1C4DA}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{F94BD8BF-37A9-4F69-A2D6-E233C6C1C4DA}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{B2051BB6-8AAC-418B-9863-DD0189D3D58D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{B2051BB6-8AAC-418B-9863-DD0189D3D58D}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{B2051BB6-8AAC-418B-9863-DD0189D3D58D}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{B2051BB6-8AAC-418B-9863-DD0189D3D58D}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
EndGlobal |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
namespace RpgSaga | ||
{ | ||
public abstract class Ability | ||
{ | ||
protected bool DoBlindActions(Player player, Player enemy) | ||
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. а почему ability знает про 2 игроков? |
||
{ | ||
if (player.playerConditions.Condition[Conditions.IsBlind]) | ||
{ | ||
enemy.GetDamage(0); | ||
player.Unblind(); | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
public abstract string AbilityName { get; } | ||
public virtual bool CanUseAbility { get; protected set; } | ||
public abstract void UseAbility(Player player, Player enemy); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace RpgSaga | ||
{ | ||
public class Archer : Player | ||
{ | ||
public Archer(int health, int strength, string name, Ability ability) : base(health, strength, name, ability) | ||
{ | ||
PlayerClass = "Лучник"; | ||
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. тут хорошо бы enum текстовый использовать |
||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
namespace RpgSaga | ||
{ | ||
public class BattleLogger : ILogger | ||
{ | ||
public void ShowRound(int round) | ||
{ | ||
System.Console.WriteLine("Кон " + round + "."); | ||
System.Console.WriteLine(); | ||
} | ||
|
||
public void SeparateBattle() | ||
{ | ||
System.Console.WriteLine(); | ||
} | ||
|
||
public void UsesAbility(Player player, Player enemy) | ||
{ | ||
Console.WriteLine($"({player.PlayerClass}) {player.Name} использует способность {player.ActiveAbility.AbilityName} и наносит {enemy.GotDamage} единиц урона противнику {enemy.Name} ({enemy.PlayerClass})"); | ||
|
||
CheckConditions(enemy); | ||
} | ||
|
||
public void Attack(Player player, Player enemy) | ||
{ | ||
Console.WriteLine($"({player.PlayerClass}) {player.Name} наносит {enemy.GotDamage} единиц урона противнику {enemy.Name} ({enemy.PlayerClass})"); | ||
|
||
CheckConditions(enemy); | ||
} | ||
|
||
public void Dead(Player player) | ||
{ | ||
System.Console.WriteLine($"{player.Name} трагично погиб в безжалостной схватке"); | ||
} | ||
|
||
private void CheckConditions(Player player) | ||
{ | ||
int conditionsCount = player.playerConditions.Condition.Count; | ||
var values = Enum.GetValues(typeof(Conditions)); | ||
foreach (Conditions condition in values) | ||
{ | ||
if (player.playerConditions.Condition[condition]) | ||
{ | ||
System.Console.WriteLine($"({player.PlayerClass}) {player.Name} " + Constants.StringConditions[condition]); | ||
} | ||
} | ||
} | ||
} | ||
} |
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.
плохая идея с конфликтами заливать