mirror of
				https://github.com/Nioux/AideDeJeu.git
				synced 2025-10-30 23:16:09 +00:00 
			
		
		
		
	Spell abstract
This commit is contained in:
		
							parent
							
								
									d2f99b15c5
								
							
						
					
					
						commit
						4274033d16
					
				
					 5 changed files with 6 additions and 73 deletions
				
			
		|  | @ -7,58 +7,8 @@ using System.Xml.Serialization; | ||||||
| 
 | 
 | ||||||
| namespace AideDeJeuLib.Spells | namespace AideDeJeuLib.Spells | ||||||
| { | { | ||||||
|     public class Spell : Item |     public abstract class Spell : Item | ||||||
|     { |     { | ||||||
|         public string LevelType |  | ||||||
|         { |  | ||||||
|             get |  | ||||||
|             { |  | ||||||
|                 if (int.Parse(Level) > 0) |  | ||||||
|                 { |  | ||||||
|                     if (string.IsNullOrEmpty(Rituel)) |  | ||||||
|                     { |  | ||||||
|                         return $"{Type} de niveau {Level}"; |  | ||||||
|                     } |  | ||||||
|                     else |  | ||||||
|                     { |  | ||||||
|                         return $"{Type} de niveau {Level} {Rituel}"; |  | ||||||
|                     } |  | ||||||
|                 } |  | ||||||
|                 else |  | ||||||
|                 { |  | ||||||
|                     return $"{Type}, tour de magie"; |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|             set |  | ||||||
|             { |  | ||||||
|                 var re = new Regex("(?<type>.*) de niveau (?<level>\\d).?(?<rituel>\\(rituel\\))?"); |  | ||||||
|                 var match = re.Match(value); |  | ||||||
|                 this.Type = match.Groups["type"].Value; |  | ||||||
|                 this.Level = match.Groups["level"].Value; |  | ||||||
|                 this.Rituel = match.Groups["rituel"].Value; |  | ||||||
|                 if (string.IsNullOrEmpty(this.Type)) |  | ||||||
|                 { |  | ||||||
|                     re = new Regex("(?<type>.*), (?<level>tour de magie)"); |  | ||||||
|                     match = re.Match(value); |  | ||||||
|                     if (match.Groups["level"].Value == "tour de magie") |  | ||||||
|                     { |  | ||||||
|                         this.Type = match.Groups["type"].Value; |  | ||||||
|                         this.Level = "0"; // match.Groups["level"].Value; |  | ||||||
|                         this.Rituel = match.Groups["rituel"].Value; |  | ||||||
|                     } |  | ||||||
|                     else |  | ||||||
|                     { |  | ||||||
|                         System.Diagnostics.Debug.WriteLine(value); |  | ||||||
|                         //re = new Regex("level (?<level>\\d) - (?<type>.*?)\\w?(?<rituel>\\(ritual\\))?"); |  | ||||||
|                         re = new Regex("^(?<level>\\d) - (?<type>.*?)\\s?(?<rituel>\\(ritual\\))?$"); |  | ||||||
|                         match = re.Match(value); |  | ||||||
|                         this.Type = match.Groups["type"].Value; |  | ||||||
|                         this.Level = match.Groups["level"].Value; |  | ||||||
|                         this.Rituel = match.Groups["rituel"].Value; |  | ||||||
|                     } |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|         public string Level { get; set; } |         public string Level { get; set; } | ||||||
|         public string Type { get; set; } |         public string Type { get; set; } | ||||||
|         public string Concentration { get; set; } |         public string Concentration { get; set; } | ||||||
|  | @ -68,25 +18,8 @@ namespace AideDeJeuLib.Spells | ||||||
|         public string Components { get; set; } |         public string Components { get; set; } | ||||||
|         public string Duration { get; set; } |         public string Duration { get; set; } | ||||||
|         public string DescriptionHtml { get; set; } |         public string DescriptionHtml { get; set; } | ||||||
| 
 |  | ||||||
|         public string Source { get; set; } |         public string Source { get; set; } | ||||||
| 
 | 
 | ||||||
|         public override string Markdown |         public abstract string LevelType { get; set; } | ||||||
|         { |  | ||||||
|             get |  | ||||||
|             { |  | ||||||
|                 return |  | ||||||
|                     $"# {Name}\n" + |  | ||||||
|                     $"{NameVO}\n" + |  | ||||||
|                     $"_{LevelType}_\n" + |  | ||||||
|                     $"**Temps d'incantation :** {CastingTime}\n" + |  | ||||||
|                     $"**Portée :** {Range}\n" + |  | ||||||
|                     $"**Composantes :** {Components}\n" + |  | ||||||
|                     $"**Durée :** {Duration}\n\n" + |  | ||||||
|                     $"{DescriptionHtml}\n\n" + |  | ||||||
|                     $"**Source :** {Source}"; |  | ||||||
| 
 |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -7,7 +7,7 @@ namespace AideDeJeuLib.Spells | ||||||
| { | { | ||||||
|     public class SpellHD : Spell |     public class SpellHD : Spell | ||||||
|     { |     { | ||||||
|         public new string LevelType |         public override string LevelType | ||||||
|         { |         { | ||||||
|             get |             get | ||||||
|             { |             { | ||||||
|  |  | ||||||
|  | @ -7,7 +7,7 @@ namespace AideDeJeuLib.Spells | ||||||
| { | { | ||||||
|     public class SpellVO : Spell |     public class SpellVO : Spell | ||||||
|     { |     { | ||||||
|         public new string LevelType |         public override string LevelType | ||||||
|         { |         { | ||||||
|             get |             get | ||||||
|             { |             { | ||||||
|  |  | ||||||
|  | @ -26,7 +26,7 @@ namespace AideDeJeu.Views | ||||||
|         { |         { | ||||||
|             InitializeComponent(); |             InitializeComponent(); | ||||||
| 
 | 
 | ||||||
|             var item = new Spell |             var item = new SpellHD | ||||||
|             { |             { | ||||||
|                 Name = "", |                 Name = "", | ||||||
|                 NameVO = "", |                 NameVO = "", | ||||||
|  |  | ||||||
|  | @ -17,7 +17,7 @@ namespace AideDeJeuWeb.Controllers | ||||||
|         { |         { | ||||||
|             //var items = AideDeJeu.Tools.Helpers.GetResourceObject<IEnumerable<Spell>>("AideDeJeu.Data.spells_vf.json"); |             //var items = AideDeJeu.Tools.Helpers.GetResourceObject<IEnumerable<Spell>>("AideDeJeu.Data.spells_vf.json"); | ||||||
|             var md = await AideDeJeu.Tools.Helpers.GetResourceStringAsync("AideDeJeu.Data.spells_hd.md"); |             var md = await AideDeJeu.Tools.Helpers.GetResourceStringAsync("AideDeJeu.Data.spells_hd.md"); | ||||||
|             var items = AideDeJeu.Tools.MarkdownExtensions.MarkdownToSpells(md); |             var items = AideDeJeu.Tools.MarkdownExtensions.MarkdownToSpells<SpellHD>(md); | ||||||
| 
 | 
 | ||||||
|             var fitems = items.Where(it => it.Source.Contains(classe)).OrderBy(it => it.Level).ThenBy(it => it.Name); |             var fitems = items.Where(it => it.Source.Contains(classe)).OrderBy(it => it.Level).ThenBy(it => it.Name); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Yan Maniez
						Yan Maniez