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:
parent
062b03547a
commit
d25de58c6d
5 changed files with 93 additions and 36 deletions
|
|
@ -212,6 +212,7 @@ namespace AideDeJeu.ViewModels.PlayerCharacter
|
|||
OnPropertyChanged(nameof(Mod));
|
||||
OnPropertyChanged(nameof(ValueString));
|
||||
OnPropertyChanged(nameof(ModString));
|
||||
OnPropertyChanged(nameof(HasRacialBonus));
|
||||
}
|
||||
}
|
||||
private int _RacialDispatchedBonus = 0;
|
||||
|
|
@ -240,6 +241,13 @@ namespace AideDeJeu.ViewModels.PlayerCharacter
|
|||
OnPropertyChanged(nameof(HasRacialDispatchedBonus));
|
||||
}
|
||||
}
|
||||
public bool HasRacialBonus
|
||||
{
|
||||
get
|
||||
{
|
||||
return _RacialBonus != 0;
|
||||
}
|
||||
}
|
||||
public bool HasRacialDispatchedBonus
|
||||
{
|
||||
get
|
||||
|
|
|
|||
|
|
@ -20,8 +20,11 @@ namespace AideDeJeu.ViewModels.PlayerCharacter
|
|||
{
|
||||
public class PlayerCharacterEditorViewModel : BaseViewModel
|
||||
{
|
||||
private Random _Random;
|
||||
public PlayerCharacterEditorViewModel()
|
||||
{
|
||||
_Random = new Random(DateTime.Now.Millisecond);
|
||||
|
||||
SelectedPlayerCharacter = new PlayerCharacterViewModel() { Background = new BackgroundViewModel(), Abilities = new AbilitiesViewModel() };
|
||||
SelectedPlayerCharacter.PropertyChanged += SelectedPlayerCharacter_PropertyChanged;
|
||||
|
||||
|
|
@ -916,17 +919,46 @@ namespace AideDeJeu.ViewModels.PlayerCharacter
|
|||
}
|
||||
}
|
||||
*/
|
||||
public ICommand RollDicesCommand
|
||||
public ICommand RollDicesMRickCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Command(async () => await ExecuteRollDicesCommandAsync());
|
||||
return new Command(() => PrefillDices(RollMRick()));
|
||||
}
|
||||
}
|
||||
private async Task ExecuteRollDicesCommandAsync()
|
||||
public ICommand RollDices2d6plus6Command
|
||||
{
|
||||
get
|
||||
{
|
||||
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)
|
||||
{
|
||||
var random = new Random(DateTime.Now.Millisecond);
|
||||
var values = RollMRick(random);
|
||||
values.Sort();
|
||||
List<int> mins;
|
||||
List<int> maxs;
|
||||
|
|
@ -942,16 +974,13 @@ namespace AideDeJeu.ViewModels.PlayerCharacter
|
|||
}
|
||||
|
||||
SelectedPlayerCharacter.Abilities.Unlisten();
|
||||
SelectedPlayerCharacter.Abilities.Strength.BaseValue = PickAbility(random, ref mins, ref maxs, "Force");
|
||||
SelectedPlayerCharacter.Abilities.Dexterity.BaseValue = PickAbility(random, ref mins, ref maxs, "Dextérité");
|
||||
SelectedPlayerCharacter.Abilities.Constitution.BaseValue = PickAbility(random, ref mins, ref maxs, "Constitution");
|
||||
SelectedPlayerCharacter.Abilities.Intelligence.BaseValue = PickAbility(random, ref mins, ref maxs, "Intelligence");
|
||||
SelectedPlayerCharacter.Abilities.Wisdom.BaseValue = PickAbility(random, ref mins, ref maxs, "Sagesse");
|
||||
SelectedPlayerCharacter.Abilities.Charisma.BaseValue = PickAbility(random, ref mins, ref maxs, "Charisme");
|
||||
SelectedPlayerCharacter.Abilities.Strength.BaseValue = PickAbility(ref mins, ref maxs, "Force");
|
||||
SelectedPlayerCharacter.Abilities.Dexterity.BaseValue = PickAbility(ref mins, ref maxs, "Dextérité");
|
||||
SelectedPlayerCharacter.Abilities.Constitution.BaseValue = PickAbility(ref mins, ref maxs, "Constitution");
|
||||
SelectedPlayerCharacter.Abilities.Intelligence.BaseValue = PickAbility(ref mins, ref maxs, "Intelligence");
|
||||
SelectedPlayerCharacter.Abilities.Wisdom.BaseValue = PickAbility(ref mins, ref maxs, "Sagesse");
|
||||
SelectedPlayerCharacter.Abilities.Charisma.BaseValue = PickAbility(ref mins, ref maxs, "Charisme");
|
||||
SelectedPlayerCharacter.Abilities.Listen();
|
||||
|
||||
//await GeneratePdfAsync();
|
||||
//await OpenPdfAsync();
|
||||
}
|
||||
|
||||
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);
|
||||
if (value == true)
|
||||
{
|
||||
return PickOne(random, ref maxs);
|
||||
return PickOne(ref maxs);
|
||||
}
|
||||
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];
|
||||
values.RemoveAt(index);
|
||||
return pick;
|
||||
}
|
||||
|
||||
private List<int> RollMRick(Random random)
|
||||
private List<int> RollMRick()
|
||||
{
|
||||
var dices = new List<int>();
|
||||
var roll = Roll2d6(random);
|
||||
var roll = Roll2d6();
|
||||
dices.Add(6 + roll);
|
||||
dices.Add(19 - roll);
|
||||
roll = Roll2d6(random);
|
||||
roll = Roll2d6();
|
||||
dices.Add(6 + roll);
|
||||
dices.Add(19 - roll);
|
||||
roll = Roll2d6(random);
|
||||
roll = Roll2d6();
|
||||
dices.Add(6 + roll);
|
||||
dices.Add(19 - roll);
|
||||
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
|
||||
|
||||
|
|
|
|||
|
|
@ -25,16 +25,16 @@
|
|||
<RowDefinition Height="auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<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 Grid.Column="1" BorderColor="Black" Padding="2">
|
||||
<ImageButton Source="cubes.png" Command="{Binding RollDicesCommand}" />
|
||||
<ImageButton Source="cubes.png" Command="{Binding RollDices2d6plus6Command}" />
|
||||
</Frame>
|
||||
<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 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>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
|
|
@ -56,10 +56,10 @@
|
|||
<RowDefinition Height="auto" />
|
||||
<RowDefinition Height="auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Label Grid.Column="0" Text="Base" HorizontalTextAlignment="Center" />
|
||||
<Label Grid.Column="1" Text="Bonus" HorizontalTextAlignment="Center"/>
|
||||
<Label Grid.Column="2" Text="Valeur" HorizontalTextAlignment="Center"/>
|
||||
<Label Grid.Column="3" Text="Mod" HorizontalTextAlignment="Center"/>
|
||||
<Label Grid.Column="0" Text="Base" HorizontalTextAlignment="Center" FontSize="Medium" />
|
||||
<Label Grid.Column="1" Text="Bonus" HorizontalTextAlignment="Center" FontSize="Medium" />
|
||||
<Label Grid.Column="2" Text="Valeur" HorizontalTextAlignment="Center" FontSize="Medium" />
|
||||
<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" />
|
||||
<pcviews:AbilityBaseValueView Grid.Row="2" Grid.Column="0" BindingContext="{Binding}" Ability="{Binding SelectedPlayerCharacter.Abilities.Strength}" />
|
||||
|
|
|
|||
|
|
@ -8,12 +8,13 @@
|
|||
<ResourceDictionary>
|
||||
<tools:MonsterMarkdownTheme x:Key="MonsterMarkdownTheme" />
|
||||
<tools:NullToFalseConverter x:Key="NullToFalseConverter" />
|
||||
<tools:NullToTrueConverter x:Key="NullToTrueConverter" />
|
||||
</ResourceDictionary>
|
||||
</ContentView.Resources>
|
||||
<ContentView.Content>
|
||||
<Grid>
|
||||
<Label Text="{Binding Ability.RacialBonus, Source={x:Reference this}, StringFormat='{}{0:+0;-#}', FallbackValue=''}" VerticalTextAlignment="Center" FontSize="Medium" HorizontalTextAlignment="Center">
|
||||
<Label.IsVisible>
|
||||
<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>
|
||||
<Binding Source="{x:Reference this}" Path="Ability.RacialBonus">
|
||||
<Binding.Converter>
|
||||
<tools:IntComparerToBooleanConverter
|
||||
|
|
@ -25,7 +26,7 @@
|
|||
<x:Int32>0</x:Int32>
|
||||
</Binding.ConverterParameter>
|
||||
</Binding>
|
||||
</Label.IsVisible>
|
||||
</Label.IsVisible>-->
|
||||
</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.ItemsSource>
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
get
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue