1
0
Fork 0
mirror of https://github.com/Nioux/AideDeJeu.git synced 2025-10-30 15:06:06 +00:00

Dés + message sur back

This commit is contained in:
Yan Maniez 2019-05-09 00:01:19 +02:00
parent 062b03547a
commit d25de58c6d
5 changed files with 93 additions and 36 deletions

View file

@ -212,6 +212,7 @@ namespace AideDeJeu.ViewModels.PlayerCharacter
OnPropertyChanged(nameof(Mod)); OnPropertyChanged(nameof(Mod));
OnPropertyChanged(nameof(ValueString)); OnPropertyChanged(nameof(ValueString));
OnPropertyChanged(nameof(ModString)); OnPropertyChanged(nameof(ModString));
OnPropertyChanged(nameof(HasRacialBonus));
} }
} }
private int _RacialDispatchedBonus = 0; private int _RacialDispatchedBonus = 0;
@ -240,6 +241,13 @@ namespace AideDeJeu.ViewModels.PlayerCharacter
OnPropertyChanged(nameof(HasRacialDispatchedBonus)); OnPropertyChanged(nameof(HasRacialDispatchedBonus));
} }
} }
public bool HasRacialBonus
{
get
{
return _RacialBonus != 0;
}
}
public bool HasRacialDispatchedBonus public bool HasRacialDispatchedBonus
{ {
get get

View file

@ -20,8 +20,11 @@ namespace AideDeJeu.ViewModels.PlayerCharacter
{ {
public class PlayerCharacterEditorViewModel : BaseViewModel public class PlayerCharacterEditorViewModel : BaseViewModel
{ {
private Random _Random;
public PlayerCharacterEditorViewModel() public PlayerCharacterEditorViewModel()
{ {
_Random = new Random(DateTime.Now.Millisecond);
SelectedPlayerCharacter = new PlayerCharacterViewModel() { Background = new BackgroundViewModel(), Abilities = new AbilitiesViewModel() }; SelectedPlayerCharacter = new PlayerCharacterViewModel() { Background = new BackgroundViewModel(), Abilities = new AbilitiesViewModel() };
SelectedPlayerCharacter.PropertyChanged += SelectedPlayerCharacter_PropertyChanged; SelectedPlayerCharacter.PropertyChanged += SelectedPlayerCharacter_PropertyChanged;
@ -916,17 +919,46 @@ namespace AideDeJeu.ViewModels.PlayerCharacter
} }
} }
*/ */
public ICommand RollDicesCommand public ICommand RollDicesMRickCommand
{ {
get get
{ {
return new Command(async () => await ExecuteRollDicesCommandAsync()); return new Command(() => PrefillDices(RollMRick()));
} }
} }
private async Task ExecuteRollDicesCommandAsync() public ICommand RollDices2d6plus6Command
{ {
var random = new Random(DateTime.Now.Millisecond); get
var values = RollMRick(random); {
return new Command(() => PrefillDices(Roll6x2d6plus6()));
}
}
public ICommand ResetDicesCommand
{
get
{
return new Command(() => ExecuteResetDicesCommand());
}
}
private void ExecuteResetDicesCommand()
{
SelectedPlayerCharacter.Abilities.Unlisten();
SelectedPlayerCharacter.Abilities.Strength.BaseValue = null;
SelectedPlayerCharacter.Abilities.Strength.RacialDispatchedBonus = 0;
SelectedPlayerCharacter.Abilities.Dexterity.BaseValue = null;
SelectedPlayerCharacter.Abilities.Dexterity.RacialDispatchedBonus = 0;
SelectedPlayerCharacter.Abilities.Constitution.BaseValue = null;
SelectedPlayerCharacter.Abilities.Constitution.RacialDispatchedBonus = 0;
SelectedPlayerCharacter.Abilities.Intelligence.BaseValue = null;
SelectedPlayerCharacter.Abilities.Intelligence.RacialDispatchedBonus = 0;
SelectedPlayerCharacter.Abilities.Wisdom.BaseValue = null;
SelectedPlayerCharacter.Abilities.Wisdom.RacialDispatchedBonus = 0;
SelectedPlayerCharacter.Abilities.Charisma.BaseValue = null;
SelectedPlayerCharacter.Abilities.Charisma.RacialDispatchedBonus = 0;
SelectedPlayerCharacter.Abilities.Listen();
}
private void PrefillDices(List<int> values)
{
values.Sort(); values.Sort();
List<int> mins; List<int> mins;
List<int> maxs; List<int> maxs;
@ -942,16 +974,13 @@ namespace AideDeJeu.ViewModels.PlayerCharacter
} }
SelectedPlayerCharacter.Abilities.Unlisten(); SelectedPlayerCharacter.Abilities.Unlisten();
SelectedPlayerCharacter.Abilities.Strength.BaseValue = PickAbility(random, ref mins, ref maxs, "Force"); SelectedPlayerCharacter.Abilities.Strength.BaseValue = PickAbility(ref mins, ref maxs, "Force");
SelectedPlayerCharacter.Abilities.Dexterity.BaseValue = PickAbility(random, ref mins, ref maxs, "Dextérité"); SelectedPlayerCharacter.Abilities.Dexterity.BaseValue = PickAbility(ref mins, ref maxs, "Dextérité");
SelectedPlayerCharacter.Abilities.Constitution.BaseValue = PickAbility(random, ref mins, ref maxs, "Constitution"); SelectedPlayerCharacter.Abilities.Constitution.BaseValue = PickAbility(ref mins, ref maxs, "Constitution");
SelectedPlayerCharacter.Abilities.Intelligence.BaseValue = PickAbility(random, ref mins, ref maxs, "Intelligence"); SelectedPlayerCharacter.Abilities.Intelligence.BaseValue = PickAbility(ref mins, ref maxs, "Intelligence");
SelectedPlayerCharacter.Abilities.Wisdom.BaseValue = PickAbility(random, ref mins, ref maxs, "Sagesse"); SelectedPlayerCharacter.Abilities.Wisdom.BaseValue = PickAbility(ref mins, ref maxs, "Sagesse");
SelectedPlayerCharacter.Abilities.Charisma.BaseValue = PickAbility(random, ref mins, ref maxs, "Charisme"); SelectedPlayerCharacter.Abilities.Charisma.BaseValue = PickAbility(ref mins, ref maxs, "Charisme");
SelectedPlayerCharacter.Abilities.Listen(); SelectedPlayerCharacter.Abilities.Listen();
//await GeneratePdfAsync();
//await OpenPdfAsync();
} }
public BaseFont findFontInForm(PdfReader reader, PdfName fontname) public BaseFont findFontInForm(PdfReader reader, PdfName fontname)
@ -1384,44 +1413,53 @@ namespace AideDeJeu.ViewModels.PlayerCharacter
*/ */
} }
private int PickAbility(Random random, ref List<int> mins, ref List<int> maxs, string name) private int PickAbility(ref List<int> mins, ref List<int> maxs, string name)
{ {
var value = SelectedPlayerCharacter.Class?.Proficiencies?.SavingThrows?.Contains(name); var value = SelectedPlayerCharacter.Class?.Proficiencies?.SavingThrows?.Contains(name);
if (value == true) if (value == true)
{ {
return PickOne(random, ref maxs); return PickOne(ref maxs);
} }
else else
{ {
return PickOne(random, ref mins); return PickOne(ref mins);
} }
} }
private int PickOne(Random random, ref List<int> values) private int PickOne(ref List<int> values)
{ {
var index = random.Next(values.Count); var index = _Random.Next(values.Count);
var pick = values[index]; var pick = values[index];
values.RemoveAt(index); values.RemoveAt(index);
return pick; return pick;
} }
private List<int> RollMRick(Random random) private List<int> RollMRick()
{ {
var dices = new List<int>(); var dices = new List<int>();
var roll = Roll2d6(random); var roll = Roll2d6();
dices.Add(6 + roll); dices.Add(6 + roll);
dices.Add(19 - roll); dices.Add(19 - roll);
roll = Roll2d6(random); roll = Roll2d6();
dices.Add(6 + roll); dices.Add(6 + roll);
dices.Add(19 - roll); dices.Add(19 - roll);
roll = Roll2d6(random); roll = Roll2d6();
dices.Add(6 + roll); dices.Add(6 + roll);
dices.Add(19 - roll); dices.Add(19 - roll);
return dices; return dices;
} }
private int Roll2d6(Random random) private List<int> Roll6x2d6plus6()
{ {
return random.Next(6) + random.Next(6) + 2; var dices = new List<int>();
for(int i = 0; i < 6; i++)
{
dices.Add(Roll2d6() + 6);
}
return dices;
}
private int Roll2d6()
{
return _Random.Next(6) + _Random.Next(6) + 2;
} }
#endregion Abilities #endregion Abilities

