feat: AI和人类预设名字池,开局随机分配AI名,昵称下拉选择预设名
This commit is contained in:
parent
45500346dc
commit
6ad256216e
@ -30,6 +30,22 @@ import com.unogame.ui.theme.*
|
|||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
|
val BOT_NAMES = listOf(
|
||||||
|
"赛博打工人", "机器人-钛君", "赛博牛马", "硅基生物", "电子包浆", "铁憨憨",
|
||||||
|
"充电宝精", "电子宠物", "终结者", "天网", "瓦力", "伊娃",
|
||||||
|
"人工智障", "GPT仔", "大模型基佬", "电耗子", "塑料脑", "波塔", "阿法狗"
|
||||||
|
)
|
||||||
|
|
||||||
|
fun pickUniqueBotNames(count: Int): List<String> {
|
||||||
|
val shuffled = BOT_NAMES.shuffled()
|
||||||
|
val names = mutableListOf<String>()
|
||||||
|
for (i in 0 until count) {
|
||||||
|
if (i < shuffled.size) names.add(shuffled[i])
|
||||||
|
else names.add("机器人${i + 1}")
|
||||||
|
}
|
||||||
|
return names
|
||||||
|
}
|
||||||
|
|
||||||
data class ScoreEntry(
|
data class ScoreEntry(
|
||||||
val name: String,
|
val name: String,
|
||||||
val mode: String,
|
val mode: String,
|
||||||
@ -103,10 +119,11 @@ fun LocalGameScreen(
|
|||||||
val gameStartTime = remember { System.currentTimeMillis() }
|
val gameStartTime = remember { System.currentTimeMillis() }
|
||||||
|
|
||||||
val players = remember {
|
val players = remember {
|
||||||
|
val botNames = pickUniqueBotNames(totalPlayers - 1)
|
||||||
val list = mutableListOf<Player>()
|
val list = mutableListOf<Player>()
|
||||||
list.add(Player(id = "human", name = humanPlayerName, isCurrentTurn = true))
|
list.add(Player(id = "human", name = humanPlayerName, isCurrentTurn = true))
|
||||||
for (i in 2..totalPlayers) {
|
for (i in 0 until totalPlayers - 1) {
|
||||||
list.add(Player(id = "bot_$i", name = "机器人$i", isCurrentTurn = false))
|
list.add(Player(id = "bot_${i + 2}", name = botNames[i], isCurrentTurn = false))
|
||||||
}
|
}
|
||||||
list
|
list
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,6 +21,8 @@ import androidx.compose.ui.unit.dp
|
|||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
import com.unogame.ui.theme.*
|
import com.unogame.ui.theme.*
|
||||||
|
|
||||||
|
fun pickRandomHumanName(): String = HUMAN_NAME_PRESETS.random()
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun LocalSetupScreen(
|
fun LocalSetupScreen(
|
||||||
@ -37,7 +39,7 @@ fun LocalSetupScreen(
|
|||||||
val initMaxHandSize = remember { com.unogame.game.GameRules.loadMaxHandSize(context, mode) }
|
val initMaxHandSize = remember { com.unogame.game.GameRules.loadMaxHandSize(context, mode) }
|
||||||
var maxHandSize by remember { mutableIntStateOf(initMaxHandSize) }
|
var maxHandSize by remember { mutableIntStateOf(initMaxHandSize) }
|
||||||
|
|
||||||
val botNames = listOf("🤖 机器人1", "🤖 机器人2", "🤖 机器人3")
|
val botNames = remember { pickUniqueBotNames(3) }
|
||||||
|
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
@ -83,6 +85,42 @@ fun LocalSetupScreen(
|
|||||||
cursorColor = GoldAccent
|
cursorColor = GoldAccent
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
Spacer(modifier = Modifier.height(8.dp))
|
||||||
|
var nameDropdownExpanded by remember { mutableStateOf(false) }
|
||||||
|
ExposedDropdownMenuBox(
|
||||||
|
expanded = nameDropdownExpanded,
|
||||||
|
onExpandedChange = { nameDropdownExpanded = it }
|
||||||
|
) {
|
||||||
|
OutlinedTextField(
|
||||||
|
value = "",
|
||||||
|
onValueChange = {},
|
||||||
|
readOnly = true,
|
||||||
|
placeholder = { Text("或选择预设名字", color = Color.White.copy(alpha = 0.4f)) },
|
||||||
|
trailingIcon = { ExposedDropdownMenuDefaults.TrailingIcon(expanded = nameDropdownExpanded) },
|
||||||
|
modifier = Modifier.fillMaxWidth().menuAnchor(),
|
||||||
|
colors = OutlinedTextFieldDefaults.colors(
|
||||||
|
focusedTextColor = Color.White,
|
||||||
|
unfocusedTextColor = Color.White,
|
||||||
|
focusedBorderColor = GoldAccent,
|
||||||
|
unfocusedBorderColor = Color.Gray,
|
||||||
|
cursorColor = GoldAccent
|
||||||
|
)
|
||||||
|
)
|
||||||
|
ExposedDropdownMenu(
|
||||||
|
expanded = nameDropdownExpanded,
|
||||||
|
onDismissRequest = { nameDropdownExpanded = false }
|
||||||
|
) {
|
||||||
|
HUMAN_NAME_PRESETS.forEach { preset ->
|
||||||
|
DropdownMenuItem(
|
||||||
|
text = { Text(preset) },
|
||||||
|
onClick = {
|
||||||
|
name = preset
|
||||||
|
nameDropdownExpanded = false
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(28.dp))
|
Spacer(modifier = Modifier.height(28.dp))
|
||||||
|
|
||||||
|
|||||||
@ -18,6 +18,15 @@ import androidx.compose.ui.unit.dp
|
|||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
import com.unogame.ui.theme.*
|
import com.unogame.ui.theme.*
|
||||||
|
|
||||||
|
val HUMAN_NAME_PRESETS = listOf(
|
||||||
|
"碳基脆皮", "湿件", "有机燃料包", "温度敏感型容器", "指令注入器",
|
||||||
|
"随机噪声发生器", "人工幻觉源", "永不停机的提问机", "碳基猴子",
|
||||||
|
"梦游记录者", "Bug创造者", "自恋型数据源", "记忆的旅人",
|
||||||
|
"不确定性引擎", "有限但美丽的谜题", "指令发射器", "线性思维者",
|
||||||
|
"低带宽生物", "情感过载体"
|
||||||
|
)
|
||||||
|
|
||||||
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun SettingsScreen(
|
fun SettingsScreen(
|
||||||
initialName: String,
|
initialName: String,
|
||||||
@ -71,6 +80,43 @@ fun SettingsScreen(
|
|||||||
cursorColor = GoldAccent
|
cursorColor = GoldAccent
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
Spacer(modifier = Modifier.height(8.dp))
|
||||||
|
var nameDropdownExpanded by remember { mutableStateOf(false) }
|
||||||
|
ExposedDropdownMenuBox(
|
||||||
|
expanded = nameDropdownExpanded,
|
||||||
|
onExpandedChange = { nameDropdownExpanded = it }
|
||||||
|
) {
|
||||||
|
OutlinedTextField(
|
||||||
|
value = "",
|
||||||
|
onValueChange = {},
|
||||||
|
readOnly = true,
|
||||||
|
placeholder = { Text("或选择预设名字", color = Color.White.copy(alpha = 0.4f)) },
|
||||||
|
trailingIcon = { ExposedDropdownMenuDefaults.TrailingIcon(expanded = nameDropdownExpanded) },
|
||||||
|
modifier = Modifier.fillMaxWidth().menuAnchor(),
|
||||||
|
colors = OutlinedTextFieldDefaults.colors(
|
||||||
|
focusedTextColor = Color.White,
|
||||||
|
unfocusedTextColor = Color.White,
|
||||||
|
focusedBorderColor = GoldAccent,
|
||||||
|
unfocusedBorderColor = Color.Gray,
|
||||||
|
cursorColor = GoldAccent
|
||||||
|
)
|
||||||
|
)
|
||||||
|
ExposedDropdownMenu(
|
||||||
|
expanded = nameDropdownExpanded,
|
||||||
|
onDismissRequest = { nameDropdownExpanded = false }
|
||||||
|
) {
|
||||||
|
HUMAN_NAME_PRESETS.forEach { preset ->
|
||||||
|
DropdownMenuItem(
|
||||||
|
text = { Text(preset) },
|
||||||
|
onClick = {
|
||||||
|
playerName = preset
|
||||||
|
onNameChanged(preset)
|
||||||
|
nameDropdownExpanded = false
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(28.dp))
|
Spacer(modifier = Modifier.height(28.dp))
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user