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

Avancement fiche monstre

This commit is contained in:
Yan Maniez 2018-04-29 18:25:06 +02:00
parent 387ce03d56
commit 411411271a
4 changed files with 240 additions and 62 deletions

View file

@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using Xamarin.Forms;
namespace AideDeJeu.Tools
{
public class NullToTrueConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return value == null;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return null;
}
}
public class NullToFalseConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return value != null;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return null;
}
}
}

View file

@ -19,12 +19,126 @@ namespace AideDeJeu.ViewModels
set
{
SetProperty(ref _Item, value);
//OnPropertyChanged(nameof(Description));
//OnPropertyChanged(nameof(TypeLevel));
//OnPropertyChanged(nameof(CastingTime));
//OnPropertyChanged(nameof(Range));
//OnPropertyChanged(nameof(Components));
OnPropertyChanged(nameof(TypeSizeAlignment));
OnPropertyChanged(nameof(ArmorClass));
OnPropertyChanged(nameof(HitPoints));
OnPropertyChanged(nameof(Speed));
OnPropertyChanged(nameof(SavingThrows));
OnPropertyChanged(nameof(Skills));
OnPropertyChanged(nameof(Senses));
OnPropertyChanged(nameof(Languages));
OnPropertyChanged(nameof(Challenge));
//OnPropertyChanged(nameof(Duration));
//OnPropertyChanged(nameof(Duration));
}
}
public FormattedString TypeSizeAlignment
{
get
{
var fd = FormatedTextHelpers.FontData.FromResource("contentital");
var fs = new FormattedString();
fs.Spans.Add(new Span() { Text = string.Format("{0} de taille {1}, {2}", Item.Type, Item.Size, Item.Alignment), FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor });
return fs;
}
}
public FormattedString ArmorClass
{
get
{
var fd = FormatedTextHelpers.FontData.FromResource("content");
var fs = new FormattedString();
fs.Spans.Add(new Span() { Text = string.Format("Classe d'armure {0}", Item.ArmorClass), FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor });
return fs;
}
}
public FormattedString HitPoints
{
get
{
var fd = FormatedTextHelpers.FontData.FromResource("content");
var fs = new FormattedString();
fs.Spans.Add(new Span() { Text = string.Format("Points de vie {0}", Item.HitPoints), FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor });
return fs;
}
}
public FormattedString Speed
{
get
{
var fd = FormatedTextHelpers.FontData.FromResource("content");
var fs = new FormattedString();
fs.Spans.Add(new Span() { Text = string.Format("Vitesse {0}", Item.Speed), FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor });
return fs;
}
}
public FormattedString SavingThrows
{
get
{
var fd = FormatedTextHelpers.FontData.FromResource("content");
var fdb = FormatedTextHelpers.FontData.FromResource("contentbold");
var fs = new FormattedString();
fs.Spans.Add(new Span() { Text = "Jets de sauvegarde : ", FontFamily = fdb.FontFamily, FontAttributes = fdb.FontAttributes, FontSize = fdb.FontSize, ForegroundColor = fdb.TextColor });
fs.Spans.Add(new Span() { Text = Item.SavingThrows, FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor });
return fs;
}
}
public FormattedString Skills
{
get
{
var fd = FormatedTextHelpers.FontData.FromResource("content");
var fdb = FormatedTextHelpers.FontData.FromResource("contentbold");
var fs = new FormattedString();
fs.Spans.Add(new Span() { Text = "Compétences : ", FontFamily = fdb.FontFamily, FontAttributes = fdb.FontAttributes, FontSize = fdb.FontSize, ForegroundColor = fdb.TextColor });
fs.Spans.Add(new Span() { Text = Item.Skills, FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor });
return fs;
}
}
public FormattedString Senses
{
get
{
var fd = FormatedTextHelpers.FontData.FromResource("content");
var fdb = FormatedTextHelpers.FontData.FromResource("contentbold");
var fs = new FormattedString();
fs.Spans.Add(new Span() { Text = "Sens : ", FontFamily = fdb.FontFamily, FontAttributes = fdb.FontAttributes, FontSize = fdb.FontSize, ForegroundColor = fdb.TextColor });
fs.Spans.Add(new Span() { Text = Item.Senses, FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor });
return fs;
}
}
public FormattedString Languages
{
get
{
var fd = FormatedTextHelpers.FontData.FromResource("content");
var fdb = FormatedTextHelpers.FontData.FromResource("contentbold");
var fs = new FormattedString();
fs.Spans.Add(new Span() { Text = "Langues : ", FontFamily = fdb.FontFamily, FontAttributes = fdb.FontAttributes, FontSize = fdb.FontSize, ForegroundColor = fdb.TextColor });
fs.Spans.Add(new Span() { Text = Item.Languages, FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor });
return fs;
}
}
public FormattedString Challenge
{
get
{
var fd = FormatedTextHelpers.FontData.FromResource("content");
var fdb = FormatedTextHelpers.FontData.FromResource("contentbold");
var fs = new FormattedString();
fs.Spans.Add(new Span() { Text = "Puissance : ", FontFamily = fdb.FontFamily, FontAttributes = fdb.FontAttributes, FontSize = fdb.FontSize, ForegroundColor = fdb.TextColor });
fs.Spans.Add(new Span() { Text = Item.Challenge, FontFamily = fd.FontFamily, FontAttributes = fd.FontAttributes, FontSize = fd.FontSize, ForegroundColor = fd.TextColor });
return fs;
}
}

