Merge request

master
cldupland 6 years ago
commit b196a1fd2b

@ -1,19 +0,0 @@
using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TheGameExtreme.model;
using TheGameExtreme.model.manager;
using TheGameExtreme.viewmodel;
namespace ProjectUnitaire
{
[TestClass]
public class TestUnit
{
[TestMethod]
public void EndTurnTest()
{
}
}
}

@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="MSTest.TestAdapter" Version="1.4.0" />
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" />
<PackageReference Include="coverlet.collector" Version="1.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TheGameExtreme.Android\TheGameExtreme.Android.csproj" />
<ProjectReference Include="..\TheGameExtreme.iOS\TheGameExtreme.iOS.csproj" />
<ProjectReference Include="..\TheGameExtreme\TheGameExtreme.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,11 @@
namespace TestUnit
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
}
}
}

@ -9,7 +9,7 @@ namespace TestUnitaire
{ {
public class AppInitializer public class AppInitializer
{ {
public static IApp StartApp(Platform platform) /*public static IApp StartApp(Platform platform)
{ {
// TODO: If the iOS or Android app being tested is included in the solution // TODO: If the iOS or Android app being tested is included in the solution
// then open the Unit Tests window, right click Test Apps, select Add App Project // then open the Unit Tests window, right click Test Apps, select Add App Project
@ -38,6 +38,6 @@ namespace TestUnitaire
// code if the app is not included in the solution. // code if the app is not included in the solution.
//.AppBundle ("../../../iOS/bin/iPhoneSimulator/Debug/XamarinForms.iOS.app") //.AppBundle ("../../../iOS/bin/iPhoneSimulator/Debug/XamarinForms.iOS.app")
.StartApp(); .StartApp();
} }*/
} }
} }

@ -1,11 +1,11 @@
#pragma warning disable 1591 #pragma warning disable 1591
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // Ce code a été généré par un outil.
// Runtime Version:4.0.30319.42000 // Version du runtime :4.0.30319.42000
// //
// Changes to this file may cause incorrect behavior and will be lost if // Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si
// the code is regenerated. // le code est régénéré.
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------

