🚧 Ajout de multiples fontions

pull/41/head
Lucas DUFLOT 1 year ago
parent 4729656fd0
commit 88f85256c4

@ -3,6 +3,7 @@
using Models; using Models;
using Models.Game;
Position pos01 = new Position(0,0); Position pos01 = new Position(0,0);
Position pos02 = new Position(1,0); Position pos02 = new Position(1,0);

@ -4,7 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Models namespace Models.Game
{ {
public class De public class De
{ {
@ -37,5 +37,11 @@ namespace Models
{ {
Nb = new Random().Next(NbMin, NbMax + 1); Nb = new Random().Next(NbMin, NbMax + 1);
} }
public bool IsLower(De de1)
{
if (de1.Nb > this.Nb) return true;
else return false;
}
} }
} }

@ -0,0 +1,71 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Models.Game
{
public class Game
{
public Player CurentPlayer { get; set; }
public Map NameMap { get; set; }
public De De1 { get; set; }
public De De2 { get; set; }
public int Turn { get; set; }
public Game(Player player,Map map)
{
NameMap = map;
CurentPlayer = player;
De1 = new De();
De2 = new De(1);
Turn = 0;
}
public void ThrowDice()
{
De1.Lancer();
De2.Lancer();
}
public int ChooseOperation(Operation o)
{
switch (o)
{
case Operation.LOWER:
if (De1.IsLower(De2))
{
return De1.Nb;
}
return De2.Nb;
case Operation.HIGHER:
if (De1.IsLower(De2))
{
return De2.Nb;
}
return De1.Nb;
case Operation.SUBTRACTION:
if (De1.IsLower(De2))
{
return De2.Nb - De1.Nb;
}
return De1.Nb - De2.Nb;
case Operation.ADDITION:
return De2.Nb + De1.Nb;
case Operation.MULTIPLICATION:
return De2.Nb * De1.Nb;
default:
return 0;
}
}
}
}

@ -1,4 +1,4 @@
namespace Models; namespace Models.Game;
public class Map public class Map
{ {

@ -1,4 +1,4 @@
namespace Models; namespace Models.Game;
public class Player public class Player
{ {
@ -18,4 +18,11 @@ public class Player
ProfilePicture = profilePicture; ProfilePicture = profilePicture;
} }
public Operation ChooseOperation()
{
return Operation.LOWER
}
} }

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Models.Rules
{
public class Rules
{
public bool NearCell(Cell playerChoice, List<Cell> cells)
{
foreach (var item in cells)
{
if(playerChoice.X == item.X +1 || playerChoice.X == item.X - 1
|| playerChoice.Y == item.Y +1 || playerChoice.Y == item.Y -1 )
{
return true;
}
}
return false;
}
}
}

@ -0,0 +1,21 @@
using Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Tests
{
public class OperationGridTest
{
public string Name = "toto";
[Theory]
[InlineData("toto")]
[InlineData(" ")]
public void testResultGrid(string name)
{
}
}
}
Loading…
Cancel
Save