Skip to content

Commit

Permalink
changelogs/10.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
jameshnsears committed Dec 23, 2024
1 parent eda91b5 commit 990be3d
Show file tree
Hide file tree
Showing 11 changed files with 122 additions and 20 deletions.
21 changes: 17 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
# Chance

[<img src="https://fdroid.gitlab.io/artwork/badge/get-it-on.png" height="75" alt="Get it on F-Droid">](https://f-droid.org/en/packages/com.github.jameshnsears.chance/)
---

## main

| codecov-test | codecov-app.androidTest | static-analysis | SonarQube Cloud | Codecov |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------|
| [![codecov-test](https://github.com/jameshnsears/Chance/actions/workflows/codecov-test.yml/badge.svg)](https://github.com/jameshnsears/Chance/actions/workflows/codecov-test.yml) | [![codecov-app.androidTest](https://github.com/jameshnsears/Chance/actions/workflows/codecov-app.androidTest.yml/badge.svg)](https://github.com/jameshnsears/Chance/actions/workflows/codecov-app.androidTest.yml) | [![static-analysis](https://github.com/jameshnsears/Chance/actions/workflows/static-analysis.yml/badge.svg)](https://github.com/jameshnsears/Chance/actions/workflows/static-analysis.yml) | [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=jameshnsears-github_chance&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=jameshnsears-github_chance) | [![codecov](https://codecov.io/gh/jameshnsears/Chance/graph/badge.svg?token=6S238TK3QV)](https://codecov.io/gh/jameshnsears/Chance) |
Static Analysis

[![static-gitleaks](https://github.com/jameshnsears/Chance/actions/workflows/static-gitleaks.yml/badge.svg)](https://github.com/jameshnsears/Chance/actions/workflows/static-gitleaks.yml)

[![static-analysis](https://github.com/jameshnsears/Chance/actions/workflows/static-analysis.yml/badge.svg)](https://github.com/jameshnsears/Chance/actions/workflows/static-analysis.yml)

[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=jameshnsears-github_chance&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=jameshnsears-github_chance)
---

Modular Coverage

[![codecov-test](https://github.com/jameshnsears/Chance/actions/workflows/codecov-test.yml/badge.svg)](https://github.com/jameshnsears/Chance/actions/workflows/codecov-test.yml)

[![codecov-app.androidTest](https://github.com/jameshnsears/Chance/actions/workflows/codecov-app.androidTest.yml/badge.svg)](https://github.com/jameshnsears/Chance/actions/workflows/codecov-app.androidTest.yml) [![codecov-data.androidTest](https://github.com/jameshnsears/Chance/actions/workflows/codecov-data.androidTest.yml/badge.svg)](https://github.com/jameshnsears/Chance/actions/workflows/codecov-data.androidTest.yml) [![codecov-ui-dialog-bag.androidTest](https://github.com/jameshnsears/Chance/actions/workflows/codecov-ui-dialog-bag.androidTest.yml/badge.svg)](https://github.com/jameshnsears/Chance/actions/workflows/codecov-ui-dialog-bag.androidTest.yml)

[![codecov](https://codecov.io/gh/jameshnsears/Chance/graph/badge.svg?token=6S238TK3QV)](https://codecov.io/gh/jameshnsears/Chance)
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ android {
targetSdk = 35

// changelog | min sdk | max sdk
versionCode = 92435
versionCode = 102435

versionName = "1.4.1"
versionName = "1.5.0"

extra["versionName"] = versionName

Expand Down
1 change: 1 addition & 0 deletions detekt-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<ID>TooGenericExceptionThrown:MainActivityComposable.kt$throw RuntimeException("Test Crash")</ID>
<ID>UnusedParameter:DialogColourPickerPreview.kt$_: String</ID>
<ID>UnusedPrivateProperty:CardSideAndroidViewModel.kt$CardSideSvgImportException$svgImportError: SvgImportError</ID>
<ID>VariableNaming:TabRollAndroidViewModel.kt$TabRollAndroidViewModel$val _stateFlowSettingsData = MutableStateFlow( SettingsState( rollIndexTime = false, rollScore = false, diceTitle = false, rollBehaviour = false, sideNumber = false, sideDescription = false, sideSVG = false, shuffle = false, rollSound = false, ) )</ID>
<ID>VariableNaming:TabRollAndroidViewModel.kt$TabRollAndroidViewModel$var _undoEnabled = MutableStateFlow(false)</ID>
<ID>VariableNaming:ZoomAndroidViewModel.kt$ZoomAndroidViewModel$protected val _stateFlowZoom = MutableStateFlow( ZoomState( resizeView = 0.dp, diceBag = mutableListOf(), rollHistory = LinkedHashMap() ) )</ID>
</CurrentIssues>
Expand Down
2 changes: 2 additions & 0 deletions fastlane/metadata/android/en-US/changelogs/10.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
&bull; Improve Shuffle behaviour
&bull; Bump dependencies (where possible)
2 changes: 0 additions & 2 deletions fastlane/metadata/android/en-US/changelogs/7.txt

This file was deleted.

4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ jsonschema-generator = "4.37.0"
junit = "1.2.1"
junit-bom = "5.11.4"
kotlin-test = "2.1.0"
kotlinx-coroutines-test = "1.9.0"
kotlinx-coroutines-test = "1.10.1"
leakcanary-android = "2.14"
lifecycle-runtime-compose = "2.8.7"
lifecycle-viewmodel-compose = "2.8.7"
mockk = "1.13.13"
mockk = "1.13.14"
org-jetbrains-kotlin-android = "2.0.20"
org-jlleitschuh-gradle-ktlint = "12.1.2"
org-sonarqube = "5.1.0.4882" # stay on 5.1.0.4882 due to: Sonarqube-gradle-plugin:6.0.1.5171 - org.bouncycastle.asn1.edec.EdECObjectIdentifiers
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sat Dec 07 17:01:59 EET 2024
#Sun Dec 22 18:29:32 EET 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,8 @@ data class Side(
descriptionColour
)
}

override fun toString(): String {
return "number=$number"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ import com.github.jameshnsears.chance.data.domain.core.Side
data class Roll(
val diceEpoch: Long,
val side: Side,
val multiplierIndex: Int = 1,
var multiplierIndex: Int = 1,
val explodeIndex: Int = 0,
var scoreAdjustment: Int = 0,
var score: Int = 0,
)
) {
override fun toString(): String {
return "diceEpoch=$diceEpoch; multiplierIndex=$multiplierIndex; side=$side"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class TabRollAndroidViewModel(
val repositoryBag: RepositoryBagInterface,
val repositoryRoll: RepositoryRollInterface,
) : AndroidViewModel(application) {
private val _stateFlowSettingsData = MutableStateFlow(
val _stateFlowSettingsData = MutableStateFlow(
SettingsState(
rollIndexTime = false,
rollScore = false,
Expand Down Expand Up @@ -194,11 +194,7 @@ class TabRollAndroidViewModel(

rollDiceSequence(newRollSequence)

if (_stateFlowSettingsData.value.shuffle) {
val selectedCount = diceBag.value.count { it.selected }
if (selectedCount > 1)
newRollSequence.shuffle()
}
shuffleRollSequence(newRollSequence)

saveNewRollSequence(newRollSequence)

Expand All @@ -210,6 +206,25 @@ class TabRollAndroidViewModel(
}
}

fun shuffleRollSequence(rollSequence: MutableList<Roll>) {
if (_stateFlowSettingsData.value.shuffle) {
val selectedCount = diceBag.value.count { it.selected }
if (selectedCount > 1) {
rollSequence.shuffle()

// order the multipleIndex into ASC order for any dice cluster
rollSequence
.groupBy { it.diceEpoch }
.forEach { (_, rolls) ->
val sortedIndices = rolls.map { it.multiplierIndex }.sorted()
rolls.forEachIndexed { index, roll ->
roll.multiplierIndex = sortedIndices[index]
}
}
}
}
}

fun dismissSettingsDialog() {
viewModelScope.launch {
saveSettings()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,71 @@ class TabRollAndroidViewModelUnitTest : UtilityAndroidHelper() {
assertEquals(4, tabRollAndroidViewModel.repositoryRoll.fetch().first().size)
}


@OptIn(DelicateCoroutinesApi::class)
@Test
fun shuffleRollSequence() = runTest {
val repositorySettings = RepositoryFactory().repositorySettings
runBlocking(Dispatchers.Main) {
repositorySettings.store(SettingsDataTestDouble())
}

val bagDataTestDouble = BagDataTestDouble()
bagDataTestDouble.d4.selected = true
bagDataTestDouble.d4.multiplierValue = 3
bagDataTestDouble.d4.explode = false
bagDataTestDouble.d6.selected = true
bagDataTestDouble.d6.multiplierValue = 5
bagDataTestDouble.d6.explode = false

val repositoryBag = RepositoryFactory().repositoryBag
runBlocking(Dispatchers.Main) {
repositoryBag.store(
mutableListOf(
bagDataTestDouble.d4,
bagDataTestDouble.d6
)
)
}

val repositoryRoll = RepositoryFactory().repositoryRoll
val rollDataTestDouble = RollHistoryDataTestDouble(bagDataTestDouble)
runBlocking(Dispatchers.Main) {
repositoryRoll.store(rollDataTestDouble.rollHistory)
}

val tabRollAndroidViewModel = spyk<TabRollAndroidViewModel>(
TabRollAndroidViewModel(
getApplication(),
repositorySettings,
repositoryBag,
repositoryRoll
)
)

every { tabRollAndroidViewModel.mediaPlayerRollSound() } returns Unit

////////////////

val rolls = mutableListOf<Roll>()

tabRollAndroidViewModel.rollDiceSequence(rolls)
assertEquals(8, rolls.size)

tabRollAndroidViewModel._stateFlowSettingsData.value.shuffle = true
tabRollAndroidViewModel.shuffleRollSequence(rolls)

assertEquals(8, rolls.size)

val diceEpochGroupRolls = rolls.groupBy { it.diceEpoch }
diceEpochGroupRolls.forEach { (_, diceEpochGroup) ->
val sortedDiceEpochGroup = diceEpochGroup.sortedBy { it.multiplierIndex }
for (i in sortedDiceEpochGroup.indices) {
assertEquals(i + 1, sortedDiceEpochGroup[i].multiplierIndex)
}
}
}

@Test
fun rollDiceSequenceWithExplosionEquals() = runTest {
val diceBag = BagDataTestDouble()
Expand Down

0 comments on commit 990be3d

Please sign in to comment.