Skip to content

Commit

Permalink
CardReset remove donotSelectCommandcard
Browse files Browse the repository at this point in the history
  • Loading branch information
SharpnelXu committed Aug 15, 2024
1 parent b37190c commit 46e1c0f
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 3 deletions.
5 changes: 4 additions & 1 deletion lib/app/battle/functions/function_executor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,10 @@ class FunctionExecutor {
break;
case FuncType.cardReset:
for (final svt in battleData.nonnullPlayers) {
svt.battleBuff.removeBuffWithTrait(NiceTrait(id: Trait.buffLockCardsDeck.value));
svt.battleBuff.removeBuffOfType(BuffType.fixCommandcard);
for (final buff in collectBuffsPerType(svt.battleBuff.validBuffs, BuffType.donotSelectCommandcard)) {
buff.setUsed(svt);
}
}
for (final target in targets) {
battleData.setFuncResult(target.uniqueId, true);
Expand Down
2 changes: 1 addition & 1 deletion lib/app/battle/functions/replace_member.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ReplaceMember {
}

for (final svt in battleData.nonnullPlayers) {
svt.battleBuff.removeBuffWithTrait(NiceTrait(id: Trait.buffLockCardsDeck.value));
svt.battleBuff.removeBuffOfType(BuffType.fixCommandcard);
}

final List<BattleServantData?> onFieldList = battleData.onFieldAllyServants;
Expand Down
2 changes: 1 addition & 1 deletion lib/app/battle/models/battle.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1390,7 +1390,7 @@ class BattleData {
actor.fieldIndex = -1;
if (actor.isPlayer) {
for (final svt in nonnullPlayers) {
svt.battleBuff.removeBuffWithTrait(NiceTrait(id: Trait.buffLockCardsDeck.value));
svt.battleBuff.removeBuffOfType(BuffType.fixCommandcard);
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions lib/app/battle/models/buff.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ class BattleBuff {
));
}

void removeBuffOfType(final BuffType type, {bool includeNoAct = false, bool includeNoField = false}) {
_activeList.removeWhere((buff) =>
(includeNoAct || !buff.checkState(BuffState.noAct)) &&
(includeNoField || !buff.checkState(BuffState.noField)) &&
buff.buff.type == type);
}

void turnProgress() {
for (final buff in getAllBuffs()) {
if (!buff.checkField()) continue;
Expand Down
18 changes: 18 additions & 0 deletions test/app/battle/functions/function_executor_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1276,5 +1276,23 @@ void main() async {
await battle.activateSvtSkill(0, 0);
expect(eliz.np, 8000);
});

test('cardRest clear fixCommandCard & donotSelectCommand', () async {
final List<PlayerSvtData> setting = [
PlayerSvtData.id(2300200), // bb SSR
PlayerSvtData.id(2300900), // ciel
];
final battle = BattleData();
await battle.init(db.gameData.questPhases[9300040603]!, setting, null);

final bb = battle.onFieldAllyServants[0]!;

await battle.activateSvtSkill(0, 2);
expect(bb.battleBuff.validBuffs.any((buff) => buff.buff.type == BuffType.fixCommandcard), true);

await battle.activateSvtSkill(1, 2);
expect(bb.battleBuff.validBuffs.any((buff) => buff.buff.type == BuffType.fixCommandcard), false);
expect(bb.battleBuff.validBuffs.any((buff) => buff.buff.type == BuffType.donotSelectCommandcard), false);
});
});
}

0 comments on commit 46e1c0f

Please sign in to comment.