hello everyone :)
continuous-integration/drone/push Build is passing Details

test_old_branch
Jérémy Mouyon 11 months ago
parent 54e6e2de6b
commit 6c2b4076f9

@ -5,8 +5,9 @@ using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using QwirkleClassLibrary.Tiles;
namespace QwirkleClassLibrary
namespace QwirkleClassLibrary.Boards
{
public class Board
{
@ -47,7 +48,7 @@ namespace QwirkleClassLibrary
{
for (int i = 0; i < cells.Count; i++)
{
if (this.cells[i].GetX != x || this.cells[i].GetY != y) continue;
if (cells[i].GetX != x || cells[i].GetY != y) continue;
if (cells[i].IsFree)
{
return cells[i].SetTile(tile);
@ -70,7 +71,7 @@ namespace QwirkleClassLibrary
{
for (int i = 0; i < cells.Count; i++)
{
if (this.cells[i].GetX == x && this.cells[i].GetY == y)
if (cells[i].GetX == x && cells[i].GetY == y)
{
return cells[i];
}

@ -1,7 +1,8 @@
// ReSharper disable All
using System.Runtime.CompilerServices;
using QwirkleClassLibrary.Tiles;
namespace QwirkleClassLibrary;
namespace QwirkleClassLibrary.Boards;
public class Cell
{
@ -42,7 +43,7 @@ public class Cell
public bool SetTile(Tile addedTile)
{
if(this.tile == null)
if (tile == null)
{
tile = addedTile;
return true;

@ -1,4 +1,4 @@
namespace QwirkleClassLibrary
namespace QwirkleClassLibrary.Events
{
public class AddPlayerNotifiedEventArgs : EventArgs
{

@ -1,4 +1,6 @@
namespace QwirkleClassLibrary
using QwirkleClassLibrary.Players;
namespace QwirkleClassLibrary.Events
{
public class EndOfGameNotifiedEventArgs
{

@ -1,4 +1,6 @@
namespace QwirkleClassLibrary
using QwirkleClassLibrary.Players;
namespace QwirkleClassLibrary.Events
{
public class NextPlayerNotifiedEventArgs : EventArgs
{

@ -1,4 +1,6 @@
namespace QwirkleClassLibrary
using QwirkleClassLibrary.Tiles;
namespace QwirkleClassLibrary.Events
{
public class PlaceTileNotifiedEventArgs : EventArgs
{

@ -8,8 +8,12 @@ using System.Xml.Linq;
using System.Security.Cryptography;
using System.Collections;
using System.Collections.Immutable;
using QwirkleClassLibrary.Tiles;
using QwirkleClassLibrary.Boards;
using QwirkleClassLibrary.Events;
using QwirkleClassLibrary.Players;
namespace QwirkleClassLibrary
namespace QwirkleClassLibrary.Games
{
public class Game : IPlayer, IRules
@ -62,7 +66,7 @@ namespace QwirkleClassLibrary
return false;
}
if (this.GameRunning)
if (GameRunning)
{
OnPlayerNotified(new AddPlayerNotifiedEventArgs("ERROR : The game is running."));
return false;
@ -116,7 +120,7 @@ namespace QwirkleClassLibrary
public bool StartGame()
{
if (players.Count < 2 || players.Count >= 5) return false;
this.GameRunning = true;
GameRunning = true;
return true;
}
@ -487,14 +491,14 @@ namespace QwirkleClassLibrary
{
for (int i = 0; i < PlayerTilesBagPos.Count; i++)
{
for (int j = 0; j < this.players[PlayerTilesBagPos[i]].Tiles.Count; j++)
for (int j = 0; j < players[PlayerTilesBagPos[i]].Tiles.Count; j++)
{
for (int b = 0; b < this.board.ReadCells.Count; b++)
for (int b = 0; b < board.ReadCells.Count; b++)
{
int x = this.board.ReadCells[b].GetX;
int y = this.board.ReadCells[b].GetY;
int x = board.ReadCells[b].GetX;
int y = board.ReadCells[b].GetY;
if (IsMoveCorrect(this.players[PlayerTilesBagPos[i]].Tiles[j], x, y, this.board))
if (IsMoveCorrect(players[PlayerTilesBagPos[i]].Tiles[j], x, y, board))
{
return true;
}

@ -1,6 +1,9 @@
using System.Collections.ObjectModel;
using QwirkleClassLibrary.Boards;
using QwirkleClassLibrary.Players;
using QwirkleClassLibrary.Tiles;
namespace QwirkleClassLibrary;
namespace QwirkleClassLibrary.Games;
public interface IPlayer
{

@ -3,8 +3,11 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using QwirkleClassLibrary.Boards;
using QwirkleClassLibrary.Players;
using QwirkleClassLibrary.Tiles;
namespace QwirkleClassLibrary
namespace QwirkleClassLibrary.Games
{
public interface IRules
{

@ -4,8 +4,9 @@ using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using QwirkleClassLibrary.Tiles;
namespace QwirkleClassLibrary
namespace QwirkleClassLibrary.Players
{
public class Player
{
@ -14,7 +15,7 @@ namespace QwirkleClassLibrary
public Player(string name)
{
if(name == null || string.IsNullOrEmpty(name))
if (name == null || string.IsNullOrEmpty(name))
{
throw new ArgumentNullException(name);
}

@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace QwirkleClassLibrary
namespace QwirkleClassLibrary.Players
{
public struct Score
{
@ -18,7 +18,8 @@ namespace QwirkleClassLibrary
throw new ArgumentNullException(nameof(p), "player cannot be null");
}
else
{ PlayerScore = 0;
{
PlayerScore = 0;
PlayerTag = p.NameTag;
}
}

@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace QwirkleClassLibrary
namespace QwirkleClassLibrary.Tiles
{
public enum Color
{

@ -5,7 +5,7 @@ using System.Text;
using System.Threading.Tasks;
namespace QwirkleClassLibrary
namespace QwirkleClassLibrary.Tiles
{
/// <summary>
/// Enum is used to have a finished number of shapes for the tiles.

@ -1,12 +1,11 @@
using QwirkleClassLibrary;
using System;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace QwirkleClassLibrary
namespace QwirkleClassLibrary.Tiles
{
public class Tile
{
@ -26,17 +25,17 @@ namespace QwirkleClassLibrary
public Shape GetShape
{
get { return this.shape; }
get { return shape; }
}
public Color GetColor
{
get { return this.color; }
get { return color; }
}
public override string ToString()
{
return color.ToString() + shape.ToString();
return color.ToString() + " " + shape.ToString();
}
}
}

@ -5,11 +5,11 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace QwirkleClassLibrary
namespace QwirkleClassLibrary.Tiles
{
public class TileBag
{
public ReadOnlyCollection<Tile> TilesBag { get ; private set; }
public ReadOnlyCollection<Tile> TilesBag { get; private set; }
private readonly List<Tile> tiles = new List<Tile>();
public TileBag(int nbSet)

@ -1,4 +1,4 @@
using QwirkleClassLibrary;
using QwirkleClassLibrary.Events;
using System;
using System.Collections.Generic;
using System.Linq;

@ -1,4 +1,7 @@
using QwirkleClassLibrary;
using QwirkleClassLibrary.Boards;
using QwirkleClassLibrary.Games;
using QwirkleClassLibrary.Players;
using QwirkleClassLibrary.Tiles;
using QwirkleConsoleApp;
using System.Collections.Immutable;
using System.Collections.ObjectModel;
@ -114,7 +117,8 @@ static void AddTile(Game game)
WriteLine("ERROR : You must type. Please retry : ");
ResetColor();
}
game.PlaceTile(game.GetPlayingPlayer(), tile, x, y);
game.PlaceTileNotified -= nc.NotificationAddTile;
}
}
}
@ -244,13 +248,14 @@ static void ShowScoreBoard(Game g)
WriteLine(" --------------------- THE SCORE BOARD : ---------------------");
int i = 0;
foreach (KeyValuePair<Player, int> pair in g.ScoreBoard)
var sb = g.ScoreBoard.OrderByDescending(x => x.Value).ThenBy(x => x.Key.NameTag);
foreach (KeyValuePair<Player, int> pair in sb)
{
i++;
WriteLine("[" + i + "] " + pair.Key.NameTag + " with " + pair.Value.ToString() + " points.");
}
}
static void MainMenu(Game game)

@ -1,4 +1,5 @@
using QwirkleClassLibrary;
using QwirkleClassLibrary.Boards;
using QwirkleClassLibrary.Tiles;
using System.Collections.ObjectModel;
namespace TestBase;

@ -1,4 +1,5 @@
using QwirkleClassLibrary;
using QwirkleClassLibrary.Boards;
using QwirkleClassLibrary.Tiles;
namespace TestBase;
public class TestCell

@ -1,4 +1,5 @@
using QwirkleClassLibrary;
using QwirkleClassLibrary.Games;
using QwirkleClassLibrary.Players;
namespace TestBase;
public class TestGame

@ -1,4 +1,5 @@
using QwirkleClassLibrary;
using QwirkleClassLibrary.Players;
using QwirkleClassLibrary.Tiles;
namespace TestBase;
public class TestPlayers

@ -1,4 +1,4 @@
using QwirkleClassLibrary;
using QwirkleClassLibrary.Players;
namespace TestBase;
public class TestScore

@ -1,4 +1,4 @@
using QwirkleClassLibrary;
using QwirkleClassLibrary.Tiles;
using System;
using System.Collections.Generic;
using System.Linq;

@ -1,4 +1,4 @@
using QwirkleClassLibrary;
using QwirkleClassLibrary.Tiles;
namespace TestBase;
public class TestTileBag

Loading…
Cancel
Save