Skip to content

Commit

Permalink
[Domain] Added custom build entity
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolfteam committed Jan 1, 2022
1 parent 21d1692 commit 46f57de
Show file tree
Hide file tree
Showing 7 changed files with 145 additions and 1 deletion.
45 changes: 45 additions & 0 deletions lib/domain/app_constants.dart
Expand Up @@ -8,6 +8,51 @@ const githubPage = 'https://github.com/Wolfteam/Shiori';
//This order matches the one in the game, and the numbers represent each image
const artifactOrder = [4, 2, 5, 1, 3];

int getArtifactOrder(ArtifactType type) {
return artifactOrder[type.index];
}

List<StatType> getArtifactPossibleMainStats(ArtifactType type) {
switch (type) {
case ArtifactType.flower:
return [StatType.hp];
case ArtifactType.plume:
return [StatType.atk];
case ArtifactType.clock:
return [
StatType.atkPercentage,
StatType.defPercentage,
StatType.hpPercentage,
StatType.energyRechargePercentage,
StatType.elementalMastery,
];
case ArtifactType.goblet:
return [
StatType.atkPercentage,
StatType.defPercentage,
StatType.hpPercentage,
StatType.elementalMastery,
StatType.physDmgPercentage,
StatType.hydroDmgBonusPercentage,
StatType.pyroDmgBonusPercentage,
StatType.cryoDmgBonusPercentage,
StatType.electroDmgBonusPercentage,
StatType.anemoDmgBonusPercentage,
StatType.geoDmgBonusPercentage,
];
case ArtifactType.crown:
return [
StatType.atkPercentage,
StatType.defPercentage,
StatType.hpPercentage,
StatType.critRatePercentage,
StatType.critDmgPercentage,
StatType.elementalMastery,
StatType.healingBonusPercentage,
];
}
}

const languagesMap = {
AppLanguageType.english: LanguageModel('en', 'US'),
AppLanguageType.spanish: LanguageModel('es', 'ES'),
Expand Down
26 changes: 26 additions & 0 deletions lib/domain/models/custom_builds/custom_build_model.dart
@@ -0,0 +1,26 @@
import 'package:shiori/domain/enums/enums.dart';
import 'package:shiori/domain/models/models.dart';

class CustomBuildModel {
final int key;
final String title;

final CharacterRoleType type;
final CharacterRoleSubType subType;
final bool showOnCharacterDetail;

final CharacterCardModel character;
final List<WeaponCardModel> weapons;
final List<ArtifactCardModel> artifacts;

CustomBuildModel({
required this.key,
required this.title,
required this.type,
required this.subType,
required this.showOnCharacterDetail,
required this.character,
required this.weapons,
required this.artifacts,
});
}
1 change: 1 addition & 0 deletions lib/domain/models/entities.dart
@@ -1,6 +1,7 @@
export 'entities/calculator/calculator_character_skill.dart';
export 'entities/calculator/calculator_item.dart';
export 'entities/calculator/calculator_session.dart';
export 'entities/custom_builds/custom_build.dart';
export 'entities/game_code/game_code.dart';
export 'entities/game_code/game_code_reward.dart';
export 'entities/inventory/inventory_item.dart';
Expand Down
42 changes: 42 additions & 0 deletions lib/domain/models/entities/custom_builds/custom_build.dart
@@ -0,0 +1,42 @@
import 'package:hive/hive.dart';

part 'custom_build.g.dart';

@HiveType(typeId: 18)
class CustomBuild extends HiveObject {
@HiveField(1)
final String characterKey;

@HiveField(2)
String title;

@HiveField(3)
int roleType;

@HiveField(4)
int roleSubType;

@HiveField(5)
bool showOnCharacterDetail;

@HiveField(6)
List<String> weaponKeys;

@HiveField(7)
//artifact key : subStat enum
Map<String, int> artifacts;

@HiveField(8)
List<int> talentPriority;

CustomBuild(
this.characterKey,
this.showOnCharacterDetail,
this.title,
this.roleType,
this.roleSubType,
this.weaponKeys,
this.artifacts,
this.talentPriority,
);
}
1 change: 1 addition & 0 deletions lib/domain/models/models.dart
Expand Up @@ -11,6 +11,7 @@ export 'characters/character_multi_talent_ascension_model.dart';
export 'characters/character_passive_talent_model.dart';
export 'characters/character_skill_card_model.dart';
export 'characters/character_talent_ascension_model.dart';
export 'custom_builds/custom_build_model.dart';
export 'db/artifacts/artifact_file_model.dart';
export 'db/artifacts/artifacts_file.dart';
export 'db/characters/character_file_model.dart';
Expand Down
28 changes: 28 additions & 0 deletions lib/domain/services/data_service.dart
Expand Up @@ -315,4 +315,32 @@ abstract class DataService {
});

Future<NotificationItem> reduceNotificationHours(int key, AppNotificationType type, int hours);

List<CustomBuildModel> getAllCustomBuilds();

CustomBuildModel getCustomBuild(int key);

Future<CustomBuildModel> saveCustomBuild(
String charKey,
String title,
CharacterRoleType type,
CharacterRoleSubType subType,
bool showOnCharacterDetail,
List<String> weaponKeys,
Map<String, int> artifacts,
List<CharacterSkillType> talentPriority,
);

Future<CustomBuildModel> updateCustomBuild(
int key,
String title,
CharacterRoleType type,
CharacterRoleSubType subType,
bool showOnCharacterDetail,
List<String> weaponKeys,
Map<String, int> artifacts,
List<CharacterSkillType> talentPriority,
);

Future<void> deleteCustomBuild(int key);
}
3 changes: 2 additions & 1 deletion lib/domain/services/genshin_service.dart
Expand Up @@ -26,7 +26,7 @@ abstract class GenshinService {
WeaponFileModel getWeapon(String key);
List<String> getUpcomingWeaponsKeys();

List<ArtifactCardModel> getArtifactsForCard();
List<ArtifactCardModel> getArtifactsForCard({ArtifactType? type});
ArtifactCardModel getArtifactForCard(String key);
ArtifactFileModel getArtifact(String key);

Expand Down Expand Up @@ -84,4 +84,5 @@ abstract class GenshinService {

List<ArtifactCardBonusModel> getArtifactBonus(TranslationArtifactFile translation);
List<String> getArtifactRelatedParts(String fullImagePath, String image, int bonus);
String getArtifactRelatedPart(String fullImagePath, String image, int bonus, ArtifactType type);
}

0 comments on commit 46f57de

Please sign in to comment.