Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
6254c6d24c
|
|||
|
cde4b41ade
|
1
android/.idea/.name
generated
Normal file
@@ -0,0 +1 @@
|
|||||||
|
MagicCounter
|
||||||
1
android/.idea/misc.xml
generated
@@ -1,4 +1,3 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="jbr-21" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="jbr-21" project-jdk-type="JavaSDK">
|
||||||
|
|||||||
1
android/.idea/vcs.xml
generated
@@ -2,5 +2,6 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="VcsDirectoryMappings">
|
<component name="VcsDirectoryMappings">
|
||||||
<mapping directory="" vcs="Git" />
|
<mapping directory="" vcs="Git" />
|
||||||
|
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
@@ -15,8 +15,8 @@ android {
|
|||||||
applicationId = "com.atridad.magiccounter"
|
applicationId = "com.atridad.magiccounter"
|
||||||
minSdk = 31
|
minSdk = 31
|
||||||
targetSdk = 36
|
targetSdk = 36
|
||||||
versionCode = 3
|
versionCode = 5
|
||||||
versionName = "1.3.0"
|
versionName = "1.4.1"
|
||||||
|
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 79 KiB After Width: | Height: | Size: 122 KiB |
@@ -65,7 +65,7 @@ fun MagicCounterApp() {
|
|||||||
val settingsVm: AppSettingsViewModel = viewModel()
|
val settingsVm: AppSettingsViewModel = viewModel()
|
||||||
val theme = settingsVm.themeMode.collectAsState()
|
val theme = settingsVm.themeMode.collectAsState()
|
||||||
val historyState = settingsVm.matchHistory.collectAsState()
|
val historyState = settingsVm.matchHistory.collectAsState()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
MagicCounterTheme(themeMode = theme.value) {
|
MagicCounterTheme(themeMode = theme.value) {
|
||||||
@@ -81,7 +81,7 @@ fun MagicCounterApp() {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions = {
|
actions = {
|
||||||
|
|
||||||
IconButton(onClick = { screenStack.add(Screen.Settings) }) {
|
IconButton(onClick = { screenStack.add(Screen.Settings) }) {
|
||||||
Icon(Icons.Default.Settings, contentDescription = "App settings")
|
Icon(Icons.Default.Settings, contentDescription = "App settings")
|
||||||
}
|
}
|
||||||
@@ -142,7 +142,7 @@ fun MagicCounterApp() {
|
|||||||
screenStack.removeAt(screenStack.lastIndex)
|
screenStack.removeAt(screenStack.lastIndex)
|
||||||
return@SetupScreen
|
return@SetupScreen
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create and persist a new MatchRecord
|
// Create and persist a new MatchRecord
|
||||||
val newId = java.util.UUID.randomUUID().toString()
|
val newId = java.util.UUID.randomUUID().toString()
|
||||||
val now = System.currentTimeMillis()
|
val now = System.currentTimeMillis()
|
||||||
@@ -175,6 +175,8 @@ fun MagicCounterApp() {
|
|||||||
.padding(paddingValues)
|
.padding(paddingValues)
|
||||||
.fillMaxSize(),
|
.fillMaxSize(),
|
||||||
state = stateForGame,
|
state = stateForGame,
|
||||||
|
matchName = record?.name ?: "Game",
|
||||||
|
startedAtEpochMs = record?.startedAtEpochMs ?: System.currentTimeMillis(),
|
||||||
onProgress = { updated ->
|
onProgress = { updated ->
|
||||||
val current = historyState.value
|
val current = historyState.value
|
||||||
val idx = current.indexOfFirst { it.id == id }
|
val idx = current.indexOfFirst { it.id == id }
|
||||||
@@ -233,7 +235,7 @@ fun MagicCounterApp() {
|
|||||||
onSelect = { settingsVm.setTheme(it) }
|
onSelect = { settingsVm.setTheme(it) }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -242,7 +244,7 @@ fun MagicCounterApp() {
|
|||||||
@Composable
|
@Composable
|
||||||
private fun SettingsContent(modifier: Modifier, current: ThemeMode, onSelect: (ThemeMode) -> Unit) {
|
private fun SettingsContent(modifier: Modifier, current: ThemeMode, onSelect: (ThemeMode) -> Unit) {
|
||||||
Column(
|
Column(
|
||||||
modifier = modifier.padding(24.dp),
|
modifier = modifier.padding(24.dp),
|
||||||
verticalArrangement = Arrangement.spacedBy(24.dp)
|
verticalArrangement = Arrangement.spacedBy(24.dp)
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
@@ -250,7 +252,7 @@ private fun SettingsContent(modifier: Modifier, current: ThemeMode, onSelect: (T
|
|||||||
style = MaterialTheme.typography.headlineSmall,
|
style = MaterialTheme.typography.headlineSmall,
|
||||||
color = MaterialTheme.colorScheme.primary
|
color = MaterialTheme.colorScheme.primary
|
||||||
)
|
)
|
||||||
|
|
||||||
Column(verticalArrangement = Arrangement.spacedBy(16.dp)) {
|
Column(verticalArrangement = Arrangement.spacedBy(16.dp)) {
|
||||||
Text(
|
Text(
|
||||||
"Theme",
|
"Theme",
|
||||||
@@ -291,17 +293,17 @@ private fun HomeScreen(
|
|||||||
contentAlignment = Alignment.Center
|
contentAlignment = Alignment.Center
|
||||||
) {
|
) {
|
||||||
Column(
|
Column(
|
||||||
horizontalAlignment = Alignment.CenterHorizontally,
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
verticalArrangement = Arrangement.spacedBy(16.dp)
|
verticalArrangement = Arrangement.spacedBy(16.dp)
|
||||||
) {
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
Icons.Default.History,
|
Icons.Default.History,
|
||||||
contentDescription = "Empty history",
|
contentDescription = "Empty history",
|
||||||
modifier = Modifier.size(64.dp),
|
modifier = Modifier.size(64.dp),
|
||||||
tint = MaterialTheme.colorScheme.onSurfaceVariant
|
tint = MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
)
|
)
|
||||||
Text(
|
Text(
|
||||||
"No games yet",
|
"No games yet",
|
||||||
style = MaterialTheme.typography.headlineSmall,
|
style = MaterialTheme.typography.headlineSmall,
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
)
|
)
|
||||||
@@ -332,13 +334,13 @@ private fun HomeScreen(
|
|||||||
onClick = { onResume(activeGame) }
|
onClick = { onResume(activeGame) }
|
||||||
) {
|
) {
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier.fillMaxWidth().padding(16.dp),
|
modifier = Modifier.fillMaxWidth().padding(16.dp),
|
||||||
horizontalArrangement = Arrangement.SpaceBetween,
|
horizontalArrangement = Arrangement.SpaceBetween,
|
||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = Alignment.CenterVertically
|
||||||
) {
|
) {
|
||||||
Column(modifier = Modifier.weight(1f)) {
|
Column(modifier = Modifier.weight(1f)) {
|
||||||
Text(
|
Text(
|
||||||
"Active Game",
|
"Active Game",
|
||||||
style = MaterialTheme.typography.titleMedium,
|
style = MaterialTheme.typography.titleMedium,
|
||||||
color = MaterialTheme.colorScheme.onPrimary
|
color = MaterialTheme.colorScheme.onPrimary
|
||||||
)
|
)
|
||||||
@@ -382,23 +384,29 @@ private fun HomeScreen(
|
|||||||
onClick = { onResume(rec) }
|
onClick = { onResume(rec) }
|
||||||
) {
|
) {
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier.fillMaxWidth().padding(16.dp),
|
modifier = Modifier.fillMaxWidth().padding(16.dp),
|
||||||
horizontalArrangement = Arrangement.SpaceBetween,
|
horizontalArrangement = Arrangement.SpaceBetween,
|
||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = Alignment.CenterVertically
|
||||||
) {
|
) {
|
||||||
Column(modifier = Modifier.weight(1f)) {
|
Column(modifier = Modifier.weight(1f)) {
|
||||||
Text(
|
Text(
|
||||||
rec.name,
|
rec.name,
|
||||||
style = MaterialTheme.typography.bodyLarge,
|
style = MaterialTheme.typography.bodyLarge,
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
)
|
)
|
||||||
val status = if (rec.state.stopped) "Stopped" else "Finished"
|
val winnerId = rec.winnerPlayerId ?: rec.state.winnerPlayerId
|
||||||
val winner = rec.winnerPlayerId?.let { " • Winner: Player ${it + 1}" } ?: ""
|
val winnerName = winnerId?.let { wId ->
|
||||||
val statusText = if (winner.isNotEmpty()) "$status$winner" else status
|
rec.state.players.find { it.id == wId }?.name
|
||||||
|
}
|
||||||
|
val statusText = when {
|
||||||
|
winnerName != null -> "Winner: $winnerName"
|
||||||
|
rec.state.stopped -> "Stopped"
|
||||||
|
else -> "Finished"
|
||||||
|
}
|
||||||
Text(
|
Text(
|
||||||
statusText,
|
statusText,
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.7f)
|
color = if (winnerName != null) Color(0xFF2E7D32) else MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.7f)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||||
@@ -409,12 +417,12 @@ private fun HomeScreen(
|
|||||||
containerColor = MaterialTheme.colorScheme.secondary,
|
containerColor = MaterialTheme.colorScheme.secondary,
|
||||||
contentColor = MaterialTheme.colorScheme.onSecondary
|
contentColor = MaterialTheme.colorScheme.onSecondary
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
Icons.Default.Visibility,
|
Icons.Default.Visibility,
|
||||||
contentDescription = "View match",
|
contentDescription = "View match",
|
||||||
modifier = Modifier.size(20.dp)
|
modifier = Modifier.size(20.dp)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
androidx.compose.material3.FilledTonalIconButton(
|
androidx.compose.material3.FilledTonalIconButton(
|
||||||
onClick = { pendingDeleteId = rec.id },
|
onClick = { pendingDeleteId = rec.id },
|
||||||
@@ -423,12 +431,12 @@ private fun HomeScreen(
|
|||||||
containerColor = MaterialTheme.colorScheme.error,
|
containerColor = MaterialTheme.colorScheme.error,
|
||||||
contentColor = MaterialTheme.colorScheme.onError
|
contentColor = MaterialTheme.colorScheme.onError
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
Icons.Default.Delete,
|
Icons.Default.Delete,
|
||||||
contentDescription = "Delete",
|
contentDescription = "Delete",
|
||||||
modifier = Modifier.size(20.dp)
|
modifier = Modifier.size(20.dp)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -461,14 +469,14 @@ private fun GameDuration(
|
|||||||
color: Color
|
color: Color
|
||||||
) {
|
) {
|
||||||
var duration by remember { mutableStateOf("") }
|
var duration by remember { mutableStateOf("") }
|
||||||
|
|
||||||
LaunchedEffect(startTime) {
|
LaunchedEffect(startTime) {
|
||||||
while (true) {
|
while (true) {
|
||||||
val elapsed = System.currentTimeMillis() - startTime
|
val elapsed = System.currentTimeMillis() - startTime
|
||||||
val seconds = (elapsed / 1000).toInt()
|
val seconds = (elapsed / 1000).toInt()
|
||||||
val minutes = seconds / 60
|
val minutes = seconds / 60
|
||||||
val remainingSeconds = seconds % 60
|
val remainingSeconds = seconds % 60
|
||||||
|
|
||||||
duration = when {
|
duration = when {
|
||||||
minutes > 0 -> "Duration: ${minutes}m ${remainingSeconds}s"
|
minutes > 0 -> "Duration: ${minutes}m ${remainingSeconds}s"
|
||||||
else -> "${remainingSeconds}s"
|
else -> "${remainingSeconds}s"
|
||||||
@@ -476,12 +484,10 @@ private fun GameDuration(
|
|||||||
delay(1000)
|
delay(1000)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Text(
|
Text(
|
||||||
text = duration,
|
text = duration,
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
color = color.copy(alpha = 0.8f)
|
color = color.copy(alpha = 0.8f)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,9 +21,8 @@ data class GameState(
|
|||||||
val startingLife: Int,
|
val startingLife: Int,
|
||||||
val trackPoison: Boolean,
|
val trackPoison: Boolean,
|
||||||
val trackCommanderDamage: Boolean,
|
val trackCommanderDamage: Boolean,
|
||||||
val stopped: Boolean = false
|
val stopped: Boolean = false,
|
||||||
|
val winnerPlayerId: Int? = null
|
||||||
)
|
)
|
||||||
|
|
||||||
fun defaultPlayerName(index: Int): String = "Player ${index + 1}"
|
fun defaultPlayerName(index: Int): String = "Player ${index + 1}"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -201,6 +201,25 @@ object CustomIcons {
|
|||||||
close()
|
close()
|
||||||
}.build()
|
}.build()
|
||||||
|
|
||||||
|
fun Droplet(color: Color = Color.Black): ImageVector = ImageVector.Builder(
|
||||||
|
name = "Droplet",
|
||||||
|
defaultWidth = 24.dp,
|
||||||
|
defaultHeight = 24.dp,
|
||||||
|
viewportWidth = 24f,
|
||||||
|
viewportHeight = 24f
|
||||||
|
).path(
|
||||||
|
fill = SolidColor(color)
|
||||||
|
) {
|
||||||
|
moveTo(12f, 2.69f)
|
||||||
|
lineTo(17.66f, 8.35f)
|
||||||
|
curveTo(19.1f, 9.79f, 20f, 11.79f, 20f, 14f)
|
||||||
|
curveTo(20f, 18.42f, 16.42f, 22f, 12f, 22f)
|
||||||
|
curveTo(7.58f, 22f, 4f, 18.42f, 4f, 14f)
|
||||||
|
curveTo(4f, 11.79f, 4.9f, 9.79f, 6.34f, 8.35f)
|
||||||
|
lineTo(12f, 2.69f)
|
||||||
|
close()
|
||||||
|
}.build()
|
||||||
|
|
||||||
fun Sword(color: Color = Color.Black): ImageVector = ImageVector.Builder(
|
fun Sword(color: Color = Color.Black): ImageVector = ImageVector.Builder(
|
||||||
name = "Sword",
|
name = "Sword",
|
||||||
defaultWidth = 24.dp,
|
defaultWidth = 24.dp,
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 4.9 KiB |
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 7.4 KiB |
|
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 5.5 KiB |
|
Before Width: | Height: | Size: 8.9 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 8.7 KiB |
|
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 8.4 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 13 KiB |
@@ -1,23 +1,23 @@
|
|||||||
[versions]
|
[versions]
|
||||||
agp = "8.12.3"
|
agp = "8.12.3"
|
||||||
kotlin = "2.0.21"
|
kotlin = "2.3.0"
|
||||||
coreKtx = "1.10.1"
|
coreKtx = "1.17.0"
|
||||||
junit = "4.13.2"
|
junit = "4.13.2"
|
||||||
junitVersion = "1.1.5"
|
junitVersion = "1.3.0"
|
||||||
espressoCore = "3.5.1"
|
espressoCore = "3.7.0"
|
||||||
appcompat = "1.6.1"
|
appcompat = "1.7.1"
|
||||||
material = "1.10.0"
|
material = "1.13.0"
|
||||||
constraintlayout = "2.1.4"
|
constraintlayout = "2.2.1"
|
||||||
lifecycleLivedataKtx = "2.6.1"
|
lifecycleLivedataKtx = "2.10.0"
|
||||||
lifecycleViewmodelKtx = "2.6.1"
|
lifecycleViewmodelKtx = "2.10.0"
|
||||||
navigationFragmentKtx = "2.6.0"
|
navigationFragmentKtx = "2.9.6"
|
||||||
navigationUiKtx = "2.6.0"
|
navigationUiKtx = "2.9.6"
|
||||||
composeBom = "2024.10.01"
|
composeBom = "2025.12.01"
|
||||||
activityCompose = "1.9.2"
|
activityCompose = "1.12.2"
|
||||||
lifecycleRuntimeCompose = "2.8.6"
|
lifecycleRuntimeCompose = "2.10.0"
|
||||||
lifecycleViewmodelCompose = "2.8.6"
|
lifecycleViewmodelCompose = "2.10.0"
|
||||||
datastore = "1.1.1"
|
datastore = "1.2.0"
|
||||||
serialization = "1.7.3"
|
serialization = "1.9.0"
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
|
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
|
||||||
|
|||||||
BIN
branding/Logo-iOS-Default-1024x1024@1x.png
Normal file
|
After Width: | Height: | Size: 3.3 MiB |
@@ -411,7 +411,7 @@
|
|||||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||||
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
|
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 4;
|
CURRENT_PROJECT_VERSION = 6;
|
||||||
DEVELOPMENT_TEAM = 4BC9Y2LL4B;
|
DEVELOPMENT_TEAM = 4BC9Y2LL4B;
|
||||||
ENABLE_PREVIEWS = YES;
|
ENABLE_PREVIEWS = YES;
|
||||||
GENERATE_INFOPLIST_FILE = YES;
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
@@ -420,14 +420,13 @@
|
|||||||
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
|
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
|
||||||
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
|
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
|
||||||
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
|
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
|
||||||
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
|
INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown";
|
||||||
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
|
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 17.6;
|
IPHONEOS_DEPLOYMENT_TARGET = 17.6;
|
||||||
LD_RUNPATH_SEARCH_PATHS = (
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"@executable_path/Frameworks",
|
"@executable_path/Frameworks",
|
||||||
);
|
);
|
||||||
MARKETING_VERSION = 1.1.0;
|
MARKETING_VERSION = 1.2.1;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.atridad.MagicCounter;
|
PRODUCT_BUNDLE_IDENTIFIER = com.atridad.MagicCounter;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
STRING_CATALOG_GENERATE_SYMBOLS = YES;
|
STRING_CATALOG_GENERATE_SYMBOLS = YES;
|
||||||
@@ -447,7 +446,7 @@
|
|||||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||||
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
|
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 4;
|
CURRENT_PROJECT_VERSION = 6;
|
||||||
DEVELOPMENT_TEAM = 4BC9Y2LL4B;
|
DEVELOPMENT_TEAM = 4BC9Y2LL4B;
|
||||||
ENABLE_PREVIEWS = YES;
|
ENABLE_PREVIEWS = YES;
|
||||||
GENERATE_INFOPLIST_FILE = YES;
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
@@ -456,14 +455,13 @@
|
|||||||
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
|
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
|
||||||
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
|
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
|
||||||
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
|
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
|
||||||
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
|
INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown";
|
||||||
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
|
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 17.6;
|
IPHONEOS_DEPLOYMENT_TARGET = 17.6;
|
||||||
LD_RUNPATH_SEARCH_PATHS = (
|
LD_RUNPATH_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"@executable_path/Frameworks",
|
"@executable_path/Frameworks",
|
||||||
);
|
);
|
||||||
MARKETING_VERSION = 1.1.0;
|
MARKETING_VERSION = 1.2.1;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.atridad.MagicCounter;
|
PRODUCT_BUNDLE_IDENTIFIER = com.atridad.MagicCounter;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
STRING_CATALOG_GENERATE_SYMBOLS = YES;
|
STRING_CATALOG_GENERATE_SYMBOLS = YES;
|
||||||
|
|||||||
@@ -6,61 +6,180 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
import Combine
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A circular button with an icon, used for game controls.
|
* A circular button with an icon, used for game controls.
|
||||||
|
* Supports optional long press to trigger a custom delta prompt.
|
||||||
*/
|
*/
|
||||||
struct CircleButton: View {
|
struct CircleButton: View {
|
||||||
let icon: String
|
let icon: String
|
||||||
let color: Color
|
let color: Color
|
||||||
let size: CGFloat
|
let size: CGFloat
|
||||||
let action: () -> Void
|
let action: () -> Void
|
||||||
|
var onLongPress: (() -> Void)? = nil
|
||||||
init(icon: String, color: Color, size: CGFloat = 44, action: @escaping () -> Void) {
|
|
||||||
|
init(icon: String, color: Color, size: CGFloat = 44, action: @escaping () -> Void, onLongPress: (() -> Void)? = nil) {
|
||||||
self.icon = icon
|
self.icon = icon
|
||||||
self.color = color
|
self.color = color
|
||||||
self.size = size
|
self.size = size
|
||||||
self.action = action
|
self.action = action
|
||||||
|
self.onLongPress = onLongPress
|
||||||
}
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
Button(action: action) {
|
Image(systemName: icon)
|
||||||
Image(systemName: icon)
|
.font(size < 40 ? .caption : .title3)
|
||||||
.font(size < 40 ? .caption : .title3)
|
.frame(width: size, height: size)
|
||||||
.frame(width: size, height: size)
|
.background(color.opacity(0.2))
|
||||||
.background(color.opacity(0.2))
|
.clipShape(Circle())
|
||||||
.clipShape(Circle())
|
.foregroundStyle(color)
|
||||||
.foregroundStyle(color)
|
.contentShape(Circle())
|
||||||
|
.onTapGesture {
|
||||||
|
action()
|
||||||
|
}
|
||||||
|
.onLongPressGesture(minimumDuration: 0.5) {
|
||||||
|
onLongPress?()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A view that shows the accumulated delta change near a counter button.
|
||||||
|
* Automatically fades out after a delay.
|
||||||
|
*/
|
||||||
|
struct DeltaIndicator: View {
|
||||||
|
let delta: Int
|
||||||
|
let alignment: HorizontalAlignment
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
if delta != 0 {
|
||||||
|
Text(delta > 0 ? "+\(delta)" : "\(delta)")
|
||||||
|
.font(.system(size: 16, weight: .bold, design: .rounded))
|
||||||
|
.foregroundStyle(delta > 0 ? .green : .red)
|
||||||
|
.opacity(0.8)
|
||||||
|
.transition(.opacity.combined(with: .scale))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Observable class to manage delta accumulation and fade-out timing.
|
||||||
|
*/
|
||||||
|
class DeltaTracker: ObservableObject {
|
||||||
|
@Published var delta: Int = 0
|
||||||
|
private var resetTimer: Timer?
|
||||||
|
|
||||||
|
func addDelta(_ amount: Int) {
|
||||||
|
delta += amount
|
||||||
|
resetTimer?.invalidate()
|
||||||
|
resetTimer = Timer.scheduledTimer(withTimeInterval: 2.0, repeats: false) { [weak self] _ in
|
||||||
|
withAnimation(.easeOut(duration: 0.3)) {
|
||||||
|
self?.delta = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func reset() {
|
||||||
|
resetTimer?.invalidate()
|
||||||
|
delta = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A control for adjusting a large numerical value (like Life).
|
* A control for adjusting a large numerical value (like Life).
|
||||||
|
* Shows delta indicators and supports long-press for custom delta input.
|
||||||
*/
|
*/
|
||||||
struct LifeCounterControl: View {
|
struct LifeCounterControl: View {
|
||||||
let value: Int
|
let value: Int
|
||||||
let onDecrease: () -> Void
|
let onDecrease: () -> Void
|
||||||
let onIncrease: () -> Void
|
let onIncrease: () -> Void
|
||||||
|
var onCustomDelta: ((Int) -> Void)? = nil
|
||||||
|
|
||||||
|
@StateObject private var deltaTracker = DeltaTracker()
|
||||||
|
@State private var showingCustomDeltaAlert = false
|
||||||
|
@State private var customDeltaText = ""
|
||||||
|
@State private var isIncreasing = true
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
HStack(spacing: 16) {
|
HStack(spacing: 16) {
|
||||||
CircleButton(icon: "minus", color: .red, action: onDecrease)
|
ZStack {
|
||||||
|
CircleButton(
|
||||||
|
icon: "minus",
|
||||||
|
color: .red,
|
||||||
|
action: {
|
||||||
|
onDecrease()
|
||||||
|
withAnimation(.easeOut(duration: 0.15)) {
|
||||||
|
deltaTracker.addDelta(-1)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onLongPress: {
|
||||||
|
isIncreasing = false
|
||||||
|
customDeltaText = ""
|
||||||
|
showingCustomDeltaAlert = true
|
||||||
|
Haptics.play(.medium)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
if deltaTracker.delta < 0 {
|
||||||
|
DeltaIndicator(delta: deltaTracker.delta, alignment: .trailing)
|
||||||
|
.offset(y: -35)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Text("\(value)")
|
Text("\(value)")
|
||||||
.font(.system(size: 56, weight: .bold, design: .rounded))
|
.font(.system(size: 56, weight: .bold, design: .rounded))
|
||||||
.minimumScaleFactor(0.5)
|
.minimumScaleFactor(0.5)
|
||||||
.lineLimit(1)
|
.lineLimit(1)
|
||||||
.foregroundStyle(.primary)
|
.foregroundStyle(.primary)
|
||||||
|
|
||||||
CircleButton(icon: "plus", color: .green, action: onIncrease)
|
ZStack {
|
||||||
|
CircleButton(
|
||||||
|
icon: "plus",
|
||||||
|
color: .green,
|
||||||
|
action: {
|
||||||
|
onIncrease()
|
||||||
|
withAnimation(.easeOut(duration: 0.15)) {
|
||||||
|
deltaTracker.addDelta(1)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onLongPress: {
|
||||||
|
isIncreasing = true
|
||||||
|
customDeltaText = ""
|
||||||
|
showingCustomDeltaAlert = true
|
||||||
|
Haptics.play(.medium)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
if deltaTracker.delta > 0 {
|
||||||
|
DeltaIndicator(delta: deltaTracker.delta, alignment: .leading)
|
||||||
|
.offset(y: -35)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.padding(.horizontal, 16)
|
.padding(.horizontal, 16)
|
||||||
|
.alert("Enter Amount", isPresented: $showingCustomDeltaAlert) {
|
||||||
|
TextField("Amount", text: $customDeltaText)
|
||||||
|
.keyboardType(.numberPad)
|
||||||
|
Button("Cancel", role: .cancel) { }
|
||||||
|
Button(isIncreasing ? "Add" : "Subtract") {
|
||||||
|
if let amount = Int(customDeltaText), amount > 0 {
|
||||||
|
let delta = isIncreasing ? amount : -amount
|
||||||
|
onCustomDelta?(delta)
|
||||||
|
withAnimation(.easeOut(duration: 0.15)) {
|
||||||
|
deltaTracker.addDelta(delta)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} message: {
|
||||||
|
Text(isIncreasing ? "Enter the amount to add" : "Enter the amount to subtract")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A smaller control for adjusting secondary values (like Poison).
|
* A smaller control for adjusting secondary values (like Poison).
|
||||||
|
* Shows delta indicators and supports long-press for custom delta input.
|
||||||
*/
|
*/
|
||||||
struct SmallCounterControl: View {
|
struct SmallCounterControl: View {
|
||||||
let value: Int
|
let value: Int
|
||||||
@@ -68,11 +187,41 @@ struct SmallCounterControl: View {
|
|||||||
let color: Color
|
let color: Color
|
||||||
let onDecrease: () -> Void
|
let onDecrease: () -> Void
|
||||||
let onIncrease: () -> Void
|
let onIncrease: () -> Void
|
||||||
|
var onCustomDelta: ((Int) -> Void)? = nil
|
||||||
|
|
||||||
|
@StateObject private var deltaTracker = DeltaTracker()
|
||||||
|
@State private var showingCustomDeltaAlert = false
|
||||||
|
@State private var customDeltaText = ""
|
||||||
|
@State private var isIncreasing = true
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
HStack(spacing: 4) {
|
HStack(spacing: 4) {
|
||||||
CircleButton(icon: "minus", color: .gray, size: 24, action: onDecrease)
|
ZStack {
|
||||||
|
CircleButton(
|
||||||
|
icon: "minus",
|
||||||
|
color: .gray,
|
||||||
|
size: 24,
|
||||||
|
action: {
|
||||||
|
onDecrease()
|
||||||
|
withAnimation(.easeOut(duration: 0.15)) {
|
||||||
|
deltaTracker.addDelta(-1)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onLongPress: {
|
||||||
|
isIncreasing = false
|
||||||
|
customDeltaText = ""
|
||||||
|
showingCustomDeltaAlert = true
|
||||||
|
Haptics.play(.medium)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
if deltaTracker.delta < 0 {
|
||||||
|
DeltaIndicator(delta: deltaTracker.delta, alignment: .trailing)
|
||||||
|
.font(.system(size: 12, weight: .bold))
|
||||||
|
.offset(y: -22)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
VStack(spacing: 0) {
|
VStack(spacing: 0) {
|
||||||
Image(systemName: icon)
|
Image(systemName: icon)
|
||||||
.font(.caption2)
|
.font(.caption2)
|
||||||
@@ -82,12 +231,52 @@ struct SmallCounterControl: View {
|
|||||||
.foregroundStyle(color)
|
.foregroundStyle(color)
|
||||||
}
|
}
|
||||||
.frame(minWidth: 30)
|
.frame(minWidth: 30)
|
||||||
|
|
||||||
CircleButton(icon: "plus", color: .gray, size: 24, action: onIncrease)
|
ZStack {
|
||||||
|
CircleButton(
|
||||||
|
icon: "plus",
|
||||||
|
color: .gray,
|
||||||
|
size: 24,
|
||||||
|
action: {
|
||||||
|
onIncrease()
|
||||||
|
withAnimation(.easeOut(duration: 0.15)) {
|
||||||
|
deltaTracker.addDelta(1)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onLongPress: {
|
||||||
|
isIncreasing = true
|
||||||
|
customDeltaText = ""
|
||||||
|
showingCustomDeltaAlert = true
|
||||||
|
Haptics.play(.medium)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
if deltaTracker.delta > 0 {
|
||||||
|
DeltaIndicator(delta: deltaTracker.delta, alignment: .leading)
|
||||||
|
.font(.system(size: 12, weight: .bold))
|
||||||
|
.offset(y: -22)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.padding(6)
|
.padding(6)
|
||||||
.background(color.opacity(0.1))
|
.background(color.opacity(0.1))
|
||||||
.cornerRadius(12)
|
.cornerRadius(12)
|
||||||
|
.alert("Enter Amount", isPresented: $showingCustomDeltaAlert) {
|
||||||
|
TextField("Amount", text: $customDeltaText)
|
||||||
|
.keyboardType(.numberPad)
|
||||||
|
Button("Cancel", role: .cancel) { }
|
||||||
|
Button(isIncreasing ? "Add" : "Subtract") {
|
||||||
|
if let amount = Int(customDeltaText), amount > 0 {
|
||||||
|
let delta = isIncreasing ? amount : -amount
|
||||||
|
onCustomDelta?(delta)
|
||||||
|
withAnimation(.easeOut(duration: 0.15)) {
|
||||||
|
deltaTracker.addDelta(delta)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} message: {
|
||||||
|
Text(isIncreasing ? "Enter the amount to add" : "Enter the amount to subtract")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,7 +288,7 @@ struct SettingSlider: View {
|
|||||||
let value: Binding<Double>
|
let value: Binding<Double>
|
||||||
let range: ClosedRange<Double>
|
let range: ClosedRange<Double>
|
||||||
let step: Double
|
let step: Double
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack(alignment: .leading) {
|
VStack(alignment: .leading) {
|
||||||
HStack {
|
HStack {
|
||||||
@@ -122,7 +311,7 @@ enum Haptics {
|
|||||||
let generator = UIImpactFeedbackGenerator(style: style)
|
let generator = UIImpactFeedbackGenerator(style: style)
|
||||||
generator.impactOccurred()
|
generator.impactOccurred()
|
||||||
}
|
}
|
||||||
|
|
||||||
static func notification(_ type: UINotificationFeedbackGenerator.FeedbackType) {
|
static func notification(_ type: UINotificationFeedbackGenerator.FeedbackType) {
|
||||||
guard UserDefaults.standard.bool(forKey: "hapticFeedbackEnabled") else { return }
|
guard UserDefaults.standard.bool(forKey: "hapticFeedbackEnabled") else { return }
|
||||||
let generator = UINotificationFeedbackGenerator()
|
let generator = UINotificationFeedbackGenerator()
|
||||||
|
|||||||
@@ -22,12 +22,12 @@ struct GameView: View {
|
|||||||
@State private var draggedPlayer: PlayerState?
|
@State private var draggedPlayer: PlayerState?
|
||||||
@State private var elapsedTime: TimeInterval = 0
|
@State private var elapsedTime: TimeInterval = 0
|
||||||
let match: MatchRecord
|
let match: MatchRecord
|
||||||
|
|
||||||
init(match: MatchRecord) {
|
init(match: MatchRecord) {
|
||||||
self.match = match
|
self.match = match
|
||||||
self._gameState = State(initialValue: match.state)
|
self._gameState = State(initialValue: match.state)
|
||||||
}
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
NavigationStack {
|
NavigationStack {
|
||||||
GeometryReader { geometry in
|
GeometryReader { geometry in
|
||||||
@@ -41,7 +41,7 @@ struct GameView: View {
|
|||||||
.lineLimit(1)
|
.lineLimit(1)
|
||||||
.truncationMode(.tail)
|
.truncationMode(.tail)
|
||||||
.foregroundStyle(.white)
|
.foregroundStyle(.white)
|
||||||
|
|
||||||
if !gameState.stopped && gameState.winner == nil {
|
if !gameState.stopped && gameState.winner == nil {
|
||||||
Text(timeString(from: elapsedTime))
|
Text(timeString(from: elapsedTime))
|
||||||
.font(.subheadline.bold())
|
.font(.subheadline.bold())
|
||||||
@@ -61,12 +61,12 @@ struct GameView: View {
|
|||||||
.background(.secondary.opacity(0.2))
|
.background(.secondary.opacity(0.2))
|
||||||
.clipShape(Capsule())
|
.clipShape(Capsule())
|
||||||
}
|
}
|
||||||
|
|
||||||
Spacer()
|
Spacer()
|
||||||
}
|
}
|
||||||
.padding(.horizontal, 24)
|
.padding(.horizontal, 24)
|
||||||
.padding(.top, 16)
|
.padding(.top, 16)
|
||||||
|
|
||||||
if gameState.stopped {
|
if gameState.stopped {
|
||||||
Text("Game Stopped")
|
Text("Game Stopped")
|
||||||
.font(.headline)
|
.font(.headline)
|
||||||
@@ -78,7 +78,7 @@ struct GameView: View {
|
|||||||
.foregroundStyle(.green)
|
.foregroundStyle(.green)
|
||||||
.padding(.horizontal, 24)
|
.padding(.horizontal, 24)
|
||||||
}
|
}
|
||||||
|
|
||||||
LazyVGrid(columns: columns, spacing: 24) {
|
LazyVGrid(columns: columns, spacing: 24) {
|
||||||
ForEach(gameState.players) { player in
|
ForEach(gameState.players) { player in
|
||||||
PlayerCell(
|
PlayerCell(
|
||||||
@@ -87,13 +87,12 @@ struct GameView: View {
|
|||||||
isWinner: gameState.winner?.id == player.id,
|
isWinner: gameState.winner?.id == player.id,
|
||||||
onUpdate: updatePlayer,
|
onUpdate: updatePlayer,
|
||||||
onCommanderTap: { selectedPlayerForCommander = player },
|
onCommanderTap: { selectedPlayerForCommander = player },
|
||||||
onScoop: { scoopPlayer(player) }
|
onScoop: { scoopPlayer(player) },
|
||||||
|
onDragStart: {
|
||||||
|
self.draggedPlayer = player
|
||||||
|
}
|
||||||
)
|
)
|
||||||
.frame(height: 260)
|
.frame(height: 260)
|
||||||
.onDrag {
|
|
||||||
self.draggedPlayer = player
|
|
||||||
return NSItemProvider(object: String(player.id) as NSString)
|
|
||||||
}
|
|
||||||
.onDrop(of: [.text], delegate: PlayerDropDelegate(item: player, items: $gameState.players, draggedItem: $draggedPlayer))
|
.onDrop(of: [.text], delegate: PlayerDropDelegate(item: player, items: $gameState.players, draggedItem: $draggedPlayer))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -109,7 +108,7 @@ struct GameView: View {
|
|||||||
Image(systemName: "xmark")
|
Image(systemName: "xmark")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ToolbarItem(placement: .topBarTrailing) {
|
ToolbarItem(placement: .topBarTrailing) {
|
||||||
if !gameState.stopped && gameState.winner == nil {
|
if !gameState.stopped && gameState.winner == nil {
|
||||||
Button(action: { showingStopConfirmation = true }) {
|
Button(action: { showingStopConfirmation = true }) {
|
||||||
@@ -151,7 +150,7 @@ struct GameView: View {
|
|||||||
gameManager.updateActiveGame(state: newState)
|
gameManager.updateActiveGame(state: newState)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func updateElapsedTime() {
|
private func updateElapsedTime() {
|
||||||
if !gameState.stopped && gameState.winner == nil {
|
if !gameState.stopped && gameState.winner == nil {
|
||||||
elapsedTime = Date().timeIntervalSince(match.startedAt)
|
elapsedTime = Date().timeIntervalSince(match.startedAt)
|
||||||
@@ -159,7 +158,7 @@ struct GameView: View {
|
|||||||
elapsedTime = match.lastUpdated.timeIntervalSince(match.startedAt)
|
elapsedTime = match.lastUpdated.timeIntervalSince(match.startedAt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func timeString(from timeInterval: TimeInterval) -> String {
|
private func timeString(from timeInterval: TimeInterval) -> String {
|
||||||
let hours = Int(timeInterval) / 3600
|
let hours = Int(timeInterval) / 3600
|
||||||
let minutes = Int(timeInterval) / 60 % 60
|
let minutes = Int(timeInterval) / 60 % 60
|
||||||
@@ -170,23 +169,23 @@ struct GameView: View {
|
|||||||
return String(format: "%02i:%02i", minutes, seconds)
|
return String(format: "%02i:%02i", minutes, seconds)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func updatePlayer(player: PlayerState) {
|
private func updatePlayer(player: PlayerState) {
|
||||||
if gameState.stopped || gameState.winner != nil { return }
|
if gameState.stopped || gameState.winner != nil { return }
|
||||||
|
|
||||||
if let index = gameState.players.firstIndex(where: { $0.id == player.id }) {
|
if let index = gameState.players.firstIndex(where: { $0.id == player.id }) {
|
||||||
gameState.players[index] = player
|
gameState.players[index] = player
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the sheet state if this is the player being edited to ensure the view refreshes
|
// Update the sheet state if this is the player being edited to ensure the view refreshes
|
||||||
if selectedPlayerForCommander?.id == player.id {
|
if selectedPlayerForCommander?.id == player.id {
|
||||||
selectedPlayerForCommander = player
|
selectedPlayerForCommander = player
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func scoopPlayer(_ player: PlayerState) {
|
private func scoopPlayer(_ player: PlayerState) {
|
||||||
if gameState.stopped || gameState.winner != nil { return }
|
if gameState.stopped || gameState.winner != nil { return }
|
||||||
|
|
||||||
var newPlayer = player
|
var newPlayer = player
|
||||||
newPlayer.scooped = true
|
newPlayer.scooped = true
|
||||||
updatePlayer(player: newPlayer)
|
updatePlayer(player: newPlayer)
|
||||||
@@ -210,9 +209,10 @@ struct PlayerCell: View {
|
|||||||
let onUpdate: (PlayerState) -> Void
|
let onUpdate: (PlayerState) -> Void
|
||||||
let onCommanderTap: () -> Void
|
let onCommanderTap: () -> Void
|
||||||
let onScoop: () -> Void
|
let onScoop: () -> Void
|
||||||
|
var onDragStart: (() -> Void)? = nil
|
||||||
|
|
||||||
@State private var showScoopConfirmation = false
|
@State private var showScoopConfirmation = false
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
ZStack {
|
ZStack {
|
||||||
RoundedRectangle(cornerRadius: 24)
|
RoundedRectangle(cornerRadius: 24)
|
||||||
@@ -222,35 +222,42 @@ struct PlayerCell: View {
|
|||||||
RoundedRectangle(cornerRadius: 24)
|
RoundedRectangle(cornerRadius: 24)
|
||||||
.stroke(isWinner ? Color.green : Color.clear, lineWidth: 3)
|
.stroke(isWinner ? Color.green : Color.clear, lineWidth: 3)
|
||||||
)
|
)
|
||||||
|
|
||||||
VStack(spacing: 12) {
|
VStack(spacing: 12) {
|
||||||
// Header
|
// Header - drag handle area
|
||||||
HStack {
|
HStack {
|
||||||
Text(player.name)
|
Text(player.name)
|
||||||
.font(.headline)
|
.font(.system(size: 22, weight: .semibold, design: .rounded))
|
||||||
.lineLimit(1)
|
.lineLimit(1)
|
||||||
.minimumScaleFactor(0.8)
|
.minimumScaleFactor(0.7)
|
||||||
.foregroundStyle(.primary)
|
.foregroundStyle(.primary)
|
||||||
|
.onDrag {
|
||||||
|
onDragStart?()
|
||||||
|
return NSItemProvider(object: String(player.id) as NSString)
|
||||||
|
}
|
||||||
|
|
||||||
Spacer()
|
Spacer()
|
||||||
|
|
||||||
Button(action: { showScoopConfirmation = true }) {
|
Button(action: { showScoopConfirmation = true }) {
|
||||||
Image(systemName: "flag.fill")
|
Image(systemName: "flag.fill")
|
||||||
|
.font(.system(size: 18))
|
||||||
.foregroundStyle(.secondary)
|
.foregroundStyle(.secondary)
|
||||||
.padding(4)
|
.padding(8)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.padding(.horizontal)
|
.padding(.horizontal)
|
||||||
.padding(.top, 12)
|
.padding(.top, 12)
|
||||||
|
|
||||||
// Life
|
// Life
|
||||||
LifeCounterControl(
|
LifeCounterControl(
|
||||||
value: player.life,
|
value: player.life,
|
||||||
onDecrease: { adjustLife(by: -1) },
|
onDecrease: { adjustLife(by: -1) },
|
||||||
onIncrease: { adjustLife(by: 1) }
|
onIncrease: { adjustLife(by: 1) },
|
||||||
|
onCustomDelta: { adjustLife(by: $0) }
|
||||||
)
|
)
|
||||||
|
|
||||||
Spacer()
|
Spacer()
|
||||||
|
|
||||||
// Counters Row
|
// Counters Row
|
||||||
HStack(spacing: 12) {
|
HStack(spacing: 12) {
|
||||||
if gameState.trackPoison {
|
if gameState.trackPoison {
|
||||||
@@ -259,10 +266,11 @@ struct PlayerCell: View {
|
|||||||
icon: "drop.fill",
|
icon: "drop.fill",
|
||||||
color: .purple,
|
color: .purple,
|
||||||
onDecrease: { adjustPoison(by: -1) },
|
onDecrease: { adjustPoison(by: -1) },
|
||||||
onIncrease: { adjustPoison(by: 1) }
|
onIncrease: { adjustPoison(by: 1) },
|
||||||
|
onCustomDelta: { adjustPoison(by: $0) }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if gameState.trackCommanderDamage {
|
if gameState.trackCommanderDamage {
|
||||||
Button(action: onCommanderTap) {
|
Button(action: onCommanderTap) {
|
||||||
VStack(spacing: 2) {
|
VStack(spacing: 2) {
|
||||||
@@ -280,7 +288,7 @@ struct PlayerCell: View {
|
|||||||
}
|
}
|
||||||
.padding(.bottom, 16)
|
.padding(.bottom, 16)
|
||||||
}
|
}
|
||||||
|
|
||||||
if player.isEliminated && !isWinner {
|
if player.isEliminated && !isWinner {
|
||||||
ZStack {
|
ZStack {
|
||||||
Color.black.opacity(0.6)
|
Color.black.opacity(0.6)
|
||||||
@@ -304,32 +312,129 @@ struct PlayerCell: View {
|
|||||||
Text("Are you sure you want to scoop?")
|
Text("Are you sure you want to scoop?")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func adjustLife(by amount: Int) {
|
private func adjustLife(by amount: Int) {
|
||||||
if player.isEliminated { return }
|
if player.isEliminated { return }
|
||||||
Haptics.play(.light)
|
Haptics.play(.light)
|
||||||
var newPlayer = player
|
var newPlayer = player
|
||||||
newPlayer.life += amount
|
newPlayer.life += amount
|
||||||
onUpdate(newPlayer)
|
onUpdate(newPlayer)
|
||||||
|
|
||||||
if newPlayer.isEliminated && !player.isEliminated {
|
if newPlayer.isEliminated && !player.isEliminated {
|
||||||
Haptics.notification(.error)
|
Haptics.notification(.error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func adjustPoison(by amount: Int) {
|
private func adjustPoison(by amount: Int) {
|
||||||
if player.isEliminated { return }
|
if player.isEliminated { return }
|
||||||
Haptics.play(.light)
|
Haptics.play(.light)
|
||||||
var newPlayer = player
|
var newPlayer = player
|
||||||
newPlayer.poison = max(0, newPlayer.poison + amount)
|
newPlayer.poison = max(0, newPlayer.poison + amount)
|
||||||
onUpdate(newPlayer)
|
onUpdate(newPlayer)
|
||||||
|
|
||||||
if newPlayer.isEliminated && !player.isEliminated {
|
if newPlayer.isEliminated && !player.isEliminated {
|
||||||
Haptics.notification(.error)
|
Haptics.notification(.error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A row for managing commander damage from a single attacker.
|
||||||
|
* Shows delta indicators and supports long-press for custom delta input.
|
||||||
|
*/
|
||||||
|
struct CommanderDamageRow: View {
|
||||||
|
let attackerName: String
|
||||||
|
let attackerId: Int
|
||||||
|
let currentDamage: Int
|
||||||
|
let onAdjust: (Int) -> Void
|
||||||
|
|
||||||
|
@StateObject private var deltaTracker = DeltaTracker()
|
||||||
|
@State private var showingCustomDeltaAlert = false
|
||||||
|
@State private var customDeltaText = ""
|
||||||
|
@State private var isIncreasing = true
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
HStack {
|
||||||
|
Text(attackerName)
|
||||||
|
.font(.headline)
|
||||||
|
Spacer()
|
||||||
|
HStack(spacing: 16) {
|
||||||
|
ZStack {
|
||||||
|
CircleButton(
|
||||||
|
icon: "minus",
|
||||||
|
color: .secondary,
|
||||||
|
action: {
|
||||||
|
onAdjust(-1)
|
||||||
|
withAnimation(.easeOut(duration: 0.15)) {
|
||||||
|
deltaTracker.addDelta(-1)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onLongPress: {
|
||||||
|
isIncreasing = false
|
||||||
|
customDeltaText = ""
|
||||||
|
showingCustomDeltaAlert = true
|
||||||
|
Haptics.play(.medium)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.buttonStyle(.borderless)
|
||||||
|
|
||||||
|
if deltaTracker.delta < 0 {
|
||||||
|
DeltaIndicator(delta: deltaTracker.delta, alignment: .trailing)
|
||||||
|
.offset(y: -30)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Text("\(currentDamage)")
|
||||||
|
.font(.title.bold())
|
||||||
|
.frame(minWidth: 40)
|
||||||
|
.multilineTextAlignment(.center)
|
||||||
|
|
||||||
|
ZStack {
|
||||||
|
CircleButton(
|
||||||
|
icon: "plus",
|
||||||
|
color: .primary,
|
||||||
|
action: {
|
||||||
|
onAdjust(1)
|
||||||
|
withAnimation(.easeOut(duration: 0.15)) {
|
||||||
|
deltaTracker.addDelta(1)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onLongPress: {
|
||||||
|
isIncreasing = true
|
||||||
|
customDeltaText = ""
|
||||||
|
showingCustomDeltaAlert = true
|
||||||
|
Haptics.play(.medium)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.buttonStyle(.borderless)
|
||||||
|
|
||||||
|
if deltaTracker.delta > 0 {
|
||||||
|
DeltaIndicator(delta: deltaTracker.delta, alignment: .leading)
|
||||||
|
.offset(y: -30)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.padding(.vertical, 8)
|
||||||
|
.alert("Enter Amount", isPresented: $showingCustomDeltaAlert) {
|
||||||
|
TextField("Amount", text: $customDeltaText)
|
||||||
|
.keyboardType(.numberPad)
|
||||||
|
Button("Cancel", role: .cancel) { }
|
||||||
|
Button(isIncreasing ? "Add" : "Subtract") {
|
||||||
|
if let amount = Int(customDeltaText), amount > 0 {
|
||||||
|
let delta = isIncreasing ? amount : -amount
|
||||||
|
onAdjust(delta)
|
||||||
|
withAnimation(.easeOut(duration: 0.15)) {
|
||||||
|
deltaTracker.addDelta(delta)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} message: {
|
||||||
|
Text(isIncreasing ? "Enter the amount to add" : "Enter the amount to subtract")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sheet for managing commander damage received by a player.
|
* Sheet for managing commander damage received by a player.
|
||||||
*
|
*
|
||||||
@@ -342,43 +447,25 @@ struct CommanderDamageView: View {
|
|||||||
let targetPlayer: PlayerState
|
let targetPlayer: PlayerState
|
||||||
let gameState: GameState
|
let gameState: GameState
|
||||||
let onUpdate: (PlayerState) -> Void
|
let onUpdate: (PlayerState) -> Void
|
||||||
|
|
||||||
init(targetPlayer: PlayerState, gameState: GameState, onUpdate: @escaping (PlayerState) -> Void) {
|
init(targetPlayer: PlayerState, gameState: GameState, onUpdate: @escaping (PlayerState) -> Void) {
|
||||||
self.targetPlayer = targetPlayer
|
self.targetPlayer = targetPlayer
|
||||||
self.gameState = gameState
|
self.gameState = gameState
|
||||||
self.onUpdate = onUpdate
|
self.onUpdate = onUpdate
|
||||||
}
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
NavigationStack {
|
NavigationStack {
|
||||||
List {
|
List {
|
||||||
ForEach(gameState.players.filter { $0.id != targetPlayer.id }) { attacker in
|
ForEach(gameState.players.filter { $0.id != targetPlayer.id }) { attacker in
|
||||||
HStack {
|
CommanderDamageRow(
|
||||||
Text(attacker.name)
|
attackerName: attacker.name,
|
||||||
.font(.headline)
|
attackerId: attacker.id,
|
||||||
Spacer()
|
currentDamage: targetPlayer.commanderDamages[attacker.id] ?? 0,
|
||||||
HStack(spacing: 16) {
|
onAdjust: { amount in
|
||||||
CircleButton(
|
adjustCommanderDamage(attackerId: attacker.id, by: amount)
|
||||||
icon: "minus",
|
|
||||||
color: .secondary,
|
|
||||||
action: { adjustCommanderDamage(attackerId: attacker.id, by: -1) }
|
|
||||||
)
|
|
||||||
.buttonStyle(.borderless)
|
|
||||||
|
|
||||||
Text("\(targetPlayer.commanderDamages[attacker.id] ?? 0)")
|
|
||||||
.font(.title.bold())
|
|
||||||
.frame(minWidth: 40)
|
|
||||||
.multilineTextAlignment(.center)
|
|
||||||
|
|
||||||
CircleButton(
|
|
||||||
icon: "plus",
|
|
||||||
color: .primary,
|
|
||||||
action: { adjustCommanderDamage(attackerId: attacker.id, by: 1) }
|
|
||||||
)
|
|
||||||
.buttonStyle(.borderless)
|
|
||||||
}
|
}
|
||||||
}
|
)
|
||||||
.padding(.vertical, 8)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.navigationTitle("Commander Damage to \(targetPlayer.name)")
|
.navigationTitle("Commander Damage to \(targetPlayer.name)")
|
||||||
@@ -390,30 +477,30 @@ struct CommanderDamageView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func adjustCommanderDamage(attackerId: Int, by amount: Int) {
|
private func adjustCommanderDamage(attackerId: Int, by amount: Int) {
|
||||||
Haptics.play(.light)
|
Haptics.play(.light)
|
||||||
let wasEliminated = targetPlayer.isEliminated
|
let wasEliminated = targetPlayer.isEliminated
|
||||||
|
|
||||||
// Get current damage value
|
// Get current damage value
|
||||||
let current = targetPlayer.commanderDamages[attackerId] ?? 0
|
let current = targetPlayer.commanderDamages[attackerId] ?? 0
|
||||||
let newDamage = max(0, current + amount)
|
let newDamage = max(0, current + amount)
|
||||||
|
|
||||||
// Only proceed if there's an actual change
|
// Only proceed if there's an actual change
|
||||||
guard newDamage != current else { return }
|
guard newDamage != current else { return }
|
||||||
|
|
||||||
// Update commander damages
|
// Update commander damages
|
||||||
var updatedPlayer = targetPlayer
|
var updatedPlayer = targetPlayer
|
||||||
var damages = updatedPlayer.commanderDamages
|
var damages = updatedPlayer.commanderDamages
|
||||||
damages[attackerId] = newDamage
|
damages[attackerId] = newDamage
|
||||||
updatedPlayer.commanderDamages = damages
|
updatedPlayer.commanderDamages = damages
|
||||||
|
|
||||||
// Adjust life total by the damage change
|
// Adjust life total by the damage change
|
||||||
updatedPlayer.life -= amount
|
updatedPlayer.life -= amount
|
||||||
|
|
||||||
// Notify parent to update
|
// Notify parent to update
|
||||||
onUpdate(updatedPlayer)
|
onUpdate(updatedPlayer)
|
||||||
|
|
||||||
if updatedPlayer.isEliminated && !wasEliminated {
|
if updatedPlayer.isEliminated && !wasEliminated {
|
||||||
Haptics.notification(.error)
|
Haptics.notification(.error)
|
||||||
}
|
}
|
||||||
@@ -441,8 +528,8 @@ struct PlayerDropDelegate: DropDelegate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func dropUpdated(info: DropInfo) -> DropProposal? {
|
func dropUpdated(info: DropInfo) -> DropProposal? {
|
||||||
return DropProposal(operation: .move)
|
return DropProposal(operation: .move)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
ios/MagicCounter/Logo.icon/Assets/MagicCounter.png
Normal file
|
After Width: | Height: | Size: 1.3 MiB |
BIN
ios/MagicCounter/Logo.icon/Assets/MagicCounter2.png
Normal file
|
After Width: | Height: | Size: 76 KiB |
BIN
ios/MagicCounter/Logo.icon/Assets/MagicCounter3.png
Normal file
|
After Width: | Height: | Size: 76 KiB |
BIN
ios/MagicCounter/Logo.icon/Assets/MagicCounter4.png
Normal file
|
After Width: | Height: | Size: 76 KiB |
BIN
ios/MagicCounter/Logo.icon/Assets/MagicCounter5.png
Normal file
|
After Width: | Height: | Size: 76 KiB |
BIN
ios/MagicCounter/Logo.icon/Assets/MagicCounter6.png
Normal file
|
After Width: | Height: | Size: 76 KiB |
|
Before Width: | Height: | Size: 1.1 MiB |
@@ -7,15 +7,63 @@
|
|||||||
{
|
{
|
||||||
"layers" : [
|
"layers" : [
|
||||||
{
|
{
|
||||||
"image-name" : "logo 2.png",
|
"image-name" : "MagicCounter4.png",
|
||||||
"name" : "logo",
|
"name" : "MagicCounter4",
|
||||||
"position" : {
|
"position" : {
|
||||||
"scale" : 0.85,
|
"scale" : 0.2,
|
||||||
|
"translation-in-points" : [
|
||||||
|
-280,
|
||||||
|
280
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"image-name" : "MagicCounter5.png",
|
||||||
|
"name" : "MagicCounter5",
|
||||||
|
"position" : {
|
||||||
|
"scale" : 0.2,
|
||||||
|
"translation-in-points" : [
|
||||||
|
280,
|
||||||
|
280
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"image-name" : "MagicCounter6.png",
|
||||||
|
"name" : "MagicCounter6",
|
||||||
|
"position" : {
|
||||||
|
"scale" : 0.2,
|
||||||
|
"translation-in-points" : [
|
||||||
|
-280,
|
||||||
|
-280
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"image-name" : "MagicCounter3.png",
|
||||||
|
"name" : "MagicCounter3",
|
||||||
|
"position" : {
|
||||||
|
"scale" : 0.2,
|
||||||
"translation-in-points" : [
|
"translation-in-points" : [
|
||||||
0,
|
0,
|
||||||
0
|
0
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"image-name" : "MagicCounter2.png",
|
||||||
|
"name" : "MagicCounter2",
|
||||||
|
"position" : {
|
||||||
|
"scale" : 0.2,
|
||||||
|
"translation-in-points" : [
|
||||||
|
280,
|
||||||
|
-280
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"image-name" : "MagicCounter.png",
|
||||||
|
"name" : "MagicCounter"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"shadow" : {
|
"shadow" : {
|
||||||
|
|||||||