Modification de la génération des fractions, des placements et début d'implémentation du pas pour les fractions

master
cldupland 5 years ago
parent f98ba11ac7
commit d19e9ab6f1

@ -2,4 +2,7 @@ Mono-utilisateur:
- Multilangue
- Changer les thèmes et les couleurs (en option) V => pour l'instant thème blanc et noir
- Option pour mettre/enlever le pas de 10
- gérer les différents pas pour les différents deck (multiples, etc...)
- gérer les différents pas pour les différents deck (multiples, etc...)
- Largeur carte pour millième V
- Génération fraction -> toutes celles qui ont un chiffre au numérateur et/ou au dénominateur unique + les fractions ayant un numérateur et un dénominateur entre 1 et 25 puis si non suffisant, entre 1 et 50
- Bluetooth

@ -29,6 +29,7 @@
<Folder Include="model\card\cardType\" />
<Folder Include="model\piles\" />
<Folder Include="model\gameActions\decimals\" />
<Folder Include="model\gameActions\abstractRules\" />
</ItemGroup>
<ItemGroup>
<Compile Remove="model\effect\StopColm.cs" />

@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using TheGameExtreme.model.gameActions.classic;
using TheGameExtreme.model.piles;
using TheGameExtreme.model.gameActions.abstractRules;
namespace TheGameExtreme.model
{

@ -12,11 +12,29 @@ namespace TheGameExtreme.model.deck
public FractionDeck(int nbCard, decimal borneMin, decimal borneMax) : base(nbCard)
{
Random random = new Random();
for (int j = 1; j < 10; j++)
{
for (int i = 1; i < 10; i++)
{
if (deck.Count < nbCard)
{
InsertionDichotomique(deck, 0, deck.Count - 1, new FractionCard(new Fraction(i, j)));
}
else
{
return;
}
}
}
while (deck.Count < nbCard)
{
int numerateur = random.Next(1, 99);
int denominateur = random.Next(1, 99);
if ((decimal)(numerateur / denominateur) > borneMin && (decimal)(numerateur / denominateur) < borneMax)
int numerateur = random.Next(10, 25);
int denominateur = random.Next(10, 25);
decimal d = (decimal)numerateur / (decimal)denominateur;
if (d.CompareTo(borneMin) > 0 && d.CompareTo(borneMax) < 0)
{
int pgcd = PGCD(numerateur, denominateur);
while (pgcd != 1)

@ -1,7 +1,7 @@
using System;
using TheGameExtreme.model.piles;
namespace TheGameExtreme.model.gameActions
namespace TheGameExtreme.model.gameActions.abstractRules
{
public abstract class GameAction
{

@ -5,11 +5,10 @@ using TheGameExtreme.model.deck;
using TheGameExtreme.model.@event;
using TheGameExtreme.model.piles;
namespace TheGameExtreme.model.gameActions.classic
namespace TheGameExtreme.model.gameActions.abstractRules
{
public class GameMode
public abstract class GameMode
{
protected List<GameAction> gameActions;
public Piles Piles { get; protected set; }
public int NbCardAtBeginOfTurn { get; set; }
@ -35,22 +34,14 @@ namespace TheGameExtreme.model.gameActions.classic
#endregion
public GameMode(Piles piles, Deck deck)
protected GameMode(Piles piles, Deck deck)
{
gameActions = new List<GameAction>();
Piles = piles;
this.deck = deck;
}
public void load(int nbPlayer, List<Player> players)
{
gameActions.Add(new Piocher(Piles));
gameActions.Add(new JouerUneCarte(Piles));
gameActions.Add(new TerminerSonTour(Piles));
defineNbMaxCard(nbPlayer);
distribueCard(players);
}
public abstract void load(int nbPlayer, List<Player> players);
protected void defineNbMaxCard(int nbPlayer)
{
@ -109,60 +100,17 @@ namespace TheGameExtreme.model.gameActions.classic
deck.removeAt(r);
}
List<Card> cards = player.getCardList();
quickSort(cards, 0, cards.Count-1);
quickSort(cards, 0, cards.Count - 1);
});
}
public void pioche(List<Card> currentHand, Player player)
{
Message = null;
((Piocher)gameActions[0]).pioche(currentHand, deck, player, nbMaxCard);
quickSort(currentHand, 0, currentHand.Count - 1);
}
public abstract void pioche(List<Card> currentHand, Player player);
public bool playCard(decimal valueCard, List<Card> currentHand, int orderedStackSelected, Player player, List<Card> CurrentCardPlayed)
{
Message = null;
if (((JouerUneCarte)gameActions[1]).play(valueCard, currentHand, orderedStackSelected, player, CurrentCardPlayed))
{
return true;
}
else
{
Message = ((JouerUneCarte)gameActions[1]).ErrorMessage;
return false;
}
}
public abstract bool playCard(decimal valueCard, List<Card> currentHand, int orderedStackSelected, Player player, List<Card> CurrentCardPlayed);
public bool endTurn(List<Card> currentHand, List<Card> CurrentCardPlayed, Player player)
{
Message = null;
if (((TerminerSonTour)gameActions[2]).end(currentHand, CurrentCardPlayed))
{
pioche(currentHand, player);
CurrentCardPlayed.Clear();
OnPlayerChanged(null);
return end;
}
else
{
Message = ((TerminerSonTour)gameActions[2]).ErrorMessage;
return false;
}
}
public abstract bool endTurn(List<Card> currentHand, List<Card> CurrentCardPlayed, Player player);
public void TestEndGame(List<Card> currentHand)
{
if (((TerminerSonTour)gameActions[2]).Test(currentHand))
{
end = false;
}
else
{
OnEndGame(new EventArgs());
end = true;
}
}
public abstract void TestEndGame(List<Card> currentHand);
public string getScore()
{

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using TheGameExtreme.model.card;
using TheGameExtreme.model.piles;
namespace TheGameExtreme.model.gameActions.abstractRules
{
public abstract class JouerUneCarte : GameAction
{
public Card OldCard { get; set; }
protected JouerUneCarte(Piles ListOrderedStacks) : base(ListOrderedStacks)
{
}
public abstract bool play(decimal valueCard, List<Card> CurrentHand, int orderedStackSelected, Player player, List<Card> CurrentCardPlayed);
protected abstract bool Rule(Card card, Stack<Card> stack, bool bottomUp, Player player, List<Card> CurrentCardPlayed);
}
}

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using TheGameExtreme.model.card;
using TheGameExtreme.model.deck;
using TheGameExtreme.model.piles;
namespace TheGameExtreme.model.gameActions.abstractRules
{
public abstract class Piocher : GameAction
{
public Piocher(Piles ListOrderedStacks) : base(ListOrderedStacks)
{
}
public abstract void pioche(List<Card> CurrentHand, Deck deck, Player player, int nbMaxCard);
}
}

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using TheGameExtreme.model.card;
using TheGameExtreme.model.piles;
namespace TheGameExtreme.model.gameActions.abstractRules
{
public abstract class TerminerSonTour : GameAction
{
protected TerminerSonTour(Piles ListOrderedStacks) : base(ListOrderedStacks)
{
}
public abstract bool end(List<Card> CurrentHand, List<Card> CurrentCardPlayed);
public bool Test(List<Card> CurrentHand)
{
if (CurrentHand.Count != 0)
{
List<Card> playableCard = new List<Card>();
tryToFindSoluce(playableCard, CurrentHand);
return testEndGame(playableCard);
}
return false;
}
protected abstract void tryToFindSoluce(List<Card> playableCard, List<Card> CurrentHand);
protected abstract bool testEndGame(List<Card> playableCard);
}
}

@ -0,0 +1,78 @@
using System;
using System.Collections.Generic;
using TheGameExtreme.model.card;
using TheGameExtreme.model.deck;
using TheGameExtreme.model.gameActions.abstractRules;
using TheGameExtreme.model.piles;
namespace TheGameExtreme.model.gameActions.classic
{
public class GameModeClassic : GameMode
{
public GameModeClassic(Piles piles, Deck deck) : base(piles, deck)
{
}
override public void load(int nbPlayer, List<Player> players)
{
gameActions.Add(new PiocherClassic(Piles));
gameActions.Add(new JouerUneCarteClassic(Piles));
gameActions.Add(new TerminerSonTourClassic(Piles));
defineNbMaxCard(nbPlayer);
distribueCard(players);
}
override public void pioche(List<Card> currentHand, Player player)
{
Message = null;
((PiocherClassic)gameActions[0]).pioche(currentHand, deck, player, nbMaxCard);
quickSort(currentHand, 0, currentHand.Count - 1);
}
override public bool playCard(decimal valueCard, List<Card> currentHand, int orderedStackSelected, Player player, List<Card> CurrentCardPlayed)
{
Message = null;
if (((JouerUneCarteClassic)gameActions[1]).play(valueCard, currentHand, orderedStackSelected, player, CurrentCardPlayed))
{
return true;
}
else
{
Message = ((JouerUneCarteClassic)gameActions[1]).ErrorMessage;
return false;
}
}
override public bool endTurn(List<Card> currentHand, List<Card> CurrentCardPlayed, Player player)
{
Message = null;
if (((TerminerSonTourClassic)gameActions[2]).end(currentHand, CurrentCardPlayed))
{
pioche(currentHand, player);
CurrentCardPlayed.Clear();
OnPlayerChanged(null);
return end;
}
else
{
Message = ((TerminerSonTourClassic)gameActions[2]).ErrorMessage;
return false;
}
}
override public void TestEndGame(List<Card> currentHand)
{
if (((TerminerSonTourClassic)gameActions[2]).Test(currentHand))
{
end = false;
}
else
{
OnEndGame(new EventArgs());
end = true;
}
}
}
}

@ -1,21 +1,19 @@
using System;
using System.Collections.Generic;
using TheGameExtreme.model.card;
using TheGameExtreme.model.gameActions.abstractRules;
using TheGameExtreme.model.piles;
namespace TheGameExtreme.model.gameActions.classic
{
public class JouerUneCarte : GameAction
public class JouerUneCarteClassic : JouerUneCarte
{
public Card OldCard { get; set; }
public JouerUneCarte(Piles ListOrderedStacks) : base(ListOrderedStacks)
public JouerUneCarteClassic(Piles ListOrderedStacks) : base(ListOrderedStacks)
{
}
public bool play(decimal valueCard, List<Card> CurrentHand, int orderedStackSelected, Player player, List<Card> CurrentCardPlayed)
override public bool play(decimal valueCard, List<Card> CurrentHand, int orderedStackSelected, Player player, List<Card> CurrentCardPlayed)
{
foreach (Card card in CurrentHand)
{
@ -50,7 +48,7 @@ namespace TheGameExtreme.model.gameActions.classic
return false;
}
protected bool Rule(Card card, Stack<Card> stack, bool bottomUp, Player player, List<Card> CurrentCardPlayed)
override protected bool Rule(Card card, Stack<Card> stack, bool bottomUp, Player player, List<Card> CurrentCardPlayed)
{
if ((bottomUp && card.Value.CompareTo(stack.Peek().Value) > 0) || (!bottomUp && card.Value.CompareTo(stack.Peek().Value) < 0) || card.Value.CompareTo(stack.Peek().Value - 10) == 0 || card.Value.CompareTo(stack.Peek().Value + 10) == 0)
{

@ -2,23 +2,19 @@
using System.Collections.Generic;
using TheGameExtreme.model.card;
using TheGameExtreme.model.deck;
using TheGameExtreme.model.gameActions.abstractRules;
using TheGameExtreme.model.piles;
namespace TheGameExtreme.model.gameActions.classic
{
public class Piocher : GameAction
public class PiocherClassic : Piocher
{
public Piocher(Piles ListOrderedStacks) : base(ListOrderedStacks)
public PiocherClassic(Piles ListOrderedStacks) : base(ListOrderedStacks)
{
}
protected bool checkRule()
{
return true;
}
public void pioche(List<Card> CurrentHand, Deck deck, Player player, int nbMaxCard)
override public void pioche(List<Card> CurrentHand, Deck deck, Player player, int nbMaxCard)
{
int nbPickedCard = nbMaxCard - CurrentHand.Count;
for (int i = 0; i < nbPickedCard; i++)

@ -1,24 +1,23 @@
using System;
using System.Collections.Generic;
using TheGameExtreme.model.card;
using TheGameExtreme.model.card.rapidCard;
using TheGameExtreme.model.gameActions.abstractRules;
using TheGameExtreme.model.piles;
namespace TheGameExtreme.model.gameActions.classic
{
public class TerminerSonTour : GameAction
public class TerminerSonTourClassic : TerminerSonTour
{
public TerminerSonTour(Piles ListOrderedStacks) : base(ListOrderedStacks)
public TerminerSonTourClassic(Piles ListOrderedStacks) : base(ListOrderedStacks)
{
}
public bool end(List<Card> CurrentHand, List<Card> CurrentCardPlayed)
override public bool end(List<Card> CurrentHand, List<Card> CurrentCardPlayed)
{
// Si carte qui fait piocher que d'un, vérifier la bonne pioche (penser si elle vient d'être recouverte)
// Sinon
if (CurrentHand.Count == 0 || CurrentCardPlayed.Count >= 2)
{ // Ne pas oublié de gérer les ThreeCard
{
// Vérifier la fin du jeu
return true;
}
else
@ -29,18 +28,7 @@ namespace TheGameExtreme.model.gameActions.classic
}
public bool Test(List<Card> CurrentHand)
{
if (CurrentHand.Count != 0)
{
List<Card> playableCard = new List<Card>();
tryToFindSoluce(playableCard, CurrentHand);
return testEndGame(playableCard);
}
return false;
}
protected void tryToFindSoluce(List<Card> playableCard, List<Card> CurrentHand)
override protected void tryToFindSoluce(List<Card> playableCard, List<Card> CurrentHand)
{
CurrentHand.ForEach(card =>
{
@ -65,7 +53,7 @@ namespace TheGameExtreme.model.gameActions.classic
});
}
protected bool testEndGame(List<Card> playableCard)
override protected bool testEndGame(List<Card> playableCard)
{
//if (playableCard.Count == 2)
//{

@ -2,6 +2,7 @@
using System.Collections.Generic;
using TheGameExtreme.model.card;
using TheGameExtreme.model.deck;
using TheGameExtreme.model.gameActions.abstractRules;
using TheGameExtreme.model.gameActions.classic;
using TheGameExtreme.model.piles;
@ -13,16 +14,24 @@ namespace TheGameExtreme.model.gameActions.decimals
{
}
new public void load(int nbPlayer, List<Player> players)
override public void load(int nbPlayer, List<Player> players)
{
base.load(nbPlayer, players);
gameActions.RemoveAt(1);
gameActions.RemoveAt(2);
gameActions.Add(new PiocherClassic(Piles));
gameActions.Add(new JouerUneCarteDecimal(Piles));
gameActions.Add(new TerminerSonTourDecimal(Piles));
defineNbMaxCard(nbPlayer);
distribueCard(players);
}
override public void pioche(List<Card> currentHand, Player player)
{
Message = null;
((PiocherClassic)gameActions[0]).pioche(currentHand, deck, player, nbMaxCard);
quickSort(currentHand, 0, currentHand.Count - 1);
}
new public bool playCard(decimal valueCard, List<Card> currentHand, int orderedStackSelected, Player player, List<Card> CurrentCardPlayed)
override public bool playCard(decimal valueCard, List<Card> currentHand, int orderedStackSelected, Player player, List<Card> CurrentCardPlayed)
{
Message = null;
if (((JouerUneCarteDecimal)gameActions[1]).play(valueCard, currentHand, orderedStackSelected, player, CurrentCardPlayed))
@ -36,7 +45,7 @@ namespace TheGameExtreme.model.gameActions.decimals
}
}
new public bool endTurn(List<Card> currentHand, List<Card> CurrentCardPlayed, Player player)
override public bool endTurn(List<Card> currentHand, List<Card> CurrentCardPlayed, Player player)
{
Message = null;
if (((TerminerSonTourDecimal)gameActions[2]).end(currentHand, CurrentCardPlayed))
@ -53,7 +62,7 @@ namespace TheGameExtreme.model.gameActions.decimals
}
}
new public void TestEndGame(List<Card> currentHand)
override public void TestEndGame(List<Card> currentHand)
{
if (((TerminerSonTourDecimal)gameActions[2]).Test(currentHand))
{

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using TheGameExtreme.model.card;
using TheGameExtreme.model.gameActions.abstractRules;
using TheGameExtreme.model.gameActions.classic;
using TheGameExtreme.model.piles;
@ -12,7 +13,42 @@ namespace TheGameExtreme.model.gameActions.decimals
{
}
new protected bool Rule(Card card, Stack<Card> stack, bool bottomUp, Player player, List<Card> CurrentCardPlayed)
override public bool play(decimal valueCard, List<Card> CurrentHand, int orderedStackSelected, Player player, List<Card> CurrentCardPlayed)
{
foreach (Card card in CurrentHand)
{
if (valueCard.CompareTo(card.Value) == 0)
{
if (orderedStackSelected >= 0 && orderedStackSelected < ListOrderedStacks.Size)
{
bool success;
if (orderedStackSelected < (ListOrderedStacks.Size * 0.5))
{
ErrorMessage = null;
success = Rule(card, ListOrderedStacks.getStack(orderedStackSelected), true, player, CurrentCardPlayed);
}
else
{
ErrorMessage = null;
success = Rule(card, ListOrderedStacks.getStack(orderedStackSelected), false, player, CurrentCardPlayed);
}
if (success)
{
CurrentHand.Remove(card);
}
return success;
}
else
{
ErrorMessage = AppRessource.StrCantGetStack;
}
}
}
ErrorMessage = AppRessource.StrCardDoesntExist;
return false;
}
override protected bool Rule(Card card, Stack<Card> stack, bool bottomUp, Player player, List<Card> CurrentCardPlayed)
{
if ((bottomUp && card.Value > stack.Peek().Value) || (!bottomUp && card.Value < stack.Peek().Value))
{

@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using TheGameExtreme.model.card;
using TheGameExtreme.model.gameActions.classic;
using TheGameExtreme.model.gameActions.abstractRules;
using TheGameExtreme.model.piles;
namespace TheGameExtreme.model.gameActions.decimals
@ -12,7 +12,22 @@ namespace TheGameExtreme.model.gameActions.decimals
{
}
new protected void tryToFindSoluce(List<Card> playableCard, List<Card> CurrentHand)
override public bool end(List<Card> CurrentHand, List<Card> CurrentCardPlayed)
{
if (CurrentHand.Count == 0 || CurrentCardPlayed.Count >= 2)
{
// Vérifier la fin du jeu
return true;
}
else
{
ErrorMessage = AppRessource.StrCardPlayedLessThanTwo;
return false;
}
}
override protected void tryToFindSoluce(List<Card> playableCard, List<Card> CurrentHand)
{
CurrentHand.ForEach(card =>
{
@ -37,7 +52,7 @@ namespace TheGameExtreme.model.gameActions.decimals
});
}
new protected bool testEndGame(List<Card> playableCard)
override protected bool testEndGame(List<Card> playableCard)
{
if (playableCard.Count < 2)
{

@ -1,5 +1,7 @@
using System;
using TheGameExtreme.model.gameActions.classic;
using System.Collections.Generic;
using TheGameExtreme.model.card;
using TheGameExtreme.model.gameActions.abstractRules;
using TheGameExtreme.model.piles;
namespace TheGameExtreme.model.gameActions.extreme
@ -9,5 +11,15 @@ namespace TheGameExtreme.model.gameActions.extreme
public ExtremeJouerUneCarte(Piles ListOrderedStacks) : base(ListOrderedStacks)
{
}
public override bool play(decimal valueCard, List<Card> CurrentHand, int orderedStackSelected, Player player, List<Card> CurrentCardPlayed)
{
throw new NotImplementedException();
}
protected override bool Rule(Card card, Stack<Card> stack, bool bottomUp, Player player, List<Card> CurrentCardPlayed)
{
throw new NotImplementedException();
}
}
}

@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
using TheGameExtreme.model.card;
using TheGameExtreme.model.deck;
using TheGameExtreme.model.gameActions.classic;
using TheGameExtreme.model.gameActions.abstractRules;
using TheGameExtreme.model.piles;
namespace TheGameExtreme.model.gameActions.extreme
@ -13,5 +15,30 @@ namespace TheGameExtreme.model.gameActions.extreme
gameActions.Add(new ExtremeJouerUneCarte(Piles));
gameActions.Add(new ExtremeTerminerSonTour(Piles));
}
public override bool endTurn(List<Card> currentHand, List<Card> CurrentCardPlayed, Player player)
{
throw new NotImplementedException();
}
public override void load(int nbPlayer, List<Player> players)
{
throw new NotImplementedException();
}
public override void pioche(List<Card> currentHand, Player player)
{
throw new NotImplementedException();
}
public override bool playCard(decimal valueCard, List<Card> currentHand, int orderedStackSelected, Player player, List<Card> CurrentCardPlayed)
{
throw new NotImplementedException();
}
public override void TestEndGame(List<Card> currentHand)
{
throw new NotImplementedException();
}
}
}

@ -1,5 +1,8 @@
using System;
using TheGameExtreme.model.gameActions.classic;
using System.Collections.Generic;
using TheGameExtreme.model.card;
using TheGameExtreme.model.deck;
using TheGameExtreme.model.gameActions.abstractRules;
using TheGameExtreme.model.piles;
namespace TheGameExtreme.model.gameActions.extreme
@ -9,5 +12,10 @@ namespace TheGameExtreme.model.gameActions.extreme
public ExtremePiocher(Piles ListOrderedStacks) : base(ListOrderedStacks)
{
}
public override void pioche(List<Card> CurrentHand, Deck deck, Player player, int nbMaxCard)
{
throw new NotImplementedException();
}
}
}

@ -1,5 +1,7 @@
using System;
using TheGameExtreme.model.gameActions.classic;
using System.Collections.Generic;
using TheGameExtreme.model.card;
using TheGameExtreme.model.gameActions.abstractRules;
using TheGameExtreme.model.piles;
namespace TheGameExtreme.model.gameActions.extreme
@ -9,5 +11,20 @@ namespace TheGameExtreme.model.gameActions.extreme
public ExtremeTerminerSonTour(Piles ListOrderedStacks) : base(ListOrderedStacks)
{
}
public override bool end(List<Card> CurrentHand, List<Card> CurrentCardPlayed)
{
throw new NotImplementedException();
}
protected override bool testEndGame(List<Card> playableCard)
{
throw new NotImplementedException();
}
protected override void tryToFindSoluce(List<Card> playableCard, List<Card> CurrentHand)
{
throw new NotImplementedException();
}
}
}

@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.ComponentModel;
using TheGameExtreme.model.card;
using TheGameExtreme.model.@event;
using TheGameExtreme.model.gameActions;
using TheGameExtreme.model.piles;
namespace TheGameExtreme.model.manager

@ -216,16 +216,25 @@ namespace TheGameExtreme.view
stackCollection.Clear();
SKPaint textPaint = new SKPaint();
float textWidth = textPaint.MeasureText("001");
float textSize = 0.05f * (float)DeviceDisplay.MainDisplayInfo.Width * textPaint.TextSize / textWidth;
SKPoint position = new SKPoint((float)((DeviceDisplay.MainDisplayInfo.Width * 0.9) / (viewmodel.getListOrderedStacks().Count * 2)) - textPaint.MeasureText("01") * 0.5f, (float)((DeviceDisplay.MainDisplayInfo.Height * 0.1) + (DeviceDisplay.MainDisplayInfo.Height * 0.9) * 0.01 + 2 * textSize));
SKPoint position = new SKPoint((float)((DeviceDisplay.MainDisplayInfo.Width * 0.9) / (viewmodel.getListOrderedStacks().Count * 2)) + (float)(DeviceDisplay.MainDisplayInfo.Width * 0.01), (float)((DeviceDisplay.MainDisplayInfo.Height * 0.1) + (DeviceDisplay.MainDisplayInfo.Height * 0.9) * 0.01 + 2 * (0.05f * (float)DeviceDisplay.MainDisplayInfo.Width * textPaint.TextSize / textPaint.MeasureText("001"))));
float inflateWidth;
if (indexMode == 4)
{
inflateWidth = 0.01f * (float)DeviceDisplay.MainDisplayInfo.Width;
}
else
{
inflateWidth = 0.02f * (float)DeviceDisplay.MainDisplayInfo.Width;
}
for (int i = 0; i < viewmodel.getListOrderedStacks().Count; i++)
{
textPaint = new SKPaint();
textPaint.TextSize = textSize;
textPaint.TextSize = 0.05f * (float)DeviceDisplay.MainDisplayInfo.Width * textPaint.TextSize / textPaint.MeasureText("000");
position.X -= textPaint.MeasureText(viewmodel.getListOrderedStacks()[i].Peek().Value.ToString()) * 0.5f;
stackCollection.Add(new TouchManipulationCard(textPaint, viewmodel.getListOrderedStacks()[i].Peek())
stackCollection.Add(new TouchManipulationCard(textPaint, viewmodel.getListOrderedStacks()[i].Peek(), inflateWidth)
{
Matrix = SKMatrix.MakeTranslation(position.X, position.Y),
InitialMatrix = SKMatrix.MakeTranslation(position.X, position.Y),
@ -243,17 +252,26 @@ namespace TheGameExtreme.view
private void InflateHand()
{
SKPaint textPaint = new SKPaint();
float textWidth = textPaint.MeasureText("001");
float textSize = 0.05f * (float)DeviceDisplay.MainDisplayInfo.Width * textPaint.TextSize / textWidth;
SKPoint position = new SKPoint((float)((DeviceDisplay.MainDisplayInfo.Width * 0.9) / (viewmodel.CurrentHand.Count * 2)) - textPaint.MeasureText("01") * 0.5f + (float)(DeviceDisplay.MainDisplayInfo.Width * 0.01), (float)((DeviceDisplay.MainDisplayInfo.Height * 0.9) - (DeviceDisplay.MainDisplayInfo.Height * 0.9) * 0.1 - 2 * textSize));
SKPoint position = new SKPoint((float)((DeviceDisplay.MainDisplayInfo.Width * 0.9) / (viewmodel.CurrentHand.Count * 2)) + (float)(DeviceDisplay.MainDisplayInfo.Width * 0.01), (float)((DeviceDisplay.MainDisplayInfo.Height * 0.9) - (DeviceDisplay.MainDisplayInfo.Height * 0.9) * 0.1 - 2 * (0.05f * (float)DeviceDisplay.MainDisplayInfo.Width * textPaint.TextSize / textPaint.MeasureText("001"))));
float inflateWidth;
if (indexMode == 4)
{
inflateWidth = 0.01f * (float)DeviceDisplay.MainDisplayInfo.Width;
}
else
{
inflateWidth = 0.015f * (float)DeviceDisplay.MainDisplayInfo.Width;
}
for (int i = 0; i < viewmodel.CurrentHand.Count; i++)
{
textPaint = new SKPaint();
textPaint.TextSize = textSize;
float textWidth = textPaint.MeasureText(viewmodel.CurrentHand[i].Value.ToString());
textPaint.TextSize = 0.05f * (float)DeviceDisplay.MainDisplayInfo.Width * textPaint.TextSize / textPaint.MeasureText("000");
position.X -= (float)(textWidth * 0.5);
textCollection.Add(new TouchManipulationCard(textPaint, viewmodel.CurrentHand[i])
textCollection.Add(new TouchManipulationCard(textPaint, viewmodel.CurrentHand[i], inflateWidth)
{
Matrix = SKMatrix.MakeTranslation(position.X, position.Y),
InitialMatrix = SKMatrix.MakeTranslation(position.X, position.Y),

@ -20,7 +20,7 @@ namespace TheGameExtreme.view
Dictionary<long, TouchManipulationInfo> touchDictionary = new Dictionary<long, TouchManipulationInfo>();
public CardVM Value;
public string display;
private float width = 0.02f * (float)DeviceDisplay.MainDisplayInfo.Width;
private float width;
private float height;
@ -28,7 +28,7 @@ namespace TheGameExtreme.view
* <param name="textPaint">Objet dessiné</param>
* <param name="value">Carte qui est dessiné par le textPaint</param>
*/
public TouchManipulationCard(SKPaint textPaint, CardVM value)
public TouchManipulationCard(SKPaint textPaint, CardVM value, float width)
{
this.textPaint = textPaint;
Value = value;
@ -42,17 +42,19 @@ namespace TheGameExtreme.view
}
display = Value.ToString();
this.width = width;
height = 2f * width;
if (!display.Contains(",") && !display.Contains(".") && !display.Contains("/"))
{
if (decimal.Parse(display) <= -10)
if (Value.Value.CompareTo(-10m) <= 0)
{
width -= textPaint.MeasureText("0") * 0.5f;
this.width -= textPaint.MeasureText("0") * 0.5f;
}
else if (decimal.Parse(display) >= 0 && decimal.Parse(display) < 10)
if (Value.Value.CompareTo(0m) >= 0 && Value.Value.CompareTo(10) < 0)
{
width += textPaint.MeasureText("0") * 0.5f;
this.width += textPaint.MeasureText("0") * 0.5f;
}
}
@ -157,7 +159,7 @@ namespace TheGameExtreme.view
SKPoint transformedPoint = inverseMatrix.MapPoint(location);
// Check if it's in the untransformed bitmap rectangle
SKRect rect = new SKRect(-width, -height * 1.5f, width * 2.5f + 5, height);
SKRect rect = new SKRect(-width, -height - textPaint.TextSize + 10, width + textPaint.MeasureText(display), height + 10);
return rect.Contains(transformedPoint);
}
return false;

@ -5,6 +5,7 @@ using TheGameExtreme.model;
using TheGameExtreme.model.card;
using TheGameExtreme.model.deck;
using TheGameExtreme.model.@event;
using TheGameExtreme.model.gameActions.abstractRules;
using TheGameExtreme.model.gameActions.classic;
using TheGameExtreme.model.gameActions.decimals;
using TheGameExtreme.model.manager;
@ -59,10 +60,10 @@ namespace TheGameExtreme.viewmodel
switch (indexMode)
{
case 0:
gameMode = new GameMode(new ClassicPiles(nbPile), new ClassicDeck(nbCard, 1, 99));
gameMode = new GameModeClassic(new ClassicPiles(nbPile), new ClassicDeck(nbCard, 1, 99));
break;
case 1:
gameMode = new GameMode(new PilesMoins51To51(nbPile), new RelativeDeck(nbCard, -49, 49));
gameMode = new GameModeClassic(new PilesMoins51To51(nbPile), new RelativeDeck(nbCard, -49, 49));
break;
case 2:
gameMode = new GameModeDecimal(new Piles0To10(nbPile), new DizaineDeck(nbCard, 0.1m, 9.9m));
@ -77,7 +78,7 @@ namespace TheGameExtreme.viewmodel
gameMode = new GameModeDecimal(new FractionPiles(nbPile), new FractionDeck(nbCard, 0m, 51m));
break;
default:
gameMode = new GameMode(new ClassicPiles(nbPile), new ClassicDeck(nbCard, 1, 99));
gameMode = new GameModeClassic(new ClassicPiles(nbPile), new ClassicDeck(nbCard, 1, 99));
break;
}
Parametreur parametreur = new Parametreur(gameMode);

Loading…
Cancel
Save