View file

@ -1,49 +1,71 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:tools="clr-namespace:AideDeJeu.Tools"
x:Class="AideDeJeu.Views.MonsterDetailPage"
Title="{Binding Title}">
<ScrollView>
<ContentPage.Resources>
<ResourceDictionary>
<tools:NullToFalseConverter x:Key="NullToFalseConverter" />
</ResourceDictionary>
</ContentPage.Resources>
<ScrollView Orientation="Vertical">
<StackLayout Orientation="Vertical" Padding="15">
<Label Text="{Binding Item.Name}" Style="{StaticResource Key=subsubsection}" />
<Label Text=" " />
<Label FormattedText="{Binding TypeLevel}" />
<!--<StackLayout Orientation="Horizontal">
<Label Text="{Binding Item.Type}" Style="{StaticResource Key=contentital}" />
<Label Text="{Binding Item.Level, StringFormat='de niveau {0}'}" Style="{StaticResource Key=contentital}" />
</StackLayout>-->
<Label FormattedText="{Binding CastingTime}" />
<!--<StackLayout Orientation="Horizontal">
<Label Text="Durée d'incantation :" LineBreakMode="NoWrap" Style="{StaticResource Key=contentbold}" />
<Label Text="{Binding Item.CastingTime}" Style="{StaticResource Key=content}" />
</StackLayout>-->
<Label FormattedText="{Binding Range}" />
<!--<StackLayout Orientation="Horizontal">
<Label Text="Portée :" LineBreakMode="NoWrap" Style="{StaticResource Key=contentbold}" />
<Label Text="{Binding Item.Range}" Style="{StaticResource Key=content}" />
</StackLayout>-->
<Label FormattedText="{Binding Components}" />
<!--<StackLayout Orientation="Horizontal">
<Label Text="Composantes :" LineBreakMode="NoWrap" Style="{StaticResource Key=contentbold}" />
<Label Text="{Binding Item.Components}" Style="{StaticResource Key=content}" />
</StackLayout>-->
<Label FormattedText="{Binding Duration}" />
<!--<StackLayout Orientation="Horizontal">
<Label Text="Durée :" LineBreakMode="NoWrap" Style="{StaticResource Key=contentbold}" />
<Label Text="{Binding Item.Duration}" Style="{StaticResource Key=content}" />
</StackLayout>-->
<Label Text=" " />
<Label FormattedText="{Binding Description}" Style="{StaticResource Key=content}" />
<Label FormattedText="{Binding TypeSizeAlignment}" />
<BoxView WidthRequest="100" HeightRequest="2" Color="Red" />
<Label FormattedText="{Binding ArmorClass}" Style="{StaticResource Key=content}" />
<Label FormattedText="{Binding HitPoints}" Style="{StaticResource Key=content}" />
<Label FormattedText="{Binding Speed}" Style="{StaticResource Key=content}" />
<BoxView WidthRequest="100" HeightRequest="2" Color="Red" />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<Label Grid.Row="0" Grid.Column="0" Text="FOR" Style="{StaticResource Key=content}" />
<Label Grid.Row="1" Grid.Column="0" Text="{Binding Item.Strength}" Style="{StaticResource Key=content}" />
<Label Grid.Row="0" Grid.Column="1" Text="DEX" Style="{StaticResource Key=content}" />
<Label Grid.Row="1" Grid.Column="1" Text="{Binding Item.Dexterity}" Style="{StaticResource Key=content}" />
<Label Grid.Row="0" Grid.Column="2" Text="CON" Style="{StaticResource Key=content}" />
<Label Grid.Row="1" Grid.Column="2" Text="{Binding Item.Constitution}" Style="{StaticResource Key=content}" />
<Label Grid.Row="0" Grid.Column="3" Text="INT" Style="{StaticResource Key=content}" />
<Label Grid.Row="1" Grid.Column="3" Text="{Binding Item.Intelligence}" Style="{StaticResource Key=content}" />
<Label Grid.Row="0" Grid.Column="4" Text="SAG" Style="{StaticResource Key=content}" />
<Label Grid.Row="1" Grid.Column="4" Text="{Binding Item.Wisdom}" Style="{StaticResource Key=content}" />
<Label Grid.Row="0" Grid.Column="5" Text="CHA" Style="{StaticResource Key=content}" />
<Label Grid.Row="1" Grid.Column="5" Text="{Binding Item.Charisma}" Style="{StaticResource Key=content}" />
</Grid>
<BoxView WidthRequest="100" HeightRequest="2" Color="Red" />
<Label FormattedText="{Binding SavingThrows}" IsVisible="{Binding Item.SavingThrows, Converter={StaticResource NullToFalseConverter}}" Style="{StaticResource Key=content}" />
<Label FormattedText="{Binding Skills}" IsVisible="{Binding Item.Skills, Converter={StaticResource NullToFalseConverter}}" Style="{StaticResource Key=content}" />
<Label FormattedText="{Binding Senses}" IsVisible="{Binding Item.Senses, Converter={StaticResource NullToFalseConverter}}" Style="{StaticResource Key=content}" />
<Label FormattedText="{Binding Languages}" IsVisible="{Binding Item.Languages, Converter={StaticResource NullToFalseConverter}}" Style="{StaticResource Key=content}" />
<!--<Label FormattedText="{Binding Power}" Style="{StaticResource Key=content}" />-->
<Label FormattedText="{Binding Challenge}" IsVisible="{Binding Item.Challenge, Converter={StaticResource NullToFalseConverter}}" Style="{StaticResource Key=content}" />
<BoxView WidthRequest="100" HeightRequest="2" Color="Red" />
<Label Text="{Binding Item.Description}" Style="{StaticResource Key=content}" />
<Label Text="{Binding Item.Picture}" Style="{StaticResource Key=content}" />
<Label Text="{Binding Item.Legendary}" Style="{StaticResource Key=content}" />
<Label Text="{Binding Item.Source}" Style="{StaticResource Key=content}" />
</StackLayout>
</ScrollView>

