Skip to content

Commit

Permalink
[Domain] Added some models for the monsters
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolfteam committed Mar 28, 2021
1 parent 76d531a commit 70108ce
Show file tree
Hide file tree
Showing 11 changed files with 107 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/domain/assets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class Assets {
static String materialsDbPath = '$dbPath/materials.json';
static String elementsDbPath = '$dbPath/elements.json';
static String gameCodesDbPath = '$dbPath/game_codes.json';
static String monstersDbPath = '$dbPath/monsters.json';
static String translationsBasePath = 'assets/i18n';

//General
Expand Down Expand Up @@ -44,6 +45,9 @@ class Assets {
//Others
static String otherImgsBasePath = 'assets/others';

//Monsters
static String monstersImgsBasePath = 'assets/monsters';

static String getArtifactPath(String name) => '$artifactsBasePath/$name';
static String getCharacterPath(String name) => '$charactersBasePath/$name';
static String getCharacterFullPath(String name) => '$characterFullBasePath/$name';
Expand All @@ -56,6 +60,8 @@ class Assets {

static String getOtherImgsPath(String name) => '$otherImgsBasePath/$name';

static String getMonsterImgPath(String name) => '$monstersImgsBasePath/$name';

static String getBowPath(String name) => '$bowsBasePath/$name';
static String getCatalystPath(String name) => '$catalystBasePath/$name';
static String getClaymorePath(String name) => '$claymoresBasePath/$name';
Expand Down
2 changes: 2 additions & 0 deletions lib/domain/enums/enums.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export 'item_status_type.dart';
export 'item_type.dart';
export 'material_filter_type.dart';
export 'material_type.dart';
export 'monster_filter_type.dart';
export 'monster_type.dart';
export 'region_type.dart';
export 'sort_direction_type.dart';
export 'stat_type.dart';
Expand Down
3 changes: 3 additions & 0 deletions lib/domain/enums/monster_filter_type.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
enum MonsterFilterType {
name,
}
11 changes: 11 additions & 0 deletions lib/domain/enums/monster_type.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
enum MonsterType {
all,
abyssOrder,
elementalLifeForm,
human,
magicalBeast,
boss,
hilichurl,
fatui,
automaton,
}
24 changes: 24 additions & 0 deletions lib/domain/models/db/monsters/monster_file_model.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:genshindb/domain/assets.dart';
import 'package:genshindb/domain/enums/enums.dart';

part 'monster_file_model.freezed.dart';
part 'monster_file_model.g.dart';

@freezed
abstract class MonsterFileModel implements _$MonsterFileModel {
@late
String get fullImagePath => Assets.getMonsterImgPath(image);

factory MonsterFileModel({
@required String key,
@required String image,
@required MonsterType type,
@required bool isComingSoon,
@required List<String> drops,
}) = _MonsterFileModel;

MonsterFileModel._();

factory MonsterFileModel.fromJson(Map<String, dynamic> json) => _$MonsterFileModelFromJson(json);
}
16 changes: 16 additions & 0 deletions lib/domain/models/db/monsters/monsters_file.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:genshindb/domain/models/models.dart';

part 'monsters_file.freezed.dart';
part 'monsters_file.g.dart';

@freezed
abstract class MonstersFile implements _$MonstersFile {
factory MonstersFile({
@required List<MonsterFileModel> monsters,
}) = _MonstersFile;

MonstersFile._();

factory MonstersFile.fromJson(Map<String, dynamic> json) => _$MonstersFileFromJson(json);
}
1 change: 1 addition & 0 deletions lib/domain/models/db/translations/translation_file.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ abstract class TranslationFile implements _$TranslationFile {
@required List<TranslationElementFile> debuffs,
@required List<TranslationElementFile> reactions,
@required List<TranslationElementFile> resonance,
@required List<TranslationMonsterFile> monsters,
}) = _TranslationFile;

factory TranslationFile.fromJson(Map<String, dynamic> json) => _$TranslationFileFromJson(json);
Expand Down
16 changes: 16 additions & 0 deletions lib/domain/models/db/translations/translation_monster_file.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import 'package:freezed_annotation/freezed_annotation.dart';

part 'translation_monster_file.freezed.dart';
part 'translation_monster_file.g.dart';

@freezed
abstract class TranslationMonsterFile implements _$TranslationMonsterFile {
factory TranslationMonsterFile({
@required String key,
@required String name,
}) = _TranslationMonsterFile;

const TranslationMonsterFile._();

factory TranslationMonsterFile.fromJson(Map<String, dynamic> json) => _$TranslationMonsterFileFromJson(json);
}
4 changes: 4 additions & 0 deletions lib/domain/models/models.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@ export 'db/elements/elements_file.dart';
export 'db/game_codes/game_codes_file.dart';
export 'db/materials/material_file_model.dart';
export 'db/materials/materials_file.dart';
export 'db/monsters/monster_file_model.dart';
export 'db/monsters/monsters_file.dart';
export 'db/translations/translation_artifact_file.dart';
export 'db/translations/translation_character_file.dart';
export 'db/translations/translation_element_file.dart';
export 'db/translations/translation_file.dart';
export 'db/translations/translation_material_file.dart';
export 'db/translations/translation_monster_file.dart';
export 'db/translations/translation_weapon_file.dart';
export 'db/weapons/weapon_file_model.dart';
export 'db/weapons/weapons_file.dart';
Expand All @@ -36,6 +39,7 @@ export 'items/item_ascension_material_model.dart';
export 'items/item_experience_model.dart';
export 'language_model.dart';
export 'materials/material_card_model.dart';
export 'monsters/monster_card_model.dart';
export 'settings/app_settings.dart';
export 'tierlist/tierlist_row_model.dart';
export 'weapons/weapon_card_model.dart';
Expand Down
18 changes: 18 additions & 0 deletions lib/domain/models/monsters/monster_card_model.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import 'package:flutter/foundation.dart';
import 'package:genshindb/domain/enums/enums.dart';

class MonsterCardModel {
final String key;
final String image;
final String name;
final MonsterType type;
final bool isComingSoon;

MonsterCardModel({
@required this.key,
@required this.image,
@required this.name,
@required this.type,
@required this.isComingSoon,
});
}
6 changes: 6 additions & 0 deletions lib/domain/services/genshin_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ abstract class GenshinService {
Future<void> initMaterials();
Future<void> initElements();
Future<void> initGameCodes();
Future<void> initMonsters();
Future<void> initTranslations(AppLanguageType languageType);

List<CharacterCardModel> getCharactersForCard();
Expand Down Expand Up @@ -59,4 +60,9 @@ abstract class GenshinService {
List<GameCodeFileModel> getAllGameCodes();

List<String> getUpcomingKeys();

MonsterFileModel getMonster(String key);
MonsterFileModel getMonsterByImg(String image);
List<MonsterCardModel> getAllMonstersForCard();
MonsterCardModel getMonsterForCardByImg(String image);
}

0 comments on commit 70108ce

Please sign in to comment.