1
0
Fork 0
mirror of https://github.com/Nioux/AideDeJeu.git synced 2025-10-29 14:35:45 +00:00

Ajustements

This commit is contained in:
Yan Maniez 2020-02-22 00:59:48 +01:00
parent 0d81ea6799
commit 033f7ec94a
3 changed files with 74 additions and 41 deletions

View file

@ -40,8 +40,11 @@ Future<Database> getDatabaseInstance() async {
Future<Item> getItemWithId(String id) async {
print("getItemWithId " + id);
final db = await database;
var response = await db
.query("Items", where: "Id = ? OR RootId = ?", whereArgs: [id, id]);
var response = await db.query(
"Items",
where: "Id = ? OR RootId = ?",
whereArgs: [id, id]
);
if (response.isEmpty) {
print("Id not found");
}
@ -54,16 +57,18 @@ Future<Item> loadChildrenItems(Item item) async {
String itemType =
item.ItemType.substring(0, item.ItemType.length - 1);
String family = "";
if (item is MonsterItems) {
family = (item as MonsterItems)?.Family ?? "";
if (item is FilteredItems) {
family = (item as FilteredItems)?.Family ?? "";
}
final db = await database;
var response = await db
.query("Items", where: "ItemType = ? AND Family = ?",
var response = await db.query(
"Items",
where: "ItemType = ? AND Family = ?",
whereArgs: [itemType, family],
orderBy: "NormalizedName");
orderBy: "NormalizedName"
);
if (response.isEmpty) {
print("Id not found");
print("Children not found");
}
item.Children = response.isNotEmpty
? itemsFromMapList(response)

View file

@ -103,8 +103,23 @@ class MonsterItem extends Item {
}
}
class MonsterItems extends Item {
class Items extends Item {
Items.fromMap(Map<String, dynamic> map)
: super.fromMap(map) {
}
}
class FilteredItems extends Items {
String Family;
FilteredItems.fromMap(Map<String, dynamic> map)
: super.fromMap(map) {
this.Family = map["Family"];
}
}
class MonsterItems extends FilteredItems {
String Type;
String Size;
String Alignment;
@ -132,7 +147,6 @@ class MonsterItems extends Item {
MonsterItems.fromMap(Map<String, dynamic> map)
: super.fromMap(map) {
this.Family = map["Family"];
this.Type = map["Type"];
this.Size = map["Size"];
this.Alignment = map["Alignment"];