View file

@ -39,28 +39,36 @@ namespace AideDeJeuLib.Monsters
public static Monster FromHtml(HtmlNode divBloc)
{
var monster = new Monster();
var divMonster = divBloc.SelectSingleNode("div[contains(@class,'monstre')]");
monster.Name = divMonster.SelectSingleNode("h1").InnerText;
monster.NameVO = divMonster.SelectSingleNode("div[contains(@class,'trad')]/a").InnerText;
var divSansSerif = divMonster.SelectSingleNode("div[contains(@class,'sansSerif')]");
var typeSizeAlignment = divSansSerif.SelectSingleNode("h2/em").InnerText;
var matchesTypeSizeAlignment = new Regex("(?<type>.*) de taille (?<size>.*), (?<alignment>.*)").Match(typeSizeAlignment);
monster.Type = matchesTypeSizeAlignment.Groups["type"].Value;
monster.Size = matchesTypeSizeAlignment.Groups["size"].Value;
monster.Alignment = matchesTypeSizeAlignment.Groups["alignment"].Value;
var divRed = divSansSerif.SelectSingleNode("div[contains(@class,'red')]");
monster.Strength = divRed.SelectSingleNode("strong").NextSibling.InnerText;
//monster.LevelType = nodeSpell.SelectSingleNode("h2/em").InnerText;
//monster.Level = spell.LevelType.Split(new string[] { " - " }, StringSplitOptions.None)[0].Split(' ')[1];
//monster.Type = spell.LevelType.Split(new string[] { " - " }, StringSplitOptions.None)[1];
//monster.CastingTime = nodeSpell.SelectSingleNode("div[@class='paragraphe']").InnerText.Split(new string[] { " : " }, StringSplitOptions.None)[1];
//monster.Range = nodeSpell.SelectSingleNode("div[strong/text()='Portée']").InnerText.Split(new string[] { " : " }, StringSplitOptions.None)[1];
//monster.Components = nodeSpell.SelectSingleNode("div[strong/text()='Composantes']").InnerText.Split(new string[] { " : " }, StringSplitOptions.None)[1];
//monster.Duration = nodeSpell.SelectSingleNode("div[strong/text()='Durée']").InnerText.Split(new string[] { " : " }, StringSplitOptions.None)[1];
//monster.DescriptionDiv = nodeSpell.SelectSingleNode("div[contains(@class,'description')]");
//monster.Overflow = nodeSpell.SelectSingleNode("div[@class='overflow']")?.InnerText;
//monster.NoOverflow = nodeSpell.SelectSingleNode("div[@class='nooverflow']")?.InnerText;
//monster.Source = nodeSpell.SelectSingleNode("div[@class='source']").InnerText;
var divMonster = divBloc?.SelectSingleNode("div[contains(@class,'monstre')]");
monster.Name = divMonster?.SelectSingleNode("h1").InnerText;
monster.NameVO = divMonster?.SelectSingleNode("div[contains(@class,'trad')]/a")?.InnerText;
var divSansSerif = divMonster?.SelectSingleNode("div[contains(@class,'sansSerif')]");
var typeSizeAlignment = divSansSerif?.SelectSingleNode("h2/em")?.InnerText;
if (typeSizeAlignment != null)
{
var matchesTypeSizeAlignment = new Regex("(?<type>.*) de taille (?<size>.*), (?<alignment>.*)").Match(typeSizeAlignment);
monster.Type = matchesTypeSizeAlignment?.Groups["type"]?.Value?.Trim();
monster.Size = matchesTypeSizeAlignment?.Groups["size"]?.Value?.Trim();
monster.Alignment = matchesTypeSizeAlignment?.Groups["alignment"]?.Value?.Trim();
}
var divRed = divSansSerif?.SelectSingleNode("div[contains(@class,'red')]");
monster.ArmorClass = divRed?.SelectSingleNode("strong[contains(text(),'armure')]")?.NextSibling?.InnerText;
monster.HitPoints = divRed?.SelectSingleNode("strong[contains(text(),'Points de vie')]")?.NextSibling?.InnerText;
monster.Speed = divRed?.SelectSingleNode("strong[contains(text(),'Vitesse')]")?.NextSibling?.InnerText;
monster.Strength = divRed?.SelectSingleNode("div[contains(@class,'carac')]/strong[contains(text(),'FOR')]")?.NextSibling?.NextSibling?.InnerText;
monster.Dexterity = divRed?.SelectSingleNode("div[contains(@class,'carac')]/strong[contains(text(),'DEX')]")?.NextSibling?.NextSibling?.InnerText;
monster.Constitution = divRed?.SelectSingleNode("div[contains(@class,'carac')]/strong[contains(text(),'CON')]")?.NextSibling?.NextSibling?.InnerText;
monster.Intelligence = divRed?.SelectSingleNode("div[contains(@class,'carac')]/strong[contains(text(),'INT')]")?.NextSibling?.NextSibling?.InnerText;
monster.Wisdom = divRed?.SelectSingleNode("div[contains(@class,'carac')]/strong[contains(text(),'SAG')]")?.NextSibling?.NextSibling?.InnerText;
monster.Charisma = divRed?.SelectSingleNode("div[contains(@class,'carac')]/strong[contains(text(),'CHA')]")?.NextSibling?.NextSibling?.InnerText;
monster.SavingThrows = divRed?.SelectSingleNode("strong[contains(text(),'Jets de sauvegarde')]")?.NextSibling?.InnerText;
monster.Skills = divRed?.SelectSingleNode("strong[contains(text(),'Compétences')]")?.NextSibling?.InnerText;
monster.Senses = divRed?.SelectSingleNode("strong[contains(text(),'Sens')]")?.NextSibling?.InnerText;
monster.Languages = divRed?.SelectSingleNode("strong[contains(text(),'Langues')]")?.NextSibling?.InnerText;
monster.Power = divRed?.SelectSingleNode("strong[contains(text(),'Puissance')]")?.NextSibling?.InnerText;
return monster;
}