mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-23 15:37:51 -08:00
Add game intro
This commit is contained in:
18
67_One_Check/csharp/Board.cs
Normal file
18
67_One_Check/csharp/Board.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
namespace OneCheck;
|
||||||
|
|
||||||
|
internal class Board
|
||||||
|
{
|
||||||
|
private readonly int[][] _checkers;
|
||||||
|
|
||||||
|
public Board()
|
||||||
|
{
|
||||||
|
_checkers =
|
||||||
|
Enumerable.Range(0, 8)
|
||||||
|
.Select(r => Enumerable.Range(0, 8)
|
||||||
|
.Select(c => r > 1 && r < 6 && c > 1 && c < 6 ? 0 : 1).ToArray())
|
||||||
|
.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString() =>
|
||||||
|
string.Join(Environment.NewLine, _checkers.Select(r => string.Join(" ", r.Select(c => $" {c}"))));
|
||||||
|
}
|
||||||
20
67_One_Check/csharp/Game.cs
Normal file
20
67_One_Check/csharp/Game.cs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
namespace OneCheck;
|
||||||
|
|
||||||
|
internal class Game
|
||||||
|
{
|
||||||
|
private readonly IReadWrite _io;
|
||||||
|
private readonly Board _board;
|
||||||
|
|
||||||
|
public Game(IReadWrite io)
|
||||||
|
{
|
||||||
|
_io = io;
|
||||||
|
_board = new Board();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Play()
|
||||||
|
{
|
||||||
|
_io.Write(Streams.Introduction);
|
||||||
|
|
||||||
|
_io.WriteLine(_board);
|
||||||
|
}
|
||||||
|
}
|
||||||
5
67_One_Check/csharp/Program.cs
Normal file
5
67_One_Check/csharp/Program.cs
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
global using Games.Common.IO;
|
||||||
|
global using static OneCheck.Resources.Resource;
|
||||||
|
using OneCheck;
|
||||||
|
|
||||||
|
new Game(new ConsoleIO()).Play();
|
||||||
@@ -17,13 +17,14 @@ question 'Jump from ?'
|
|||||||
|
|
||||||
Here is the numerical board:
|
Here is the numerical board:
|
||||||
|
|
||||||
1 2 3 4 5 6 7 8
|
1 2 3 4 5 6 7 8
|
||||||
9 10 11 12 13 14 15 16
|
9 10 11 12 13 14 15 16
|
||||||
17 18 19 20 21 22 23 24
|
17 18 19 20 21 22 23 24
|
||||||
25 26 27 28 29 30 31 32
|
25 26 27 28 29 30 31 32
|
||||||
33 34 35 36 37 38 39 40
|
33 34 35 36 37 38 39 40
|
||||||
41 42 43 44 45 46 47 48
|
41 42 43 44 45 46 47 48
|
||||||
49 50 51 52 53 54 55 56
|
49 50 51 52 53 54 55 56
|
||||||
57 58 59 60 61 62 63 64
|
57 58 59 60 61 62 63 64
|
||||||
|
|
||||||
And here is the opening position of the checkers.
|
And here is the opening position of the checkers.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user