-
Notifications
You must be signed in to change notification settings - Fork 24
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
Mishina_Violetta_Aleksandrovna #20
Open
Violettam88
wants to merge
12
commits into
ISUCT:Mishina_Violetta_Aleksandrovna
Choose a base branch
from
Violettam88:Mishina_Violetta_Aleksandrovna
base: Mishina_Violetta_Aleksandrovna
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
7d24737
1 classes sample
jskonst 6e6e4d9
Merge pull request #1 from ISUCT/jskonst
jskonst 448314d
Task one done
Violettam88 e47832b
some edition in program.cs, created unit test
Violettam88 a39869e
done task 2
Violettam88 2f52ffd
Create n_1_player
Violettam88 32770b5
Add files via upload
Violettam88 30c33b4
Delete n_1_player
Violettam88 f7d754e
Add files via upload
Violettam88 eb75728
Add files via upload
Violettam88 2d69b2a
Add files via upload
Violettam88 7dd2455
залила нормально :(
Violettam88 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
namespace CourseApp.Tests.Task_one | ||
{ | ||
using System; | ||
using System.IO; | ||
using CourseApp.Task_one; | ||
using Xunit; | ||
|
||
[Collection("Sequential")] | ||
public class CountryTests : IDisposable | ||
{ | ||
private const string Inp1 = "England 121321 3213"; | ||
|
||
private const string Out1 = @"The country of England has a population of 121321 people and an area of 3213 km^2 | ||
Incorrect value of population. | ||
Incorrect value of area. | ||
The country of England has a population of 121321 people and an area of 15 km^2 | ||
"; | ||
|
||
public void Dispose() | ||
{ | ||
var standardOut = new StreamWriter(Console.OpenStandardOutput()); | ||
standardOut.AutoFlush = true; | ||
var standardIn = new StreamReader(Console.OpenStandardInput()); | ||
Console.SetOut(standardOut); | ||
Console.SetIn(standardIn); | ||
} | ||
|
||
[Theory] | ||
[InlineData(Inp1, Out1)] | ||
public void EditingWithAndWithoutErorrs(string input, string expected) | ||
{ | ||
var stringWriter = new StringWriter(); | ||
Console.SetOut(stringWriter); | ||
|
||
var stringReader = new StringReader(input); | ||
Console.SetIn(stringReader); | ||
|
||
// act | ||
string[] buff = input.Split(' '); | ||
Country one = new Country(buff[0], int.Parse(buff[1]), int.Parse(buff[2])); | ||
one.Info(); | ||
one.Population = -15; | ||
one.Square = 0; | ||
one.Square = 15; | ||
one.Info(); | ||
|
||
// assert | ||
var output = stringWriter.ToString(); | ||
Assert.Equal($"{expected}", output); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,10 @@ | ||
namespace CourseApp | ||
{ | ||
using System; | ||
|
||
public class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
Console.WriteLine("Hello World"); | ||
Game.Play(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
namespace CourseApp | ||
{ | ||
using System; | ||
|
||
public class Archer : Player | ||
{ | ||
public Archer(int health, int strength, string name) | ||
: base(health, strength, name, "Cтрелы любви") | ||
{ | ||
} | ||
|
||
public override string ToString() | ||
{ | ||
return "(Лучница) " + Name; | ||
} | ||
|
||
public override string Ability() | ||
{ | ||
if (AbilityLeft > 0) | ||
{ | ||
AbilityLeft--; | ||
return AbilityName; | ||
} | ||
else | ||
{ | ||
return "нанесла урон"; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
namespace CourseApp | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
public class Game | ||
{ | ||
public static void Play() | ||
{ | ||
int num = AskNum(); | ||
List<Player> playerList = PlayersList(num); | ||
RNDList(ref playerList); | ||
PlayGame(ref playerList); | ||
} | ||
|
||
private static void PlayGame(ref List<Player> playerList) | ||
{ | ||
for (int i = 1; playerList.Count != 1; i++) | ||
{ | ||
Logger.Write(i); | ||
PlayRound(ref playerList); | ||
} | ||
|
||
Logger.Write(playerList[0]); | ||
} | ||
|
||
private static void PlayRound(ref List<Player> playerList) | ||
{ | ||
for (int i = 0; i < playerList.Count / 2; i++) | ||
{ | ||
Logger.Write(playerList[i * 2], playerList[(i * 2) + 1]); | ||
playerList[i * 2] = Fight(playerList[i * 2], playerList[(i * 2) + 1]); | ||
} | ||
|
||
for (int i = 1; i < playerList.Count; i++) | ||
{ | ||
playerList.RemoveAt(i); | ||
} | ||
} | ||
|
||
private static Player Fight(Player first, Player second) | ||
{ | ||
for (int i = 0; true; i++) | ||
{ | ||
if (i != 0) | ||
{ | ||
(first, second) = (second, first); | ||
} | ||
|
||
string debaffinf = first.DebaffInfo(); | ||
Logger.Write(first, debaffinf); | ||
bool checkDeath = first.IsDeath(); | ||
if (checkDeath) | ||
{ | ||
Logger.Write(first, true); | ||
second.Update(); | ||
return second; | ||
} | ||
|
||
if (debaffinf == "Заколдованная пыль") | ||
{ | ||
continue; | ||
} | ||
|
||
string action = PlayerAct(); | ||
if (action == "ab") | ||
{ | ||
var actionisdone = first.Ability(); | ||
if (actionisdone != "нанесла урон") | ||
{ | ||
if (actionisdone == "Розовый удар") | ||
{ | ||
Logger.Write(first, second, actionisdone, (float)Math.Round(first.Attack() * 1.3f, 2)); | ||
second.Damage((float)Math.Round(first.Attack() * 1.3f, 2)); | ||
} | ||
else | ||
{ | ||
Logger.Write(first, second, actionisdone); | ||
second.Debaff(actionisdone); | ||
} | ||
} | ||
else | ||
{ | ||
Logger.Write(first, second, actionisdone, first.Attack()); | ||
second.Damage(first.Attack()); | ||
} | ||
} | ||
else | ||
{ | ||
Logger.Write(first, second, "нанесла урон", first.Attack()); | ||
second.Damage(first.Attack()); | ||
} | ||
|
||
checkDeath = second.IsDeath(); | ||
if (checkDeath) | ||
{ | ||
Logger.Write(second, true); | ||
first.Update(); | ||
return first; | ||
} | ||
} | ||
} | ||
|
||
private static string PlayerAct() | ||
{ | ||
Random rnd = new Random(); | ||
int action = rnd.Next(0, 2); | ||
if (action == 0) | ||
{ | ||
return "ab"; | ||
} | ||
else | ||
{ | ||
return "at"; | ||
} | ||
} | ||
|
||
private static int AskNum() | ||
{ | ||
while (true) | ||
{ | ||
Console.WriteLine("Введите четное количество игроков:"); | ||
int number = Convert.ToInt32(Console.ReadLine()); | ||
if (number <= 0) | ||
{ | ||
Console.WriteLine("КАКОЕ НОЛЬ, КАК ИХ МЕНЬШЕ 2 МОЖЕТ БЫТЬ!"); | ||
} | ||
else if (number % 2 != 0) | ||
{ | ||
Console.WriteLine("ЧЕТНОЕ ДАЙ МНЕ!"); | ||
} | ||
else | ||
{ | ||
return number; | ||
} | ||
} | ||
} | ||
|
||
private static void RNDList(ref List<Player> input) | ||
{ | ||
Random rnd = new Random(); | ||
Player[] buffer = input.ToArray(); | ||
for (int i = 0; i < input.Count; i++) | ||
{ | ||
int pos = rnd.Next(i, buffer.Length); | ||
(buffer[i], buffer[pos]) = (buffer[pos], buffer[i]); | ||
} | ||
|
||
input = buffer.ToList(); | ||
} | ||
|
||
private static List<Player> PlayersList(int count) | ||
{ | ||
List<Player> players = new List<Player>(); | ||
for (int i = 0; i < count; i++) | ||
{ | ||
players.Add(PGen()); | ||
} | ||
|
||
return players; | ||
} | ||
|
||
private static Player PGen() | ||
{ | ||
Random rnd = new Random(); | ||
string[] name = { "Колмезер", "Мэлдебель", "Сьюбексика", "Вилоура", "Бонреетта", "Эрсэн", "Челриция", "Антлейси", "Кейоан", "Хоуелоун", "Дамсзен", "Анжиия", "Глозетда" }; | ||
int health = rnd.Next(1, 50); | ||
int strength = rnd.Next(1, 20); | ||
int classChouse = rnd.Next(0, 3); | ||
if (classChouse == 0) | ||
{ | ||
return new Warrior(health, strength, name[rnd.Next(name.Length)]); | ||
} | ||
else if (classChouse == 1) | ||
{ | ||
return new Mage(health, strength, name[rnd.Next(name.Length)]); | ||
} | ||
else | ||
{ | ||
return new Archer(health, strength, name[rnd.Next(name.Length)]); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
namespace CourseApp | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
public static class Logger | ||
{ | ||
public static void Write(Player winner) | ||
{ | ||
Console.WriteLine($"{winner.ToString()} ПОБЕДИЛА!"); | ||
} | ||
|
||
public static void Write(int round) | ||
{ | ||
Console.WriteLine($"Раунд {round}"); | ||
} | ||
|
||
public static void Write(Player first, Player second) | ||
{ | ||
Console.WriteLine($"{first.ToString()} VS {second.ToString()}"); | ||
} | ||
|
||
public static void Write(Player first, Player second, string action) | ||
{ | ||
Console.WriteLine($"{first.ToString()} применила ({action}) по противнику {second.ToString()}"); | ||
} | ||
|
||
public static void Write(Player first, Player second, string action, float damage) | ||
{ | ||
if (action != "нанесла урон") | ||
{ | ||
Console.WriteLine($"{first.ToString()} применила ({action}) и нанесла урон {damage} противнику {second.ToString()}"); | ||
} | ||
else | ||
{ | ||
Console.WriteLine($"{first.ToString()} нанесла урон {damage} противнику {second.ToString()}"); | ||
} | ||
} | ||
|
||
public static void Write(Player inputP, string debaff) | ||
{ | ||
switch (debaff) | ||
{ | ||
case "Cтрелы любви": | ||
Console.WriteLine($"{inputP.ToString()} получила периодический урон 2 от ({debaff})"); | ||
break; | ||
case "Заколдованная пыль": | ||
Console.WriteLine($"{inputP.ToString()} пропустила ход из-за ({debaff})"); | ||
break; | ||
} | ||
} | ||
|
||
public static void Write(Player inputP, bool isDeath) | ||
{ | ||
if (isDeath) | ||
{ | ||
Console.WriteLine($"{inputP.ToString()} погибла :)"); | ||
Console.WriteLine(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
namespace CourseApp | ||
{ | ||
using System; | ||
|
||
public class Mage : Player | ||
{ | ||
public Mage(int health, int strength, string name) | ||
: base(health, strength, name, "Заколдованная пыль") | ||
{ | ||
} | ||
|
||
public override string ToString() | ||
{ | ||
return "(Волшебница) " + Name; | ||
} | ||
|
||
public override string Ability() | ||
{ | ||
if (AbilityLeft > 0) | ||
{ | ||
AbilityLeft--; | ||
return AbilityName; | ||
} | ||
else | ||
{ | ||
return "нанесла урон"; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
лучше вместо таких сложных тестов поменять код - тесты будут проще и не будет нарушаться принцип единой ответственности