Skip to content

Commit

Permalink
Fix append 5 vs transformSvt
Browse files Browse the repository at this point in the history
  • Loading branch information
SharpnelXu committed Aug 13, 2024
1 parent 95bc339 commit 1436130
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
21 changes: 12 additions & 9 deletions lib/app/battle/models/svt_entity.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1292,7 +1292,7 @@ class BattleServantData {
}

Future<bool> activateSkill(final BattleData battleData, final int skillIndex) async {
final skillInfo = skillInfoList.getOrNull(skillIndex);
BattleSkillInfoData? skillInfo = skillInfoList.getOrNull(skillIndex);
if (skillInfo == null || skillInfo.chargeTurn > 0) return false;

final rankUp = countBuffWithTrait([NiceTrait(id: Trait.buffSkillRankUp.value)]);
Expand All @@ -1312,16 +1312,19 @@ class BattleServantData {
param: param,
);

int shortenSkillAfterUseSkill = 0;
for (final buff in collectBuffsPerAction(battleBuff.validBuffs, BuffAction.shortenSkillAfterUseSkill)) {
final curSkillUseCount = buff.shortenMaxCountEachSkill?.getOrNull(skillIndex);
if (curSkillUseCount == null || curSkillUseCount > 0) {
buff.shortenMaxCountEachSkill?[skillIndex] -= 1;
shortenSkillAfterUseSkill += buff.param;
buff.setUsed(this);
skillInfo = skillInfoList.getOrNull(skillIndex);
if (skillInfo != null) {
int shortenSkillAfterUseSkill = 0;
for (final buff in collectBuffsPerAction(battleBuff.validBuffs, BuffAction.shortenSkillAfterUseSkill)) {
final curSkillUseCount = buff.shortenMaxCountEachSkill?.getOrNull(skillIndex);
if (curSkillUseCount == null || curSkillUseCount > 0) {
buff.shortenMaxCountEachSkill?[skillIndex] -= 1;
shortenSkillAfterUseSkill += buff.param;
buff.setUsed(this);
}
}
skillInfo.shortenSkill(shortenSkillAfterUseSkill);
}
skillInfo.shortenSkill(shortenSkillAfterUseSkill);
}
return activated;
}
Expand Down
23 changes: 12 additions & 11 deletions test/app/battle/models/battle_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1424,9 +1424,10 @@ void main() async {
expect(kama.np, 3882);
});

test('Append 5', () async {
test('Append 5 & transformSvt', () async {
final List<PlayerSvtData> setting = [
PlayerSvtData.id(404800)
PlayerSvtData.id(304800)
..limitCount = 0
..skillLvs = [10, 10, 10]
..appendLvs = [10, 10, 10, 10, 10],
];
Expand All @@ -1435,25 +1436,25 @@ void main() async {
await battle.init(quest, setting, null);

final maqin = battle.onFieldAllyServants[0]!;
await battle.activateSvtSkill(0, 2);
expect(maqin.skillInfoList[2].chargeTurn, 5); // her default is 6, so count in append should be 5
await battle.activateSvtSkill(0, 0);
expect(maqin.skillInfoList[0].chargeTurn, 5); // her default is 6, so count in append should be 5

await battle.resetPlayerSkillCD(isMysticCode: false, svt: maqin);
await battle.activateSvtSkill(0, 2);
expect(maqin.skillInfoList[2].chargeTurn, 6);

await battle.activateSvtSkill(0, 0);
expect(maqin.skillInfoList[0].chargeTurn, 5);
expect(maqin.skillInfoList[0].chargeTurn, 6);

await battle.activateSvtSkill(0, 1);
expect(maqin.skillInfoList[1].chargeTurn, 5);
expect(maqin.skillInfoList[1].chargeTurn, 4);
await battle.activateSvtSkill(0, 2);
expect(maqin.skillInfoList[2].chargeTurn, 4);

await battle.resetPlayerSkillCD(isMysticCode: false, svt: maqin);
await battle.activateSvtSkill(0, 0);
expect(maqin.skillInfoList[0].chargeTurn, 6);
await battle.activateSvtSkill(0, 1);
expect(maqin.skillInfoList[1].chargeTurn, 6);
expect(maqin.skillInfoList[1].chargeTurn, 5);
await battle.activateSvtSkill(0, 2);
expect(maqin.skillInfoList[2].chargeTurn, 6);
expect(maqin.skillInfoList[2].chargeTurn, 5);
});

group('Summer Eresh related tests', () {
Expand Down

0 comments on commit 1436130

Please sign in to comment.