42 lines
963 B
C#
42 lines
963 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
|
|
namespace CoopSweeper.GameTypes
|
|
{
|
|
class Game
|
|
{
|
|
private readonly Random _random = new Random();
|
|
|
|
public IField[,] Map { get; protected set; }
|
|
|
|
private bool IsBomb(int bombratePercent)
|
|
{
|
|
int r = _random.Next(0, 100);
|
|
return r < bombratePercent;
|
|
}
|
|
|
|
public void GenerateGame(int x, int y, int bombratePercent)
|
|
{
|
|
Map = new IField[x, y];
|
|
for (int i = 0; i < x; i++)
|
|
{
|
|
for (int j = 0; j < y; j++)
|
|
{
|
|
var field = new Field
|
|
{
|
|
ContainsBomb = IsBomb(bombratePercent)
|
|
};
|
|
Map[i, j] = field;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void GenerateGame(int x, int y)
|
|
{
|
|
GenerateGame(x, y, 10);
|
|
}
|
|
|
|
}
|
|
}
|