Skip to content

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

Open
wants to merge 16 commits into
base: Beljakov_Aleksej_Vasilevich
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
<<<<<<< HEAD
BinaryTree/bin/
BinaryTree/net6.0/
BinaryTree/obj/

RpgSaga/bin/
RpgSaga/net6.0/
RpgSaga/obj/
=======
Comment on lines +1 to +9
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

плохая идея с конфликтами заливать

# Download this file using PowerShell v3 under Windows with the following comand:
# Invoke-WebRequest https://gist.githubusercontent.com/kmorcinek/2710267/raw/ -OutFile .gitignore
# or wget:
Expand Down Expand Up @@ -203,4 +212,5 @@ Properties/

#####
# End of core ignore list, below put you custom 'per project' settings (patterns or path)
#####
#####
>>>>>>> 320c07ab2c692730e727cc0ce95e1cf70bcba780
26 changes: 26 additions & 0 deletions .vscode/launch.json
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"
}
]
}
41 changes: 41 additions & 0 deletions .vscode/tasks.json
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"
}
]
}
68 changes: 68 additions & 0 deletions BinaryTree/BinaryNode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
namespace BinaryTree
Copy link
Contributor

Choose a reason for hiding this comment

The 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;
}
}
}
95 changes: 95 additions & 0 deletions BinaryTree/BinaryTree.cs
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)
{

}
}
}
9 changes: 9 additions & 0 deletions BinaryTree/BinaryTree.csproj
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>
28 changes: 28 additions & 0 deletions RPG-Saga.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

Copy link
Contributor

Choose a reason for hiding this comment

The 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
21 changes: 21 additions & 0 deletions RpgSaga/Ability.cs
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)
Copy link
Contributor

Choose a reason for hiding this comment

The 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);
}
}
10 changes: 10 additions & 0 deletions RpgSaga/Archer.cs
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 = "Лучник";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут хорошо бы enum текстовый использовать

}
}
}
48 changes: 48 additions & 0 deletions RpgSaga/BattleLogger.cs
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]);
}
}
}
}
}
Loading