|
|
@ -25,10 +25,14 @@ namespace TheGameExtreme
|
|
|
|
{
|
|
|
|
{
|
|
|
|
InitializeComponent();
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
|
|
|
|
viewmodel = new Main(Alert);
|
|
|
|
viewmodel = new Main();
|
|
|
|
|
|
|
|
|
|
|
|
viewmodel.BindingChanged += OnBindingChanged;
|
|
|
|
viewmodel.BindingChanged += OnBindingChanged;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Alert.SetBinding(Label.TextProperty, new Binding("Alert", source: viewmodel));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inflateHand();
|
|
|
|
|
|
|
|
|
|
|
|
//pile0.SetBinding(Label.TextProperty, new Binding("Stack0", source: viewmodel));
|
|
|
|
//pile0.SetBinding(Label.TextProperty, new Binding("Stack0", source: viewmodel));
|
|
|
|
//pile1.SetBinding(Label.TextProperty, new Binding("Stack1", source: viewmodel));
|
|
|
|
//pile1.SetBinding(Label.TextProperty, new Binding("Stack1", source: viewmodel));
|
|
|
|
//pile2.SetBinding(Label.TextProperty, new Binding("Stack2", source: viewmodel));
|
|
|
|
//pile2.SetBinding(Label.TextProperty, new Binding("Stack2", source: viewmodel));
|
|
|
@ -42,27 +46,51 @@ namespace TheGameExtreme
|
|
|
|
//card7.SetBinding(Button.TextProperty, new Binding("ValueCard7", source: viewmodel));
|
|
|
|
//card7.SetBinding(Button.TextProperty, new Binding("ValueCard7", source: viewmodel));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void inflateHand()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Hand.Children.Clear();
|
|
|
|
|
|
|
|
for (int i = 0; i < viewmodel.CurrentHand.Count; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Button card = new Button();
|
|
|
|
|
|
|
|
card.Text = viewmodel.CurrentHand[i].Value.ToString();
|
|
|
|
|
|
|
|
card.Clicked += played;
|
|
|
|
|
|
|
|
Hand.Children.Add(card);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnBindingChanged(object sender, TopRangeChangedEventArgs args)
|
|
|
|
private void OnBindingChanged(object sender, TopRangeChangedEventArgs args)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
switch (args.NumStackChanged)
|
|
|
|
switch (args.NumStackChanged)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
case 0:
|
|
|
|
pile0.SetBinding(Label.TextProperty, new Binding("ListOrderedStacks[0].Peek().Value", source: viewmodel));
|
|
|
|
pile0.Text = args.NewTopRangeCard.Value.ToString();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
case 1:
|
|
|
|
pile1.SetBinding(Label.TextProperty, new Binding("ListOrderedStacks[1].Peek().Value", source: viewmodel));
|
|
|
|
pile1.Text = args.NewTopRangeCard.Value.ToString();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
case 2:
|
|
|
|
pile2.SetBinding(Label.TextProperty, new Binding("ListOrderedStacks[2].Peek().Value", source: viewmodel));
|
|
|
|
pile2.Text = args.NewTopRangeCard.Value.ToString();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
case 3:
|
|
|
|
pile3.SetBinding(Label.TextProperty, new Binding("ListOrderedStacks[3].Peek().Value", source: viewmodel));
|
|
|
|
pile3.Text = args.NewTopRangeCard.Value.ToString();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < Hand.Children.Count; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Button b = Hand.Children[i] as Button;
|
|
|
|
|
|
|
|
if (String.Equals(b.Text,args.NewTopRangeCard.Value.ToString()))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Hand.Children.RemoveAt(i);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void played(object sender, EventArgs args)
|
|
|
|
private void played(object sender, EventArgs args)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
viewmodel.Alert = "";
|
|
|
|
|
|
|
|
|
|
|
|
int numStack;
|
|
|
|
int numStack;
|
|
|
|
if (checkbox0.IsChecked)
|
|
|
|
if (checkbox0.IsChecked)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -82,7 +110,8 @@ namespace TheGameExtreme
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw new Exception();
|
|
|
|
viewmodel.Alert = "Aucune pile selectionné! Veuillez séléctionner une pile.";
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
viewmodel.played(numStack, Convert.ToInt32((sender as Button).Text));
|
|
|
|
viewmodel.played(numStack, Convert.ToInt32((sender as Button).Text));
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -90,6 +119,7 @@ namespace TheGameExtreme
|
|
|
|
private void endTurn(object sender, EventArgs args)
|
|
|
|
private void endTurn(object sender, EventArgs args)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
viewmodel.endTurn();
|
|
|
|
viewmodel.endTurn();
|
|
|
|
|
|
|
|
inflateHand();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|