Ajout des fractions finales

master
cldupland 5 years ago
parent fd586abfa6
commit 0d82f28836

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?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"> <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" /> <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_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

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

@ -24,41 +24,86 @@ namespace TheGameExtreme.model.deck
return deck[index]; return deck[index];
} }
//protected void InsertionDichotomique(List<Card> deck, int start, int end, Card card) protected void InsertionDichotomique(List<Card> deck, int start, int end, Card card)
//{ {
// int mediane = (end - start) % 2 + start; if (deck.Count == 0)
// if (mediane > deck.Count - 1) {
// { deck.Add(card);
// deck.Add(card); return;
// return; }
// }
// int comparateur = deck[mediane].Value.CompareTo(card.Value); int mediane = (end - start) / 2 + start;
// if (mediane == end) int comparateur = deck[mediane].Value.CompareTo(card.Value);
// {
// if (comparateur > 0) if (comparateur == 0)
// { {
// deck.Insert(start, card); return;
// } }
// else
// { if (mediane == start)
// deck.Insert(end, card); {
// } if (comparateur < 0)
// return; {
// } if (deck[end].Value.CompareTo(card.Value) < 0)
// if (comparateur == 0) {
// { deck.Insert(end + 1, card);
// return; return;
// } }
// else if (comparateur > 0) else
// { {
// InsertionDichotomique(deck, start, mediane, card); deck.Insert(end, card);
// return; return;
// } }
// else }
// { else
// InsertionDichotomique(deck, mediane, end, card); {
// return; 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)
// {
// deck.Insert(start, card);
// }
// else
// {
// deck.Insert(end, card);
// }
// return;
//}
//if (comparateur == 0)
//{
// return;
//}
//else if (comparateur < 0)
//{
// InsertionDichotomique(deck, start, mediane, card);
// return;
//}
//else
//{
// InsertionDichotomique(deck, mediane, end, card);
// return;
//}
}
} }
} }

@ -14,19 +14,16 @@ namespace TheGameExtreme.model.deck
Random random = new Random(); Random random = new Random();
for (int i = 1; i < 100; i ++) for (int i = 1; i < 100; i ++)
{ {
int entier = random.Next(0, 100); int numerateur = random.Next(1, 100);
int deci = random.Next(0,100); int denominateur = random.Next(1, 100);
decimal d = (decimal)entier + (decimal)deci * 0.001m;
int numerateur = (int)(d * 1000m);
int denominateur = 1000;
int pgcd = PGCD(numerateur, denominateur); int pgcd = PGCD(numerateur, denominateur);
while (pgcd != 1) while (pgcd != 1)
{ {
numerateur = numerateur / pgcd; numerateur /= pgcd;
denominateur = denominateur / pgcd; denominateur /= pgcd;
pgcd = PGCD(numerateur, denominateur); 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="*"/> <RowDefinition Height="*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Label Text="TRIONS" TextColor="{DynamicResource WhiteColor}" <Label Text="OrderStacks" TextColor="{DynamicResource WhiteColor}"
Grid.Row="0" Grid.Column="1" Grid.Row="0" Grid.Column="1"
HorizontalTextAlignment="Center" HorizontalTextAlignment="Center"
FontSize="35" FontSize="35"
@ -55,15 +55,6 @@
Margin="15" Margin="15"
BackgroundColor="{DynamicResource SkyBlueColor}"/> 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" <ImageButton Source="imagesRules.png" Grid.Column="0"
Grid.Row="0" Grid.Row="0"
HeightRequest="60" HeightRequest="60"

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

@ -17,8 +17,8 @@ namespace TheGameExtreme.view
Dictionary<long, TouchManipulationInfo> touchDictionary = new Dictionary<long, TouchManipulationInfo>(); Dictionary<long, TouchManipulationInfo> touchDictionary = new Dictionary<long, TouchManipulationInfo>();
public CardVM Value; public CardVM Value;
public string display; public string display;
private float width = 0.01f * (float)DeviceDisplay.MainDisplayInfo.Width; private float width = 0.02f * (float)DeviceDisplay.MainDisplayInfo.Width;
private float height = 0.01f * (float)DeviceDisplay.MainDisplayInfo.Width * 3f; private float height;
/** /**
@ -30,16 +30,17 @@ namespace TheGameExtreme.view
this.textPaint = textPaint; this.textPaint = textPaint;
Value = value; Value = value;
display = Value.ToString(); display = Value.ToString();
height = 2f * width;
if (!display.Contains(",") && !display.Contains(".") && !display.Contains("/")) 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) 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.StrokeWidth = 5;
textPaint.Style = SKPaintStyle.Stroke; textPaint.Style = SKPaintStyle.Stroke;
SKRect textBounds = new SKRect(); SKRect card = new SKRect();
textPaint.MeasureText(display, ref textBounds); textPaint.MeasureText(display, ref card);
SKRoundRect card = new SKRoundRect(textBounds, 1f, 1f);
card.Inflate(width, height); card.Inflate(width, height);
canvas.DrawRoundRect(card, textPaint); canvas.DrawRect(card, textPaint);
canvas.DrawText(display, 0, 0, textPaint); canvas.DrawText(display, 0, 0, textPaint);
canvas.Restore(); canvas.Restore();

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

Loading…
Cancel
Save