| 
									
										
										
										
											2020-02-27 17:24:45 +01:00
										 |  |  | import 'package:flutter/material.dart'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-19 15:50:44 +01:00
										 |  |  | class Item { | 
					
						
							|  |  |  |   String Id; | 
					
						
							|  |  |  |   String RootId; | 
					
						
							|  |  |  |   String ParentLink; | 
					
						
							|  |  |  |   String Name; | 
					
						
							|  |  |  |   String NormalizedName; | 
					
						
							|  |  |  |   String ParentName; | 
					
						
							|  |  |  |   int NameLevel; | 
					
						
							|  |  |  |   String Alias; | 
					
						
							|  |  |  |   String AliasText; | 
					
						
							|  |  |  |   String NormalizedAlias; | 
					
						
							|  |  |  |   String Source; | 
					
						
							|  |  |  |   String Markdown; | 
					
						
							|  |  |  |   String FullText; | 
					
						
							| 
									
										
										
										
											2020-02-21 21:28:14 +01:00
										 |  |  |   String ItemType; | 
					
						
							| 
									
										
										
										
											2020-02-19 15:50:44 +01:00
										 |  |  |   List<Item> Children; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-21 21:28:14 +01:00
										 |  |  |   Item({this.Id, this.Name, this.Alias, this.Markdown, this.ItemType}); | 
					
						
							| 
									
										
										
										
											2020-02-19 15:50:44 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |   Item.fromMap(Map<String, dynamic> map) { | 
					
						
							|  |  |  |     this.Id = map["Id"]; | 
					
						
							|  |  |  |     this.Name = map["Name"]; | 
					
						
							|  |  |  |     this.Alias = map["AltName"]; | 
					
						
							| 
									
										
										
										
											2020-02-21 14:49:39 +01:00
										 |  |  |     this.AliasText = map["AltNameText"]; | 
					
						
							| 
									
										
										
										
											2020-02-19 15:50:44 +01:00
										 |  |  |     this.Markdown = map["Markdown"]; | 
					
						
							| 
									
										
										
										
											2020-02-21 21:28:14 +01:00
										 |  |  |     this.ItemType = map["ItemType"]; | 
					
						
							| 
									
										
										
										
											2020-02-19 15:50:44 +01:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /*factory Item.fromMap(Map<String, dynamic> json) => new Item( | 
					
						
							|  |  |  |     Id: json["Id"], | 
					
						
							|  |  |  |     Name: json["Name"], | 
					
						
							|  |  |  |     Alias: json["AltName"], | 
					
						
							|  |  |  |     Markdown: json["Markdown"], | 
					
						
							|  |  |  |     Discriminator: json["Discriminator"], | 
					
						
							|  |  |  |   );*/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Map<String, dynamic> toMap() => { | 
					
						
							|  |  |  |     "Id": Id, | 
					
						
							|  |  |  |     "RootId": Id, | 
					
						
							|  |  |  |     "Name": Name, | 
					
						
							|  |  |  |     "AltName": Alias, | 
					
						
							| 
									
										
										
										
											2020-02-21 14:49:39 +01:00
										 |  |  |     "AltNameText": AliasText, | 
					
						
							| 
									
										
										
										
											2020-02-19 15:50:44 +01:00
										 |  |  |     "Markdown": Markdown, | 
					
						
							| 
									
										
										
										
											2020-02-21 21:28:14 +01:00
										 |  |  |     "ItemType": ItemType, | 
					
						
							| 
									
										
										
										
											2020-02-19 15:50:44 +01:00
										 |  |  |   }; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class MonsterItem extends Item { | 
					
						
							|  |  |  |   String Family; | 
					
						
							|  |  |  |   String Type; | 
					
						
							|  |  |  |   String Size; | 
					
						
							|  |  |  |   String Alignment; | 
					
						
							|  |  |  |   String Terrain; | 
					
						
							|  |  |  |   String Legendary; | 
					
						
							|  |  |  |   String ArmorClass; | 
					
						
							|  |  |  |   String HitPoints; | 
					
						
							|  |  |  |   String Speed; | 
					
						
							|  |  |  |   String Strength; | 
					
						
							|  |  |  |   String Dexterity; | 
					
						
							|  |  |  |   String Constitution; | 
					
						
							|  |  |  |   String Intelligence; | 
					
						
							|  |  |  |   String Wisdom; | 
					
						
							|  |  |  |   String Charisma; | 
					
						
							|  |  |  |   String SavingThrows; | 
					
						
							|  |  |  |   String Skills; | 
					
						
							|  |  |  |   String DamageVulnerabilities; | 
					
						
							|  |  |  |   String DamageImmunities; | 
					
						
							|  |  |  |   String ConditionImmunities; | 
					
						
							|  |  |  |   String DamageResistances; | 
					
						
							|  |  |  |   String Senses; | 
					
						
							|  |  |  |   String Languages; | 
					
						
							|  |  |  |   String Challenge; | 
					
						
							|  |  |  |   int XP; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   MonsterItem.fromMap(Map<String, dynamic> map) | 
					
						
							|  |  |  |     : super.fromMap(map) { | 
					
						
							|  |  |  |     this.Family = map["Family"]; | 
					
						
							|  |  |  |     this.Type = map["Type"]; | 
					
						
							|  |  |  |     this.Size = map["Size"]; | 
					
						
							|  |  |  |     this.Alignment = map["Alignment"]; | 
					
						
							|  |  |  |     this.Terrain = map["Terrain"]; | 
					
						
							|  |  |  |     this.Legendary = map["Legendary"]; | 
					
						
							|  |  |  |     this.ArmorClass = map["ArmorClass"]; | 
					
						
							|  |  |  |     this.HitPoints = map["HitPoints"]; | 
					
						
							|  |  |  |     this.Speed = map["Speed"]; | 
					
						
							|  |  |  |     this.Strength = map["Strength"]; | 
					
						
							|  |  |  |     this.Dexterity = map["Dexterity"]; | 
					
						
							|  |  |  |     this.Constitution = map["Constitution"]; | 
					
						
							|  |  |  |     this.Intelligence = map["Intelligence"]; | 
					
						
							|  |  |  |     this.Wisdom = map["Wisdom"]; | 
					
						
							|  |  |  |     this.Charisma = map["Charisma"]; | 
					
						
							|  |  |  |     this.SavingThrows = map["SavingThrows"]; | 
					
						
							|  |  |  |     this.Skills = map["Skills"]; | 
					
						
							|  |  |  |     this.DamageVulnerabilities = map["DamageVulnerabilities"]; | 
					
						
							|  |  |  |     this.DamageImmunities = map["DamageImmunities"]; | 
					
						
							|  |  |  |     this.ConditionImmunities = map["ConditionImmunities"]; | 
					
						
							|  |  |  |     this.DamageResistances = map["DamageResistances"]; | 
					
						
							|  |  |  |     this.Senses = map["Senses"]; | 
					
						
							|  |  |  |     this.Languages = map["Languages"]; | 
					
						
							|  |  |  |     this.Challenge = map["Challenge"]; | 
					
						
							|  |  |  |     this.XP = map["XP"]; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-22 00:59:48 +01:00
										 |  |  | class Items extends Item { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Items.fromMap(Map<String, dynamic> map) | 
					
						
							|  |  |  |       : super.fromMap(map) { | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-26 17:20:09 +01:00
										 |  |  | abstract class FilteredItems extends Items { | 
					
						
							| 
									
										
										
										
											2020-02-21 14:49:39 +01:00
										 |  |  |   String Family; | 
					
						
							| 
									
										
										
										
											2020-02-22 00:59:48 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |   FilteredItems.fromMap(Map<String, dynamic> map) | 
					
						
							|  |  |  |       : super.fromMap(map) { | 
					
						
							|  |  |  |     this.Family = map["Family"]; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2020-02-25 17:51:11 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-26 17:20:09 +01:00
										 |  |  |   List<Filter> toFilterList(); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2020-02-25 17:51:11 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-26 17:20:09 +01:00
										 |  |  | enum FilterType { | 
					
						
							|  |  |  |   Choices, Range | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | class Filter { | 
					
						
							|  |  |  |   String name; | 
					
						
							|  |  |  |   FilterType type; | 
					
						
							|  |  |  |   List<String> values; | 
					
						
							| 
									
										
										
										
											2020-02-27 17:24:45 +01:00
										 |  |  |   Set<String> selectedValues = Set<String>(); | 
					
						
							|  |  |  |   RangeValues rangeValues; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Filter({this.name, this.type, this.values}) { | 
					
						
							|  |  |  |     rangeValues = RangeValues(0, values.length.toDouble() - 1); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2020-02-22 00:59:48 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class MonsterItems extends FilteredItems { | 
					
						
							| 
									
										
										
										
											2020-02-26 17:20:09 +01:00
										 |  |  |   Filter types; | 
					
						
							|  |  |  |   Filter challenges; | 
					
						
							|  |  |  |   Filter sizes; | 
					
						
							|  |  |  |   Filter sources; | 
					
						
							|  |  |  |   Filter terrains; | 
					
						
							| 
									
										
										
										
											2020-02-21 14:49:39 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |   MonsterItems.fromMap(Map<String, dynamic> map) | 
					
						
							|  |  |  |       : super.fromMap(map) { | 
					
						
							| 
									
										
										
										
											2020-02-26 17:20:09 +01:00
										 |  |  |     this.types = Filter(name: "Type", type: FilterType.Choices, values: map["Types"].toString().split("|")); | 
					
						
							|  |  |  |     this.challenges = Filter(name: "Dangerosité", type: FilterType.Range, values: map["Challenges"].toString().split("|")); | 
					
						
							|  |  |  |     this.sizes = Filter(name: "Taille", type: FilterType.Range, values: map["Sizes"].toString().split("|"));; | 
					
						
							|  |  |  |     this.sources = Filter(name: "Source", type: FilterType.Choices, values: map["Sources"].toString().split("|")); | 
					
						
							|  |  |  |     this.terrains = Filter(name: "Terrain", type: FilterType.Choices, values: map["Terrains"].toString().split("|")); | 
					
						
							| 
									
										
										
										
											2020-02-21 14:49:39 +01:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2020-02-25 17:51:11 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | //  Map<String, dynamic> toMap() => {
 | 
					
						
							|  |  |  |   //"Id": Id,
 | 
					
						
							| 
									
										
										
										
											2020-02-26 17:20:09 +01:00
										 |  |  |   List<Filter> toFilterList() => { | 
					
						
							|  |  |  |     types, | 
					
						
							|  |  |  |     challenges, | 
					
						
							|  |  |  |     sizes, | 
					
						
							|  |  |  |     sources, | 
					
						
							|  |  |  |     terrains, | 
					
						
							|  |  |  |   }.toList(); | 
					
						
							| 
									
										
										
										
											2020-02-25 17:51:11 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-21 14:49:39 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-19 15:50:44 +01:00
										 |  |  | Item itemFromMap(Map<String, dynamic> map) { | 
					
						
							| 
									
										
										
										
											2020-02-21 21:28:14 +01:00
										 |  |  |   switch(map["ItemType"]) { | 
					
						
							| 
									
										
										
										
											2020-02-19 15:50:44 +01:00
										 |  |  |     case "MonsterItem": return MonsterItem.fromMap(map); | 
					
						
							| 
									
										
										
										
											2020-02-21 14:49:39 +01:00
										 |  |  |     case "MonsterItems": return MonsterItems.fromMap(map); | 
					
						
							| 
									
										
										
										
											2020-02-19 15:50:44 +01:00
										 |  |  |   } | 
					
						
							|  |  |  |   return Item.fromMap(map); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | List<Item> itemsFromMapList(List<Map<String, dynamic>> mapList) { | 
					
						
							|  |  |  |   return List.generate(mapList.length, (i) { | 
					
						
							|  |  |  |     return itemFromMap(mapList[i]); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | } |