File tree Expand file tree Collapse file tree 6 files changed +64
-11
lines changed
common/src/commonMain/kotlin/cz/frantisekmasa/wfrp_master/common Expand file tree Collapse file tree 6 files changed +64
-11
lines changed Original file line number Diff line number Diff line change 1+ package cz.frantisekmasa.wfrp_master.common.character.effects
2+
3+ import cz.frantisekmasa.wfrp_master.common.core.domain.character.Character
4+
5+ class ConstructWoundsModification : CharacterEffect {
6+ override fun apply (character : Character , otherEffects : List <CharacterEffect >): Character {
7+ if (otherEffects.any { it is ConstructWoundsModification }) {
8+ return character // This effect does not stack
9+ }
10+
11+ return character.modifyWounds(
12+ character.woundsModifiers.copy(isConstruct = true )
13+ )
14+ }
15+
16+ override fun revert (character : Character , otherEffects : List <CharacterEffect >): Character {
17+ if (otherEffects.any { it is ConstructWoundsModification }) {
18+ return character // This effect does not stack
19+ }
20+
21+ return character.modifyWounds(
22+ character.woundsModifiers.copy(isConstruct = false )
23+ )
24+ }
25+
26+ companion object {
27+ fun fromTraitNameOrNull (name : String ): ConstructWoundsModification ? {
28+ if (name.equals(" construct" , ignoreCase = true )) {
29+ return ConstructWoundsModification ()
30+ }
31+
32+ return null
33+ }
34+ }
35+ }
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ class EffectFactory {
1010 SizeChange .fromTraitNameOrNull(name),
1111 CharacteristicChange .fromTraitNameOrNull(name),
1212 SwarmWoundsModification .fromTraitNameOrNull(name),
13+ ConstructWoundsModification .fromTraitNameOrNull(name),
1314 )
1415 }
1516 is EffectSource .Talent -> {
Original file line number Diff line number Diff line change @@ -244,24 +244,31 @@ data class Character(
244244 characteristics : Stats ,
245245 ): Int {
246246 val manualMaxWounds = points.maxWounds
247- val tb = characteristics.toughnessBonus
247+ val toughnessBonus = characteristics.toughnessBonus
248248
249249 if (manualMaxWounds != null ) {
250250 // TODO: Remove support for hasHardyTalent flag
251251 if (hasHardyTalent) {
252- return manualMaxWounds + tb
252+ return manualMaxWounds + toughnessBonus
253253 }
254254
255255 return manualMaxWounds
256256 }
257257
258- val baseWounds = Wounds .calculateMax(size ? : Size .AVERAGE , characteristics)
258+ val baseWounds = Wounds .calculateMax(
259+ size = size ? : Size .AVERAGE ,
260+ toughnessBonus = toughnessBonus,
261+ strengthBonus = characteristics.strengthBonus,
262+ willPowerBonus = if (modifiers.isConstruct)
263+ characteristics.strengthBonus
264+ else characteristics.willPowerBonus
265+ )
259266 return (
260267 baseWounds +
261- modifiers.extraToughnessBonusMultiplier.toInt() * tb +
262- (if (hasHardyTalent) tb else 0 )
268+ modifiers.extraToughnessBonusMultiplier * toughnessBonus +
269+ (if (hasHardyTalent) toughnessBonus else 0 )
263270 ) *
264- modifiers.afterMultiplier.toInt()
271+ modifiers.afterMultiplier
265272 }
266273 }
267274}
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import kotlinx.serialization.Serializable
1111data class WoundsModifiers (
1212 val afterMultiplier : Int = 1 ,
1313 val extraToughnessBonusMultiplier : Int = 0 ,
14+ val isConstruct : Boolean = false ,
1415) : Parcelable {
1516 init {
1617 require(extraToughnessBonusMultiplier >= 0 )
Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ package cz.frantisekmasa.wfrp_master.common.encounters.domain
22
33import androidx.compose.runtime.Immutable
44import cz.frantisekmasa.wfrp_master.common.core.domain.Size
5- import cz.frantisekmasa.wfrp_master.common.core.domain.Stats
65import cz.frantisekmasa.wfrp_master.common.core.shared.Parcelable
76import cz.frantisekmasa.wfrp_master.common.core.shared.Parcelize
87import kotlinx.serialization.Serializable
@@ -23,8 +22,13 @@ data class Wounds(
2322 fun fromMax (max : Int ) = Wounds (max, max)
2423
2524 // See rulebook page 341
26- fun calculateMax (size : Size , characteristics : Stats ): Int = with (characteristics) {
27- when (size) {
25+ fun calculateMax (
26+ size : Size ,
27+ toughnessBonus : Int ,
28+ strengthBonus : Int ,
29+ willPowerBonus : Int ,
30+ ): Int {
31+ return when (size) {
2832 Size .TINY -> 1
2933 Size .LITTLE -> toughnessBonus
3034 Size .SMALL -> (2 * toughnessBonus) + willPowerBonus
Original file line number Diff line number Diff line change @@ -497,9 +497,14 @@ service cloud.firestore {
497497 )
498498 && ! (" woundsModifiers" in character ) || (
499499 character .woundsModifiers is map &&
500- character .woundsModifiers .keys ().toSet () == [" afterMultiplier" , " extraToughnessBonusMultiplier" ].toSet () &&
500+ [
501+ " afterMultiplier" ,
502+ " extraToughnessBonusMultiplier" ,
503+ " isConstruct"
504+ ].hasAll (character .woundsModifiers .keys ()) &&
501505 character .woundsModifiers.afterMultiplier is int &&
502- character .woundsModifiers.extraToughnessBonusMultiplier is int
506+ character .woundsModifiers.extraToughnessBonusMultiplier is int &&
507+ (! (" isConstruct" in character .woundsModifiers ) || character .woundsModifiers.isConstruct is bool )
503508 )
504509 && (! (" compendiumCareer" in character ) || character .compendiumCareer == null || (
505510 character .compendiumCareer is map &&
You can’t perform that action at this time.
0 commit comments