Skip to content

Commit

Permalink
[Domain] Added a model for the chart ascension stats
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolfteam committed May 18, 2022
1 parent 14975f8 commit 0c16646
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 0 deletions.
40 changes: 40 additions & 0 deletions lib/domain/app_constants.dart
Expand Up @@ -87,6 +87,46 @@ int getArtifactMaxNumberOfSubStats(int rarity) {
}
}

List<StatType> getWeaponPossibleAscensionStats() {
const ignoredSubStats = [
StatType.atk,
StatType.critAtk,
StatType.critRate,
StatType.physDmgPercentage,
StatType.hp,
StatType.electroDmgBonusPercentage,
StatType.cryoDmgBonusPercentage,
StatType.pyroDmgBonusPercentage,
StatType.hydroDmgBonusPercentage,
StatType.geoDmgBonusPercentage,
StatType.anemoDmgBonusPercentage,
StatType.healingBonusPercentage,
StatType.def,
];

return StatType.values.except(ignoredSubStats).toList();
}

List<StatType> getCharacterPossibleAscensionStats() {
return [
StatType.elementalMastery,
StatType.energyRechargePercentage,
StatType.critRatePercentage,
StatType.critDmgPercentage,
StatType.hpPercentage,
StatType.electroDmgBonusPercentage,
StatType.cryoDmgBonusPercentage,
StatType.pyroDmgBonusPercentage,
StatType.hydroDmgBonusPercentage,
StatType.geoDmgBonusPercentage,
StatType.anemoDmgBonusPercentage,
StatType.healingBonusPercentage,
StatType.physDmgPercentage,
StatType.atkPercentage,
StatType.defPercentage,
];
}

const languagesMap = {
AppLanguageType.english: LanguageModel('en', 'US'),
AppLanguageType.spanish: LanguageModel('es', 'ES'),
Expand Down
18 changes: 18 additions & 0 deletions lib/domain/extensions/string_extensions.dart
Expand Up @@ -3,4 +3,22 @@ extension StringExtensions on String? {
bool get isNotNullEmptyOrWhitespace => !isNullEmptyOrWhitespace;

bool isValidLength({int minLength = 0, int maxLength = 255}) => isNotNullEmptyOrWhitespace || this!.length > maxLength || this!.length < minLength;

String substringIfOverflow(int maxLength, {int numberOfDots = 3}) {
if (isNullEmptyOrWhitespace) {
return '';
}

if (this!.length < maxLength) {
return this!;
}

final take = maxLength - numberOfDots;
if (this!.length < take) {
return this!;
}

final newValue = this!.substring(0, take);
return '$newValue...';
}
}
13 changes: 13 additions & 0 deletions lib/domain/models/charts/chart_ascension_stat_model.dart
@@ -0,0 +1,13 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:shiori/domain/enums/enums.dart';

part 'chart_ascension_stat_model.freezed.dart';

@freezed
class ChartAscensionStatModel with _$ChartAscensionStatModel {
const factory ChartAscensionStatModel({
required StatType type,
required ItemType itemType,
required int quantity,
}) = _ChartAscensionStatModel;
}
1 change: 1 addition & 0 deletions lib/domain/models/models.dart
Expand Up @@ -15,6 +15,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 'charts/chart_ascension_stat_model.dart';
export 'charts/chart_birthday_month_model.dart';
export 'charts/chart_element_item_model.dart';
export 'charts/chart_top_item_model.dart';
Expand Down
1 change: 1 addition & 0 deletions lib/domain/services/genshin_service.dart
Expand Up @@ -96,6 +96,7 @@ abstract class GenshinService {
List<ChartTopItemModel> getTopCharts(ChartType type);
List<ChartBirthdayMonthModel> getCharacterBirthdaysForCharts();
List<ChartElementItemModel> getElementsForCharts(double fromVersion, double untilVersion);
List<ChartAscensionStatModel> getItemAscensionStatsForCharts(ItemType itemType);

List<CharacterBirthdayModel> getCharacterBirthdays({int? month, int? day});
}

0 comments on commit 0c16646

Please sign in to comment.