|
|
|
@ -10,6 +10,10 @@ public partial class PageBoard : ContentPage
|
|
|
|
|
{
|
|
|
|
|
public Game GameManager => (App.Current as App).Manager;
|
|
|
|
|
|
|
|
|
|
public int Resultat { get; set; }
|
|
|
|
|
|
|
|
|
|
public Cell ChoosenCell { get; set; }
|
|
|
|
|
|
|
|
|
|
public PageBoard()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
@ -21,6 +25,7 @@ public partial class PageBoard : ContentPage
|
|
|
|
|
GameManager.DiceRolled += ResultHigher;
|
|
|
|
|
GameManager.DiceRolled += ResultSubstraction;
|
|
|
|
|
GameManager.DiceRolled += ResultMultiplication;
|
|
|
|
|
GameManager.PlayerOption += GameManager_PlayerOption;
|
|
|
|
|
|
|
|
|
|
// We add this game to the list of games
|
|
|
|
|
GameManager.AddGame(GameManager);
|
|
|
|
@ -28,6 +33,18 @@ public partial class PageBoard : ContentPage
|
|
|
|
|
GameManager.SaveData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void GameManager_PlayerOption(object? sender, PlayerOptionEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
/* IEnumerable<Cell> PlayedCellsQuery =
|
|
|
|
|
from cell in e.Board
|
|
|
|
|
where cell.Valid == true
|
|
|
|
|
where cell.Value != null
|
|
|
|
|
select cell;*/
|
|
|
|
|
|
|
|
|
|
// prévisualisation des zone disponible, Je ne sais pas comment ca marche... 😵
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ResultMultiplication(object? sender, DiceRolledEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Multiplication.IsVisible = true;
|
|
|
|
@ -66,8 +83,11 @@ public partial class PageBoard : ContentPage
|
|
|
|
|
|
|
|
|
|
private void TheGame_DiceRolled(object? sender, Models.Events.DiceRolledEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
YellowDice.IsVisible = true;
|
|
|
|
|
RedDice.IsVisible = true;
|
|
|
|
|
Dice1.Text = $"{e.Dice1Value}";
|
|
|
|
|
Dice2.Text = $"{e.Dice2Value}";
|
|
|
|
|
RollButton.IsEnabled = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnOperationCellSelected(object sender, SelectionChangedEventArgs e)
|
|
|
|
@ -87,27 +107,43 @@ public partial class PageBoard : ContentPage
|
|
|
|
|
|
|
|
|
|
private void HigherClicked(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Higher.IsVisible = false;
|
|
|
|
|
GameManager.PlayerOperation = Operation.HIGHER;
|
|
|
|
|
Resultat = GameManager.PlayerChooseOperation();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LowerClicked(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
GameManager.PlayerOperation = Operation.LOWER;
|
|
|
|
|
Resultat = GameManager.PlayerChooseOperation();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AdditionClicked(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
GameManager.PlayerOperation = Operation.ADDITION;
|
|
|
|
|
Resultat = GameManager.PlayerChooseOperation();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SubstractionClicked(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
GameManager.PlayerOperation = Operation.SUBTRACTION;
|
|
|
|
|
Resultat = GameManager.PlayerChooseOperation();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void MultiplicationClicked(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
GameManager.PlayerOperation = Operation.MULTIPLICATION;
|
|
|
|
|
Resultat = GameManager.PlayerChooseOperation();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DiceButton_Clicked(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
GameManager.RollAllDice();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnCellSelected(object sender, SelectionChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ChoosenCell = (Cell)e.CurrentSelection[0];
|
|
|
|
|
GameManager.PlayerCell = ChoosenCell;
|
|
|
|
|
GameManager.PlayerSelectionCell();
|
|
|
|
|
}
|
|
|
|
|
}
|