mirror of
https://gitlab.com/cable-mc/cobblemon.git
synced 2026-11-25 09:38:53 -05:00
Prototype of wifi battles
This commit is contained in:
1 parent
c11f2b15d9
commit
aebe2bb2d9
11 files changed
+187
-54
No files matched your search
@@ -15,10 +15,7 @@ import com.cobblemon.mod.common.Cobblemon
|
||||
import com.cobblemon.mod.common.Cobblemon.LOGGER
|
||||
import com.cobblemon.mod.common.CobblemonNetwork
|
||||
import com.cobblemon.mod.common.api.battles.interpreter.BattleMessage
|
||||
import com.cobblemon.mod.common.api.battles.model.actor.ActorType
|
||||
import com.cobblemon.mod.common.api.battles.model.actor.BattleActor
|
||||
import com.cobblemon.mod.common.api.battles.model.actor.EntityBackedBattleActor
|
||||
import com.cobblemon.mod.common.api.battles.model.actor.FleeableBattleActor
|
||||
import com.cobblemon.mod.common.api.battles.model.actor.*
|
||||
import com.cobblemon.mod.common.api.events.CobblemonEvents
|
||||
import com.cobblemon.mod.common.api.events.battles.BattleFledEvent
|
||||
import com.cobblemon.mod.common.api.molang.MoLangFunctions.asMoLangValue
|
||||
@@ -75,7 +72,8 @@ open class PokemonBattle(
|
||||
val format: BattleFormat,
|
||||
val side1: BattleSide,
|
||||
val side2: BattleSide,
|
||||
val service: ShowdownService
|
||||
val service: ShowdownService = ShowdownService.get(),
|
||||
val battleId: UUID = UUID.randomUUID()
|
||||
) {
|
||||
/** Whether logging will be silenced for this battle. */
|
||||
var mute = true
|
||||
@@ -110,8 +108,6 @@ open class PokemonBattle(
|
||||
val players = playerUUIDs.mapNotNull { it.getPlayer() }
|
||||
val spectators = mutableSetOf<UUID>()
|
||||
|
||||
val battleId = UUID.randomUUID()
|
||||
|
||||
val showdownMessages = mutableListOf<String>()
|
||||
val battleLog = mutableListOf<String>()
|
||||
val chatLog = mutableListOf<Component>()
|
||||
@@ -502,6 +498,7 @@ open class PokemonBattle(
|
||||
}
|
||||
|
||||
fun checkForInputDispatch() {
|
||||
actors.filter { it is UnionBattleActor }.forEach { it.mustChoose = false }
|
||||
if (checkForfeit()) return // ignore actors that are still choosing, their choices don't matter anymore
|
||||
val readyToInput = (actors.any { !it.mustChoose && it.responses.isNotEmpty() } && actors.none { it.mustChoose })
|
||||
if (readyToInput && captureActions.isEmpty()) {
|
||||
|
||||
+4
-4
@@ -73,7 +73,7 @@ abstract class BattleActor(
|
||||
open fun isForPlayer(serverPlayerEntity: ServerPlayer) = serverPlayerEntity.uuid in getPlayerUUIDs()
|
||||
open fun isForPokemon(pokemonEntity: PokemonEntity) = activePokemon.any { it.battlePokemon?.effectedPokemon?.entity == pokemonEntity }
|
||||
|
||||
fun turn() {
|
||||
open fun turn() {
|
||||
val request = request ?: return
|
||||
responses.clear()
|
||||
if(activePokemon.any { it.isAlive() }) {
|
||||
@@ -90,7 +90,7 @@ abstract class BattleActor(
|
||||
}
|
||||
}
|
||||
|
||||
fun upkeep() {
|
||||
open fun upkeep() {
|
||||
val request = request ?: return
|
||||
val forceSwitchPokemon = request.forceSwitch.mapIndexedNotNull { index, b -> if (b) activePokemon[index] else null }
|
||||
if (forceSwitchPokemon.isEmpty()) {
|
||||
@@ -125,7 +125,7 @@ abstract class BattleActor(
|
||||
battle.checkForInputDispatch()
|
||||
}
|
||||
|
||||
fun writeShowdownResponse() {
|
||||
open fun writeShowdownResponse() {
|
||||
val showdownMessages = mutableListOf<String>()
|
||||
var index = 0
|
||||
request!!.iterate(activePokemon) { activeBattlePokemon, showdownMoveSet, forceSwitch ->
|
||||
@@ -159,4 +159,4 @@ abstract class BattleActor(
|
||||
|
||||
open fun win(otherWinners: List<BattleActor>, losers: List<BattleActor>) {}
|
||||
open fun lose(winners: List<BattleActor>, otherLosers: List<BattleActor>) {}
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package com.cobblemon.mod.common.api.battles.model.actor
|
||||
|
||||
import com.cobblemon.mod.common.battles.pokemon.BattlePokemon
|
||||
import com.cobblemon.mod.common.entity.npc.NPCBattleActor
|
||||
import com.cobblemon.mod.common.entity.npc.NPCEntity
|
||||
|
||||
class UnionBattleActor(npc: NPCEntity, pokemonList: List<BattlePokemon>) : NPCBattleActor(npc, pokemonList.toMutableList(), 1) {
|
||||
|
||||
override fun writeShowdownResponse() {}
|
||||
|
||||
override fun onChoiceRequested() {
|
||||
this.mustChoose = false
|
||||
}
|
||||
|
||||
override fun turn() {
|
||||
super.turn()
|
||||
this.mustChoose = false
|
||||
}
|
||||
|
||||
override fun upkeep() {
|
||||
super.upkeep()
|
||||
this.mustChoose = false
|
||||
}
|
||||
|
||||
}
|
||||
@@ -61,7 +61,8 @@ object BattleBuilder {
|
||||
cloneParties: Boolean = false,
|
||||
healFirst: Boolean = false,
|
||||
partyAccessor: (ServerPlayer) -> PartyStore = { it.party() },
|
||||
service: ShowdownService = ShowdownService.get()
|
||||
service: ShowdownService = ShowdownService.get(),
|
||||
battleId: UUID = UUID.randomUUID()
|
||||
): BattleStartResult {
|
||||
|
||||
val adjustLevel = battleFormat.adjustLevel
|
||||
@@ -119,7 +120,8 @@ object BattleBuilder {
|
||||
battleFormat = battleFormat,
|
||||
side1 = BattleSide(player1Actor),
|
||||
side2 = BattleSide(player2Actor),
|
||||
service = service
|
||||
service = service,
|
||||
battleId = battleId
|
||||
).ifSuccessful {
|
||||
it.battlePartyStores.addAll(battlePartyStores)
|
||||
}
|
||||
@@ -136,7 +138,8 @@ object BattleBuilder {
|
||||
cloneParties: Boolean = false,
|
||||
healFirst: Boolean = false,
|
||||
partyAccessor: (ServerPlayer) -> PartyStore = { it.party() },
|
||||
service: ShowdownService = ShowdownService.get()
|
||||
service: ShowdownService = ShowdownService.get(),
|
||||
battleId: UUID = UUID.randomUUID()
|
||||
): BattleStartResult {
|
||||
val adjustLevel = battleFormat.adjustLevel
|
||||
val teams = players.mapIndexed { index, it ->
|
||||
@@ -218,7 +221,8 @@ object BattleBuilder {
|
||||
battleFormat = battleFormat,
|
||||
side1 = BattleSide(playerActors[0], playerActors[1]),
|
||||
side2 = BattleSide(playerActors[2], playerActors[3]),
|
||||
service = service
|
||||
service = service,
|
||||
battleId = battleId
|
||||
).ifSuccessful {
|
||||
it.battlePartyStores.addAll(battlePartyStores)
|
||||
}
|
||||
@@ -251,7 +255,8 @@ object BattleBuilder {
|
||||
healFirst: Boolean = false,
|
||||
fleeDistance: Float = Cobblemon.config.defaultFleeDistance,
|
||||
party: PartyStore = player.party(),
|
||||
service: ShowdownService = ShowdownService.get()
|
||||
service: ShowdownService = ShowdownService.get(),
|
||||
battleId: UUID = UUID.randomUUID()
|
||||
): BattleStartResult {
|
||||
val playerTeam = party.toBattleTeam(clone = cloneParties, healPokemon = healFirst, leadingPokemon = leadingPokemon).sortedBy { it.health <= 0 }
|
||||
val playerActor = PlayerBattleActor(player.uuid, playerTeam)
|
||||
@@ -293,7 +298,8 @@ object BattleBuilder {
|
||||
battleFormat = battleFormat,
|
||||
side1 = BattleSide(playerActor),
|
||||
side2 = BattleSide(wildActor),
|
||||
service = service
|
||||
service = service,
|
||||
battleId = battleId
|
||||
).ifSuccessful {
|
||||
if (!cloneParties) {
|
||||
pokemonEntity.battleId = it.battleId
|
||||
@@ -324,7 +330,8 @@ object BattleBuilder {
|
||||
cloneParties: Boolean = false,
|
||||
healFirst: Boolean = false,
|
||||
party: PartyStore = player.party(),
|
||||
service: ShowdownService = ShowdownService.get()
|
||||
service: ShowdownService = ShowdownService.get(),
|
||||
battleId: UUID = UUID.randomUUID()
|
||||
): BattleStartResult {
|
||||
val playerTeam = party.toBattleTeam(clone = cloneParties, healPokemon = healFirst, leadingPokemon = leadingPokemon)
|
||||
val playerActor = PlayerBattleActor(player.uuid, playerTeam)
|
||||
@@ -372,7 +379,8 @@ object BattleBuilder {
|
||||
battleFormat = battleFormat,
|
||||
side1 = BattleSide(playerActor),
|
||||
side2 = BattleSide(npcActor),
|
||||
service = service
|
||||
service = service,
|
||||
battleId = battleId
|
||||
).ifSuccessful { battle ->
|
||||
npcEntity.entityData.update(NPCEntity.BATTLE_IDS) { it + battle.battleId }
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ object BattleRegistry {
|
||||
return team.joinToString("]")
|
||||
}
|
||||
|
||||
private fun startShowdown(battle: PokemonBattle) {
|
||||
private fun startShowdown(battle: PokemonBattle, sendMessages: Boolean = true) {
|
||||
|
||||
// Build request message
|
||||
val messages = mutableListOf<String>()
|
||||
@@ -176,7 +176,9 @@ object BattleRegistry {
|
||||
}
|
||||
|
||||
// Compiles the request and sends it off
|
||||
battle.service.startBattle(battle, messages.toTypedArray())
|
||||
if (sendMessages) {
|
||||
battle.service.startBattle(battle, messages.toTypedArray())
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -197,12 +199,14 @@ object BattleRegistry {
|
||||
side1: BattleSide,
|
||||
side2: BattleSide,
|
||||
canPreempt: Boolean = true,
|
||||
service: ShowdownService = ShowdownService.get()
|
||||
service: ShowdownService = ShowdownService.get(),
|
||||
battleId: UUID = UUID.randomUUID(),
|
||||
sendMessages: Boolean = true
|
||||
): BattleStartResult {
|
||||
val battle = PokemonBattle(battleFormat, side1, side2, service)
|
||||
val battle = PokemonBattle(battleFormat, side1, side2, service, battleId)
|
||||
val start: () -> Unit = {
|
||||
battleMap[battle.battleId] = battle
|
||||
startShowdown(battle)
|
||||
startShowdown(battle, sendMessages)
|
||||
}
|
||||
|
||||
if (!canPreempt) start().also { return SuccessfulBattleStart(battle) }
|
||||
|
||||
+109
-8
@@ -2,18 +2,22 @@ package com.cobblemon.mod.common.battles.runner.remote
|
||||
|
||||
import com.cobblemon.mod.common.Cobblemon
|
||||
import com.cobblemon.mod.common.api.battles.model.PokemonBattle
|
||||
import com.cobblemon.mod.common.api.battles.model.actor.UnionBattleActor
|
||||
import com.cobblemon.mod.common.api.npc.NPCClasses
|
||||
import com.cobblemon.mod.common.api.pokemon.PokemonSpecies
|
||||
import com.cobblemon.mod.common.battles.BagItems
|
||||
import com.cobblemon.mod.common.battles.BattleBuilder
|
||||
import com.cobblemon.mod.common.battles.ShowdownInterpreter
|
||||
import com.cobblemon.mod.common.api.storage.party.PartyStore
|
||||
import com.cobblemon.mod.common.battles.*
|
||||
import com.cobblemon.mod.common.battles.actor.PlayerBattleActor
|
||||
import com.cobblemon.mod.common.battles.pokemon.BattlePokemon
|
||||
import com.cobblemon.mod.common.battles.runner.ShowdownService
|
||||
import com.cobblemon.mod.common.battles.runner.ShowdownStatus
|
||||
import com.cobblemon.mod.common.entity.npc.NPCEntity
|
||||
import com.cobblemon.mod.common.pokemon.Pokemon
|
||||
import com.cobblemon.mod.common.util.HttpService
|
||||
import com.cobblemon.mod.common.util.cobblemonResource
|
||||
import com.cobblemon.mod.common.util.server
|
||||
import com.google.gson.JsonArray
|
||||
import com.google.gson.JsonParser
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import java.net.URI
|
||||
import java.net.http.HttpClient
|
||||
@@ -223,17 +227,114 @@ class UnionShowdownService(
|
||||
super.onOpen(webSocket)
|
||||
}
|
||||
|
||||
fun startBattle(instruction: String) {
|
||||
val arguments = instruction.replace("|start-battle|", "").split("|")
|
||||
if (arguments.size != 5) return
|
||||
val battleId = UUID.fromString(arguments[0])
|
||||
val playerIdA = UUID.fromString(arguments[1])
|
||||
val playerIdB = UUID.fromString(arguments[2])
|
||||
val teamA = JsonParser.parseString(arguments[3]).asJsonObject
|
||||
val teamB = JsonParser.parseString(arguments[4]).asJsonObject
|
||||
|
||||
val playerA = server()?.playerList?.getPlayer(playerIdA)
|
||||
val playerB = server()?.playerList?.getPlayer(playerIdB)
|
||||
|
||||
if (playerA == null && playerB == null) {
|
||||
Cobblemon.LOGGER.warn("Tried to start battle with no players present on server")
|
||||
return
|
||||
}
|
||||
|
||||
val registryAccess = server()?.registryAccess() ?: return
|
||||
|
||||
val playerAParty = PartyStore(UUID.randomUUID()).loadFromJSON(teamA, registryAccess)
|
||||
val playerBParty = PartyStore(UUID.randomUUID()).loadFromJSON(teamB, registryAccess)
|
||||
val playerATeam = toShowdownBattleTeam(playerAParty.toList()).onEach {
|
||||
it.effectedPokemon.level = 100
|
||||
it.effectedPokemon.heal()
|
||||
}
|
||||
val playerBTeam = toShowdownBattleTeam(playerBParty.toList()).onEach {
|
||||
it.effectedPokemon.level = 100
|
||||
it.effectedPokemon.heal()
|
||||
}
|
||||
|
||||
if (playerA != null && playerB != null) {
|
||||
val playerActorA = PlayerBattleActor(playerIdA, playerATeam)
|
||||
val playerActorB = PlayerBattleActor(playerIdB, playerBTeam)
|
||||
BattleRegistry.startBattle(
|
||||
battleId = battleId,
|
||||
battleFormat = BattleFormat.GEN_9_SINGLES,
|
||||
side1 = BattleSide(playerActorA),
|
||||
side2 = BattleSide(playerActorB),
|
||||
sendMessages = false,
|
||||
service = service
|
||||
)
|
||||
}
|
||||
else if (playerA != null && playerB == null) {
|
||||
val playerActorA = PlayerBattleActor(playerIdA, playerATeam)
|
||||
val npc = NPCEntity(playerA.level())
|
||||
npc.moveTo(playerA.x + 5, playerA.y, playerA.z, playerA.yRot, playerA.xRot)
|
||||
npc.npc = NPCClasses.getByIdentifier(cobblemonResource("ai_test"))!!
|
||||
npc.initialize(1)
|
||||
npc.uuid = playerIdB
|
||||
playerA.level().addFreshEntity(npc)
|
||||
val playerActorB = UnionBattleActor(npc, playerBTeam)
|
||||
BattleRegistry.startBattle(
|
||||
battleId = battleId,
|
||||
battleFormat = BattleFormat.GEN_9_SINGLES,
|
||||
side1 = BattleSide(playerActorA),
|
||||
side2 = BattleSide(playerActorB),
|
||||
sendMessages = false,
|
||||
service = service
|
||||
)
|
||||
}
|
||||
else {
|
||||
val npc = NPCEntity(playerB!!.level())
|
||||
npc.moveTo(playerB.x + 5, playerB.y, playerB.z, playerB.yRot, playerB.xRot)
|
||||
npc.npc = NPCClasses.getByIdentifier(cobblemonResource("ai_test"))!!
|
||||
npc.initialize(1)
|
||||
npc.uuid = playerIdA
|
||||
playerB.level().addFreshEntity(npc)
|
||||
val playerActorA = UnionBattleActor(npc, playerATeam)
|
||||
val playerActorB = PlayerBattleActor(playerIdB, playerBTeam)
|
||||
BattleRegistry.startBattle(
|
||||
battleId = battleId,
|
||||
battleFormat = BattleFormat.GEN_9_SINGLES,
|
||||
side1 = BattleSide(playerActorA),
|
||||
side2 = BattleSide(playerActorB),
|
||||
sendMessages = false,
|
||||
service = service
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun toShowdownBattleTeam(team: List<Pokemon>): List<BattlePokemon> {
|
||||
return team.map { pokemon ->
|
||||
BattlePokemon(
|
||||
originalPokemon = pokemon,
|
||||
effectedPokemon = pokemon.clone(newUUID = false),
|
||||
postBattleEntityOperation = { entity -> entity.discard() }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onText(webSocket: WebSocket, data: CharSequence, last: Boolean): CompletionStage<*>? {
|
||||
if (last) {
|
||||
builder.append(data)
|
||||
val message = builder.toString()
|
||||
service.addToShowdownLog(source = "Showdown", message = message)
|
||||
val battleIdRegex = Regex("^\\[([^]]+)]")
|
||||
val match = battleIdRegex.find(message) ?: return null
|
||||
|
||||
val battleId = match.groupValues[1]
|
||||
val instruction = message.replace("[$battleId]", "")
|
||||
ShowdownInterpreter.interpretMessage(UUID.fromString(battleId), instruction)
|
||||
if (data.startsWith("|start-battle|")) {
|
||||
startBattle(data.toString())
|
||||
}
|
||||
else {
|
||||
val battleIdRegex = Regex("^\\[([^]]+)]")
|
||||
val match = battleIdRegex.find(message) ?: return null
|
||||
|
||||
val battleId = match.groupValues[1]
|
||||
val instruction = message.replace("[$battleId]", "")
|
||||
ShowdownInterpreter.interpretMessage(UUID.fromString(battleId), instruction)
|
||||
}
|
||||
|
||||
builder.clear()
|
||||
}
|
||||
else {
|
||||
|
||||
+2
-2
@@ -79,10 +79,10 @@ class ShowdownDebugGUI : Screen(lang("ui.debug.showdown")), CobblemonRenderable
|
||||
)
|
||||
|
||||
val startNPCBattleButton = addRenderableWidget(
|
||||
Button.builder(Component.literal("Create NPC Battle")) { button ->
|
||||
Button.builder(Component.literal("Queue")) { button ->
|
||||
CobblemonNetwork.sendToServer(ShowdownActionPacket(
|
||||
service = activeShowdownService,
|
||||
action = ShowdownActionPacket.Action.START_NPC_BATTLE
|
||||
action = ShowdownActionPacket.Action.QUEUE
|
||||
))
|
||||
}.bounds(10, 70, 100, 20).build()
|
||||
)
|
||||
|
||||
@@ -23,7 +23,7 @@ import com.cobblemon.mod.common.util.effectiveName
|
||||
import com.cobblemon.mod.common.util.update
|
||||
import java.util.concurrent.CompletableFuture
|
||||
|
||||
class NPCBattleActor(
|
||||
open class NPCBattleActor(
|
||||
val npc: NPCEntity,
|
||||
pokemonList: List<BattlePokemon>,
|
||||
val skill: Int
|
||||
@@ -84,4 +84,4 @@ class NPCBattleActor(
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -44,6 +44,6 @@ class ShowdownActionPacket(val service: ResourceLocation, val action: Action) :
|
||||
* Enum representing possible actions for the Showdown service.
|
||||
*/
|
||||
enum class Action {
|
||||
START, STOP, RESTART, START_NPC_BATTLE
|
||||
START, STOP, RESTART, QUEUE
|
||||
}
|
||||
}
|
||||
+13
-15
@@ -2,12 +2,12 @@ package com.cobblemon.mod.common.net.serverhandling.debug.showdown
|
||||
|
||||
import com.cobblemon.mod.common.Cobblemon
|
||||
import com.cobblemon.mod.common.api.net.ServerNetworkPacketHandler
|
||||
import com.cobblemon.mod.common.api.npc.NPCClasses
|
||||
import com.cobblemon.mod.common.battles.BattleBuilder
|
||||
import com.cobblemon.mod.common.battles.BattleRegistry.packTeam
|
||||
import com.cobblemon.mod.common.battles.pokemon.BattlePokemon
|
||||
import com.cobblemon.mod.common.battles.runner.ShowdownService
|
||||
import com.cobblemon.mod.common.entity.npc.NPCEntity
|
||||
import com.cobblemon.mod.common.net.messages.server.debug.showdown.ShowdownActionPacket
|
||||
import com.cobblemon.mod.common.util.cobblemonResource
|
||||
import com.cobblemon.mod.common.util.party
|
||||
import com.google.gson.JsonObject
|
||||
import net.minecraft.server.MinecraftServer
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
|
||||
@@ -37,17 +37,15 @@ object ShowdownActionHandler : ServerNetworkPacketHandler<ShowdownActionPacket>
|
||||
ShowdownActionPacket.Action.START -> service.openConnection()
|
||||
ShowdownActionPacket.Action.STOP -> service.closeConnection()
|
||||
ShowdownActionPacket.Action.RESTART -> service.restartConnection()
|
||||
ShowdownActionPacket.Action.START_NPC_BATTLE -> {
|
||||
val npc = NPCEntity(player.level())
|
||||
npc.moveTo(player.x + 5, player.y, player.z, player.yRot, player.xRot)
|
||||
npc.npc = NPCClasses.getByIdentifier(cobblemonResource("ai_test"))!!
|
||||
npc.initialize(1)
|
||||
player.level().addFreshEntity(npc)
|
||||
BattleBuilder.pvn(
|
||||
player = player,
|
||||
npcEntity = npc,
|
||||
service = service
|
||||
)
|
||||
ShowdownActionPacket.Action.QUEUE -> {
|
||||
val cobblemonTeam = player.party().saveToJSON(JsonObject(), player.registryAccess())
|
||||
val showdownTeam = player.party().map { BattlePokemon(it, it.clone(false)) { entity -> entity.discard() } }
|
||||
showdownTeam.forEach {
|
||||
it.effectedPokemon.level = 100
|
||||
it.effectedPokemon.heal()
|
||||
}
|
||||
val showdownTeamStr = showdownTeam.packTeam()
|
||||
service.send(">queue-battle ${player.uuid} $cobblemonTeam@|@$showdownTeamStr")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,9 +16,9 @@ val bundle: Configuration by configurations.creating {
|
||||
loom {
|
||||
val clientConfig = runConfigs.getByName("client")
|
||||
clientConfig.runDir = "runClient"
|
||||
clientConfig.programArg("--username=AshKetchum")
|
||||
// clientConfig.programArg("--username=GaryOak")
|
||||
//This is AshKetchum's UUID so you get an Ash Ketchum skin
|
||||
clientConfig.programArg("--uuid=93e4e551-589a-41cb-ab2d-435266c8e035")
|
||||
// clientConfig.programArg("--uuid=93e4e551-589a-41cb-ab2d-435266c8e035")
|
||||
val serverConfig = runConfigs.getByName("server")
|
||||
serverConfig.runDir = "runServer"
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user