package com.craigvg.lichun_android.utils /** * Canonical WebSocket command envelopes for client → server messages. */ object WebSocketCommands { private fun envelope(type: String, payload: Any?): Map { return mapOf("type" to type, "message" to payload) } fun init(userId: String): Map { return mapOf( "type" to "init", "userID" to userId ) } fun claimEvent(eventId: String, timestamp: String): Map { return envelope( "claimEvent", mapOf( "eventId" to eventId, "timestamp" to timestamp ) ) } fun eventResponse(eventId: String, choiceId: String): Map { return envelope( "eventResponse", mapOf( "eventId" to eventId, "choiceId" to choiceId ) ) } fun speed(speed: Int): Map { return envelope("speed", speed) } /** * Begin a new life (sent from the death screen). [mode] selects the legacy * path: "heir" continues the lineage (preserves familyPrestige/familyTree, * applies inheritance) or "fresh" does a clean reset clearing the * generational layer. Server falls back to "fresh" when no heir exists. */ fun startNewLife(mode: String): Map { return envelope("startNewLife", mapOf("mode" to mode)) } /** * In-life restart: resets the current character back to character creation * (server handler `restart`, type-only). Distinct from [startNewLife], which * is the death-screen legacy/heir path. Guarded behind a confirmation in the * UI since it ends the current life. */ fun restart(): Map { return mapOf("type" to "restart") } /** * Perform / schedule a player-initiated activity by stable id. The server * responds with activityPerformed/activityPlanned plus a playerObject. */ fun performActivity(activityId: String): Map { return envelope("performActivity", mapOf("activityId" to activityId)) } fun getAchievements(): Map { return mapOf("type" to "getAchievements") } fun acknowledgeAchievement(achievementId: String): Map { return envelope("acknowledgeAchievement", mapOf("achievementId" to achievementId)) } fun getDailyRewards(): Map { return mapOf("type" to "getDailyRewards") } fun claimDailyReward(day: Int): Map { return envelope("claimDailyReward", mapOf("day" to day)) } fun getDailyQuests(): Map { return mapOf("type" to "getDailyQuests") } fun claimQuestReward(questId: String): Map { return envelope("claimQuestReward", mapOf("questId" to questId)) } fun getEnergyRefillTiers(): Map { return mapOf("type" to "getEnergyRefillTiers") } fun purchaseEnergyRefill(refillType: String): Map { return envelope("purchaseEnergyRefill", mapOf("refillType" to refillType)) } fun getTimeSkipTiers(): Map { return mapOf("type" to "getTimeSkipTiers") } fun purchaseTimeSkip(skipType: String): Map { return envelope("purchaseTimeSkip", mapOf("skipType" to skipType)) } fun debugSetup(preset: String): Map { return envelope("debugSetup", mapOf("preset" to preset)) } fun debugGrant( money: Int? = null, energy: Int? = null, diamonds: Int? = null, mode: String = "add" ): Map { val payload = mutableMapOf("mode" to mode) money?.let { payload["money"] = it } energy?.let { payload["energy"] = it } diamonds?.let { payload["diamonds"] = it } return envelope("debugGrant", payload) } fun quitHabit(habitId: String): Map { return envelope( "quitHabit", mapOf( "habitId" to habitId, "habit" to habitId ) ) } fun stopQuitHabit(habitId: String): Map { return envelope( "stopQuitHabit", mapOf( "habitId" to habitId, "habit" to habitId ) ) } fun applyForJob(jobId: String): Map { return envelope("applyForJob", mapOf("jobId" to jobId)) } fun applyForExtracurricular(activityId: String): Map { return envelope("applyForExtracurricular", mapOf("activityId" to activityId)) } fun quitExtracurricular(activityId: String): Map { return envelope("quitExtracurricular", mapOf("activityId" to activityId)) } fun focusUpdate(activityId: String, newFocus: Int): Map { return envelope( "focusUpdate", mapOf( "activityId" to activityId, "newFocus" to newFocus ) ) } fun purchaseItem(itemId: String): Map { return envelope("purchaseItem", mapOf("itemId" to itemId)) } fun purchaseInAppItem(productId: String): Map { return envelope("purchaseInAppItem", mapOf("productId" to productId)) } fun purchaseInAppItem(productId: String, receiptData: String): Map { return envelope( "purchaseInAppItem", mapOf( "productId" to productId, "receiptData" to receiptData ) ) } fun partnerGift(partnerId: String): Map { return envelope("partnerGift", partnerId) } fun romance(partnerId: String): Map { return envelope("romance", mapOf("partnerId" to partnerId)) } fun dateNight(activityName: String): Map { return envelope("dateNight", mapOf("ideaName" to activityName)) } fun breakUp(partnerId: String): Map { return mapOf( "type" to "breakUp", "partnerId" to partnerId ) } fun divorce(partnerId: String): Map { return envelope("divorce", mapOf("partnerId" to partnerId)) } fun startDate(activityId: String, partnerId: String): Map { return envelope( "startDate", mapOf( "activityId" to activityId, "partnerId" to partnerId ) ) } fun relationshipEventResponse(eventId: String, choiceId: String): Map { return mapOf( "type" to "relationshipEventResponse", "eventId" to eventId, "choiceId" to choiceId ) } fun dateMiniGameResponse(gameId: String, round: Int, responseId: String): Map { return envelope( "dateMiniGameResponse", mapOf( "gameId" to gameId, "round" to round, "responseId" to responseId ) ) } fun deleteAccount(confirmation: String): Map { return envelope("deleteAccount", mapOf("confirmation" to confirmation)) } fun exportData(userId: String): Map { return mapOf( "type" to "exportData", "userId" to userId ) } fun tutorialStepComplete(step: Int): Map { return envelope("tutorialStepComplete", mapOf("step" to step)) } fun tooltipSeen(tooltipId: String): Map { return envelope("tooltipSeen", mapOf("tooltipId" to tooltipId)) } fun retrievePerson(personId: String): Map { return envelope("retrievePerson", mapOf("personId" to personId)) } fun characterSetup(name: String, age: Int, sex: String): Map { return envelope( "characterSetup", mapOf( "name" to name, "age" to age, "sex" to sex ) ) } fun conversationResponse(characterId: String, response: String): Map { return envelope( "conversation", mapOf( "characterID" to characterId, "response" to response, "conversationEvent" to "response", "cType" to "chat" ) ) } fun conversationInit(characterId: String): Map { return envelope( "conversation", mapOf( "characterID" to characterId, "conversationEvent" to "init", "cType" to "chat" ) ) } fun swipeMatch(): Map { return envelope("swipeMatch", "") } fun getSwipeCharacter(): Map { return mapOf("type" to "getSwipeCharacter") } fun getExtraCurriculars(): Map { return mapOf("type" to "getExtraCurriculars") } fun getDateIdeas(): Map { return mapOf("type" to "getDateIdeas") } fun deviceToken(token: String): Map { return envelope("deviceToken", mapOf("token" to token)) } }