-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGameView.cs
51 lines (47 loc) · 1.49 KB
/
GameView.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Battleships
{
class GameView : Battleships.IGameView
{
public void SetGameInfo(int size, int gameId)
{
Console.WriteLine("Game {0} on a {1}x{1} board.", gameId, size+1);
}
public void AddShips(IEnumerable<ShipInfo> ships) {
foreach (var ship in ships)
{
Console.Write("Ship ({0}): ", ship.Size);
foreach (var cell in ship.PositionCells)
{
Console.Write("[{0}, {1}] ", cell.x, cell.y);
}
Console.WriteLine("");
}
}
public void AddShot(CellCoords cell, ShotResult result)
{
//Console.Write("[{0}, {1}]:{2} ", cell.x, cell.y, GetShotResult(result));
Console.Write(GetShotResult(result));
}
public void SetResults(int shoots, int points, int bestResult)
{
Console.WriteLine("\n-> shoots: {0}; current score: {1}; best result: {2}", shoots, points, bestResult);
}
private static string GetShotResult(ShotResult result)
{
switch (result)
{
case ShotResult.Miss:
return ".";
case ShotResult.Hit:
return "x";
case ShotResult.HitAndSunk:
return "X";
}
return " ";
}
}
}