@@ -259,7 +259,11 @@ class ActiveCombatScreen(
259259 }
260260
261261 if (isGroupAdvantageSystemEnabled) {
262- GroupAdvantageBar (groupAdvantage, viewModel)
262+ GroupAdvantageBar (
263+ groupAdvantage = groupAdvantage,
264+ isGameMaster = isGameMaster,
265+ screenModel = viewModel,
266+ )
263267 }
264268
265269 if (isGameMaster) {
@@ -277,6 +281,7 @@ class ActiveCombatScreen(
277281 @Composable
278282 private fun GroupAdvantageBar (
279283 groupAdvantage : GroupAdvantage ,
284+ isGameMaster : Boolean ,
280285 screenModel : CombatScreenModel ,
281286 ) {
282287 Surface (elevation = 2 .dp) {
@@ -289,34 +294,68 @@ class ActiveCombatScreen(
289294 fontWeight = FontWeight .Bold ,
290295 )
291296
297+ val strings = LocalStrings .current.combat
298+
292299 Row {
293- val coroutineScope = rememberCoroutineScope()
294- val update = { groupAdvantage: GroupAdvantage ->
295- coroutineScope.launch(Dispatchers .IO ) {
296- screenModel.updateGroupAdvantage(groupAdvantage)
300+ if (isGameMaster) {
301+ val coroutineScope = rememberCoroutineScope()
302+ val update = { groupAdvantage: GroupAdvantage ->
303+ coroutineScope.launch(Dispatchers .IO ) {
304+ screenModel.updateGroupAdvantage(groupAdvantage)
305+ }
297306 }
298- }
299307
300- val strings = LocalStrings .current.combat
308+ AdvantagePicker (
309+ label = strings.labelAllies,
310+ value = groupAdvantage.allies,
311+ onChange = { update(groupAdvantage.copy(allies = it)) },
312+ modifier = Modifier .weight(1f ),
313+ )
301314
302- AdvantagePicker (
303- label = strings.labelAllies,
304- value = groupAdvantage.allies,
305- onChange = { update(groupAdvantage.copy(allies = it)) },
306- modifier = Modifier .weight(1f ),
307- )
315+ AdvantagePicker (
316+ label = strings.labelEnemies,
317+ value = groupAdvantage.enemies,
318+ onChange = { update(groupAdvantage.copy(enemies = it)) },
319+ modifier = Modifier .weight(1f ),
320+ )
321+ } else {
322+ AdvantageValue (
323+ label = strings.labelAllies,
324+ value = groupAdvantage.allies,
325+ modifier = Modifier .weight(1f ),
326+ )
308327
309- AdvantagePicker (
310- label = strings.labelEnemies,
311- value = groupAdvantage.enemies,
312- onChange = { update(groupAdvantage.copy(enemies = it)) } ,
313- modifier = Modifier .weight( 1f ),
314- )
328+ AdvantageValue (
329+ label = strings.labelEnemies,
330+ value = groupAdvantage.enemies,
331+ modifier = Modifier .weight( 1f ) ,
332+ )
333+ }
315334 }
316335 }
317336 }
318337 }
319338
339+ @Composable
340+ private fun AdvantageValue (
341+ label : String ,
342+ value : Advantage ,
343+ modifier : Modifier ,
344+ ) {
345+ Column (
346+ horizontalAlignment = Alignment .CenterHorizontally ,
347+ modifier = modifier
348+ .padding(vertical = 4 .dp)
349+ .then(modifier)
350+ ) {
351+ Text (label, style = MaterialTheme .typography.subtitle1)
352+ Text (
353+ text = value.toString(),
354+ style = MaterialTheme .typography.h5,
355+ )
356+ }
357+ }
358+
320359 @Composable
321360 private fun AdvantagePicker (
322361 label : String ,
0 commit comments