You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
103 lines
2.2 KiB
103 lines
2.2 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
namespace QwirkleClassLibrary
|
|
{
|
|
public class Game
|
|
{
|
|
private TileBag bag;
|
|
private List<Player> players;
|
|
|
|
public Game(List<Player> players)
|
|
{
|
|
this.players = players;
|
|
bag = new TileBag(3);
|
|
}
|
|
|
|
public int GetPlayingPlayerPosition()
|
|
{
|
|
for (int i = 0; i < players.Count; i++)
|
|
{
|
|
if (players[i].IsPlaying == true)
|
|
{
|
|
return i;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
public int GetNbPlayers
|
|
{
|
|
get { return players.Count; }
|
|
}
|
|
|
|
public List<Tile> ListTilesBag
|
|
{
|
|
get { return bag.TilesInBag(); }
|
|
}
|
|
|
|
public string ShowTileOfPlayer(int posplayer)
|
|
{
|
|
List<Tile> tiles = players[posplayer].Tiles;
|
|
|
|
string r = ("Tile of " + posplayer + " : ");
|
|
|
|
foreach(Tile tile in tiles)
|
|
{
|
|
r = (r + " " + tile.NameColorTile());
|
|
}
|
|
return r;
|
|
|
|
}
|
|
|
|
public void SetNextPlayer(int old, int neew)
|
|
{
|
|
if (old >= 0)
|
|
{
|
|
players[old].IsPlaying = false;
|
|
}
|
|
players[neew].IsPlaying = true;
|
|
|
|
|
|
}
|
|
|
|
public void TilsBagPlayer()
|
|
{
|
|
for (int i = 0; i < players.Count; i++)
|
|
{
|
|
for (int j = 0; j < 6; j++)
|
|
{
|
|
Tile tile = ListTilesBag[j];
|
|
players[i].AddTilePlayer(tile);
|
|
bag.RemoveTileInBag(tile);
|
|
}
|
|
}
|
|
}
|
|
|
|
public string NextPlayer()
|
|
{
|
|
int posPlayerPlay = GetPlayingPlayerPosition();
|
|
|
|
int posPlayerNextPlay = GetPlayingPlayerPosition() + 1;
|
|
|
|
if (posPlayerNextPlay >= GetNbPlayers)
|
|
{
|
|
posPlayerNextPlay = 0;
|
|
}
|
|
|
|
SetNextPlayer(posPlayerPlay, posPlayerNextPlay);
|
|
|
|
return (players[posPlayerNextPlay].GetNameTag);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|