Stage-01 done

This commit is contained in:
Vizard
2026-09-30 21:25:34 +03:00
parent bbdd2980e2
commit b8890bcb34
8 changed files with 293 additions and 0 deletions
+210
View File
@@ -0,0 +1,210 @@
using HelpMethods;
using System;
namespace Test
{
internal class Program
{
static Random rand = new Random();
static void Main(string[] args)
{
// System's varibles
short
hp = 60,
number = 25,
attack2Damage = 20,
retreatCost = 1;
double
height = 0.4,
weight = 6.0;
// User's varibles
string
stage,
name,
category,
attack1Name,
attack1Desc,
attack2Name,
attack2Desc,
weakness,
resistance;
SetValues(out stage,
out name,
out category,
out attack1Name,
out attack1Desc,
out attack2Name,
out attack2Desc,
out weakness,
out resistance);
ShowCard(hp,
number,
attack2Damage,
retreatCost,
height,
weight,
stage,
name,
category,
attack1Name,
attack1Desc,
attack2Name,
attack2Desc,
weakness,
resistance);
}
static void ShowCard(short hp,
short number,
short attack2Damage,
short retreatCost,
double height,
double weight,
string stage,
string name,
string category,
string attack1Name,
string attack1Desc,
string attack2Name,
string attack2Desc,
string weakness,
string resistance)
{
// Seporation line
const string
SEP_1 = "======================================================================\n",
SEP_2 = "\n----------------------------------------------------------------------\n";
// Constants
const byte
GLOBAL_MAX_LENGTH = 70,
MAX_LENGTH_FOR_DESC = 62,
RESERVED_CHAR_NUMBER_FOR_HEAD = 11,
RESERVED_CHAR_NUMBER_FOR_DESC = 8,
RESERVED_CHAR_NUMBER_FOR_DESC_PART_2 = 17;
const sbyte FORMATED_MARGINE = -14;
// Calculation of free space
short
sumCharForHead = (short)(stage.Length + name.Length + hp.ToString().Length + RESERVED_CHAR_NUMBER_FOR_HEAD),
sumCharForDescPart_2 = (short)(RESERVED_CHAR_NUMBER_FOR_DESC_PART_2 + attack2Name.Length + attack2Damage.ToString().Length);
// Creating a large gap
string margine1 = String.Empty;
for (byte _char = 0; _char < GLOBAL_MAX_LENGTH - sumCharForHead; _char++)
margine1 += ' ';
string margine2 = String.Empty;
for (byte _char = 0; _char < GLOBAL_MAX_LENGTH - sumCharForDescPart_2; _char++)
margine2 += ' ';
// Formate: Attack & Description
string
margine3 = " ",
desc1_Part1 = attack1Desc,
desc1_Part2 = String.Empty,
desc2_Part1 = attack2Desc,
desc2_Part2 = String.Empty;
if(attack1Desc.Length > MAX_LENGTH_FOR_DESC)
{
desc1_Part1 = String.Empty;
for (byte i = 0; i < MAX_LENGTH_FOR_DESC; i++)
desc1_Part1 += attack1Desc[i];
for(byte i = MAX_LENGTH_FOR_DESC; i < attack1Desc.Length; i++)
desc1_Part2 += attack1Desc[i];
}
if (attack2Desc.Length > MAX_LENGTH_FOR_DESC)
{
desc2_Part1 = String.Empty;
for (byte i = 0; i < MAX_LENGTH_FOR_DESC; i++)
desc2_Part1 += attack2Desc[i];
for (byte i = MAX_LENGTH_FOR_DESC; i < attack2Desc.Length; i++)
desc2_Part2 += attack2Desc[i];
}
// Print card
Console.Write(SEP_1 + $"[{stage}] {name}{margine1}HP: {hp} [⚡]");
Console.Write(SEP_2 + $"№ {number} | Вид: {category} | Рост: {height} м | Вес: {weight} кг");
Console.Write(SEP_2 + $"[Атака 1] {attack1Name}\n");
Console.Write($"Эффект: {desc1_Part1}\n{margine3}{desc1_Part2}\n\n");
Console.Write($"[Атака 2] {attack2Name}{margine2}Урон: {attack2Damage}+\n");
Console.Write($"Эффект: {desc2_Part1}\n{margine3}{desc2_Part2}");
Console.Write(SEP_2 + $"{"Слабость:",FORMATED_MARGINE}{weakness}\n{"Устойчивость:",FORMATED_MARGINE}{resistance}\n{"Отступление:",FORMATED_MARGINE}{retreatCost}\n" + SEP_1);
}
static void SetValues(out string stage,
out string name,
out string category,
out string attack1Name,
out string attack1Desc,
out string attack2Name,
out string attack2Desc,
out string weakness,
out string resistance)
{
Console.Write("Enter the stage.\t[ not more than 7 chars ]\nStage: ");
stage = StringHelp.CutString(Console.ReadLine(), 7).Trim();
if (stage == String.Empty)
stage = "Default";
Console.Write("Enter the name.\t[ not more than 10 chars ]\nName: ");
name = StringHelp.CutString(Console.ReadLine(), 10).Trim();
if (name == String.Empty)
name = "Unknown";
Console.Write("Enter the category.\t[ not more than 10 chars ]\nCategory: ");
category = StringHelp.CutString(Console.ReadLine(), 10).Trim();
if (category == String.Empty)
category = "Unknown";
Console.Write("Enter the name for first attack.\t[ not more than 35 chars ]\nAttack name: ");
attack1Name = StringHelp.CutString(Console.ReadLine(), 35).Trim();
if (attack1Name == String.Empty)
attack1Name = "Unknown";
Console.Write("Enter the description for first attack.\t[ not more than 124 chars ]\nDescription: ");
attack1Desc = StringHelp.CutString(Console.ReadLine(), 124).Trim();
if (attack1Desc == String.Empty)
attack1Desc = "Unknown";
Console.Write("Enter the name for second attack.\t[ not more than 35 chars ]\nAttack name: ");
attack2Name = StringHelp.CutString(Console.ReadLine(), 35).Trim();
if (attack2Name == String.Empty)
attack2Name = "Unknown";
Console.Write("Enter the description for second attack.\t[ not more than 124 chars ]\nDescription: ");
attack2Desc = StringHelp.CutString(Console.ReadLine(), 124).Trim();
if (attack2Desc == String.Empty)
attack2Desc = "Unknown";
Console.Write("Enter the weakness.\t[ not more than 20 chars ]\nWeakness: ");
weakness = StringHelp.CutString(Console.ReadLine(), 20).Trim();
if (weakness == String.Empty)
weakness = "Default";
Console.Write("Enter the resistance.\t[ not more than 20 chars ]\nResistance: ");
resistance = StringHelp.CutString(Console.ReadLine(), 20).Trim();
if (resistance == String.Empty)
resistance = "Default";
StringHelp.Br();
SystemHelp.Waiting(true);
}
}
}
+58
View File
@@ -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.