Ajout des fractions finales

master
cldupland 5 years ago
parent fd586abfa6
commit 0d82f28836

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="6" android:versionName="3.1" package="com.uca.thegameextreme" android:installLocation="auto">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28" />
<application android:label="TheGameExtreme.Android" android:icon="@drawable/TrierImageB"></application>
<application android:icon="@drawable/TrierImageB" android:label="OrderStacks"></application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

@ -29,9 +29,9 @@
<string>1.0</string>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>CFBundleName</key>
<string>TheGameExtreme</string>
<key>XSAppIconAssets</key>
<string>Assets.xcassets/AppIcon.appiconset</string>
<key>CFBundleName</key>
<string>OrderStacks</string>
</dict>
</plist>

@ -24,18 +24,63 @@ namespace TheGameExtreme.model.deck
return deck[index];
}
//protected void InsertionDichotomique(List<Card> deck, int start, int end, Card card)
//{
// int mediane = (end - start) % 2 + start;
// if (mediane > deck.Count - 1)
// {
// deck.Add(card);
// return;
// }
protected void InsertionDichotomique(List<Card> deck, int start, int end, Card card)
{
if (deck.Count == 0)
{
deck.Add(card);
return;
}
int mediane = (end - start) / 2 + start;
int comparateur = deck[mediane].Value.CompareTo(card.Value);
if (comparateur == 0)
{
return;
}
if (mediane == start)
{
if (comparateur < 0)
{
if (deck[end].Value.CompareTo(card.Value) < 0)
{
deck.Insert(end + 1, card);
return;
}
else
{
deck.Insert(end, card);
return;
}
}
else
{
deck.Insert(start, card);
return;
}
}
else
{
if (comparateur < 0)
{
InsertionDichotomique(deck, mediane, end, card);
return;
}
else
{
InsertionDichotomique(deck, start, mediane, card);
return;
}
}
//int mediane = (end - start) / 2 + start;
//int comparateur = deck[mediane].Value.CompareTo(card.Value);
//if (mediane == end)
//{
// if (comparateur > 0)
// if (comparateur < 0)
// {
// deck.Insert(start, card);
// }
@ -49,7 +94,7 @@ namespace TheGameExtreme.model.deck
//{
// return;
//}
// else if (comparateur > 0)
//else if (comparateur < 0)
//{
// InsertionDichotomique(deck, start, mediane, card);
// return;
@ -59,6 +104,6 @@ namespace TheGameExtreme.model.deck
// InsertionDichotomique(deck, mediane, end, card);
// return;
//}
//}
}
}
}

@ -14,19 +14,16 @@ namespace TheGameExtreme.model.deck
Random random = new Random();
for (int i = 1; i < 100; i ++)
{
int entier = random.Next(0, 100);
int deci = random.Next(0,100);
decimal d = (decimal)entier + (decimal)deci * 0.001m;
int numerateur = (int)(d * 1000m);
int denominateur = 1000;
int numerateur = random.Next(1, 100);
int denominateur = random.Next(1, 100);
int pgcd = PGCD(numerateur, denominateur);
while (pgcd != 1)
{
numerateur = numerateur / pgcd;
denominateur = denominateur / pgcd;
numerateur /= pgcd;
denominateur /= pgcd;
pgcd = PGCD(numerateur, denominateur);
}
deck.Add(new FractionCard(new Fraction(numerateur, denominateur)));
InsertionDichotomique(deck, 0, deck.Count-1, new FractionCard(new Fraction(numerateur, denominateur)));
}
}

@ -0,0 +1,23 @@
using System;
using TheGameExtreme.model.card.cardType;
namespace TheGameExtreme.model.piles
{
public class Piles0To10 : Piles
{
public Piles0To10(int nbPile) : base(nbPile)
{
for (int i = 0; i < nbPile; i++)
{
if (i < (nbPile * 0.5))
{
ListOrderedStacks[i].Push(new ClassicCard(0m));
}
else
{
ListOrderedStacks[i].Push(new ClassicCard(10m));
}
}
}
}
}

