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.Security.Cryptography;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using QwirkleClassLibrary.Tiles;
namespace QwirkleClassLibrary namespace QwirkleClassLibrary.Boards
{ {
public class Board public class Board
{ {
@ -47,7 +48,7 @@ namespace QwirkleClassLibrary
{ {
for (int i = 0; i < cells.Count; i++) 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) if (cells[i].IsFree)
{ {
return cells[i].SetTile(tile); return cells[i].SetTile(tile);
@ -70,7 +71,7 @@ namespace QwirkleClassLibrary
{ {
for (int i = 0; i < cells.Count; i++) 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]; return cells[i];
} }

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

@ -1,8 +1,8 @@
namespace QwirkleClassLibrary namespace QwirkleClassLibrary.Events
{ {
public class AddPlayerNotifiedEventArgs : EventArgs public class AddPlayerNotifiedEventArgs : EventArgs
{ {
public string returnedNotified { get; private set; } public string returnedNotified { get; private set; }
public AddPlayerNotifiedEventArgs(string returnedNotified) public AddPlayerNotifiedEventArgs(string returnedNotified)
{ {

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

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

@ -1,8 +1,10 @@
namespace QwirkleClassLibrary using QwirkleClassLibrary.Tiles;
namespace QwirkleClassLibrary.Events
{ {
public class PlaceTileNotifiedEventArgs : EventArgs public class PlaceTileNotifiedEventArgs : EventArgs
{ {
public Tile tile { get; private set; } public Tile tile { get; private set; }
public string reason { get; private set; } public string reason { get; private set; }

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

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

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

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

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

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

@ -5,7 +5,7 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace QwirkleClassLibrary namespace QwirkleClassLibrary.Tiles
{ {
/// <summary> /// <summary>
/// Enum is used to have a finished number of shapes for the tiles. /// 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.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace QwirkleClassLibrary namespace QwirkleClassLibrary.Tiles
{ {
public class Tile public class Tile
{ {
@ -26,17 +25,17 @@ namespace QwirkleClassLibrary
public Shape GetShape public Shape GetShape
{ {
get { return this.shape; } get { return shape; }
} }
public Color GetColor public Color GetColor
{ {
get { return this.color; } get { return color; }
} }
public override string ToString() 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.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace QwirkleClassLibrary namespace QwirkleClassLibrary.Tiles
{ {
public class TileBag 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>(); private readonly List<Tile> tiles = new List<Tile>();
public TileBag(int nbSet) public TileBag(int nbSet)

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

@ -1,4 +1,7 @@
using QwirkleClassLibrary; using QwirkleClassLibrary.Boards;
using QwirkleClassLibrary.Games;
using QwirkleClassLibrary.Players;
using QwirkleClassLibrary.Tiles;
using QwirkleConsoleApp; using QwirkleConsoleApp;
using System.Collections.Immutable; using System.Collections.Immutable;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
@ -114,7 +117,8 @@ static void AddTile(Game game)
WriteLine("ERROR : You must type. Please retry : "); WriteLine("ERROR : You must type. Please retry : ");
ResetColor(); 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 : ---------------------"); WriteLine(" --------------------- THE SCORE BOARD : ---------------------");
int i = 0; 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++; i++;
WriteLine("[" + i + "] " + pair.Key.NameTag + " with " + pair.Value.ToString() + " points."); WriteLine("[" + i + "] " + pair.Key.NameTag + " with " + pair.Value.ToString() + " points.");
} }
} }
static void MainMenu(Game game) static void MainMenu(Game game)

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

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

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

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

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

@ -1,4 +1,4 @@
using QwirkleClassLibrary; using QwirkleClassLibrary.Tiles;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace TestBase namespace TestBase
{ {
public class TestTile public class TestTile
{ {
[Fact] [Fact]
public void TestCreateCorrect() public void TestCreateCorrect()

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

Loading…
Cancel
Save