@ -10,7 +10,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TheGameExtreme", "TheGameEx
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestUnitaire", "TestUnitaire\TestUnitaire.csproj", "{DAB0A3A0-CD99-4819-A813-01F10D77BAB1}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestUnitaire", "TestUnitaire\TestUnitaire.csproj", "{DAB0A3A0-CD99-4819-A813-01F10D77BAB1}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProjectUnitaire", "ProjectUnitaire\ProjectUnitaire.csproj", "{FA55654F-097D-4E83-809E-A2C7E46563A4}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTestProjectGame", "UnitTestProjectGame\UnitTestProjectGame.csproj", "{4092C852-D253-42F7-A800-E618C99C349E}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -70,18 +70,18 @@ Global
{DAB0A3A0-CD99-4819-A813-01F10D77BAB1}.Release|iPhone.Build.0 = Release|Any CPU {DAB0A3A0-CD99-4819-A813-01F10D77BAB1}.Release|iPhone.Build.0 = Release|Any CPU
{DAB0A3A0-CD99-4819-A813-01F10D77BAB1}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU {DAB0A3A0-CD99-4819-A813-01F10D77BAB1}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{DAB0A3A0-CD99-4819-A813-01F10D77BAB1}.Release|iPhoneSimulator.Build.0 = Release|Any CPU {DAB0A3A0-CD99-4819-A813-01F10D77BAB1}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{FA55654F-097D-4E83-809E-A2C7E46563A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {4092C852-D253-42F7-A800-E618C99C349E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FA55654F-097D-4E83-809E-A2C7E46563A4}.Debug|Any CPU.Build.0 = Debug|Any CPU {4092C852-D253-42F7-A800-E618C99C349E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FA55654F-097D-4E83-809E-A2C7E46563A4}.Debug|iPhone.ActiveCfg = Debug|Any CPU {4092C852-D253-42F7-A800-E618C99C349E}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{FA55654F-097D-4E83-809E-A2C7E46563A4}.Debug|iPhone.Build.0 = Debug|Any CPU {4092C852-D253-42F7-A800-E618C99C349E}.Debug|iPhone.Build.0 = Debug|Any CPU
{FA55654F-097D-4E83-809E-A2C7E46563A4}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU {4092C852-D253-42F7-A800-E618C99C349E}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{FA55654F-097D-4E83-809E-A2C7E46563A4}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU {4092C852-D253-42F7-A800-E618C99C349E}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{FA55654F-097D-4E83-809E-A2C7E46563A4}.Release|Any CPU.ActiveCfg = Release|Any CPU {4092C852-D253-42F7-A800-E618C99C349E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FA55654F-097D-4E83-809E-A2C7E46563A4}.Release|Any CPU.Build.0 = Release|Any CPU {4092C852-D253-42F7-A800-E618C99C349E}.Release|Any CPU.Build.0 = Release|Any CPU
{FA55654F-097D-4E83-809E-A2C7E46563A4}.Release|iPhone.ActiveCfg = Release|Any CPU {4092C852-D253-42F7-A800-E618C99C349E}.Release|iPhone.ActiveCfg = Release|Any CPU
{FA55654F-097D-4E83-809E-A2C7E46563A4}.Release|iPhone.Build.0 = Release|Any CPU {4092C852-D253-42F7-A800-E618C99C349E}.Release|iPhone.Build.0 = Release|Any CPU
{FA55654F-097D-4E83-809E-A2C7E46563A4}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU {4092C852-D253-42F7-A800-E618C99C349E}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{FA55654F-097D-4E83-809E-A2C7E46563A4}.Release|iPhoneSimulator.Build.0 = Release|Any CPU {4092C852-D253-42F7-A800-E618C99C349E}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using TheGameExtreme.model.card; using TheGameExtreme.model.card;
using TheGameExtreme.model.@event; using TheGameExtreme.model.@event;

@ -0,0 +1,164 @@
using System;
using System.Collections.Generic;
using TheGameExtreme.model.card;
using TheGameExtreme.model.@event;
namespace TheGameExtreme.model.manager
{
public class SoloGameManager : GameManager
{
public SoloGameManager(int nbPlayer, List<String> players)
: base(nbPlayer, players)
{
}
public override bool endTurn()
{
<<<<<<< HEAD
verifyNbCardPlay();
=======
// Vérifie que l'utilisateur a bien joué deux cartes
>>>>>>> c1e072686aecc6833e1faf062739820e55484d86
pioche();
currentIndexPlayer += 1;
if (currentIndexPlayer == playerList.Count)
{
currentIndexPlayer = 0;
}
CurrentHand = playerList[currentIndexPlayer].getCardList();
OnPlayerChanged(new PlayerChangedEventArgs(CurrentHand));
nbCardAtBeginOfTurn = CurrentHand.Count;
CurrentCardPlayed.Clear();
if (isEndGame()) // Ajouter le score en calculant les cartes restantes dans la pile et dans les mains des joueurs
{
displayWinner();
return true;
}
return false;
}
protected void verifyNbCardPlay()
{
foreach (Card cardPlayed in CurrentCardPlayed)
{
if (cardPlayed.GetType() == typeof(ThreeCard))
{
if ((nbCardAtBeginOfTurn - CurrentHand.Count) < 3) // Penser à vérifier s'il a joué une ThreeCard pour regarder s'il a bien joué 3 cartes
{
testIsEndGame();
}
return;
}
}
if ((nbCardAtBeginOfTurn - CurrentHand.Count) < 2) // Penser à vérifier s'il a joué une ThreeCard pour regarder s'il a bien joué 3 cartes
{
testIsEndGame();
}
}
protected void testIsEndGame()
{
if (isEndGame())
{
displayWinner();
}
else
{
throw new Exception("Vous n'avez pas joué assez de carte!");
}
}
protected void displayWinner()
{
if (win)
{
EndMessage = "Le jeu est terminé!\n Bravo vous avez gagné!";
}
}
protected override void pioche()
{
int nbPickedCard = nbMaxCard - CurrentHand.Count;
for (int i = 0; i < nbPickedCard; i++)
{
if (deck.Count == 0)
{
return;
}
int random = new Random().Next(0, deck.Count - 1);
playerList[currentIndexPlayer].pioche(deck[random]);
deck.RemoveAt(random);
}
}
protected override bool isEndGame()
{
if (CurrentHand.Count != 0)
{
List<Card> playableCard = new List<Card>();
tryToFindSoluce(playableCard);
return testEndGame(playableCard);
}
return false;
}
protected override void tryToFindSoluce(List<Card> playableCard)
{
CurrentHand.ForEach(card =>
{
if (card.Value > ListOrderedStacks[0].Peek().Value || card.Value > ListOrderedStacks[1].Peek().Value || card.Value < ListOrderedStacks[2].Peek().Value || card.Value < ListOrderedStacks[3].Peek().Value)
{
playableCard.Add(card);
}
});
}
protected override bool testEndGame(List<Card> playableCard)
{
if (playableCard.Count == 2)
{
foreach (Card c in playableCard)
{
if (c.Equals(typeof(ThreeCard)))
{
win = false;
EndMessage = "Le jeu est terminé!\n Désolé, vous avez perdu... Vous deviez jouer trois cartes à cause de l'effet \"Trois cartes joué\" hors votre jeu ne permet pas d'en jouer autant! Essayez encore!";
return true;
}
}
}
else if (playableCard.Count < 2)
{
win = false;
EndMessage = "Le jeu est terminé!\n Désolé, vous avez perdu... Essayez encore!";
return true;
}
else if (effectLose())
{
win = false;
EndMessage = "Désolé, vous n'avez pas recouvert la tête de mort... Réessayez ;)";
return true;
}
return false;
}
protected override bool effectLose()
{
foreach (Stack<Card> orderedStack in ListOrderedStacks)
{
if (orderedStack.Peek().GetType() == typeof(EndGameCard))
{
return true;
}
}
return false;
}
}
}

@ -2,18 +2,18 @@ using System.Reflection;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
[assembly: AssemblyTitle("ProjectUnitaire")] [assembly: AssemblyTitle("UnitTestProjectGame")]
[assembly: AssemblyDescription("")] [assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")] [assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")] [assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ProjectUnitaire")] [assembly: AssemblyProduct("UnitTestProjectGame")]
[assembly: AssemblyCopyright("Copyright © 2019")] [assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")] [assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: ComVisible(false)] [assembly: ComVisible(false)]
[assembly: Guid("fa55654f-097d-4e83-809e-a2c7e46563a4")] [assembly: Guid("4092c852-d253-42f7-a800-e618c99c349e")]
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyVersion("1.0.0.0")]

@ -0,0 +1,71 @@
using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TheGameExtreme.model;
using TheGameExtreme.model.manager;
using TheGameExtreme.viewmodel;
namespace UnitTestProjectGame
{
[TestClass]
public class UnitTest1
{
GameManager g1 = new SoloGameManager(2, new List<String> { "clement", " baptiste" });
[TestMethod]
public void JoueTest()
{
object expectedRes = null;
int valueCard = 89;
int orderedStackSelected = 3;
g1.joue(valueCard, orderedStackSelected);
Assert.AreEqual(expectedRes, null);
}
[TestMethod]
public void isCanPlayTest()
{
List<Card> currentHhand = new List<Card>();
bool valeur;
bool expected1 = true;
bool expected2 = false;
g1.isCanPlay();
if(g1.isCanPlay() == true)
{
valeur = true;
Assert.AreEqual(expected1, valeur);
}
/*else
{
//Exception à gérer//
}*/
if(g1.isCanPlay() == false)
{
valeur = false;
Assert.Equals(expected2, valeur);
}
else
{
//Exception à gérer//
}
}
[TestMethod]
public void EndTurnTest()
{
object expectedRes = null;
g1.endTurn();
Assert.AreEqual(expectedRes, null);
}
[TestMethod]
public void getCurentIndexPlayerTest()
{
}
}
}

@ -5,11 +5,11 @@
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{FA55654F-097D-4E83-809E-A2C7E46563A4}</ProjectGuid> <ProjectGuid>{4092C852-D253-42F7-A800-E618C99C349E}</ProjectGuid>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ProjectUnitaire</RootNamespace> <RootNamespace>UnitTestProjectGame</RootNamespace>
<AssemblyName>ProjectUnitaire</AssemblyName> <AssemblyName>UnitTestProjectGame</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
@ -49,7 +49,7 @@
<Reference Include="System.Core" /> <Reference Include="System.Core" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="TestUnit.cs" /> <Compile Include="UnitTest1.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -57,7 +57,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\TheGameExtreme\TheGameExtreme.csproj"> <ProjectReference Include="..\TheGameExtreme\TheGameExtreme.csproj">
<Project>{8de6c881-ff77-4cc4-b8c4-cdedd9ab13b3}</Project> <Project>{8DE6C881-FF77-4CC4-B8C4-CDEDD9AB13B3}</Project>
<Name>TheGameExtreme</Name> <Name>TheGameExtreme</Name>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
Loading…
Cancel
Save