diff --git a/TestUnitaire/AppInitializer.cs b/TestUnitaire/AppInitializer.cs
new file mode 100644
index 0000000..af77aa0
--- /dev/null
+++ b/TestUnitaire/AppInitializer.cs
@@ -0,0 +1,42 @@
+using System;
+using System.IO;
+using System.Linq;
+using Xamarin.UITest;
+using Xamarin.UITest.Queries;
+
+namespace TestUnitaire
+{
+ public class AppInitializer
+ {
+ public static IApp StartApp(Platform platform)
+ {
+ // 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
+ // and select the app projects that should be tested.
+ //
+ // The iOS project should have the Xamarin.TestCloud.Agent NuGet package
+ // installed. To start the Test Cloud Agent the following code should be
+ // added to the FinishedLaunching method of the AppDelegate:
+ //
+ // #if ENABLE_TEST_CLOUD
+ // Xamarin.Calabash.Start();
+ // #endif
+ if (platform == Platform.Android)
+ {
+ return ConfigureApp
+ .Android
+ // TODO: Update this path to point to your Android app and uncomment the
+ // code if the app is not included in the solution.
+ //.ApkFile ("../../../Droid/bin/Debug/xamarinforms.apk")
+ .StartApp();
+ }
+
+ return ConfigureApp
+ .iOS
+ // TODO: Update this path to point to your iOS app and uncomment the
+ // code if the app is not included in the solution.
+ //.AppBundle ("../../../iOS/bin/iPhoneSimulator/Debug/XamarinForms.iOS.app")
+ .StartApp();
+ }
+ }
+}
diff --git a/TestUnitaire/TestUnitaire.csproj b/TestUnitaire/TestUnitaire.csproj
new file mode 100644
index 0000000..c3bb5ac
--- /dev/null
+++ b/TestUnitaire/TestUnitaire.csproj
@@ -0,0 +1,44 @@
+
+
+
+ Debug
+ AnyCPU
+ {DAB0A3A0-CD99-4819-A813-01F10D77BAB1}
+ Library
+ TestUnitaire
+ TestUnitaire
+ v4.7.2
+
+
+ true
+ full
+ false
+ bin\Debug
+ DEBUG;
+ prompt
+ 4
+
+
+ true
+ bin\Release
+ prompt
+ 4
+
+
+
+
+ ..\packages\NUnit.2.6.3\lib\nunit.framework.dll
+
+
+ ..\packages\Xamarin.UITest.2.2.7\lib\net45\Xamarin.UITest.dll
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/TestUnitaire/Tests.cs b/TestUnitaire/Tests.cs
new file mode 100644
index 0000000..8a34a6d
--- /dev/null
+++ b/TestUnitaire/Tests.cs
@@ -0,0 +1,34 @@
+using System;
+using System.IO;
+using System.Linq;
+using NUnit.Framework;
+using Xamarin.UITest;
+using Xamarin.UITest.Queries;
+
+namespace TestUnitaire
+{
+ [TestFixture(Platform.Android)]
+ [TestFixture(Platform.iOS)]
+ public class Tests
+ {
+ IApp app;
+ Platform platform;
+
+ public Tests(Platform platform)
+ {
+ this.platform = platform;
+ }
+
+ [SetUp]
+ public void BeforeEachTest()
+ {
+ app = AppInitializer.StartApp(platform);
+ }
+
+ [Test]
+ public void AppLaunches()
+ {
+ app.Screenshot("First screen.");
+ }
+ }
+}
diff --git a/TestUnitaire/packages.config b/TestUnitaire/packages.config
new file mode 100644
index 0000000..11318d5
--- /dev/null
+++ b/TestUnitaire/packages.config
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/TheGameExtreme.sln b/TheGameExtreme.sln
index 91580fa..d542605 100644
--- a/TheGameExtreme.sln
+++ b/TheGameExtreme.sln
@@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TheGameExtreme.iOS", "TheGa
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TheGameExtreme", "TheGameExtreme\TheGameExtreme.csproj", "{8DE6C881-FF77-4CC4-B8C4-CDEDD9AB13B3}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestUnitaire", "TestUnitaire\TestUnitaire.csproj", "{DAB0A3A0-CD99-4819-A813-01F10D77BAB1}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -53,5 +55,17 @@ Global
{8DE6C881-FF77-4CC4-B8C4-CDEDD9AB13B3}.Debug|iPhone.Build.0 = Debug|Any CPU
{8DE6C881-FF77-4CC4-B8C4-CDEDD9AB13B3}.Release|iPhone.ActiveCfg = Release|Any CPU
{8DE6C881-FF77-4CC4-B8C4-CDEDD9AB13B3}.Release|iPhone.Build.0 = Release|Any CPU
+ {DAB0A3A0-CD99-4819-A813-01F10D77BAB1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {DAB0A3A0-CD99-4819-A813-01F10D77BAB1}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {DAB0A3A0-CD99-4819-A813-01F10D77BAB1}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {DAB0A3A0-CD99-4819-A813-01F10D77BAB1}.Release|Any CPU.Build.0 = Release|Any CPU
+ {DAB0A3A0-CD99-4819-A813-01F10D77BAB1}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
+ {DAB0A3A0-CD99-4819-A813-01F10D77BAB1}.Debug|iPhoneSimulator.Build.0 = Debug|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}.Debug|iPhone.ActiveCfg = Debug|Any CPU
+ {DAB0A3A0-CD99-4819-A813-01F10D77BAB1}.Debug|iPhone.Build.0 = Debug|Any CPU
+ {DAB0A3A0-CD99-4819-A813-01F10D77BAB1}.Release|iPhone.ActiveCfg = Release|Any CPU
+ {DAB0A3A0-CD99-4819-A813-01F10D77BAB1}.Release|iPhone.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
diff --git a/TheGameExtreme/TheGameExtreme.csproj b/TheGameExtreme/TheGameExtreme.csproj
index ebbb853..d583dae 100644
--- a/TheGameExtreme/TheGameExtreme.csproj
+++ b/TheGameExtreme/TheGameExtreme.csproj
@@ -30,13 +30,13 @@
-
+
PublicResXFileCodeGenerator
AppResources.Designer.cs
-
+
AppResources.resx
diff --git a/TheGameExtreme/App.xaml b/TheGameExtreme/view/App.xaml
similarity index 100%
rename from TheGameExtreme/App.xaml
rename to TheGameExtreme/view/App.xaml
diff --git a/TheGameExtreme/App.xaml.cs b/TheGameExtreme/view/App.xaml.cs
similarity index 100%
rename from TheGameExtreme/App.xaml.cs
rename to TheGameExtreme/view/App.xaml.cs
diff --git a/TheGameExtreme/AppResources.Designer.cs b/TheGameExtreme/view/AppResources.Designer.cs
similarity index 93%
rename from TheGameExtreme/AppResources.Designer.cs
rename to TheGameExtreme/view/AppResources.Designer.cs
index 745769e..169b709 100644
--- a/TheGameExtreme/AppResources.Designer.cs
+++ b/TheGameExtreme/view/AppResources.Designer.cs
@@ -8,7 +8,7 @@
//
//------------------------------------------------------------------------------
-namespace TheGameExtreme {
+namespace TheGameExtreme.view {
using System;
using System.Reflection;
@@ -30,7 +30,7 @@ namespace TheGameExtreme {
public static System.Resources.ResourceManager ResourceManager {
get {
if (object.Equals(null, resourceMan)) {
- System.Resources.ResourceManager temp = new System.Resources.ResourceManager("TheGameExtreme.AppResources", typeof(AppResources).Assembly);
+ System.Resources.ResourceManager temp = new System.Resources.ResourceManager("TheGameExtreme.view.AppResources", typeof(AppResources).Assembly);
resourceMan = temp;
}
return resourceMan;
diff --git a/TheGameExtreme/AppResources.resx b/TheGameExtreme/view/AppResources.resx
similarity index 100%
rename from TheGameExtreme/AppResources.resx
rename to TheGameExtreme/view/AppResources.resx
diff --git a/TheGameExtreme/AssemblyInfo.cs b/TheGameExtreme/view/AssemblyInfo.cs
similarity index 100%
rename from TheGameExtreme/AssemblyInfo.cs
rename to TheGameExtreme/view/AssemblyInfo.cs
diff --git a/TheGameExtreme/view/MainPage.xaml b/TheGameExtreme/view/MainPage.xaml
index d8bc594..fbb8ebb 100644
--- a/TheGameExtreme/view/MainPage.xaml
+++ b/TheGameExtreme/view/MainPage.xaml
@@ -1,24 +1,33 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/TheGameExtreme/view/MainPage.xaml.cs b/TheGameExtreme/view/MainPage.xaml.cs
index b313461..45c7925 100644
--- a/TheGameExtreme/view/MainPage.xaml.cs
+++ b/TheGameExtreme/view/MainPage.xaml.cs
@@ -25,17 +25,22 @@ namespace TheGameExtreme
{
InitializeComponent();
- pile0.SetBinding(Label.TextProperty, new Binding("Text", source: viewmodel.Stack0));
- pile1.SetBinding(Label.TextProperty, new Binding("Text", source: viewmodel.Stack1));
- pile2.SetBinding(Label.TextProperty, new Binding("Text", source: viewmodel.Stack2));
- //pile3.SetBinding(Label.TextProperty, new Binding("Value", source: viewmodel.Stack3));
- //card1.SetBinding(Button.TextProperty, new Binding("Text", source: viewmodel.))
+ pile0.SetBinding(Label.TextProperty, new Binding("Stack0", source: viewmodel));
+ pile1.SetBinding(Label.TextProperty, new Binding("Stack1", source: viewmodel));
+ pile2.SetBinding(Label.TextProperty, new Binding("Stack2", source: viewmodel));
+ pile3.SetBinding(Label.TextProperty, new Binding("Stack3", source: viewmodel));
+ card1.SetBinding(Button.TextProperty, new Binding("ValueCard1", source: viewmodel));
+ card2.SetBinding(Button.TextProperty, new Binding("ValueCard2", source: viewmodel));
+ card3.SetBinding(Button.TextProperty, new Binding("ValueCard3", source: viewmodel));
+ card4.SetBinding(Button.TextProperty, new Binding("ValueCard4", source: viewmodel));
+ card5.SetBinding(Button.TextProperty, new Binding("ValueCard5", source: viewmodel));
+ card6.SetBinding(Button.TextProperty, new Binding("ValueCard6", source: viewmodel));
+ card7.SetBinding(Button.TextProperty, new Binding("ValueCard7", source: viewmodel));
}
private void played(object sender, EventArgs args)
{
- string text = (sender as Button).Text;
- viewmodel.played(text);
+ viewmodel.played((sender as Button).CommandParameter as string);
}
private void endTurn(object sender, EventArgs args)
diff --git a/TheGameExtreme/viewmodel/Main.cs b/TheGameExtreme/viewmodel/Main.cs
index db50aad..7453859 100644
--- a/TheGameExtreme/viewmodel/Main.cs
+++ b/TheGameExtreme/viewmodel/Main.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.ComponentModel;
using TheGameExtreme.model;
using TheGameExtreme.model.@event;
using TheGameExtreme.model.manager;
@@ -7,19 +8,76 @@ using Xamarin.Forms;
namespace TheGameExtreme.viewmodel
{
- public class Main
+ public class Main : INotifyPropertyChanged
{
private List players;
private GameManager gameManager;
private int currentIndexPlayer;
- public string Stack0 { get; set; } = "1";
- public string Stack1 { get; set; } = "1";
- public string Stack2 { get; set; } = "100";
- public string Stack3 { get; set; } = "100";
+
+ public event PropertyChangedEventHandler PropertyChanged;
+ private string stack0;
+ public String Stack0
+ {
+ get { return stack0; }
+ set
+ {
+ stack0 = value;
+ OnPropertyChanged("Stack0");
+ }
+ }
+ public string stack1;
+ public String Stack1
+ {
+ get { return stack1; }
+ set
+ {
+ stack1 = value;
+ OnPropertyChanged("Stack1");
+ }
+ }
+ public string stack2;
+ public String Stack2
+ {
+ get { return stack2; }
+ set
+ {
+ stack2 = value;
+ OnPropertyChanged("Stack2");
+ }
+ }
+ public string stack3;
+ public String Stack3
+ {
+ get { return stack3; }
+ set
+ {
+ stack3 = value;
+ OnPropertyChanged("Stack3");
+ }
+ }
+ private int valueCard1;
+ public int ValueCard1
+ {
+ get { return valueCard1; }
+ set
+ {
+ valueCard1 = value;
+ OnPropertyChanged("ValueCard1");
+ }
+ }
+ private void OnPropertyChanged(string v)
+ {
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(v));
+ }
public Main()
{
+ stack0 = "1";
+ stack1 = "1";
+ stack2 = "100";
+ stack3 = "100";
+
players = new List { new Player("Clément"), new Player("Baptiste") };
gameManager = new SoloGameManager(2, players);
@@ -30,7 +88,8 @@ namespace TheGameExtreme.viewmodel
player.HandCardChanged += OnHandCardChanged;
});
gameManager.CurrentPlayerChanged += OnCurrentPlayerChanged;
- // Ecoute le changement de vue
+
+ valueCard1 = players[currentIndexPlayer].getCardList()[0].Value;
}
public void OnTopRangeChanged(object source, TopRangeChangedEventArgs args)
@@ -38,7 +97,7 @@ namespace TheGameExtreme.viewmodel
switch (args.NumStackChanged)
{
case 0:
- Stack0 = args.NewTopRangeCard.Value.ToString();
+ stack0 = args.NewTopRangeCard.Value.ToString();
break;
case 1:
Stack1 = args.NewTopRangeCard.Value.ToString();
@@ -52,17 +111,13 @@ namespace TheGameExtreme.viewmodel
}
}
- private void OnHandCardChanged(object source, HandCardChangedEventArgs args)
+ private void OnHandCardChanged(object source, HandCardChangedEventArgs args) // Double les appels car les joueurs sont les mêmes dans le model et ici
{
- //if (args.NewHandCard == null)
- //{
- // players[currentIndexPlayer].getCardList().Remove(args.OldHandCard);
- //}
- //else
- //{
- // players[currentIndexPlayer].getCardList().Add(args.NewHandCard);
- //}
+ players[currentIndexPlayer].getCardList().ForEach(card =>
+ {
+ });
+ valueCard1 = players[currentIndexPlayer].getCardList()[0].Value;
}
private void OnCurrentPlayerChanged(object source, CurrentPlayerChangedEventArgs args)
@@ -87,25 +142,25 @@ namespace TheGameExtreme.viewmodel
{
switch (text)
{
- case "Card 1":
+ case "card1":
gameManager.joue(players[currentIndexPlayer].getCardList()[0], r);
break;
- case "Card 2":
+ case "card2":
gameManager.joue(players[currentIndexPlayer].getCardList()[1], r);
break;
- case "Card 3":
+ case "card3":
gameManager.joue(players[currentIndexPlayer].getCardList()[2], r);
break;
- case "Card 4":
+ case "card4":
gameManager.joue(players[currentIndexPlayer].getCardList()[3], r);
break;
- case "Card 5":
+ case "card5":
gameManager.joue(players[currentIndexPlayer].getCardList()[4], r);
break;
- case "Card 6":
+ case "card6":
gameManager.joue(players[currentIndexPlayer].getCardList()[5], r);
break;
- case "Card 7":
+ case "card7":
gameManager.joue(players[currentIndexPlayer].getCardList()[6], r);
break;
}