Skip to content

Commit

Permalink
td dmg rank: support each append skill
Browse files Browse the repository at this point in the history
  • Loading branch information
narumi147 committed Aug 16, 2024
1 parent 45e7040 commit c1d83e7
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 18 deletions.
2 changes: 1 addition & 1 deletion lib/app/battle/models/buff.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class BattleBuff {

void removeBuffOfType(final BuffType type, {bool includeNoAct = false, bool includeNoField = false}) {
_activeList.removeWhere((buff) =>
(includeNoAct || !buff.checkState(BuffState.noAct)) &&
(includeNoAct || !buff.checkState(BuffState.noAct)) &&
(includeNoField || !buff.checkState(BuffState.noField)) &&
buff.buff.type == type);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/app/battle/models/user.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import '../utils/battle_utils.dart';
class PlayerSvtData {
Servant? svt;
int limitCount = 4;
List<int> skillLvs = [10, 10, 10];
List<int> skillLvs = List.generate(kActiveSkillNums.length, (_) => 10);
List<NiceSkill?> skills = [null, null, null];
List<int> appendLvs = [0, 0, 0, 0, 0];
List<int> appendLvs = List.generate(kAppendSkillNums.length, (_) => 0);
List<NiceSkill> extraPassives = [];
Set<int> disabledExtraSkills = {};
List<BaseSkill> customPassives = [];
Expand Down
4 changes: 2 additions & 2 deletions lib/app/modules/battle/td_damage/model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,8 @@ class TdDmgSolver {
if (!options.enableActiveSkills) {
data.skills.fillRange(0, data.skills.length, null);
}
if (options.enableAppendSkills) {
data.appendLvs.fillRange(0, data.appendLvs.length, 10);
for (int index = 0; index < data.appendLvs.length; index++) {
data.appendLvs[index] = (options.appendSkills.getOrNull(index) ?? false) ? 10 : 0;
}

final extraBuffs = options.extraBuffs.buildSkill();
Expand Down
24 changes: 17 additions & 7 deletions lib/app/modules/battle/td_damage/options_tab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -449,15 +449,25 @@ class _TdDmgOptionsTabState extends State<TdDmgOptionsTab> {
});
},
),
CheckboxListTile(
ListTile(
dense: true,
value: options.enableAppendSkills,
title: Text(S.current.append_skill),
onChanged: (value) {
setState(() {
options.enableAppendSkills = !options.enableAppendSkills;
});
},
trailing: FilterGroup<int>(
combined: true,
padding: EdgeInsets.zero,
options: List.generate(options.appendSkills.length, (i) => i),
optionBuilder: (value) => Text(options.appendSkills[value] ? '10' : 'x'),
values: FilterGroupData(options: {
for (final (index, enabled) in options.appendSkills.indexed)
if (enabled) index,
}),
onFilterChanged: (v, lastChanged) {
for (int index = 0; index < options.appendSkills.length; index++) {
options.appendSkills[index] = v.options.contains(index);
}
setState(() {});
},
),
),
kIndentDivider,
CheckboxListTile(
Expand Down
10 changes: 8 additions & 2 deletions lib/app/modules/common/filter_group.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class FilterGroup<T> extends StatelessWidget {
final EdgeInsetsGeometry padding;
final bool showCollapse;
final BoxConstraints? constraints;
final Size? minimumSize;
final ButtonStyle? buttonStyle;

const FilterGroup({
Expand All @@ -37,6 +38,7 @@ class FilterGroup<T> extends StatelessWidget {
this.padding = const EdgeInsets.symmetric(horizontal: 12),
this.showCollapse = false,
this.constraints,
this.minimumSize,
this.buttonStyle,
});

Expand Down Expand Up @@ -82,6 +84,7 @@ class FilterGroup<T> extends StatelessWidget {
value: key,
shrinkWrap: shrinkWrap,
constraints: constraints,
minimumSize: minimumSize,
buttonStyle: buttonStyle,
borderRadius: combined
? BorderRadius.horizontal(
Expand Down Expand Up @@ -193,6 +196,7 @@ class FilterOption<T> extends StatelessWidget {
final BorderRadius borderRadius;
final bool shrinkWrap;
final BoxConstraints? constraints;
final Size? minimumSize;
final ButtonStyle? buttonStyle;

const FilterOption({
Expand All @@ -208,6 +212,7 @@ class FilterOption<T> extends StatelessWidget {
this.borderRadius = const BorderRadius.all(Radius.circular(3)),
this.shrinkWrap = false,
this.constraints,
this.minimumSize,
this.buttonStyle,
});

Expand All @@ -232,10 +237,11 @@ class FilterOption<T> extends StatelessWidget {
backgroundColor: selected
? (enabled ? selectedColor : selectedColor.withOpacity(selectedColor.opacity * 0.5))
: unselectedColor,
minimumSize: shrinkWrap ? const Size(2, 2) : const Size(48, 36),
minimumSize: minimumSize ?? (shrinkWrap ? const Size(2, 2) : const Size(48, 36)),
padding: shrinkWrap ? const EdgeInsets.all(0) : null,
textStyle: const TextStyle(fontWeight: FontWeight.normal),
tapTargetSize: shrinkWrap ? MaterialTapTargetSize.shrinkWrap : null,
// tapTargetSize: shrinkWrap ? MaterialTapTargetSize.shrinkWrap : null,
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
shape: ContinuousRectangleBorder(borderRadius: borderRadius),
side: themeData.useMaterial3 ? BorderSide(color: themeData.colorScheme.outline, width: 0.5) : null,
).merge(buttonStyle),
Expand Down
2 changes: 2 additions & 0 deletions lib/app/modules/servant/filter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,9 @@ class _ServantFilterPageState extends FilterPageState<SvtFilterData, ServantFilt
),
FilterGroup<int>(
combined: true,
padding: EdgeInsets.zero,
options: const [5, 6, 10, 15],
minimumSize: const Size(36, 36),
values: filterData.bondValue,
onFilterChanged: (v, _) {
setState(() {
Expand Down
4 changes: 2 additions & 2 deletions lib/generated/models/userdata/battle.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions lib/models/userdata/battle.dart
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ class TdDamageOptions {
bool enableActiveSkills;
bool twiceActiveSkill;
bool twiceSkillOnTurn3;
bool enableAppendSkills;
List<bool> appendSkills;
// bool includeRefundAfterTd = true; // 重蓄力
SvtLv svtLv;
int fouHpAtk;
Expand Down Expand Up @@ -814,7 +814,7 @@ class TdDamageOptions {
this.enableActiveSkills = true,
this.twiceActiveSkill = false,
this.twiceSkillOnTurn3 = false,
this.enableAppendSkills = false,
List<bool>? appendSkills,
this.svtLv = SvtLv.maxLv,
this.fouHpAtk = 1000,
this.tdR3 = 5,
Expand All @@ -838,6 +838,7 @@ class TdDamageOptions {
this.damageNpHpRatioMax = false,
}) : enemy = enemy ?? QuestEnemy.blankEnemy(),
supports = supports ?? [],
appendSkills = List.generate(kAppendSkillNums.length, (i) => appendSkills?.getOrNull(i) ?? false),
extraBuffs = extraBuffs ?? CustomSkillData(buffOnly: true, hasTurnCount: false),
fieldTraits = fieldTraits ?? [];

Expand Down

0 comments on commit c1d83e7

Please sign in to comment.