Merge branch 'master' of gitlab.iut-clermont.uca.fr:cldupland/thegameextreme

master
Baptiste ARNAUD 5 years ago
commit 39f85acb15

@ -6,11 +6,13 @@ namespace TheGameExtreme.model
{
public int Numerateur;
public int Denominateur;
public int SizeMax;
public Fraction(int numerateur, int denominateur)
public Fraction(int numerateur, int denominateur, int sizeMax)
{
Numerateur = numerateur;
Denominateur = denominateur;
SizeMax = sizeMax;
}
public bool isMultiple(Fraction fraction)

@ -14,7 +14,7 @@ namespace TheGameExtreme.model.deck
while (deck.Count < nbCard && deck.Count < (borneMaxRandom - borneMinRandom))
{
int value = random.Next(borneMinRandom, borneMaxRandom);
InsertionDichotomique(deck, 0, deck.Count-1, new FractionCard(new Fraction(value, 100)));
InsertionDichotomique(deck, 0, deck.Count-1, new FractionCard(new Fraction(value, 100, 3)));
}
}
}

@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using TheGameExtreme.model.card;
using TheGameExtreme.model.card.cardType;
@ -12,6 +13,14 @@ namespace TheGameExtreme.model.deck
while (deck.Count < nbCard && deck.Count < (borneMax - borneMin))
{
int value = random.Next(borneMin, borneMax);
//foreach (Card card in deck)
//{
// if (card.Value.CompareTo(value) == 0)
// {
// Debug.WriteLine("Regarde!");
// break;
// }
//}
InsertionDichotomique(deck, 0, deck.Count-1, new ClassicCard(value));
}
}

@ -55,11 +55,15 @@ namespace TheGameExtreme.model.deck
deck.Insert(end + 1, card);
return;
}
else
else if (deck[end].Value.CompareTo(card.Value) > 0)
{
deck.Insert(end, card);
return;
}
else
{
return;
}
}
else
{

@ -13,7 +13,7 @@ namespace TheGameExtreme.model.deck
while (deck.Count < nbCard && deck.Count < (borneMaxRandom - borneMinRandom))
{
int value = random.Next(borneMinRandom, borneMaxRandom);
InsertionDichotomique(deck, 0, deck.Count-1, new FractionCard(new Fraction(value, 10)));
InsertionDichotomique(deck, 0, deck.Count-1, new FractionCard(new Fraction(value, 10, 2)));
}
}
}

@ -19,7 +19,7 @@ namespace TheGameExtreme.model.deck
{
if (deck.Count < nbCard)
{
InsertionDichotomique(deck, 0, deck.Count - 1, new FractionCard(new Fraction(i, j)));
InsertionDichotomique(deck, 0, deck.Count - 1, new FractionCard(new Fraction(i, j, 2)));
}
else
{
@ -43,7 +43,7 @@ namespace TheGameExtreme.model.deck
denominateur /= pgcd;
pgcd = PGCD(numerateur, denominateur);
}
InsertionDichotomique(deck, 0, deck.Count - 1, new FractionCard(new Fraction(numerateur, denominateur)));
InsertionDichotomique(deck, 0, deck.Count - 1, new FractionCard(new Fraction(numerateur, denominateur, 2)));
}
}
}

@ -14,7 +14,7 @@ namespace TheGameExtreme.model.deck
while (deck.Count < nbCard && deck.Count < (borneMaxRandom - borneMinRandom))
{
int value = random.Next(borneMinRandom, borneMaxRandom);
InsertionDichotomique(deck, 0, deck.Count-1, new FractionCard(new Fraction(value, 1000)));
InsertionDichotomique(deck, 0, deck.Count-1, new FractionCard(new Fraction(value, 1000, 4)));
}
}
}

@ -11,11 +11,11 @@ namespace TheGameExtreme.model.piles
{
if (i < (nbPile * 0.5))
{
ListOrderedStacks[i].Push(new ClassicCard(0m));
ListOrderedStacks[i].Push(new FractionCard(new Fraction(0, 1, 2)));
}
else
{
ListOrderedStacks[i].Push(new ClassicCard(100m));
ListOrderedStacks[i].Push(new FractionCard(new Fraction(25, 1, 2)));
}
}
}

@ -167,7 +167,8 @@
HorizontalOptions="Center"
MinimumWidthRequest="50"
WidthRequest="200"
MaxLength="18"/>
MaxLength="18"
IsTextPredictionEnabled="False"/>
</StackLayout>
</ScrollView>

@ -88,7 +88,8 @@ namespace TheGameExtreme.view
WidthRequest = 200,
MinimumWidthRequest = 50,
HorizontalOptions = LayoutOptions.Center,
MaxLength = 18
MaxLength = 18,
IsTextPredictionEnabled = false
};

