Skip to content

Commit bb8cf07

Browse files
authored
Merge pull request #282 from fmasa/hardy-flag-removal
Remove deprecated Hardy flag
2 parents d488013 + d28eee8 commit bb8cf07

File tree

11 files changed

+10
-61
lines changed

11 files changed

+10
-61
lines changed

common/src/commonMain/kotlin/cz/frantisekmasa/wfrp_master/common/characterEdit/MaxWoundsSection.kt

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,18 @@ import androidx.compose.foundation.layout.fillMaxWidth
55
import androidx.compose.foundation.layout.padding
66
import androidx.compose.foundation.text.KeyboardOptions
77
import androidx.compose.runtime.Composable
8-
import androidx.compose.runtime.MutableState
9-
import androidx.compose.runtime.mutableStateOf
10-
import androidx.compose.runtime.saveable.rememberSaveable
118
import androidx.compose.ui.Modifier
129
import androidx.compose.ui.text.input.KeyboardType
1310
import androidx.compose.ui.unit.dp
1411
import cz.frantisekmasa.wfrp_master.common.Str
1512
import cz.frantisekmasa.wfrp_master.common.character.CharacterScreenModel
1613
import cz.frantisekmasa.wfrp_master.common.core.domain.character.Character
17-
import cz.frantisekmasa.wfrp_master.common.core.ui.forms.CheckboxWithText
1814
import cz.frantisekmasa.wfrp_master.common.core.ui.forms.FormScreen
1915
import cz.frantisekmasa.wfrp_master.common.core.ui.forms.HydratedFormData
2016
import cz.frantisekmasa.wfrp_master.common.core.ui.forms.InputValue
2117
import cz.frantisekmasa.wfrp_master.common.core.ui.forms.Rules
2218
import cz.frantisekmasa.wfrp_master.common.core.ui.forms.TextInput
2319
import cz.frantisekmasa.wfrp_master.common.core.ui.forms.inputValue
24-
import cz.frantisekmasa.wfrp_master.common.core.ui.primitives.UserTip
25-
import cz.frantisekmasa.wfrp_master.common.core.ui.primitives.UserTipCard
2620
import dev.icerock.moko.resources.compose.stringResource
2721

2822
@Composable
@@ -35,7 +29,7 @@ fun MaxWoundsSection(
3529
title = stringResource(Str.points_wounds),
3630
formData = formData,
3731
onSave = { data ->
38-
screenModel.update { it.updateMaxWounds(data.maxWounds, data.hardyTalent) }
32+
screenModel.update { it.updateMaxWounds(data.maxWounds) }
3933
},
4034
) { validate ->
4135
Column(Modifier.padding(top = 20.dp)) {
@@ -51,37 +45,22 @@ fun MaxWoundsSection(
5145
validate = validate,
5246
placeholder = stringResource(Str.points_auto_max_wounds_placeholder),
5347
)
54-
55-
if (character.hasHardyTalent) {
56-
if (formData.hardyTalent.value) {
57-
UserTipCard(UserTip.HARDY_TALENTS)
58-
}
59-
60-
CheckboxWithText(
61-
text = stringResource(Str.points_label_hardy),
62-
checked = formData.hardyTalent.value,
63-
onCheckedChange = { formData.hardyTalent.value = it },
64-
)
65-
}
6648
}
6749
}
6850
}
6951

7052
private data class WoundsData(
7153
val maxWounds: Int?,
72-
val hardyTalent: Boolean,
7354
)
7455

7556
private data class WoundsFormData(
7657
val maxWounds: InputValue,
77-
val hardyTalent: MutableState<Boolean>,
7858
) : HydratedFormData<WoundsData> {
7959
override fun isValid(): Boolean = maxWounds.isValid()
8060

8161
override fun toValue(): WoundsData =
8262
WoundsData(
8363
maxWounds.value.toIntOrNull(),
84-
hardyTalent.value,
8564
)
8665

8766
companion object {
@@ -93,7 +72,6 @@ private data class WoundsFormData(
9372
character.points.maxWounds?.toString() ?: "",
9473
Rules.ifNotBlank(Rules.PositiveInteger()),
9574
),
96-
hardyTalent = rememberSaveable { mutableStateOf(character.hasHardyTalent) },
9775
)
9876
}
9977
}

