From e3e6c55050f68bdfb7715248a82b6f4300672afd Mon Sep 17 00:00:00 2001 From: Bagadat <32618276+Bagadat@users.noreply.github.com> Date: Wed, 8 Nov 2017 18:58:04 +0300 Subject: [PATCH 1/5] Add files via upload --- Creator.cs | 69 +++++++++++++++++++++++++++++++++++++++++ Game.cs | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ Gamer.cs | 83 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 242 insertions(+) create mode 100644 Creator.cs create mode 100644 Game.cs create mode 100644 Gamer.cs diff --git a/Creator.cs b/Creator.cs new file mode 100644 index 0000000..5dd5384 --- /dev/null +++ b/Creator.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Chess +{ + abstract class ChessFigureFactory + { + public abstract ChessFigure ChessFigureCreator(Coordinates position, bool color); + + } + + class PawnCreator : ChessFigureFactory + { + public PawnCreator() { } + public override ChessFigure ChessFigureCreator(Coordinates position, bool color) + { + return new Pawn(position, color); + } + } + class CastleCreator : ChessFigureFactory + { + public CastleCreator() + { } + public override ChessFigure ChessFigureCreator(Coordinates position, bool color) + { + return new Castle(position, color); + } + } + class HorseCreator : ChessFigureFactory +{ + public HorseCreator() + { } + public override ChessFigure ChessFigureCreator(Coordinates position, bool color) + { + return new Horse(position, color); + } + } + class KingCreator : ChessFigureFactory +{ + public KingCreator() + { } + public override ChessFigure ChessFigureCreator(Coordinates position, bool color) + { + return new King(position, color); + } + } + class ElephantCreator : ChessFigureFactory +{ + public ElephantCreator() + { } + public override ChessFigure ChessFigureCreator(Coordinates position, bool color) + { + return new Elephant(position, color); + } + } + class QueenCreator : ChessFigureFactory +{ + public QueenCreator() + { } + public override ChessFigure ChessFigureCreator(Coordinates position, bool color) + { + return new Queen(position,color); + } + } + +} diff --git a/Game.cs b/Game.cs new file mode 100644 index 0000000..b4167df --- /dev/null +++ b/Game.cs @@ -0,0 +1,90 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Chess +{ + class Game + { + static List listFigures = new List(); + private static Gamer _currentPlayer; + + private static Gamer _blackPlayer; + private static Gamer _whitePlayer; + + public static void Main(string[] param) + { + InitializeFigures(); + InitializePlayers(); + PassStepTo(true); + Console.ReadKey(); + } + + public Game() + { + + } + + private static void PassStepTo(bool color) + { + if (color) + _currentPlayer = _whitePlayer; + else + _currentPlayer = _blackPlayer; + Console.WriteLine($"Ходит игрок: {_currentPlayer.Name}"); + _currentPlayer.Step(); + } + + private static void InitializePlayers() + { + _whitePlayer = new Gamer("Ilya", listFigures.Where(figure => figure.Color), PassStepTo); + _blackPlayer = new Gamer("Bagadat", listFigures.Where(figure => !figure.Color), PassStepTo); + } + + + private static void InitializeFigures() + { + // Почитай про фабрику и попробуй реализовать!!! + + // ChessFigureFactory creator = new PawnCreator(); + // ChessFigure figure = creator.ChessFigureCreator(); + listFigures = new List() + { + new Elephant(new Coordinates('c', '1'), true), + new Elephant(new Coordinates('f', '1'), true), + new Elephant(new Coordinates('c', '8'), false), + new Elephant(new Coordinates('f', '8'), false), + new Castle(new Coordinates('a', '1'), true), + new Castle(new Coordinates('h', '1'), true), + new Castle(new Coordinates('a', '8'), false), + new Castle(new Coordinates('h', '8'), false), + new Horse(new Coordinates('b', '1'), true), + new Horse(new Coordinates('g', '1'), true), + new Horse(new Coordinates('b', '8'), false), + new Horse(new Coordinates('g', '8'), false), + new King(new Coordinates('e', '1'), true), + new King(new Coordinates('e', '8'), false), + new Queen(new Coordinates('d', '1'), true), + new Queen(new Coordinates('d', '8'), false), + new Pawn(new Coordinates('a', '2'), true), + new Pawn(new Coordinates('b', '2'), true), + new Pawn(new Coordinates('c', '2'), true), + new Pawn(new Coordinates('d', '2'), true), + new Pawn(new Coordinates('e', '2'), true), + new Pawn(new Coordinates('f', '2'), true), + new Pawn(new Coordinates('g', '2'), true), + new Pawn(new Coordinates('h', '2'), true), + new Pawn(new Coordinates('a', '7'), false), + new Pawn(new Coordinates('b', '7'), false), + new Pawn(new Coordinates('c', '7'), false), + new Pawn(new Coordinates('d', '7'), false), + new Pawn(new Coordinates('e', '7'), false), + new Pawn(new Coordinates('f', '7'), false), + new Pawn(new Coordinates('g', '7'), false), + new Pawn(new Coordinates('h', '7'), false), + }; + } + + } + +} diff --git a/Gamer.cs b/Gamer.cs new file mode 100644 index 0000000..27a1e11 --- /dev/null +++ b/Gamer.cs @@ -0,0 +1,83 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +namespace Chess +{ + class Gamer + { + private bool _flagFinish=false; + TimeSpan _gamersTime = new TimeSpan(0, 5, 0); + private Action PassStepTo; + + public string Name { get; } + IEnumerable _figures { get; } + + public Gamer(string name, IEnumerable figures, Action passStepTo) + { + _figures = figures; + Name = name; + PassStepTo = passStepTo; + } + + public void Step() + { + DateTime start = DateTime.Now; + // Засечь время (таймер или поток) + TimerCallback timerCallback = new TimerCallback(Hello); + Timer timer = new Timer(timerCallback, null, _gamersTime, new TimeSpan(1,0,0)); + + string gamerStep = Console.ReadLine(); + + //Заюзать флаг окончания игры + + + timer.Dispose(); + + string[] startToEnd = gamerStep.Split('-'); + + foreach (var figure in _figures) + { + + + if (figure.CheckCurrentPosition(startToEnd[0])) + { + + startToEnd[1] = startToEnd[1].ToLower(); + if (!figure.Move(startToEnd[1][0], startToEnd[1][1])) + { + Console.WriteLine("Фигура не может так ходить"); + + } + else + Console.WriteLine("Фигура может так ходить"); + + break; + } + + + // Обработать случаи: + // 1) когда фигуры найдено не было + // 2) когда фигурой сходить не получилось + // Только в случае успешного хода мы передаем ход + } + // Console.Clear(); + DateTime stop = DateTime.Now; + TimeSpan delta = stop.Subtract(start); + _gamersTime = _gamersTime.Subtract(delta); + PassStepTo.Invoke(!GetColor()); + } + + private void Hello(object state) + { + if (_gamersTime.Minutes == 0) ; + Console.WriteLine("Время истекло"); + + } + + public bool GetColor() + { + return _figures.FirstOrDefault().Color; + } + } +} From 9dab72fd02496a1f7edf0ecb5b7d73ab9b29f376 Mon Sep 17 00:00:00 2001 From: Bagadat <32618276+Bagadat@users.noreply.github.com> Date: Wed, 8 Nov 2017 18:59:05 +0300 Subject: [PATCH 2/5] Delete Creator.cs --- Creator.cs | 69 ------------------------------------------------------ 1 file changed, 69 deletions(-) delete mode 100644 Creator.cs diff --git a/Creator.cs b/Creator.cs deleted file mode 100644 index 5dd5384..0000000 --- a/Creator.cs +++ /dev/null @@ -1,69 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Chess -{ - abstract class ChessFigureFactory - { - public abstract ChessFigure ChessFigureCreator(Coordinates position, bool color); - - } - - class PawnCreator : ChessFigureFactory - { - public PawnCreator() { } - public override ChessFigure ChessFigureCreator(Coordinates position, bool color) - { - return new Pawn(position, color); - } - } - class CastleCreator : ChessFigureFactory - { - public CastleCreator() - { } - public override ChessFigure ChessFigureCreator(Coordinates position, bool color) - { - return new Castle(position, color); - } - } - class HorseCreator : ChessFigureFactory -{ - public HorseCreator() - { } - public override ChessFigure ChessFigureCreator(Coordinates position, bool color) - { - return new Horse(position, color); - } - } - class KingCreator : ChessFigureFactory -{ - public KingCreator() - { } - public override ChessFigure ChessFigureCreator(Coordinates position, bool color) - { - return new King(position, color); - } - } - class ElephantCreator : ChessFigureFactory -{ - public ElephantCreator() - { } - public override ChessFigure ChessFigureCreator(Coordinates position, bool color) - { - return new Elephant(position, color); - } - } - class QueenCreator : ChessFigureFactory -{ - public QueenCreator() - { } - public override ChessFigure ChessFigureCreator(Coordinates position, bool color) - { - return new Queen(position,color); - } - } - -} From 9a45c1f0f246f9d98595582db0b75ac2bca9a65b Mon Sep 17 00:00:00 2001 From: Bagadat <32618276+Bagadat@users.noreply.github.com> Date: Wed, 8 Nov 2017 18:59:19 +0300 Subject: [PATCH 3/5] Delete Gamer.cs --- Gamer.cs | 83 -------------------------------------------------------- 1 file changed, 83 deletions(-) delete mode 100644 Gamer.cs diff --git a/Gamer.cs b/Gamer.cs deleted file mode 100644 index 27a1e11..0000000 --- a/Gamer.cs +++ /dev/null @@ -1,83 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -namespace Chess -{ - class Gamer - { - private bool _flagFinish=false; - TimeSpan _gamersTime = new TimeSpan(0, 5, 0); - private Action PassStepTo; - - public string Name { get; } - IEnumerable _figures { get; } - - public Gamer(string name, IEnumerable figures, Action passStepTo) - { - _figures = figures; - Name = name; - PassStepTo = passStepTo; - } - - public void Step() - { - DateTime start = DateTime.Now; - // Засечь время (таймер или поток) - TimerCallback timerCallback = new TimerCallback(Hello); - Timer timer = new Timer(timerCallback, null, _gamersTime, new TimeSpan(1,0,0)); - - string gamerStep = Console.ReadLine(); - - //Заюзать флаг окончания игры - - - timer.Dispose(); - - string[] startToEnd = gamerStep.Split('-'); - - foreach (var figure in _figures) - { - - - if (figure.CheckCurrentPosition(startToEnd[0])) - { - - startToEnd[1] = startToEnd[1].ToLower(); - if (!figure.Move(startToEnd[1][0], startToEnd[1][1])) - { - Console.WriteLine("Фигура не может так ходить"); - - } - else - Console.WriteLine("Фигура может так ходить"); - - break; - } - - - // Обработать случаи: - // 1) когда фигуры найдено не было - // 2) когда фигурой сходить не получилось - // Только в случае успешного хода мы передаем ход - } - // Console.Clear(); - DateTime stop = DateTime.Now; - TimeSpan delta = stop.Subtract(start); - _gamersTime = _gamersTime.Subtract(delta); - PassStepTo.Invoke(!GetColor()); - } - - private void Hello(object state) - { - if (_gamersTime.Minutes == 0) ; - Console.WriteLine("Время истекло"); - - } - - public bool GetColor() - { - return _figures.FirstOrDefault().Color; - } - } -} From 966207efc820c2d6a0dbe933890c087afe16bade Mon Sep 17 00:00:00 2001 From: Bagadat <32618276+Bagadat@users.noreply.github.com> Date: Wed, 8 Nov 2017 18:59:30 +0300 Subject: [PATCH 4/5] Delete Game.cs --- Game.cs | 90 --------------------------------------------------------- 1 file changed, 90 deletions(-) delete mode 100644 Game.cs diff --git a/Game.cs b/Game.cs deleted file mode 100644 index b4167df..0000000 --- a/Game.cs +++ /dev/null @@ -1,90 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; - -namespace Chess -{ - class Game - { - static List listFigures = new List(); - private static Gamer _currentPlayer; - - private static Gamer _blackPlayer; - private static Gamer _whitePlayer; - - public static void Main(string[] param) - { - InitializeFigures(); - InitializePlayers(); - PassStepTo(true); - Console.ReadKey(); - } - - public Game() - { - - } - - private static void PassStepTo(bool color) - { - if (color) - _currentPlayer = _whitePlayer; - else - _currentPlayer = _blackPlayer; - Console.WriteLine($"Ходит игрок: {_currentPlayer.Name}"); - _currentPlayer.Step(); - } - - private static void InitializePlayers() - { - _whitePlayer = new Gamer("Ilya", listFigures.Where(figure => figure.Color), PassStepTo); - _blackPlayer = new Gamer("Bagadat", listFigures.Where(figure => !figure.Color), PassStepTo); - } - - - private static void InitializeFigures() - { - // Почитай про фабрику и попробуй реализовать!!! - - // ChessFigureFactory creator = new PawnCreator(); - // ChessFigure figure = creator.ChessFigureCreator(); - listFigures = new List() - { - new Elephant(new Coordinates('c', '1'), true), - new Elephant(new Coordinates('f', '1'), true), - new Elephant(new Coordinates('c', '8'), false), - new Elephant(new Coordinates('f', '8'), false), - new Castle(new Coordinates('a', '1'), true), - new Castle(new Coordinates('h', '1'), true), - new Castle(new Coordinates('a', '8'), false), - new Castle(new Coordinates('h', '8'), false), - new Horse(new Coordinates('b', '1'), true), - new Horse(new Coordinates('g', '1'), true), - new Horse(new Coordinates('b', '8'), false), - new Horse(new Coordinates('g', '8'), false), - new King(new Coordinates('e', '1'), true), - new King(new Coordinates('e', '8'), false), - new Queen(new Coordinates('d', '1'), true), - new Queen(new Coordinates('d', '8'), false), - new Pawn(new Coordinates('a', '2'), true), - new Pawn(new Coordinates('b', '2'), true), - new Pawn(new Coordinates('c', '2'), true), - new Pawn(new Coordinates('d', '2'), true), - new Pawn(new Coordinates('e', '2'), true), - new Pawn(new Coordinates('f', '2'), true), - new Pawn(new Coordinates('g', '2'), true), - new Pawn(new Coordinates('h', '2'), true), - new Pawn(new Coordinates('a', '7'), false), - new Pawn(new Coordinates('b', '7'), false), - new Pawn(new Coordinates('c', '7'), false), - new Pawn(new Coordinates('d', '7'), false), - new Pawn(new Coordinates('e', '7'), false), - new Pawn(new Coordinates('f', '7'), false), - new Pawn(new Coordinates('g', '7'), false), - new Pawn(new Coordinates('h', '7'), false), - }; - } - - } - -} From b216dc612d3c32d84066415dbe651db684a4013a Mon Sep 17 00:00:00 2001 From: Bagadat <32618276+Bagadat@users.noreply.github.com> Date: Wed, 8 Nov 2017 19:00:00 +0300 Subject: [PATCH 5/5] Add files via upload --- Chess/Creator.cs | 69 +++++++++++++++++++++++++++ Chess/Game.cs | 122 +++++++++++++++++++++++------------------------ Chess/Gamer.cs | 61 ++++++++++++++++-------- 3 files changed, 170 insertions(+), 82 deletions(-) create mode 100644 Chess/Creator.cs diff --git a/Chess/Creator.cs b/Chess/Creator.cs new file mode 100644 index 0000000..5dd5384 --- /dev/null +++ b/Chess/Creator.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Chess +{ + abstract class ChessFigureFactory + { + public abstract ChessFigure ChessFigureCreator(Coordinates position, bool color); + + } + + class PawnCreator : ChessFigureFactory + { + public PawnCreator() { } + public override ChessFigure ChessFigureCreator(Coordinates position, bool color) + { + return new Pawn(position, color); + } + } + class CastleCreator : ChessFigureFactory + { + public CastleCreator() + { } + public override ChessFigure ChessFigureCreator(Coordinates position, bool color) + { + return new Castle(position, color); + } + } + class HorseCreator : ChessFigureFactory +{ + public HorseCreator() + { } + public override ChessFigure ChessFigureCreator(Coordinates position, bool color) + { + return new Horse(position, color); + } + } + class KingCreator : ChessFigureFactory +{ + public KingCreator() + { } + public override ChessFigure ChessFigureCreator(Coordinates position, bool color) + { + return new King(position, color); + } + } + class ElephantCreator : ChessFigureFactory +{ + public ElephantCreator() + { } + public override ChessFigure ChessFigureCreator(Coordinates position, bool color) + { + return new Elephant(position, color); + } + } + class QueenCreator : ChessFigureFactory +{ + public QueenCreator() + { } + public override ChessFigure ChessFigureCreator(Coordinates position, bool color) + { + return new Queen(position,color); + } + } + +} diff --git a/Chess/Game.cs b/Chess/Game.cs index 878dec1..b4167df 100644 --- a/Chess/Game.cs +++ b/Chess/Game.cs @@ -1,94 +1,90 @@ using System; using System.Collections.Generic; +using System.Linq; namespace Chess -{ +{ class Game { - - private Gamer _currentPlayer; + static List listFigures = new List(); + private static Gamer _currentPlayer; - private Gamer _blackPlayer; - private Gamer _whitePlayer; + private static Gamer _blackPlayer; + private static Gamer _whitePlayer; public static void Main(string[] param) { - + InitializeFigures(); + InitializePlayers(); + PassStepTo(true); + Console.ReadKey(); } public Game() { + } - public void PassStepTo(bool color) + private static void PassStepTo(bool color) { - - if (color) _currentPlayer = _whitePlayer; else _currentPlayer = _blackPlayer; - + Console.WriteLine($"Ходит игрок: {_currentPlayer.Name}"); _currentPlayer.Step(); - - } + private static void InitializePlayers() + { + _whitePlayer = new Gamer("Ilya", listFigures.Where(figure => figure.Color), PassStepTo); + _blackPlayer = new Gamer("Bagadat", listFigures.Where(figure => !figure.Color), PassStepTo); + } - private void SetFigureStartPosition(ChessFigure figure, bool color) + + private static void InitializeFigures() { - if (figure is Elephant) - { - Elephant elephantc1 = new Elephant(new Coordinates('c', 1), true); - Elephant elephantf1 = new Elephant(new Coordinates('f', 1), true); - Elephant elephantc8 = new Elephant(new Coordinates('c', 8), false); - Elephant elephantf8 = new Elephant(new Coordinates('f', 1), false); - } - else if (figure is Castle) - { - Castle castlea1 = new Castle(new Coordinates('a', 1), true); - Castle castleh1 = new Castle(new Coordinates('h', 1), true); - Castle castlea8 = new Castle(new Coordinates('a', 8), false); - Castle castleh8 = new Castle(new Coordinates('h', 8), false); - } - else if (figure is Horse) - { - Horse horseb1 = new Horse(new Coordinates('b', 1), true); - Horse horseg1 = new Horse(new Coordinates('g', 1), true); - Horse horseb8 = new Horse(new Coordinates('b', 8), false); - Horse horseg8 = new Horse(new Coordinates('g', 8), false); + // Почитай про фабрику и попробуй реализовать!!! - - } - else if (figure is King) + // ChessFigureFactory creator = new PawnCreator(); + // ChessFigure figure = creator.ChessFigureCreator(); + listFigures = new List() { - King kinge1 = new King(new Coordinates('e', 1), true); - King kinge8 = new King(new Coordinates('e', 8), false); - } - else if (figure is Queen) - { - Queen queend1 = new Queen(new Coordinates('d', 1), true); - Queen queend8 = new Queen(new Coordinates('d', 8), false); - } - else if (figure is Pawn) - { - Pawn pawna2 = new Pawn(new Coordinates('a', 2), true); - Pawn pawnb2 = new Pawn(new Coordinates('b', 2), true); - Pawn pawnc2 = new Pawn(new Coordinates('c', 2), true); - Pawn pawnd2 = new Pawn(new Coordinates('d', 2), true); - Pawn pawne2 = new Pawn(new Coordinates('e', 2), true); - Pawn pawnf2 = new Pawn(new Coordinates('f', 2), true); - Pawn pawng2 = new Pawn(new Coordinates('g', 2), true); - Pawn pawnh2 = new Pawn(new Coordinates('h', 2), true); - Pawn pawna7 = new Pawn(new Coordinates('a', 7), false); - Pawn pawnb7 = new Pawn(new Coordinates('b', 7), false); - Pawn pawnc7 = new Pawn(new Coordinates('c', 7), false); - Pawn pawnd7 = new Pawn(new Coordinates('d', 7), false); - Pawn pawne7 = new Pawn(new Coordinates('e', 7), false); - Pawn pawnf7 = new Pawn(new Coordinates('f', 7), false); - Pawn pawng7 = new Pawn(new Coordinates('g', 7), false); - Pawn pawnh7 = new Pawn(new Coordinates('h', 7), false); - } + new Elephant(new Coordinates('c', '1'), true), + new Elephant(new Coordinates('f', '1'), true), + new Elephant(new Coordinates('c', '8'), false), + new Elephant(new Coordinates('f', '8'), false), + new Castle(new Coordinates('a', '1'), true), + new Castle(new Coordinates('h', '1'), true), + new Castle(new Coordinates('a', '8'), false), + new Castle(new Coordinates('h', '8'), false), + new Horse(new Coordinates('b', '1'), true), + new Horse(new Coordinates('g', '1'), true), + new Horse(new Coordinates('b', '8'), false), + new Horse(new Coordinates('g', '8'), false), + new King(new Coordinates('e', '1'), true), + new King(new Coordinates('e', '8'), false), + new Queen(new Coordinates('d', '1'), true), + new Queen(new Coordinates('d', '8'), false), + new Pawn(new Coordinates('a', '2'), true), + new Pawn(new Coordinates('b', '2'), true), + new Pawn(new Coordinates('c', '2'), true), + new Pawn(new Coordinates('d', '2'), true), + new Pawn(new Coordinates('e', '2'), true), + new Pawn(new Coordinates('f', '2'), true), + new Pawn(new Coordinates('g', '2'), true), + new Pawn(new Coordinates('h', '2'), true), + new Pawn(new Coordinates('a', '7'), false), + new Pawn(new Coordinates('b', '7'), false), + new Pawn(new Coordinates('c', '7'), false), + new Pawn(new Coordinates('d', '7'), false), + new Pawn(new Coordinates('e', '7'), false), + new Pawn(new Coordinates('f', '7'), false), + new Pawn(new Coordinates('g', '7'), false), + new Pawn(new Coordinates('h', '7'), false), + }; } + } + } diff --git a/Chess/Gamer.cs b/Chess/Gamer.cs index e6594a6..27a1e11 100644 --- a/Chess/Gamer.cs +++ b/Chess/Gamer.cs @@ -1,55 +1,78 @@ using System; using System.Collections.Generic; using System.Linq; - -using System.Text; -using System.Threading.Tasks; +using System.Threading; namespace Chess { class Gamer { - Game _passToStep; + private bool _flagFinish=false; TimeSpan _gamersTime = new TimeSpan(0, 5, 0); + private Action PassStepTo; public string Name { get; } - List _figures { get; } + IEnumerable _figures { get; } - public Gamer(string name, List figures) + public Gamer(string name, IEnumerable figures, Action passStepTo) { _figures = figures; Name = name; + PassStepTo = passStepTo; } public void Step() { - DateTime start = DateTime.Now; + // Засечь время (таймер или поток) + TimerCallback timerCallback = new TimerCallback(Hello); + Timer timer = new Timer(timerCallback, null, _gamersTime, new TimeSpan(1,0,0)); + string gamerStep = Console.ReadLine(); + //Заюзать флаг окончания игры + + + timer.Dispose(); + string[] startToEnd = gamerStep.Split('-'); foreach (var figure in _figures) { + + if (figure.CheckCurrentPosition(startToEnd[0])) { + startToEnd[1] = startToEnd[1].ToLower(); - figure.Move(startToEnd[1][0], startToEnd[1][1]); + if (!figure.Move(startToEnd[1][0], startToEnd[1][1])) + { + Console.WriteLine("Фигура не может так ходить"); + + } + else + Console.WriteLine("Фигура может так ходить"); + break; } + + + // Обработать случаи: + // 1) когда фигуры найдено не было + // 2) когда фигурой сходить не получилось + // Только в случае успешного хода мы передаем ход } + // Console.Clear(); DateTime stop = DateTime.Now; - TimeSpan delta = start - stop; - long seconds = delta.Seconds; - - TimeSpan newTime = new TimeSpan(seconds); - _gamersTime = _gamersTime.Subtract(newTime); - if (_gamersTime != null) - { - Action method = _passToStep.PassStepTo; - method(GetColor()); - } - + TimeSpan delta = stop.Subtract(start); + _gamersTime = _gamersTime.Subtract(delta); + PassStepTo.Invoke(!GetColor()); + } + private void Hello(object state) + { + if (_gamersTime.Minutes == 0) ; + Console.WriteLine("Время истекло"); + } public bool GetColor()