generated from admin/template
stage-02 done
This commit is contained in:
@@ -0,0 +1,222 @@
|
|||||||
|
using HelpMethods;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Test
|
||||||
|
{
|
||||||
|
internal class Program
|
||||||
|
{
|
||||||
|
static Random rand = new Random();
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
short
|
||||||
|
pokemonHp,
|
||||||
|
attack2BaseDamage = 10,
|
||||||
|
incomingDamage;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
SetPokemonHp(out pokemonHp);
|
||||||
|
StringHelp.Br();
|
||||||
|
|
||||||
|
SetIncomingDamage(out incomingDamage);
|
||||||
|
StringHelp.Br();
|
||||||
|
|
||||||
|
SetType(ref incomingDamage);
|
||||||
|
|
||||||
|
ToParalyze();
|
||||||
|
IncreaseTheDamage(ref attack2BaseDamage);
|
||||||
|
|
||||||
|
ShowPokemonState(TakeDamage(ref pokemonHp, incomingDamage));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set value for Pokemon hp
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="hp"></param>
|
||||||
|
/// <exception cref="Exception"></exception>
|
||||||
|
static void SetPokemonHp(out short hp)
|
||||||
|
{
|
||||||
|
const short
|
||||||
|
MAX_HP = 2000,
|
||||||
|
MIN_HP = 1;
|
||||||
|
|
||||||
|
string ERROR = $"The value must be between {MIN_HP} and {MAX_HP}";
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Console.Write("Enter the number of HP Pokemon.\nHP: ");
|
||||||
|
hp = short.Parse(Console.ReadLine());
|
||||||
|
|
||||||
|
if(hp > MAX_HP || hp < MIN_HP)
|
||||||
|
throw new Exception (ERROR);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
catch (Exception err) {SystemHelp.PrintError(err);}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Return true or false
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
static bool FlipACoin()
|
||||||
|
{
|
||||||
|
if(rand.Next(0, 2) == 1)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Stun the enemy
|
||||||
|
/// </summary>
|
||||||
|
static void ToParalyze()
|
||||||
|
{
|
||||||
|
if (FlipACoin())
|
||||||
|
{
|
||||||
|
Console.WriteLine("Результат: Активный Покемон противника парализован!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("Результат: Эффект паралича не сработал.");
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Increase the pokemon's base damage to 10 points
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="damage"></param>
|
||||||
|
static void IncreaseTheDamage(ref short damage)
|
||||||
|
{
|
||||||
|
const short MAX_DAMAGE = 350;
|
||||||
|
const byte ADDING_POINTS = 10;
|
||||||
|
|
||||||
|
short initialDamage = damage;
|
||||||
|
|
||||||
|
|
||||||
|
if (FlipACoin())
|
||||||
|
{
|
||||||
|
if (damage > MAX_DAMAGE - ADDING_POINTS)
|
||||||
|
{
|
||||||
|
damage = MAX_DAMAGE;
|
||||||
|
Console.WriteLine($"Результат: Выпал орёл! Итоговый урон: {damage} | до: {initialDamage}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
damage += ADDING_POINTS;
|
||||||
|
Console.WriteLine($"Результат: Выпал орёл! Итоговый урон: {damage} | до: {initialDamage}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine($"Результат: Выпала решка! Итоговый урон: {damage}");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set value for incoming damage
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="damage"></param>
|
||||||
|
static void SetIncomingDamage(out short damage)
|
||||||
|
{
|
||||||
|
const short
|
||||||
|
MAX_DAMAGE = 350,
|
||||||
|
MIN_DAMAGE = 5;
|
||||||
|
|
||||||
|
string ERROR = $"The value must be between {MIN_DAMAGE} and {MAX_DAMAGE}";
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Console.Write("Enter the number of incoming attack damage for Pokemon.\nDamage: ");
|
||||||
|
damage = short.Parse(Console.ReadLine());
|
||||||
|
|
||||||
|
if (damage > MAX_DAMAGE || damage < MIN_DAMAGE)
|
||||||
|
throw new Exception(ERROR);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
catch (Exception err) { SystemHelp.PrintError(err); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Set type for incoming damage
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="damage"></param>
|
||||||
|
static void SetType(ref short damage)
|
||||||
|
{
|
||||||
|
const string
|
||||||
|
TYPE_1 = "Боевой тип (Weakness: x2)\n",
|
||||||
|
TYPE_2 = "Стальной тип (Resistance: -20)\n",
|
||||||
|
TYPE_3 = "Обычный тип (Без изменений)\n",
|
||||||
|
DEFAULT_TYPE = TYPE_3;
|
||||||
|
|
||||||
|
|
||||||
|
switch (SetValue())
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
Console.WriteLine(TYPE_1);
|
||||||
|
damage *= 2;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
Console.WriteLine(TYPE_2);
|
||||||
|
|
||||||
|
if(damage < 20)
|
||||||
|
{
|
||||||
|
damage /= 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
damage -= 20;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
default:
|
||||||
|
Console.WriteLine(DEFAULT_TYPE);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static byte SetValue()
|
||||||
|
{
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Console.Write("Enter the type for incoming attack damage.\nType: ");
|
||||||
|
byte type = byte.Parse(Console.ReadLine());
|
||||||
|
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
catch (Exception err) { SystemHelp.PrintError(err); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Pokemon take the damage
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="hp"></param>
|
||||||
|
/// <param name="incomingDamage"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
static short TakeDamage(ref short hp, short incomingDamage) => hp -= incomingDamage;
|
||||||
|
/// <summary>
|
||||||
|
/// Show the state of Pokemon
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="hp"></param>
|
||||||
|
static void ShowPokemonState(short hp)
|
||||||
|
{
|
||||||
|
if(hp < 1)
|
||||||
|
{
|
||||||
|
Console.WriteLine("\nThe Pokemon is knocked out!\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine($"\nThe Pokemon withstood the hit! HP left: {hp}\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{0580ACC5-9C57-48B6-A97B-75103119F024}</ProjectGuid>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<RootNamespace>Test</RootNamespace>
|
||||||
|
<AssemblyName>Test</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||||
|
<LangVersion>latest</LangVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||||
|
<Deterministic>true</Deterministic>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="MyDll, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>.\MyDll.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Net.Http" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Program.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="App.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
</Project>
|
||||||
Binary file not shown.
Reference in New Issue
Block a user