@ -18,7 +18,7 @@
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Label Text="TRIONS" TextColor="{DynamicResource WhiteColor}"
<Label Text="OrderStacks" TextColor="{DynamicResource WhiteColor}"
Grid.Row="0" Grid.Column="1"
HorizontalTextAlignment="Center"
FontSize="35"
@ -55,15 +55,6 @@
Margin="15"
BackgroundColor="{DynamicResource SkyBlueColor}"/>
<!--<Button Text="Connexion en ligne" FontSize="16" Grid.Row="3" Grid.Column="1"
HorizontalOptions="Center"
VerticalOptions="Center"
WidthRequest="230"
HeightRequest="57"
CornerRadius="10"
Margin="15"
BackgroundColor="{DynamicResource SkyBlueColor}"/>-->
<ImageButton Source="imagesRules.png" Grid.Column="0"
Grid.Row="0"
HeightRequest="60"

@ -18,7 +18,6 @@ namespace TheGameExtreme.view
public partial class MainPage : ContentPage
{
private Main viewmodel;
Button button;
private List<string> playersNames;
private int nbPile;
private int indexMode;
@ -249,7 +248,6 @@ namespace TheGameExtreme.view
*/
private void OnEndGame(object sender, EventArgs args)
{
button = (Button)gameOption.Children[0];
gameOption.Children.Clear();
Button retryButton = new Button();
retryButton.Text = "Retry";
@ -294,6 +292,10 @@ namespace TheGameExtreme.view
InflateHand();
gameOption.Children.Clear();
Button button = new Button();
button.Text = AppRessource.StrEndTurn;
button.Clicked += Retry;
button.BackgroundColor = (Color)Application.Current.Resources["SkyBlueColor"];
gameOption.Children.Add(button);
}

@ -17,8 +17,8 @@ namespace TheGameExtreme.view
Dictionary<long, TouchManipulationInfo> touchDictionary = new Dictionary<long, TouchManipulationInfo>();
public CardVM Value;
public string display;
private float width = 0.01f * (float)DeviceDisplay.MainDisplayInfo.Width;
private float height = 0.01f * (float)DeviceDisplay.MainDisplayInfo.Width * 3f;
private float width = 0.02f * (float)DeviceDisplay.MainDisplayInfo.Width;
private float height;
/**
@ -30,16 +30,17 @@ namespace TheGameExtreme.view
this.textPaint = textPaint;
Value = value;
display = Value.ToString();
height = 2f * width;
if (!display.Contains(",") && !display.Contains(".") && !display.Contains("/"))
{
if (decimal.Parse(display) < 0 && decimal.Parse(display) > -10)
if (decimal.Parse(display) <= -10)
{
display = "-0" + Math.Abs(decimal.Parse(display)).ToString();
width -= textPaint.MeasureText("0") * 0.5f;
}
else if (decimal.Parse(display) >= 0 && decimal.Parse(display) < 10)
{
display = "0" + display;
width += textPaint.MeasureText("0") * 0.5f;
}
}
@ -70,13 +71,11 @@ namespace TheGameExtreme.view
textPaint.StrokeWidth = 5;
textPaint.Style = SKPaintStyle.Stroke;
SKRect textBounds = new SKRect();
textPaint.MeasureText(display, ref textBounds);
SKRoundRect card = new SKRoundRect(textBounds, 1f, 1f);
SKRect card = new SKRect();
textPaint.MeasureText(display, ref card);
card.Inflate(width, height);
canvas.DrawRoundRect(card, textPaint);
canvas.DrawRect(card, textPaint);
canvas.DrawText(display, 0, 0, textPaint);
canvas.Restore();

@ -68,7 +68,7 @@ namespace TheGameExtreme.viewmodel
gameMode = new GameMode(new Piles0To1(nbPile), new DecimalDeck());
break;
case 3:
gameMode = new GameModeDecimal(new PilesMoins5To5(nbPile), new DizaineDeck());
gameMode = new GameModeDecimal(new Piles0To10(nbPile), new DizaineDeck());
break;
case 4:
gameMode = new GameMode(new PilesMoins5To5(nbPile), new CentaineDeck());
@ -77,7 +77,7 @@ namespace TheGameExtreme.viewmodel
gameMode = new GameMode(new PilesMoins5To5(nbPile), new MilliemeDeck());
break;
case 6:
gameMode = new GameMode(new FractionPiles(nbPile), new FractionDeck());
gameMode = new GameModeDecimal(new FractionPiles(nbPile), new FractionDeck());
break;
default:
gameMode = new GameMode(new ClassicPiles(nbPile), new ClassicDeck());

Loading…
Cancel
Save