Skip to content
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
5 changes: 3 additions & 2 deletions .github/workflows/dotnetcore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
dotnet: [ '2.1', '3.1.x', '5.0.x' ]
dotnet: [ '2.1', '5.0.x', '6.0.x' ]

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ matrix.dotnet-version }}
include-prerelease: true
- name: Build with dotnet
run: |
cd CourseApp
Expand Down
3 changes: 2 additions & 1 deletion CourseApp.Tests/CourseApp.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp5</TargetFramework>
<TargetFramework>netcoreapp6</TargetFramework>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<IsPackable>false</IsPackable>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
18 changes: 0 additions & 18 deletions CourseApp.Tests/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,5 @@ namespace CourseApp.Tests

public class Tests
{
private readonly Function _function;

public Tests()
{
_function = new Function();
}

[Theory]
[InlineData(1.2, 0.8256)]
[InlineData(1.7, 0.9182)]
[InlineData(2.2, 3.9286)]
[InlineData(3.7, 385.8624)]
public void RunTest(double x, double expected)
{
var a = 1.6;
var actual = _function.CalculateFunction(a, x);
Assert.Equal(expected, actual, 3);
}
}
}
3 changes: 2 additions & 1 deletion CourseApp/CourseApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp5</TargetFramework>
<TargetFramework>netcoreapp6</TargetFramework>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
12 changes: 0 additions & 12 deletions CourseApp/Function.cs

This file was deleted.

30 changes: 8 additions & 22 deletions CourseApp/Program.cs
Original file line number Diff line number Diff line change
@@ -1,33 +1,19 @@
namespace CourseApp
{
using System;
using System.Collections.Generic;
using Kantaiko.ConsoleFormatting;
using CourseApp.RPGSaga.GameBuilder;
using CourseApp.RPGSaga.Generators;

public class Program
{
public static void Main(string[] args)
{
var runner = new TaskRunner();
var a = 1.6;
var xn = 1.2;
var xk = 3.7;
var dx = 0.5;
Console.WriteLine(Colors.FgCyan("-----TASK A-----").BgBlack());
var listA = runner.Calculation(a, xn, xk, dx);
ConsoleOutput(listA);
Console.WriteLine(Colors.FgCyan("-----TASK B-----").BgBlack());
var xs = new List<double>() { 1.28, 1.36, 2.47, 3.68, 4.56 };
var listB = runner.Calculation(a, xs);
ConsoleOutput(listB);
}

private static void ConsoleOutput(List<double> ys)
{
foreach (var y in ys)
{
Console.WriteLine(Colors.FgCyan($"y = {y}").BgBlack());
}
var playerFactory = new PlayerFabric();
var playerOne = playerFactory.FactoryMethod();
var playerTwo = playerFactory.FactoryMethod();
var fight = new FightBuilder(playerOne, playerTwo);
fight.SetTargets();
Console.WriteLine(fight.StartFight());
}
}
}
36 changes: 36 additions & 0 deletions CourseApp/RPGSaga/Abilities/Attack.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
namespace CourseApp.RPGSaga.Abilities
{
using CourseApp.RPGSaga.Interfaces;

public class Attack : IAbility
{
public Attack(int damage)
{
Name = "Attack";
Damage = damage;
IsSkipRound = false;
ActionDuration = 1;
NumOfUses = 100000000;
IsFire = false;
}

public int Damage { get; set; }

public string Name { get; }

public bool IsSkipRound { get; }

public int ActionDuration { get; set; }

public double Multiplier { get; set; }

public int NumOfUses { get; set; }

public bool IsFire { get; }

public override string ToString()
{
return $"{Name}";
}
}
}
35 changes: 35 additions & 0 deletions CourseApp/RPGSaga/Abilities/FireArrows.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
namespace CourseApp.RPGSaga.Abilities
{
using System.ComponentModel;
using CourseApp.RPGSaga.Interfaces;

public class FireArrows : IAbility
{
public FireArrows()
{
Damage = 0;
Name = "Fire arrows";
IsSkipRound = false;
ActionDuration = 100000;
NumOfUses = 1;
IsFire = true;
}

public int Damage { get; set; }

public string Name { get; }

public bool IsSkipRound { get; }

public int ActionDuration { get; set; }

public int NumOfUses { get; set; }

public bool IsFire { get; }

public override string ToString()
{
return $"{Name}";
}
}
}
34 changes: 34 additions & 0 deletions CourseApp/RPGSaga/Abilities/Spellbinding.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
namespace CourseApp.RPGSaga.Abilities
{
using CourseApp.RPGSaga.Interfaces;

public class Spellbinding : IAbility
{
public Spellbinding()
{
Damage = 0;
Name = "Spellbinding";
IsSkipRound = true;
ActionDuration = 1;
NumOfUses = 1;
IsFire = false;
}

public int Damage { get; set; }

public string Name { get; }

public bool IsSkipRound { get; }

public int ActionDuration { get; set; }

public int NumOfUses { get; set; }

public bool IsFire { get; }

public override string ToString()
{
return $"{Name}";
}
}
}
43 changes: 43 additions & 0 deletions CourseApp/RPGSaga/Abilities/VengeanceStrike.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
namespace CourseApp.RPGSaga.Abilities
{
using CourseApp.RPGSaga.Interfaces;

public class VengeanceStrike : IAbility
{
public VengeanceStrike(int damage)
{
Multiplier = 1.3;
Damage = (int)(Multiplier * damage);
Name = "Vengeance Strike";
IsSkipRound = false;
ActionDuration = 1;
NumOfUses = 1;
IsFire = false;
}

public int Damage { get; set; }

public string Name { get; }

public bool IsSkipRound { get; }

public int ActionDuration { get; set; }

public int NumOfUses { get; set; }

public bool IsFire { get; }

private double Multiplier { get; }

public void SetDefaultValue()
{
ActionDuration = 1;
NumOfUses = 1;
}

public override string ToString()
{
return $"{Name}";
}
}
}
49 changes: 49 additions & 0 deletions CourseApp/RPGSaga/GameBuilder/FightBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
namespace CourseApp.RPGSaga.GameBuilder
{
using CourseApp.RPGSaga.Heroes;

public class FightBuilder
{
private readonly Player _p1;
private readonly Player _p2;
private Player _winner;
private Player _looser;

public FightBuilder(Player p1, Player p2)
{
_p1 = p1;
_p2 = p2;
}

public void SetTargets()
{
_p1.SetTarget(_p2);
_p2.SetTarget(_p1);
}

public Player StartFight()
{
Logger.WriteLog($"Fight: [{_p1} {_p1.Hp} HP {_p1.Strength} Strength] against [{_p2} {_p2.Hp} HP {_p2.Strength} Strength]");
while (!_p1.IsDead && !_p2.IsDead)
{
_p1.MakeAMove();
_p2.MakeAMove();
}

if (_p1.IsDead)
{
_looser = _p1;
_winner = _p2;
}
else
{
_looser = _p2;
_winner = _p1;
}

Logger.WriteLog($"Winner of this match is {_winner}");
Logger.WriteLog($"Such a good victory against {_looser}");
return _winner;
}
}
}
Loading