Skip to content

Commit

Permalink
Remove infinite repeat from dumb actions tries
Browse files Browse the repository at this point in the history
  • Loading branch information
Nain57 committed Sep 22, 2024
1 parent 2e73481 commit 27217ff
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ package com.buzbuz.smartautoclicker.core.dumb.engine

import com.buzbuz.smartautoclicker.core.base.identifier.Identifier
import com.buzbuz.smartautoclicker.core.dumb.domain.model.DumbAction
import com.buzbuz.smartautoclicker.core.dumb.domain.model.DumbAction.DumbClick
import com.buzbuz.smartautoclicker.core.dumb.domain.model.DumbAction.DumbPause
import com.buzbuz.smartautoclicker.core.dumb.domain.model.DumbAction.DumbSwipe
import com.buzbuz.smartautoclicker.core.dumb.domain.model.DumbScenario

internal fun DumbAction.toDumbScenarioTry(): DumbScenario {
Expand All @@ -31,7 +34,21 @@ internal fun DumbAction.toDumbScenarioTry(): DumbScenario {
maxDurationMin = 1,
isDurationInfinite = false,
randomize = false,
dumbActions = listOf(copyWithNewScenarioId(scenarioId = scenarioId))
dumbActions = listOf(toFiniteDumbAction(scenarioId))
)
}

private fun DumbAction.toFiniteDumbAction(scenarioId: Identifier): DumbAction =
when (this) {
is DumbClick -> copy(
scenarioId = scenarioId,
isRepeatInfinite = false,
)
is DumbSwipe -> copy(
scenarioId = scenarioId,
isRepeatInfinite = false,
)
is DumbPause -> copy(
scenarioId = scenarioId
)
}

2 comments on commit 27217ff

@Aimansolana
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Nain57
Copy link
Owner Author

@Nain57 Nain57 commented on 27217ff Sep 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Please sign in to comment.