common/src/commonMain/kotlin/cz/frantisekmasa/wfrp_master/common/compendium/domain/importer/books/CoreRulebook.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ object CoreRulebook :
9696
specialLores =
9797
mapOf(
9898
"Petty Spells" to setOf(SpellLore.PETTY),
99-
"Arcane Spells" to SpellLore.values().toSet() - SpellLore.PETTY,
99+
"Arcane Spells" to SpellLore.entries.toSet() - SpellLore.PETTY,
100100
),
101101
).import(document, this, sequenceOf(240..257))
102102
}

common/src/commonMain/kotlin/cz/frantisekmasa/wfrp_master/common/core/domain/character/Character.kt

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ data class Character(
4040
val conditions: CurrentConditions = CurrentConditions.none(),
4141
val mutation: String = "",
4242
val note: String = "",
43-
@SerialName("hardyTalent") val hasHardyTalent: Boolean = false,
4443
val woundsModifiers: WoundsModifiers = WoundsModifiers(),
4544
val encumbranceBonus: Encumbrance = Encumbrance.Zero,
4645
@SerialName("archived") val isArchived: Boolean = false,
@@ -53,7 +52,7 @@ data class Character(
5352
val wounds: Wounds get() =
5453
Wounds(
5554
points.wounds,
56-
calculateMaxWounds(size ?: race?.size, points, hasHardyTalent, woundsModifiers, characteristics),
55+
calculateMaxWounds(size ?: race?.size, points, woundsModifiers, characteristics),
5756
)
5857

5958
val maxEncumbrance: Encumbrance
@@ -82,7 +81,6 @@ data class Character(
8281
calculateMaxWounds(
8382
size ?: race?.size,
8483
points,
85-
hasHardyTalent,
8684
woundsModifiers,
8785
characteristics,
8886
)
@@ -110,7 +108,6 @@ data class Character(
110108
calculateMaxWounds(
111109
size ?: race?.size,
112110
points,
113-
hasHardyTalent,
114111
woundsModifiers,
115112
base + advances,
116113
),
@@ -129,7 +126,6 @@ data class Character(
129126
calculateMaxWounds(
130127
size ?: race?.size,
131128
points,
132-
hasHardyTalent,
133129
woundsModifiers,
134130
characteristics,
135131
),
@@ -148,7 +144,6 @@ data class Character(
148144
calculateMaxWounds(
149145
size ?: race?.size,
150146
points,
151-
hasHardyTalent,
152147
woundsModifiers,
153148
characteristics,
154149
),
@@ -190,26 +185,20 @@ data class Character(
190185
calculateMaxWounds(
191186
size ?: race?.size,
192187
points,
193-
hasHardyTalent,
194188
woundsModifiers,
195189
characteristics,
196190
),
197191
),
198192
)
199193

200-
fun updateMaxWounds(
201-
maxWounds: Int?,
202-
hasHardyTalent: Boolean,
203-
): Character {
194+
fun updateMaxWounds(maxWounds: Int?): Character {
204195
val newPoints = points.copy(maxWounds = maxWounds)
205196
return copy(
206-
hasHardyTalent = hasHardyTalent,
207197
points =
208198
newPoints.coerceWoundsAtMost(
209199
calculateMaxWounds(
210200
size ?: race?.size,
211201
newPoints,
212-
hasHardyTalent,
213202
woundsModifiers,
214203
characteristics,
215204
),
@@ -298,19 +287,13 @@ data class Character(
298287
private fun calculateMaxWounds(
299288
size: Size?,
300289
points: Points,
301-
hasHardyTalent: Boolean,
302290
modifiers: WoundsModifiers,
303291
characteristics: Stats,
304292
): Int {
305293
val manualMaxWounds = points.maxWounds
306294
val toughnessBonus = characteristics.toughnessBonus
307295

308296
if (manualMaxWounds != null) {
309-
// TODO: Remove support for hasHardyTalent flag
310-
if (hasHardyTalent) {
311-
return manualMaxWounds + toughnessBonus
312-
}
313-
314297
return manualMaxWounds
315298
}
316299

@@ -326,11 +309,7 @@ data class Character(
326309
characteristics.willPowerBonus
327310
},
328311
)
329-
return (
330-
baseWounds +
331-
modifiers.extraToughnessBonusMultiplier * toughnessBonus +
332-
(if (hasHardyTalent) toughnessBonus else 0)
333-
) *
312+
return (baseWounds + modifiers.extraToughnessBonusMultiplier * toughnessBonus) *
334313
modifiers.afterMultiplier
335314
}
336315
}

common/src/commonMain/kotlin/cz/frantisekmasa/wfrp_master/common/core/ui/primitives/UserTipCard.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,5 @@ fun UserTipCard(
110110

111111
enum class UserTip(override val translatableName: StringResource) : NamedEnum {
112112
ARMOUR_TRAPPINGS(Str.armour_tip_trappings),
113-
HARDY_TALENTS(Str.talents_tip_hardy_talent_checkbox),
114113
COMPENDIUM_LINK_MOVED(Str.parties_messages_compendium_card_moved),
115114
}

common/src/commonTest/kotlin/cz/frantisekmasa/wfrp_master/common/character/effects/EffectManagerTest.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,6 @@ class EffectManagerTest {
492492
sin = 0,
493493
experience = 0,
494494
spentExperience = 0,
495-
hardyWoundsBonus = 0,
496495
),
497496
motivation = "",
498497
psychology = "",

common/src/commonTest/kotlin/cz/frantisekmasa/wfrp_master/common/core/domain/character/CharacterTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class CharacterTest {
2323
race = Race.HALFLING,
2424
characteristicsBase = Stats(20, 40, 2, 4, 80, 5, 5, 4, 0, 10),
2525
characteristicsAdvances = Stats(20, 40, 2, 4, 80, 5, 5, 4, 0, 10),
26-
points = Points(0, 4, 4, 5, 5, 0, 0, 0, 0, 0, 0),
26+
points = Points(0, 4, 4, 5, 5, 0, 0, 0, 0, 0),
2727
)
2828

2929
@Test
@@ -67,7 +67,7 @@ class CharacterTest {
6767
race = Race.HALFLING,
6868
characteristicsBase = Stats(20, 40, 2, 4, 80, 5, 5, 4, 0, 10),
6969
characteristicsAdvances = Stats(20, 40, 2, 4, 80, 5, 5, 4, 0, 10),
70-
points = Points(0, 4, 4, 5, 5, 0, 0, 0, 0, 0, 0),
70+
points = Points(0, 4, 4, 5, 5, 0, 0, 0, 0, 0),
7171
)
7272

7373
val playerCharacter = character.turnIntoPlayerCharacter()

common/src/commonTest/kotlin/cz/frantisekmasa/wfrp_master/common/core/domain/character/effects/HardyWoundsModificationTest.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ class HardyWoundsModificationTest {
8686
sin = 0,
8787
experience = 0,
8888
spentExperience = 0,
89-
hardyWoundsBonus = 0,
9089
),
9190
socialClass = "Warriors",
9291
race = Race.HUMAN,

firebase/api.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ export interface Character {
8585
resilience: number,
8686
resolve: number,
8787
sin: number,
88-
hardyWoundsBonus: number
8988
},
9089
woundsModifiers: {
9190
afterMultiplier: number,
@@ -105,7 +104,6 @@ export interface Character {
105104
money: {
106105
pennies: number,
107106
},
108-
hardyTalent: boolean,
109107
note: string,
110108
conditions: Conditions,
111109
archived: boolean,

firebase/firestore.rules

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ service cloud.firestore {
560560
&& areMoneyValid(character.money)
561561
&& areAmbitionsValid(character.ambitions)
562562
&& character.note is string && character.note.size() <= 2000
563-
&& character.hardyTalent is bool
563+
&& (! ("hardyTalent" in character) || character.hardyTalent is bool)
564564
&& (
565565
character.hiddenTabs is list &&
566566
character.hiddenTabs.toSet().size() == character.hiddenTabs.size() &&
@@ -642,7 +642,7 @@ service cloud.firestore {
642642
&& points.wounds is int
643643
&& points.experience is int
644644
&& (! ("spentExperience" in points) || points.experience is int)
645-
&& points.hardyWoundsBonus is int;
645+
&& (! ("hardyWoundsBonus " in points) || points.hardyWoundsBonus is int);
646646
}
647647

648648
function areStatsValid(stats) {

firebase/tests/Parties.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,9 +516,8 @@ class Parties extends Suite {
516516

517517
await firebase.assertSucceeds(document.set({points: {resilience: 10}}, {merge: true}));
518518
await firebase.assertSucceeds(document.update("note", "a".repeat(400)));
519-
await firebase.assertSucceeds(document.update("hardyTalent", true));
520519
await firebase.assertSucceeds(
521-
document.update("points", {...this.validCharacter(userId).points, hardyWoundsBonus: 3})
520+
document.update("points", {...this.validCharacter(userId).points, corruption: 3})
522521
);
523522
await firebase.assertSucceeds(document.update("hiddenTabs", ["ATTRIBUTES"]))
524523
}

0 commit comments

Comments
 (0)