2020-02-29 01:40:05 +01:00
|
|
|
import 'package:aidedejeu_flutter/models/filters.dart';
|
2020-02-27 17:24:45 +01:00
|
|
|
|
2020-02-19 15:50:44 +01:00
|
|
|
class Item {
|
2020-02-28 17:59:22 +01:00
|
|
|
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;
|
|
|
|
|
String itemType;
|
|
|
|
|
List<Item> children;
|
|
|
|
|
|
2020-02-29 01:40:05 +01:00
|
|
|
Item(Map<String, dynamic> map) {
|
2020-02-28 17:59:22 +01:00
|
|
|
this.id = map["Id"];
|
|
|
|
|
this.rootId = map["RootId"];
|
|
|
|
|
this.name = map["Name"];
|
|
|
|
|
this.alias = map["AltName"];
|
|
|
|
|
this.aliasText = map["AltNameText"];
|
|
|
|
|
this.markdown = map["Markdown"];
|
|
|
|
|
this.itemType = map["ItemType"];
|
2020-02-19 15:50:44 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class MonsterItem extends Item {
|
2020-02-28 17:59:22 +01:00
|
|
|
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;
|
2020-02-19 15:50:44 +01:00
|
|
|
|
2020-02-29 01:40:05 +01:00
|
|
|
MonsterItem(Map<String, dynamic> map)
|
|
|
|
|
: super(map) {
|
2020-02-28 17:59:22 +01:00
|
|
|
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-19 15:50:44 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-22 00:59:48 +01:00
|
|
|
class Items extends Item {
|
|
|
|
|
|
2020-02-29 01:40:05 +01:00
|
|
|
Items(Map<String, dynamic> map)
|
|
|
|
|
: super(map) {
|
2020-02-22 00:59:48 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-26 17:20:09 +01:00
|
|
|
abstract class FilteredItems extends Items {
|
2020-02-28 17:59:22 +01:00
|
|
|
String family;
|
2020-02-22 00:59:48 +01:00
|
|
|
|
2020-02-29 01:40:05 +01:00
|
|
|
FilteredItems(Map<String, dynamic> map)
|
|
|
|
|
: super(map) {
|
2020-02-28 17:59:22 +01:00
|
|
|
this.family = map["Family"];
|
2020-02-22 00:59:48 +01:00
|
|
|
}
|
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-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
|
|
|
|
2020-02-29 01:40:05 +01:00
|
|
|
MonsterItems(Map<String, dynamic> map)
|
|
|
|
|
: super(map) {
|
2020-02-26 17:20:09 +01:00
|
|
|
this.types = Filter(name: "Type", type: FilterType.Choices, values: map["Types"].toString().split("|"));
|
2020-02-27 23:30:22 +01:00
|
|
|
this.challenges = Filter(name: "Challenge", type: FilterType.Range, values: map["Challenges"].toString().split("|"));
|
|
|
|
|
this.sizes = Filter(name: "Size", type: FilterType.Range, values: map["Sizes"].toString().split("|"));;
|
2020-02-26 17:20:09 +01:00
|
|
|
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
|
|
|
|
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-29 02:36:15 +01:00
|
|
|
class RaceItem extends Item {
|
|
|
|
|
RaceItem(Map<String, dynamic> map) : super(map);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class RaceItems extends FilteredItems {
|
|
|
|
|
RaceItems(Map<String, dynamic> map) : super(map);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
List<Filter> toFilterList() {
|
|
|
|
|
return [].toList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
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-29 02:36:15 +01:00
|
|
|
case "RaceItem": return RaceItem(map);
|
|
|
|
|
case "RaceItems": return RaceItems(map);
|
2020-02-29 01:40:05 +01:00
|
|
|
case "MonsterItem": return MonsterItem(map);
|
|
|
|
|
case "MonsterItems": return MonsterItems(map);
|
2020-02-19 15:50:44 +01:00
|
|
|
}
|
2020-02-29 01:40:05 +01:00
|
|
|
return Item(map);
|
2020-02-19 15:50:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<Item> itemsFromMapList(List<Map<String, dynamic>> mapList) {
|
|
|
|
|
return List.generate(mapList.length, (i) {
|
|
|
|
|
return itemFromMap(mapList[i]);
|
|
|
|
|
});
|
|
|
|
|
}
|