View file

@ -25,16 +25,16 @@
<RowDefinition Height="auto" /> <RowDefinition Height="auto" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Frame Grid.Column="0" BorderColor="Black" Padding="2" VerticalOptions="Start"> <Frame Grid.Column="0" BorderColor="Black" Padding="2" VerticalOptions="Start">
<ImageButton Source="rolling_dice_cup.png" Command="{Binding RollDicesCommand}" /> <ImageButton Source="rolling_dice_cup.png" Command="{Binding RollDicesMRickCommand}" />
</Frame> </Frame>
<Frame Grid.Column="1" BorderColor="Black" Padding="2"> <Frame Grid.Column="1" BorderColor="Black" Padding="2">
<ImageButton Source="cubes.png" Command="{Binding RollDicesCommand}" /> <ImageButton Source="cubes.png" Command="{Binding RollDices2d6plus6Command}" />
</Frame> </Frame>
<Frame Grid.Column="2" BorderColor="Black" Padding="2"> <Frame Grid.Column="2" BorderColor="Black" Padding="2">
<ImageButton Source="trash_can.png" Command="{Binding RollDicesCommand}" /> <ImageButton Source="trash_can.png" Command="{Binding ResetDicesCommand}" />
</Frame> </Frame>
<Frame Grid.Row="1" Grid.ColumnSpan="3" BorderColor="Black" Padding="2" Margin="10"> <Frame Grid.Row="1" Grid.ColumnSpan="3" BorderColor="Black" Padding="2" Margin="10">
<Grid ColumnSpacing="15" RowSpacing="10" Margin="15"> <Grid RowSpacing="10" Margin="15">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
@ -56,10 +56,10 @@
<RowDefinition Height="auto" /> <RowDefinition Height="auto" />
<RowDefinition Height="auto" /> <RowDefinition Height="auto" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Label Grid.Column="0" Text="Base" HorizontalTextAlignment="Center" /> <Label Grid.Column="0" Text="Base" HorizontalTextAlignment="Center" FontSize="Medium" />
<Label Grid.Column="1" Text="Bonus" HorizontalTextAlignment="Center"/> <Label Grid.Column="1" Text="Bonus" HorizontalTextAlignment="Center" FontSize="Medium" />
<Label Grid.Column="2" Text="Valeur" HorizontalTextAlignment="Center"/> <Label Grid.Column="2" Text="Valeur" HorizontalTextAlignment="Center" FontSize="Medium" />
<Label Grid.Column="3" Text="Mod" HorizontalTextAlignment="Center"/> <Label Grid.Column="3" Text="Mod" HorizontalTextAlignment="Center" FontSize="Medium" />
<Label Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="4" Text="Force" VerticalTextAlignment="Center" FontSize="Medium" /> <Label Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="4" Text="Force" VerticalTextAlignment="Center" FontSize="Medium" />
<pcviews:AbilityBaseValueView Grid.Row="2" Grid.Column="0" BindingContext="{Binding}" Ability="{Binding SelectedPlayerCharacter.Abilities.Strength}" /> <pcviews:AbilityBaseValueView Grid.Row="2" Grid.Column="0" BindingContext="{Binding}" Ability="{Binding SelectedPlayerCharacter.Abilities.Strength}" />

