Add game intro

This commit is contained in:
Andrew Cooper
2022-08-12 17:49:05 +10:00
parent 7ab0e91c1f
commit 35f8248b1f
4 changed files with 52 additions and 8 deletions

View 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}"))));
}

View 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);
}
}

View File

@@ -0,0 +1,5 @@
global using Games.Common.IO;
global using static OneCheck.Resources.Resource;
using OneCheck;
new Game(new ConsoleIO()).Play();

View File

@@ -17,13 +17,14 @@ question 'Jump from ?'
Here is the numerical board:
1 2 3 4 5 6 7 8
9 10 11 12 13 14 15 16
17 18 19 20 21 22 23 24
25 26 27 28 29 30 31 32
33 34 35 36 37 38 39 40
41 42 43 44 45 46 47 48
49 50 51 52 53 54 55 56
57 58 59 60 61 62 63 64
1 2 3 4 5 6 7 8
9 10 11 12 13 14 15 16
17 18 19 20 21 22 23 24
25 26 27 28 29 30 31 32
33 34 35 36 37 38 39 40
41 42 43 44 45 46 47 48
49 50 51 52 53 54 55 56
57 58 59 60 61 62 63 64
And here is the opening position of the checkers.