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
198 changes: 183 additions & 15 deletions AppsLab.CSharp.Exercises.sln

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions Bettlesimulator/Bettlesimulator.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
51 changes: 51 additions & 0 deletions Bettlesimulator/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
namespace Cvicenie_BattleSimulator
{
internal class Program
{
static void Main(string[] args)
{
Hero ourHero = new Hero();
Monster monster1 = new Monster("Goblin", 150, 3);
Monster monster2 = new Monster("Ork", 200, 5);
Monster monster3 = new Monster("Dragon", 300, 10);
List<int> cisla = new List<int>();
List<Monster> monsters = new List<Monster>();
monsters.Add(monster1);
monsters.Add(monster2);
monsters.Add(monster3);



while (true)
{
//Hero dostal utok od monstra
monster1.MonsterAttack(ourHero);
monster2.MonsterAttack(ourHero);
monster3.MonsterAttack(ourHero);
Console.WriteLine("HERO:HP " + ourHero.HP);

//Monster dostal utok od hrdinu
bool wasAttack = ourHero.HeroAttack(monster1);
if (wasAttack)
{
{
Console.WriteLine("---Not enough energy to attack! Restoring energy...");
Console.WriteLine("HERO:energy " + ourHero.Eng);
}

if (ourHero.HP <= 0)
{
Console.WriteLine("Hero is dead!");
break;
}

if (monster1.HP <= 0)
{
Console.WriteLine("Monster is dead!");
break;
}
}
}
}
}
}
94 changes: 94 additions & 0 deletions Bettlesimulator/hero.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static Cvicenie_BattleSimulator.Monster;

namespace Cvicenie_BattleSimulator
{
internal class Hero
{
public string Name { get; set; } = "Gumkac";
public int HP { get; set; } = 100;
public int DMG { get; set; } = 10;

public int Eng { get; set; } = 100;
public int Armor { get; set; } = 15;

public bool HeroAttack(Monster monster)
{
if (Eng - 20 >= 0)
{
Eng -= 20;
monster.HP -= this.DMG;
return true;
}
else

{
Eng = Eng + 50;
return false;
}
}
public bool HeroAttack2(MonsterSpecial monster2)
{
if (Eng - 20 >= 0)
{
Eng -= 20;
monster2.HP -= this.DMG;
return true;
}
else

{
Eng = Eng + 50;
return false;
}
}
public void TakeDamage(int damage)
{
int finalDamage = damage - Armor;

if (finalDamage < 0)
finalDamage = 0;

HP -= finalDamage;
}

public bool HeroDMG(Monster monster)
{
if (Eng - 20 >= 0)
{
Eng -= 20;
monster.HP -= this.DMG;
return true;
}
else
{
Eng += 50;
return false;
}
}

public bool HeroDMG2(MonsterSpecial monster2)
{
if (Eng - 20 >= 0)
{
Eng -= 20;
monster2.HP -= this.DMG;
return true;
}
else
{
Eng += 50;
return false;
}
}





}
}
29 changes: 29 additions & 0 deletions Bettlesimulator/monster.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Cvicenie_BattleSimulator
{
internal class Monster
{

public string RaceType { get; set; }
public int HP { get; set; }
public int DMG { get; set; }

public Monster(string raceType, int hP, int dMG)
{
RaceType = raceType;
HP = hP;
DMG = dMG;
}

public void MonsterAttack(Hero hero)
{
hero.HP -= this.DMG;
}

}
}
29 changes: 29 additions & 0 deletions Bettlesimulator/monsterspecial.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Cvicenie_BattleSimulator
{
internal class MonsterSpecial
{
public string RaceType { get; set; }
public int HP { get; set; }
public int DMG { get; set; }

public MonsterSpecial(string raceType, int hp, int dmg)
{
RaceType = raceType;
HP = hp;
DMG = dmg;
}

public void MonsterAttack(Hero hero)
{
hero.TakeDamage(this.DMG);
this.DMG += 1;
}
}

}
10 changes: 10 additions & 0 deletions ConsoleApp1/ConsoleApp1.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
Loading