@ -8,6 +8,7 @@ using SkiaSharp.Views.Forms;
using TouchTracking;
using Xamarin.Essentials;
using TheGameExtreme.Resx;
using TheGameExtreme.model.card.cardType;
namespace TheGameExtreme.view
{
@ -195,17 +196,9 @@ namespace TheGameExtreme.view
stackCollection.Clear();
SKPaint textPaint = new SKPaint();
SKPoint position = new SKPoint((float)((DeviceDisplay.MainDisplayInfo.Width) / (viewmodel.getListOrderedStacks().Count * 2)), (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"))));
SKPoint position = new SKPoint((float)((DeviceDisplay.MainDisplayInfo.Width - 20) / (viewmodel.getListOrderedStacks().Count * 2)) + 10f, (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 || indexMode == 3)
{
inflateWidth = 0.03f * (float)DeviceDisplay.MainDisplayInfo.Width;
}
else
{
inflateWidth = 0.02f * (float)DeviceDisplay.MainDisplayInfo.Width;
}
float inflateWidth = 0.024f * (float)(DeviceDisplay.MainDisplayInfo.Width - 20);
position.X -= inflateWidth;
@ -214,21 +207,16 @@ namespace TheGameExtreme.view
textPaint = new SKPaint();
float textWidth;
if (indexMode == 3)
{
textWidth = textPaint.MeasureText("000");
textPaint.TextSize = 0.04f * (float)DeviceDisplay.MainDisplayInfo.Width * textPaint.TextSize / textPaint.MeasureText("000");
}
else if (indexMode == 4)
if (viewmodel.getListOrderedStacks()[i].Peek().View.GetType() == typeof(FractionCard))
{
textWidth = textPaint.MeasureText("0000");
textPaint.TextSize = 0.04f * (float)DeviceDisplay.MainDisplayInfo.Width * textPaint.TextSize / textPaint.MeasureText("0000");
string displayMax = Math.Pow(10, ((FractionCard)(viewmodel.getListOrderedStacks()[i].Peek().View)).Fraction.SizeMax-1).ToString();
textWidth = textPaint.MeasureText(displayMax);
}
else
{
textWidth = textPaint.MeasureText("00");
textPaint.TextSize = 0.04f * (float)DeviceDisplay.MainDisplayInfo.Width * textPaint.TextSize / textPaint.MeasureText("00");
}
textPaint.TextSize = 0.03f * (float)(DeviceDisplay.MainDisplayInfo.Width - 20) * textPaint.TextSize / textPaint.MeasureText("00");
position.X -= textWidth * 0.5f;
stackCollection.Add(new TouchManipulationCard(textPaint, viewmodel.getListOrderedStacks()[i].Peek(), inflateWidth)
@ -238,7 +226,7 @@ namespace TheGameExtreme.view
InitialPoint = position
});
position.X += (float)((DeviceDisplay.MainDisplayInfo.Width) / viewmodel.getListOrderedStacks().Count);
position.X += (float)((DeviceDisplay.MainDisplayInfo.Width - 20) / viewmodel.getListOrderedStacks().Count) + textWidth * 0.5f;
}
}
@ -249,17 +237,9 @@ namespace TheGameExtreme.view
private void InflateHand()
{
SKPaint textPaint = new SKPaint();
SKPoint position = new SKPoint((float)((DeviceDisplay.MainDisplayInfo.Width) / (viewmodel.CurrentHand.Count * 2)), (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"))));
SKPoint position = new SKPoint((float)((DeviceDisplay.MainDisplayInfo.Width - 20) / (viewmodel.CurrentHand.Count * 2)) + 10f, (float)((DeviceDisplay.MainDisplayInfo.Height * 0.9) - (DeviceDisplay.MainDisplayInfo.Height * 0.9) * 0.1 - 2 * (0.05f * (float)(DeviceDisplay.MainDisplayInfo.Width - 20) * textPaint.TextSize / textPaint.MeasureText("001"))));
float inflateWidth;
if (indexMode == 4 || indexMode == 3)
{
inflateWidth = 0.03f * (float)DeviceDisplay.MainDisplayInfo.Width;
}
else
{
inflateWidth = 0.015f * (float)DeviceDisplay.MainDisplayInfo.Width;
}
float inflateWidth = 0.024f * (float)(DeviceDisplay.MainDisplayInfo.Width - 20);
position.X -= inflateWidth;
@ -268,21 +248,16 @@ namespace TheGameExtreme.view
textPaint = new SKPaint();
float textWidth;
if (indexMode == 3)
{
textWidth = textPaint.MeasureText("000");
textPaint.TextSize = 0.048f * (float)DeviceDisplay.MainDisplayInfo.Width * textPaint.TextSize / textPaint.MeasureText("000");
}
else if (indexMode == 4)
if (viewmodel.CurrentHand[i].View.GetType() == typeof(FractionCard))
{
textWidth = textPaint.MeasureText("0000");
textPaint.TextSize = 0.04f * (float)DeviceDisplay.MainDisplayInfo.Width * textPaint.TextSize / textPaint.MeasureText("0000");
string displayMax = Math.Pow(10, ((FractionCard)(viewmodel.CurrentHand[i].View)).Fraction.SizeMax-1).ToString();
textWidth = textPaint.MeasureText(displayMax);
}
else
{
textWidth = textPaint.MeasureText("00");
textPaint.TextSize = 0.048f * (float)DeviceDisplay.MainDisplayInfo.Width * textPaint.TextSize / textPaint.MeasureText("00");
}
textPaint.TextSize = 0.03f * (float)(DeviceDisplay.MainDisplayInfo.Width - 20) * textPaint.TextSize / textPaint.MeasureText("00");
position.X -= textWidth * 0.5f;
textCollection.Add(new TouchManipulationCard(textPaint, viewmodel.CurrentHand[i], inflateWidth)
@ -292,7 +267,7 @@ namespace TheGameExtreme.view
InitialPoint = position
});
position.X += (float)((DeviceDisplay.MainDisplayInfo.Width) / viewmodel.CurrentHand.Count);
position.X += (float)((DeviceDisplay.MainDisplayInfo.Width - 20) / viewmodel.CurrentHand.Count) + textWidth * 0.5f;
}
}

@ -44,8 +44,8 @@ namespace TheGameExtreme.view
textPaint1.TextSize = textPaint.TextSize;
textPaint2.TextSize = textPaint.TextSize;
}
//else
//{
else
{
if (!display.Contains(",") && !display.Contains(".") && !display.Contains("/"))
{
if (Value.Value.CompareTo(-10m) <= 0)
@ -57,7 +57,7 @@ namespace TheGameExtreme.view
this.width += textPaint.MeasureText("0") * 0.5f;
}
}
//}
}
Matrix = SKMatrix.MakeIdentity();
@ -86,13 +86,11 @@ namespace TheGameExtreme.view
textPaint.StrokeWidth = 5;
textPaint.Style = SKPaintStyle.Stroke;
//SKRect card = new SKRect(0, 0, 100, 100);
SKRect card;
if (Value.View.GetType() == typeof(FractionCard))
{
card = new SKRect(-width, -height - textPaint.TextSize, width + textPaint.MeasureText("00"), height);
card = new SKRect(-width, -height - textPaint.TextSize, width + textPaint.MeasureText(Math.Pow(10, ((FractionCard)(Value.View)).Fraction.SizeMax-1).ToString()), height);
textPaint1.Color = color;
textPaint1.StrokeWidth = 5;
textPaint1.Style = SKPaintStyle.Stroke;
@ -107,10 +105,40 @@ namespace TheGameExtreme.view
if (Value.View.GetType() == typeof(FractionCard))
{
float xNum = 0;
float xDen = 0;
int sizeMax = ((FractionCard)(Value.View)).Fraction.SizeMax;
int tailleNum = Math.Abs(((FractionCard)(Value.View)).Fraction.Numerateur);
int tailleDen = Math.Abs(((FractionCard)(Value.View)).Fraction.Denominateur);
if (tailleNum == 0)
{
tailleNum += 1;
}
if (tailleDen == 0)
{
tailleDen += 1;
}
string fractionBarre = "__";
for (int i = 2; i < sizeMax; i++){
fractionBarre += "_";
}
while (tailleNum < Math.Pow(10, (int)(sizeMax * 0.5)))
{
xNum += textPaint.MeasureText("0");
tailleNum *= 10;
}
while (tailleDen < Math.Pow(10, (int)(sizeMax * 0.5)))
{
xDen += textPaint2.MeasureText("0");
tailleDen *= 10;
}
canvas.DrawRect(card, textPaint1);
canvas.DrawText(((FractionCard)Value.View).Fraction.Numerateur.ToString(), width * 0.5f - textPaint.MeasureText(((FractionCard)Value.View).Fraction.Numerateur.ToString()) * 0.5f, - textPaint.TextSize * 0.5f - height * 0.5f, textPaint);
canvas.DrawText("___", width * 0.5f - textPaint1.MeasureText("___") * 0.5f, -textPaint1.TextSize * 0.6f, textPaint1);
canvas.DrawText(((FractionCard)Value.View).Fraction.Denominateur.ToString(), width * 0.5f - textPaint2.MeasureText(((FractionCard)Value.View).Fraction.Numerateur.ToString()) * 0.5f, height * 0.5f, textPaint2);
canvas.DrawText(((FractionCard)Value.View).Fraction.Numerateur.ToString(), xNum, -height * 0.5f, textPaint);
canvas.DrawText(fractionBarre, 0, -textPaint1.TextSize * 0.5f, textPaint1);
canvas.DrawText(((FractionCard)Value.View).Fraction.Denominateur.ToString(), xDen, height * 0.5f, textPaint2);
}
else
{
@ -147,7 +175,15 @@ namespace TheGameExtreme.view
SKPoint transformedPoint = inverseMatrix.MapPoint(location);
// Check if it's in the untransformed bitmap rectangle
SKRect rect = new SKRect(-width, -height - textPaint.TextSize, width + textPaint.MeasureText(display), height);
SKRect rect;
if (Value.View.GetType() == typeof(FractionCard))
{
rect = new SKRect(-width, -height - textPaint.TextSize, width + textPaint.MeasureText(Math.Pow(10, ((FractionCard)(Value.View)).Fraction.SizeMax - 1).ToString()), height);
}
else
{
rect = new SKRect(-width, -height - textPaint.TextSize, width + textPaint.MeasureText(display), height);
}
return rect.Contains(transformedPoint);
}
return false;

Loading…
Cancel
Save