some changes

This commit is contained in:
Tim Wundenberg
2018-05-25 10:58:07 +02:00
parent d11258d3ed
commit f29beae0fa
4 changed files with 54 additions and 20 deletions

View File

@@ -16,6 +16,8 @@ namespace CoopSweeper.GameTypes
public FieldState State { get; set; } public FieldState State { get; set; }
public int SurroundingBombs { get; set; }
public char ToChar() public char ToChar()
{ {
throw new NotImplementedException(); throw new NotImplementedException();

View File

@@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
using System.Text; using System.Text;
namespace CoopSweeper.GameTypes namespace CoopSweeper.GameTypes
@@ -30,6 +31,39 @@ namespace CoopSweeper.GameTypes
Map[i, j] = field; Map[i, j] = field;
} }
} }
UpdateSorroundingBombs();
}
private void UpdateSorroundingBombs()
{
for (int i = 0; i < Map.GetLength(0); i++)
{
for (int j = 0; j < Map.GetLength(1); j++)
{
var field = Map[i, j];
}
}
}
private List<Point> GetSorroundedFields(int x, int y)
{
var points = new List<Point>();
points.Add(new Point(x - 1, y - 1));
points.Add(new Point(x, y - 1));
points.Add(new Point(x + 1, y - 1));
points.Add(new Point(x + 1, y));
points.Add(new Point(x - 1, y));
points.Add(new Point(x - 1, y + 1));
points.Add(new Point(x, y + 1));
points.Add(new Point(x + 1, y + 1));
return points;
} }
public void GenerateGame(int x, int y) public void GenerateGame(int x, int y)
@@ -65,6 +99,7 @@ namespace CoopSweeper.GameTypes
public void Reveal(int x, int y) public void Reveal(int x, int y)
{ {
CheckMap();
var field = Map[x, y]; var field = Map[x, y];
if (field.State != FieldState.REVEALED) if (field.State != FieldState.REVEALED)
{ {
@@ -77,24 +112,23 @@ namespace CoopSweeper.GameTypes
GameFinished?.Invoke(true); GameFinished?.Invoke(true);
} }
public void SetQuestionMark(int x, int y) public void ToggleMark(int x, int y)
{
Map[x, y].State = FieldState.QUESTIONMARK;
}
public void SetFlag(int x, int y)
{
Map[x, y].State = FieldState.FLAG;
}
public void ResetField(int x, int y)
{ {
CheckMap();
var field = Map[x, y]; var field = Map[x, y];
if (field.State == FieldState.REVEALED)
throw new Exception("A Revealed Field can't be resetet!");
field.State = FieldState.FLAG;
switch (field.State)
{
case FieldState.NONE:
field.State = FieldState.FLAG;
return;
case FieldState.FLAG:
field.State = FieldState.QUESTIONMARK;
return;
case FieldState.QUESTIONMARK:
field.State = FieldState.NONE;
return;
}
} }
} }

View File

@@ -17,6 +17,8 @@ namespace CoopSweeper.GameTypes
bool ContainsBomb { get; set; } bool ContainsBomb { get; set; }
int SurroundingBombs { get; set; }
FieldState State { get; set; } FieldState State { get; set; }
char ToChar(); char ToChar();

View File

@@ -10,10 +10,6 @@ namespace CoopSweeper.GameTypes
void Reveal(int x, int y); void Reveal(int x, int y);
void SetQuestionMark(int x, int y); void ToggleMark(int x, int y);
void SetFlag(int x, int y);
void ResetField(int x, int y);
} }
} }