View file

@ -8,12 +8,13 @@
<ResourceDictionary> <ResourceDictionary>
<tools:MonsterMarkdownTheme x:Key="MonsterMarkdownTheme" /> <tools:MonsterMarkdownTheme x:Key="MonsterMarkdownTheme" />
<tools:NullToFalseConverter x:Key="NullToFalseConverter" /> <tools:NullToFalseConverter x:Key="NullToFalseConverter" />
<tools:NullToTrueConverter x:Key="NullToTrueConverter" />
</ResourceDictionary> </ResourceDictionary>
</ContentView.Resources> </ContentView.Resources>
<ContentView.Content> <ContentView.Content>
<Grid> <Grid>
<Label Text="{Binding Ability.RacialBonus, Source={x:Reference this}, StringFormat='{}{0:+0;-#}', FallbackValue=''}" VerticalTextAlignment="Center" FontSize="Medium" HorizontalTextAlignment="Center"> <Label Text="{Binding Ability.RacialBonus, Source={x:Reference this}, StringFormat='{}{0:+0;-#}', FallbackValue=''}" VerticalTextAlignment="Center" FontSize="Medium" HorizontalTextAlignment="Center" IsVisible="{Binding Ability.HasRacialBonus, Source={x:Reference this}}">
<Label.IsVisible> <!--<Label.IsVisible>
<Binding Source="{x:Reference this}" Path="Ability.RacialBonus"> <Binding Source="{x:Reference this}" Path="Ability.RacialBonus">
<Binding.Converter> <Binding.Converter>
<tools:IntComparerToBooleanConverter <tools:IntComparerToBooleanConverter
@ -25,7 +26,7 @@
<x:Int32>0</x:Int32> <x:Int32>0</x:Int32>
</Binding.ConverterParameter> </Binding.ConverterParameter>
</Binding> </Binding>
</Label.IsVisible> </Label.IsVisible>-->
</Label> </Label>
<Picker SelectedItem="{Binding Ability.RacialDispatchedBonus, Source={x:Reference this}, FallbackValue=''}" ItemDisplayBinding="{Binding StringFormat='{}{0:+0;-#}'}" IsVisible="{Binding Ability.HasRacialDispatchedBonus, Source={x:Reference this}}"> <Picker SelectedItem="{Binding Ability.RacialDispatchedBonus, Source={x:Reference this}, FallbackValue=''}" ItemDisplayBinding="{Binding StringFormat='{}{0:+0;-#}'}" IsVisible="{Binding Ability.HasRacialDispatchedBonus, Source={x:Reference this}}">
<Picker.ItemsSource> <Picker.ItemsSource>

View file

@ -23,6 +23,16 @@ namespace AideDeJeu.Views.PlayerCharacter
} }
protected override bool OnBackButtonPressed()
{
Device.BeginInvokeOnMainThread(async () => {
var result = await this.DisplayAlert("Attention", "Si vous revenez au menu, vous perdrez le personnage en cours de création", "Menu", "Annuler");
if (result) await this.Navigation.PopAsync();
});
return true;
//return base.OnBackButtonPressed();
}
public Command ChangePageCommand public Command ChangePageCommand
{ {
get get