1
0
Fork 0
mirror of https://github.com/Nioux/AideDeJeu.git synced 2025-10-29 22:45:44 +00:00
AideDeJeu/aidedejeu_flutter/lib/models/items.dart

384 lines
11 KiB
Dart
Raw Normal View History

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-03-01 01:44:08 +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-03-05 16:50:31 +01:00
class SpellItem extends Item {
String family;
String level;
String type;
String ritual;
String castingTime;
String range;
String components;
String verbalComponent;
String somaticComponent;
String materialComponent;
String concentration;
String duration;
String classes;
SpellItem(Map<String, dynamic> map) : super(map) {
this.family = map["Family"];
this.level = map["Level"];
this.type = map["Type"];
this.ritual = map["Ritual"];
this.castingTime = map["CastingTime"];
this.range = map["Range"];
this.components = map["Components"];
this.verbalComponent = map["VerbalComponent"];
this.somaticComponent = map["SomaticComponent"];
this.materialComponent = map["MaterialComponent"];
this.concentration = map["Concentration"];
this.duration = map["Duration"];
this.classes = map["Classes"];
}
}
2020-02-22 00:59:48 +01:00
class Items extends Item {
2020-03-12 17:05:53 +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-03-01 01:44:08 +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-03-13 09:46:17 +01:00
MonsterItems(Map<String, dynamic> map) : super(map) {
2020-03-01 01:44:08 +01:00
this.types = Filter(
2020-03-13 09:46:17 +01:00
name: "Types",
displayName: "monstersTypes",
2020-03-01 01:44:08 +01:00
type: FilterType.Choices,
values: map["Types"].toString().split("|"));
this.challenges = Filter(
2020-03-13 09:46:17 +01:00
name: "Challenges",
displayName: "monstersChallenges",
2020-03-01 01:44:08 +01:00
type: FilterType.Range,
values: map["Challenges"].toString().split("|"));
this.sizes = Filter(
2020-03-13 09:46:17 +01:00
name: "Sizes",
displayName: "monstersSizes",
2020-03-01 01:44:08 +01:00
type: FilterType.Range,
values: map["Sizes"].toString().split("|"));
this.sources = Filter(
2020-03-13 09:46:17 +01:00
name: "Sources",
displayName: "monstersSources",
2020-03-01 01:44:08 +01:00
type: FilterType.Choices,
values: map["Sources"].toString().split("|"));
this.terrains = Filter(
2020-03-13 09:46:17 +01:00
name: "Terrains",
displayName: "monstersTerrains",
2020-03-01 01:44:08 +01:00
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() => {
2020-03-01 01:44:08 +01:00
types,
challenges,
sizes,
sources,
terrains,
}.toList();
2020-02-21 14:49:39 +01:00
}
2020-03-05 16:50:31 +01:00
class SpellItems extends FilteredItems {
Filter classes;
Filter levels;
Filter schools;
Filter rituals;
Filter castingTimes;
Filter ranges;
Filter verbalComponents;
Filter somaticComponents;
Filter materialComponents;
Filter concentrations;
Filter durations;
Filter sources;
2020-03-13 09:46:17 +01:00
SpellItems(Map<String, dynamic> map) : super(map) {
2020-03-05 16:50:31 +01:00
this.classes = Filter(
2020-03-13 09:46:17 +01:00
name: "Classes",
displayName: "spellsClasses",
2020-03-05 16:50:31 +01:00
type: FilterType.Choices,
values: map["Classes"].toString().split("|"));
this.levels = Filter(
2020-03-13 09:46:17 +01:00
name: "Levels",
displayName: "spellsLevels",
2020-03-05 16:50:31 +01:00
type: FilterType.Choices,
values: map["Levels"].toString().split("|"));
this.schools = Filter(
2020-03-13 09:46:17 +01:00
name: "Schools",
displayName: "spellsSchools",
2020-03-05 16:50:31 +01:00
type: FilterType.Choices,
values: map["Schools"].toString().split("|"));
this.rituals = Filter(
2020-03-13 09:46:17 +01:00
name: "Rituals",
displayName: "spellsRituals",
2020-03-05 16:50:31 +01:00
type: FilterType.Choices,
values: map["Rituals"].toString().split("|"));
this.castingTimes = Filter(
2020-03-13 09:46:17 +01:00
name: "CastingTimes",
displayName: "spellsCastingTimes",
2020-03-05 16:50:31 +01:00
type: FilterType.Choices,
values: map["CastingTimes"].toString().split("|"));
this.ranges = Filter(
2020-03-13 09:46:17 +01:00
name: "Ranges",
displayName: "spellsRanges",
2020-03-05 16:50:31 +01:00
type: FilterType.Choices,
values: map["Ranges"].toString().split("|"));
this.verbalComponents = Filter(
2020-03-13 09:46:17 +01:00
name: "VerbalComponents",
displayName: "spellsVerbalComponents",
2020-03-05 16:50:31 +01:00
type: FilterType.Choices,
values: map["VerbalComponents"].toString().split("|"));
this.somaticComponents = Filter(
2020-03-13 09:46:17 +01:00
name: "SomaticComponents",
displayName: "spellsSomaticComponents",
2020-03-05 16:50:31 +01:00
type: FilterType.Choices,
values: map["SomaticComponents"].toString().split("|"));
this.materialComponents = Filter(
2020-03-13 09:46:17 +01:00
name: "MaterialComponents",
displayName: "spellsMaterialComponents",
2020-03-05 16:50:31 +01:00
type: FilterType.Choices,
values: map["MaterialComponents"].toString().split("|"));
this.concentrations = Filter(
2020-03-13 09:46:17 +01:00
name: "Concentrations",
displayName: "spellsConcentrations",
2020-03-05 16:50:31 +01:00
type: FilterType.Choices,
values: map["Concentrations"].toString().split("|"));
this.durations = Filter(
2020-03-13 09:46:17 +01:00
name: "Durations",
displayName: "spellsDurations",
2020-03-05 16:50:31 +01:00
type: FilterType.Choices,
values: map["Durations"].toString().split("|"));
this.sources = Filter(
2020-03-13 09:46:17 +01:00
name: "Sources",
displayName: "spellsSources",
2020-03-05 16:50:31 +01:00
type: FilterType.Choices,
values: map["Sources"].toString().split("|"));
}
List<Filter> toFilterList() => {
classes,
levels,
schools,
rituals,
castingTimes,
ranges,
verbalComponents,
somaticComponents,
materialComponents,
concentrations,
durations,
sources,
}.toList();
}
2020-02-29 02:36:15 +01:00
class RaceItem extends Item {
2020-03-01 01:44:08 +01:00
String fullName;
bool hasSubRaces;
String strengthBonus;
String dexterityBonus;
String constitutionBonus;
String intelligenceBonus;
String wisdomBonus;
String charismaBonus;
String dispatchedBonus;
String maxDispatchedStrengthBonus;
String maxDispatchedDexterityBonus;
String maxDispatchedConstitutionBonus;
String maxDispatchedIntelligenceBonus;
String maxDispatchedWisdomBonus;
String maxDispatchedCharismaBonus;
String abilityScoreIncrease;
String age;
String alignment;
String size;
String speed;
String darkvision;
String languages;
2020-02-29 02:36:15 +01:00
2020-03-01 01:44:08 +01:00
RaceItem(Map<String, dynamic> map) : super(map) {
this.fullName = map["FullName"];
this.hasSubRaces = map["HasSubRaces"] == "true";
this.strengthBonus = map["StrengthBonus"];
this.dexterityBonus = map["DexterityBonus"];
this.constitutionBonus = map["ConstitutionBonus"];
this.intelligenceBonus = map["IntelligenceBonus"];
this.wisdomBonus = map["WisdomBonus"];
this.charismaBonus = map["CharismaBonus"];
this.dispatchedBonus = map["DispatchedBonus"];
this.maxDispatchedStrengthBonus = map["MaxDispatchedStrengthBonus"];
this.maxDispatchedDexterityBonus = map["MaxDispatchedDexterityBonus"];
this.maxDispatchedConstitutionBonus = map["MaxDispatchedConstitutionBonus"];
this.maxDispatchedIntelligenceBonus = map["MaxDispatchedIntelligenceBonus"];
this.maxDispatchedWisdomBonus = map["MaxDispatchedWisdomBonus"];
this.maxDispatchedCharismaBonus = map["MaxDispatchedCharismaBonus"];
this.abilityScoreIncrease = map["AbilityScoreIncrease"];
this.age = map["Age"];
this.alignment = map["Alignment"];
this.size = map["Size"];
this.speed = map["Speed"];
this.darkvision = map["Darkvision"];
this.languages = map["Languages"];
}
2020-02-29 02:36:15 +01:00
}
2020-03-01 00:27:51 +01:00
class SubRaceItem extends RaceItem {
2020-03-01 01:44:08 +01:00
String parentRaceId;
2020-03-01 00:27:51 +01:00
2020-03-01 01:44:08 +01:00
SubRaceItem(Map<String, dynamic> map) : super(map) {
this.parentRaceId = map["ParentRaceId"];
}
2020-03-01 00:27:51 +01:00
}
2020-02-29 02:36:15 +01:00
class RaceItems extends FilteredItems {
RaceItems(Map<String, dynamic> map) : super(map);
@override
List<Filter> toFilterList() {
return [].toList();
}
}
2020-03-01 21:30:33 +01:00
class BackgroundItem extends Item {
String skillProficiencies;
String masteredTools;
String masteredLanguages;
String equipment;
BackgroundItem(Map<String, dynamic> map) : super(map) {
this.skillProficiencies = map["SkillProficiencies"];
this.masteredTools = map["MasteredTools"];
this.masteredLanguages = map["MasteredLanguages"];
this.equipment = map["Equipment"];
}
}
class SubBackgroundItem extends BackgroundItem {
SubBackgroundItem(Map<String, dynamic> map) : super(map);
}
2020-03-13 09:46:17 +01:00
Item itemFromMap(Map<String, dynamic> map) {
2020-03-01 01:44:08 +01:00
switch (map["ItemType"]) {
case "RaceItem":
return RaceItem(map);
case "SubRaceItem":
return SubRaceItem(map);
case "RaceItems":
return RaceItems(map);
2020-03-01 21:30:33 +01:00
case "BackgroundItem":
return BackgroundItem(map);
case "SubBackgroundItem":
return SubBackgroundItem(map);
2020-03-01 01:44:08 +01:00
case "MonsterItem":
return MonsterItem(map);
case "MonsterItems":
2020-03-13 09:46:17 +01:00
return MonsterItems(map);
2020-03-05 16:50:31 +01:00
case "SpellItem":
return SpellItem(map);
case "SpellItems":
2020-03-13 09:46:17 +01:00
return SpellItems(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
}
2020-03-13 09:46:17 +01:00
List<T> itemsFromMapList<T extends Item>(List<Map<String, dynamic>> mapList) {
2020-02-19 15:50:44 +01:00
return List.generate(mapList.length, (i) {
2020-03-13 09:46:17 +01:00
return itemFromMap(mapList[i]);
2020-02-19 15:50:44 +01:00
});
2020-03-01 00:27:51 +01:00
}