diff --git a/TheGameExtreme.Android/MainActivity.cs b/TheGameExtreme.Android/MainActivity.cs
index 167676f..05749b2 100644
--- a/TheGameExtreme.Android/MainActivity.cs
+++ b/TheGameExtreme.Android/MainActivity.cs
@@ -9,7 +9,7 @@ using Android.OS;
namespace TheGameExtreme.Droid
{
- [Activity(Label = "TheGameExtreme", Icon = "@mipmap/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
+ [Activity(Label = "TheGameExtreme", Icon = "@mipmap/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation, ScreenOrientation = ScreenOrientation.Landscape)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate(Bundle savedInstanceState)
@@ -30,4 +30,4 @@ namespace TheGameExtreme.Droid
base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
}
}
-}
\ No newline at end of file
+}
diff --git a/TheGameExtreme.Android/Properties/AndroidManifest.xml b/TheGameExtreme.Android/Properties/AndroidManifest.xml
index e1c2d4f..cb1c31c 100644
--- a/TheGameExtreme.Android/Properties/AndroidManifest.xml
+++ b/TheGameExtreme.Android/Properties/AndroidManifest.xml
@@ -1,6 +1,6 @@
-
-
-
-
\ No newline at end of file
+
+
+
+
diff --git a/TheGameExtreme.iOS/Info.plist b/TheGameExtreme.iOS/Info.plist
index 711e7cc..90ddd14 100644
--- a/TheGameExtreme.iOS/Info.plist
+++ b/TheGameExtreme.iOS/Info.plist
@@ -2,37 +2,36 @@
- UIDeviceFamily
-
- 1
- 2
-
- UISupportedInterfaceOrientations
-
- UIInterfaceOrientationPortrait
- UIInterfaceOrientationLandscapeLeft
- UIInterfaceOrientationLandscapeRight
-
- UISupportedInterfaceOrientations~ipad
-
- UIInterfaceOrientationPortrait
- UIInterfaceOrientationPortraitUpsideDown
- UIInterfaceOrientationLandscapeLeft
- UIInterfaceOrientationLandscapeRight
-
- MinimumOSVersion
- 8.0
- CFBundleDisplayName
- TheGameExtreme
- CFBundleIdentifier
- com.uca.TheGameExtreme
- CFBundleVersion
- 1.0
- UILaunchStoryboardName
- LaunchScreen
- CFBundleName
- TheGameExtreme
- XSAppIconAssets
- Assets.xcassets/AppIcon.appiconset
+ UIDeviceFamily
+
+ 1
+ 2
+
+ UISupportedInterfaceOrientations
+
+ UIInterfaceOrientationLandscapeLeft
+ UIInterfaceOrientationLandscapeRight
+
+ UISupportedInterfaceOrientations~ipad
+
+ UIInterfaceOrientationPortrait
+ UIInterfaceOrientationPortraitUpsideDown
+ UIInterfaceOrientationLandscapeLeft
+ UIInterfaceOrientationLandscapeRight
+
+ MinimumOSVersion
+ 8.0
+ CFBundleDisplayName
+ TheGameExtreme
+ CFBundleIdentifier
+ com.uca.TheGameExtreme
+ CFBundleVersion
+ 1.0
+ UILaunchStoryboardName
+ LaunchScreen
+ CFBundleName
+ TheGameExtreme
+ XSAppIconAssets
+ Assets.xcassets/AppIcon.appiconset
diff --git a/TheGameExtreme/model/deck/ClassicDeck.cs b/TheGameExtreme/model/deck/ClassicDeck.cs
index df3ba5f..72f53a1 100644
--- a/TheGameExtreme/model/deck/ClassicDeck.cs
+++ b/TheGameExtreme/model/deck/ClassicDeck.cs
@@ -1,10 +1,18 @@
using System;
+using TheGameExtreme.model.card;
+
namespace TheGameExtreme.model.deck
{
- public class ClassicDeck
+ public class ClassicDeck : Deck
{
public ClassicDeck()
{
+ Card card;
+ for (int i = 2; i <= 99; i++)
+ {
+ card = new ClassicCard(i);
+ deck.Add(card);
+ }
}
}
}
diff --git a/TheGameExtreme/model/deck/CreationDack.cs b/TheGameExtreme/model/deck/CreationDack.cs
deleted file mode 100644
index 1dbf3a7..0000000
--- a/TheGameExtreme/model/deck/CreationDack.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using System;
-using System.Collections.Generic;
-using TheGameExtreme.model.card;
-
-namespace TheGameExtreme.model
-{
- public abstract class CreationDack
- {
-
- private List deck = new List();
-
- public CreationDack()
- {
- }
- }
-}
diff --git a/TheGameExtreme/model/deck/Deck.cs b/TheGameExtreme/model/deck/Deck.cs
new file mode 100644
index 0000000..2028ce2
--- /dev/null
+++ b/TheGameExtreme/model/deck/Deck.cs
@@ -0,0 +1,32 @@
+using System;
+using System.Collections.Generic;
+using TheGameExtreme.model.card;
+
+namespace TheGameExtreme.model
+{
+ public abstract class Deck
+ {
+
+ protected List deck = new List();
+
+ public Deck()
+ {
+
+ }
+
+ public int size()
+ {
+ return deck.Count;
+ }
+
+ public void removeAt(int index)
+ {
+ deck.RemoveAt(index);
+ }
+
+ public Card getCard(int index)
+ {
+ return deck[index];
+ }
+ }
+}
diff --git a/TheGameExtreme/model/deck/ExtremeDeck.cs b/TheGameExtreme/model/deck/ExtremeDeck.cs
index b8d6589..0f33b68 100644
--- a/TheGameExtreme/model/deck/ExtremeDeck.cs
+++ b/TheGameExtreme/model/deck/ExtremeDeck.cs
@@ -1,10 +1,49 @@
using System;
+using System.Collections.Generic;
+using TheGameExtreme.model.card;
+
namespace TheGameExtreme.model.deck
{
- public class ExtremeDeck
+ public class ExtremeDeck : Deck
{
public ExtremeDeck()
{
+ Random random = new Random();
+ List endGame = new List();
+ while (endGame.Count < 4)
+ {
+ int r = random.Next(2, 99);
+ if (!endGame.Contains(r))
+ {
+ endGame.Add(r);
+ }
+ }
+ List threeCard = new List();
+ while (threeCard.Count < 4)
+ {
+ int r = random.Next(2, 99);
+ if (!endGame.Contains(r) && !threeCard.Contains(r))
+ {
+ threeCard.Add(r);
+ }
+ }
+ Card card;
+ for (int i = 2; i <= 99; i++)
+ {
+ if (endGame.Contains(i))
+ {
+ card = new EndGameCard(i);
+ }
+ else if (threeCard.Contains(i))
+ {
+ card = new ThreeCard(i);
+ }
+ else
+ {
+ card = new ClassicCard(i);
+ }
+ deck.Add(card);
+ }
}
}
}
diff --git a/TheGameExtreme/model/event/PlayerChangedEventArgs.cs b/TheGameExtreme/model/event/PlayerChangedEventArgs.cs
index 4e9095f..7c89ffb 100644
--- a/TheGameExtreme/model/event/PlayerChangedEventArgs.cs
+++ b/TheGameExtreme/model/event/PlayerChangedEventArgs.cs
@@ -7,11 +7,13 @@ namespace TheGameExtreme.model.@event
public class PlayerChangedEventArgs : EventArgs
{
+ public String Pseudo;
public List NewCurrentHand;
- public PlayerChangedEventArgs(List newCurrentHand)
+ public PlayerChangedEventArgs(List newCurrentHand, string pseudo)
{
NewCurrentHand = newCurrentHand;
+ Pseudo = pseudo;
}
}
}
diff --git a/TheGameExtreme/model/manager/GameManager.cs b/TheGameExtreme/model/manager/GameManager.cs
index 57778ad..6c9701d 100644
--- a/TheGameExtreme/model/manager/GameManager.cs
+++ b/TheGameExtreme/model/manager/GameManager.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using TheGameExtreme.model.card;
+using TheGameExtreme.model.deck;
using TheGameExtreme.model.@event;
namespace TheGameExtreme.model.manager
@@ -13,7 +14,7 @@ namespace TheGameExtreme.model.manager
protected int currentIndexPlayer;
protected List playerList = new List();
public List> ListOrderedStacks { get; set; }
- protected List deck = new List();
+ protected Deck deck;
protected bool win = true;
public String EndMessage { get; set; }
public event EventHandler TopRangeChanged;
@@ -60,41 +61,15 @@ namespace TheGameExtreme.model.manager
protected void createDeck()
{
- Random random = new Random();
- List endGame = new List();
- while (endGame.Count < 4)
+ switch (true)
{
- int r = random.Next(2, 99);
- if (!endGame.Contains(r))
- {
- endGame.Add(r);
- }
- }
- List threeCard = new List();
- while (threeCard.Count < 4)
- {
- int r = random.Next(2, 99);
- if (!endGame.Contains(r) && !threeCard.Contains(r))
- {
- threeCard.Add(r);
- }
- }
- Card card;
- for (int i = 2; i <= 99; i++)
- {
- if (endGame.Contains(i))
- {
- card = new EndGameCard(i);
- }
- else if (threeCard.Contains(i))
- {
- card = new ThreeCard(i);
- }
- else
- {
- card = new ClassicCard(i);
- }
- deck.Add(card);
+ case false:
+ deck = new ClassicDeck();
+ break;
+
+ default:
+ deck = new ExtremeDeck();
+ break;
}
}
@@ -119,9 +94,9 @@ namespace TheGameExtreme.model.manager
for (int i = 0; i < nbMaxCard; i++)
{
playerList.ForEach(player => {
- int r = new Random().Next(0, deck.Count - 1);
- player.pioche(deck[r]);
- deck.RemoveAt(r);
+ int r = new Random().Next(0, deck.size() - 1);
+ player.pioche(deck.getCard(r));
+ deck.removeAt(r);
});
}
}
diff --git a/TheGameExtreme/model/manager/SoloGameManager.cs b/TheGameExtreme/model/manager/SoloGameManager.cs
index 9d196be..6a2df8f 100644
--- a/TheGameExtreme/model/manager/SoloGameManager.cs
+++ b/TheGameExtreme/model/manager/SoloGameManager.cs
@@ -26,7 +26,7 @@ namespace TheGameExtreme.model.manager
currentIndexPlayer = 0;
}
CurrentHand = playerList[currentIndexPlayer].getCardList();
- OnPlayerChanged(new PlayerChangedEventArgs(CurrentHand));
+ OnPlayerChanged(new PlayerChangedEventArgs(CurrentHand, playerList[currentIndexPlayer].Pseudo));
nbCardAtBeginOfTurn = CurrentHand.Count;
CurrentCardPlayed.Clear();
@@ -85,13 +85,13 @@ namespace TheGameExtreme.model.manager
int nbPickedCard = nbMaxCard - CurrentHand.Count;
for (int i = 0; i < nbPickedCard; i++)
{
- if (deck.Count == 0)
+ if (deck.size() == 0)
{
return;
}
- int random = new Random().Next(0, deck.Count - 1);
- playerList[currentIndexPlayer].pioche(deck[random]);
- deck.RemoveAt(random);
+ int random = new Random().Next(0, deck.size() - 1);
+ playerList[currentIndexPlayer].pioche(deck.getCard(random));
+ deck.removeAt(random);
}
}
diff --git a/TheGameExtreme/model/manager/SoloGameManager.cs.orig b/TheGameExtreme/model/manager/SoloGameManager.cs.orig
deleted file mode 100644
index 5751b62..0000000
--- a/TheGameExtreme/model/manager/SoloGameManager.cs.orig
+++ /dev/null
@@ -1,164 +0,0 @@
-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 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 playableCard = new List();
- tryToFindSoluce(playableCard);
- return testEndGame(playableCard);
- }
- return false;
- }
-
- protected override void tryToFindSoluce(List 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 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 orderedStack in ListOrderedStacks)
- {
- if (orderedStack.Peek().GetType() == typeof(EndGameCard))
- {
- return true;
- }
- }
- return false;
- }
- }
-}
diff --git a/TheGameExtreme/view/MainPage.xaml b/TheGameExtreme/view/MainPage.xaml
index 5ba921d..c957131 100644
--- a/TheGameExtreme/view/MainPage.xaml
+++ b/TheGameExtreme/view/MainPage.xaml
@@ -16,6 +16,7 @@
+
CurrentHand { get; set; }
- private ObservableCollection> ListOrderedStacks;
+ //private ObservableCollection> ListOrderedStacks;
public Main()
@@ -43,12 +53,13 @@ namespace TheGameExtreme.viewmodel
CurrentHand = gameManager.CurrentHand;
- ListOrderedStacks = new ObservableCollection>(gameManager.ListOrderedStacks);
+ //ListOrderedStacks = new ObservableCollection>(gameManager.ListOrderedStacks);
}
protected internal void OnPlayerChanged(object source, PlayerChangedEventArgs args)
{
CurrentHand = args.NewCurrentHand;
+ Pseudo = args.Pseudo;
}
public void OnTopRangeChanged(object source, TopRangeChangedEventArgs args)