From 5be8ebde3a896fd0be7518bc823de4b4ad70657a Mon Sep 17 00:00:00 2001 From: max Date: Thu, 30 May 2024 19:18:05 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E5=AE=8C=E5=96=84=E6=B8=B8=E6=88=8F?= =?UTF-8?q?=E6=88=BF=E7=8A=B6=E6=80=81=E7=BB=B4=E6=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 2 - .../com/chwl/app/avroom/game/GameDelegate.kt | 6 +- .../chwl/app/avroom/game/SudMGPAPPState.java | 61 - .../chwl/app/avroom/game/SudMGPMGState.java | 125 -- .../app/support/PreloadResourceViewModel.kt | 5 + app/src/main/res/values/colors.xml | 1 + .../chwl/app/game/core/BaseGameActivity.kt | 101 + .../chwl/app/game/core/GameIMEngineAbility.kt | 3 + .../chwl/app/game/core/GameQueueAbility.kt | 12 + .../chwl/app/game/core/GameStateAbility.kt | 80 +- .../game/core/engine/GameEngineViewModel.kt | 164 +- .../chwl/app/game/core/engine/GameSudFSMMG.kt | 48 - .../app/game/core/engine/GameSudFSTAPP.kt | 37 - .../core/engine/model/GameStateResponse.kt | 25 - .../java/com/chwl/app/game/data/GameModel2.kt | 17 +- .../app/game/data/bean/GameInfoUiState.kt | 15 + .../com/chwl/app/game/ui/buy/GameBuyDialog.kt | 4 +- .../com/chwl/app/game/ui/game/GameActivity.kt | 115 +- .../chwl/app/game/ui/game/GameViewModel.kt | 42 + .../ui/game/widgets/queue/GameQueueWidget.kt | 55 +- .../chwl/app/game/ui/home/GameHomeAdapter.kt | 2 +- .../chwl/app/game/ui/home/GameHomeFragment.kt | 2 +- .../app/game/ui/home/GameHomeViewModel.kt | 2 +- .../module_game/res/layout/game_activity.xml | 9 +- app/src/module_game/res/values-ar/strings.xml | 3 + .../module_game/res/values-zh-rTW/strings.xml | 3 + app/src/module_game/res/values/strings.xml | 3 + core/build.gradle | 5 +- .../chwl/core/bean/game}/GameConfigBean.kt | 2 +- .../com/chwl/core/bean/game}/GameModeBean.kt | 2 +- .../com/chwl/core/bean/game}/GameRoomData.kt | 2 +- .../com/chwl/core/bean/game}/GameRoomInfo.kt | 2 +- .../chwl/core/bean/room/RoomMicUserInfo.kt | 2 +- .../im/custom/bean/CustomAttachParser.java | 13 + .../core/im/custom/bean/CustomAttachment.java | 10 + .../im/custom/bean/GameForcedEndAttachment.kt | 14 + .../custom/bean/GameMatchFailedAttachment.kt | 16 + .../custom/bean/GameQueueChangedAttachment.kt | 22 + .../core/sud/decorator/SudFSMMGCache.java | 231 ++ .../core/sud/decorator/SudFSMMGDecorator.java | 1126 ++++++++++ .../core/sud/decorator/SudFSMMGListener.java | 1154 ++++++++++ .../sud/decorator/SudFSTAPPDecorator.java | 415 ++++ .../chwl/core/sud/model/GameConfigModel.java | 351 ++++ .../core/sud}/model/GameViewInfoModel.java | 4 +- .../chwl/core/sud/state/MGStateResponse.java | 35 + .../chwl/core/sud/state/SudMGPAPPState.java | 1321 ++++++++++++ .../chwl/core/sud/state/SudMGPMGState.java | 1870 +++++++++++++++++ .../core/sud/utils/GameCommonStateUtils.java | 138 ++ .../sud/utils/ISudFSMStateHandleUtils.java | 25 + .../com/chwl/core/sud/utils/SudJsonUtils.java | 43 + .../chwl/library/utils/json/JsonUtils.java | 27 +- 51 files changed, 7346 insertions(+), 426 deletions(-) delete mode 100644 app/src/main/java/com/chwl/app/avroom/game/SudMGPAPPState.java delete mode 100644 app/src/main/java/com/chwl/app/avroom/game/SudMGPMGState.java delete mode 100644 app/src/module_game/java/com/chwl/app/game/core/engine/GameSudFSMMG.kt delete mode 100644 app/src/module_game/java/com/chwl/app/game/core/engine/GameSudFSTAPP.kt delete mode 100644 app/src/module_game/java/com/chwl/app/game/core/engine/model/GameStateResponse.kt create mode 100644 app/src/module_game/java/com/chwl/app/game/data/bean/GameInfoUiState.kt rename {app/src/module_game/java/com/chwl/app/game/data/bean => core/src/main/java/com/chwl/core/bean/game}/GameConfigBean.kt (86%) rename {app/src/module_game/java/com/chwl/app/game/data/bean => core/src/main/java/com/chwl/core/bean/game}/GameModeBean.kt (89%) rename {app/src/module_game/java/com/chwl/app/game/data/bean => core/src/main/java/com/chwl/core/bean/game}/GameRoomData.kt (92%) rename {app/src/module_game/java/com/chwl/app/game/data/bean => core/src/main/java/com/chwl/core/bean/game}/GameRoomInfo.kt (79%) create mode 100644 core/src/main/java/com/chwl/core/im/custom/bean/GameForcedEndAttachment.kt create mode 100644 core/src/main/java/com/chwl/core/im/custom/bean/GameMatchFailedAttachment.kt create mode 100644 core/src/main/java/com/chwl/core/im/custom/bean/GameQueueChangedAttachment.kt create mode 100644 core/src/model_sud_wrapper/java/com/chwl/core/sud/decorator/SudFSMMGCache.java create mode 100644 core/src/model_sud_wrapper/java/com/chwl/core/sud/decorator/SudFSMMGDecorator.java create mode 100644 core/src/model_sud_wrapper/java/com/chwl/core/sud/decorator/SudFSMMGListener.java create mode 100644 core/src/model_sud_wrapper/java/com/chwl/core/sud/decorator/SudFSTAPPDecorator.java create mode 100644 core/src/model_sud_wrapper/java/com/chwl/core/sud/model/GameConfigModel.java rename {app/src/module_game/java/com/chwl/app/game/core/engine => core/src/model_sud_wrapper/java/com/chwl/core/sud}/model/GameViewInfoModel.java (96%) create mode 100644 core/src/model_sud_wrapper/java/com/chwl/core/sud/state/MGStateResponse.java create mode 100644 core/src/model_sud_wrapper/java/com/chwl/core/sud/state/SudMGPAPPState.java create mode 100644 core/src/model_sud_wrapper/java/com/chwl/core/sud/state/SudMGPMGState.java create mode 100644 core/src/model_sud_wrapper/java/com/chwl/core/sud/utils/GameCommonStateUtils.java create mode 100644 core/src/model_sud_wrapper/java/com/chwl/core/sud/utils/ISudFSMStateHandleUtils.java create mode 100644 core/src/model_sud_wrapper/java/com/chwl/core/sud/utils/SudJsonUtils.java diff --git a/app/build.gradle b/app/build.gradle index 9565aa3d2..33a4c9582 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -274,8 +274,6 @@ dependencies { if (!isolationMode && file("../modules/module_google/build.gradle").exists()) { implementation project(':modules:module_google') } - - implementation 'tech.sud.mgp:SudMGP-static:1.3.3.1158' } channel { diff --git a/app/src/main/java/com/chwl/app/avroom/game/GameDelegate.kt b/app/src/main/java/com/chwl/app/avroom/game/GameDelegate.kt index 575a25a8a..cc37a4dca 100644 --- a/app/src/main/java/com/chwl/app/avroom/game/GameDelegate.kt +++ b/app/src/main/java/com/chwl/app/avroom/game/GameDelegate.kt @@ -18,6 +18,8 @@ import com.chwl.core.room.game.bean.GameCfg import com.chwl.core.room.game.GameModel import com.chwl.core.room.game.GameStatus import com.chwl.core.room.model.HomePartyModel +import com.chwl.core.sud.state.SudMGPAPPState +import com.chwl.core.sud.state.SudMGPMGState import com.chwl.core.user.UserModel import com.chwl.core.utils.LogUtils import com.chwl.core.utils.net.RxHelper @@ -386,7 +388,7 @@ class GameDelegate(val activity: Activity, val container: FrameLayout, var mgId: } } } - SudMGPMGState.APP_COMMON_SELF_CLICK_JOIN_BTN -> { + SudMGPMGState.MG_COMMON_SELF_CLICK_JOIN_BTN -> { try { val jsonObject = JSONObject(dataJson) @@ -397,7 +399,7 @@ class GameDelegate(val activity: Activity, val container: FrameLayout, var mgId: } } - SudMGPMGState.APP_COMMON_SELF_CLICK_START_BTN -> { + SudMGPMGState.MG_COMMON_SELF_CLICK_START_BTN -> { notifySelfPlayingState(true) } SudMGPMGState.MG_COMMON_GAME_STATE -> handleGameState(dataJson) diff --git a/app/src/main/java/com/chwl/app/avroom/game/SudMGPAPPState.java b/app/src/main/java/com/chwl/app/avroom/game/SudMGPAPPState.java deleted file mode 100644 index 667b34c45..000000000 --- a/app/src/main/java/com/chwl/app/avroom/game/SudMGPAPPState.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - Copyright © Sud.Tech - https://sud.tech - */ -package com.chwl.app.avroom.game; - -/** - * Time:2021/10/19 - * Description: APP to MG 的状态定义 - */ -public class SudMGPAPPState { - - // region 通用状态 - - /** - * 加入状态 - * 最低版本: v1.1.30.xx - */ - public static final String APP_COMMON_SELF_IN = "app_common_self_in"; - - /** - * 准备状态 - * 最低版本: v1.1.30.xx - */ - public static final String APP_COMMON_SELF_READY = "app_common_self_ready"; - - /** - * 游戏状态 - * 最低版本: v1.1.30.xx - */ - public static final String APP_COMMON_SELF_PLAYING = "app_common_self_playing"; - - /** - * 队长状态 - * 最低版本: v1.1.30.xx - */ - public static final String APP_COMMON_SELF_CAPTAIN = "app_common_self_captain"; - - /** - * 踢人 - * v1.1.30.xx - */ - public static final String APP_COMMON_SELF_KICK = "app_common_self_kick"; - - /** - * 结束游戏 - * v1.1.30.xx - */ - public static final String APP_COMMON_SELF_END = "app_common_self_end"; - - /** - * 麦克风状态 - */ - public static final String APP_COMMON_SELF_MICROPHONE = "app_common_self_microphone"; - - /** - * 文字命中状态 - */ - public static final String APP_COMMON_SELF_TEXT_HIT = "app_common_self_text_hit"; - -} diff --git a/app/src/main/java/com/chwl/app/avroom/game/SudMGPMGState.java b/app/src/main/java/com/chwl/app/avroom/game/SudMGPMGState.java deleted file mode 100644 index b4309738e..000000000 --- a/app/src/main/java/com/chwl/app/avroom/game/SudMGPMGState.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - Copyright © Sud.Tech - https://sud.tech - */ -package com.chwl.app.avroom.game; - -/** - * Time:2021/10/19 - * Description: MG to APP 的状态定义 - */ -public class SudMGPMGState { - - // region 通用状态-游戏 - - /** - * 公屏消息 (已修改) - * 最低版本: v1.1.30.xx - */ - public static final String MG_COMMON_PUBLIC_MESSAGE = "mg_common_public_message"; - - /** - * 关键词状态 - */ - public static final String MG_COMMON_KEY_WORD_TO_HIT = "mg_common_key_word_to_hit"; - - // endregion 通用状态-游戏 - - - // region 通用状态-玩家 - - /** - * 加入状态 (已修改) - * 最低版本: v1.1.30.xx - */ - public static final String MG_COMMON_PLAYER_IN = "mg_common_player_in"; - - /** - * 准备状态 (已修改) - * 最低版本: v1.1.30.xx - */ - public static final String MG_COMMON_PLAYER_READY = "mg_common_player_ready"; - - /** - * 队长状态 (已修改) - * 最低版本: v1.1.30.xx - */ - public static final String MG_COMMON_PLAYER_CAPTAIN = "mg_common_player_captain"; - - /** - * 游戏状态 (已修改) - * 最低版本: v1.1.30.xx - */ - public static final String MG_COMMON_PLAYER_PLAYING = "mg_common_player_playing"; - - /** - * 游戏状态(已修改) - * 最低版本: v1.1.30.xx - */ - public static final String MG_COMMON_GAME_STATE = "mg_common_game_state"; - - // endregion 通用状态-玩家 - - - // region 碰碰我最强 - // endregion 碰碰我最强 - - // region 飞刀达人 - // endregion 飞刀达人 - - // region 你画我猜 - - /** - * 选词中 - */ - public static final String MG_DG_SELECTING = "mg_dg_selecting"; - - /** - * 作画中 - */ - public static final String MG_DG_PAINTING = "mg_dg_painting"; - - /** - * 错误答案 - */ - public static final String MG_DG_ERRORANSWER = "mg_dg_erroranswer"; - - /** - * 总积分 - */ - public static final String MG_DG_TOTALSCORE = "mg_dg_totalscore"; - - /** - * 本次积分 - */ - public static final String MG_DG_SCORE = "mg_dg_score"; - - // endregion 你画我猜 - - - /** - * 加入游戏按钮点击状态 - */ - public static final String APP_COMMON_SELF_CLICK_JOIN_BTN = "mg_common_self_click_join_btn"; - /** - * 取消加入游戏按钮点击状态 - */ - public static final String APP_COMMON_SELF_CLICK_CANCEL_JOIN_BTN = "mg_common_self_click_cancel_join_btn"; - /** - * 准备按钮点击状态 - */ - public static final String APP_COMMON_SELF_CLICK_READY_BTN = "mg_common_self_click_ready_btn"; - /** - * 取消准备按钮点击状态 - */ - public static final String APP_COMMON_SELF_CLICK_CANCEL_READY_BTN = "mg_common_self_click_cancel_ready_btn"; - /** - * 开始游戏按钮点击状态 - */ - public static final String APP_COMMON_SELF_CLICK_START_BTN = "mg_common_self_click_start_btn"; - /** - * 分享按钮点击状态 - */ - public static final String APP_COMMON_SELF_CLICK_SHARE_BTN = "mg_common_self_click_share_btn"; - -} diff --git a/app/src/main/java/com/chwl/app/support/PreloadResourceViewModel.kt b/app/src/main/java/com/chwl/app/support/PreloadResourceViewModel.kt index 7a0eb49c5..fa0788039 100644 --- a/app/src/main/java/com/chwl/app/support/PreloadResourceViewModel.kt +++ b/app/src/main/java/com/chwl/app/support/PreloadResourceViewModel.kt @@ -1,6 +1,7 @@ package com.chwl.app.support import androidx.lifecycle.viewModelScope +import com.chwl.app.BuildConfig import com.chwl.app.base.BaseViewModel import com.chwl.core.helper.PathHelper import com.chwl.core.home.model.HomeModel @@ -27,6 +28,10 @@ class PreloadResourceViewModel : BaseViewModel(), DownloadListener, ILog { private var isStarted = false fun start() { + if (BuildConfig.DEBUG) { + // 太多请求了,影响查看控制台日志 + return + } if (isStarted) { return } diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 4a31c46e2..58484fc73 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -728,4 +728,5 @@ #10ECD6 #4D415E #DE3446 + #FF6629 diff --git a/app/src/module_game/java/com/chwl/app/game/core/BaseGameActivity.kt b/app/src/module_game/java/com/chwl/app/game/core/BaseGameActivity.kt index e2df49e6c..32796378c 100644 --- a/app/src/module_game/java/com/chwl/app/game/core/BaseGameActivity.kt +++ b/app/src/module_game/java/com/chwl/app/game/core/BaseGameActivity.kt @@ -1,18 +1,27 @@ package com.chwl.app.game.core import android.app.Activity +import android.view.View +import android.widget.FrameLayout import androidx.activity.viewModels import androidx.fragment.app.FragmentManager import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.LiveData +import androidx.lifecycle.lifecycleScope import androidx.viewbinding.ViewBinding +import com.chwl.app.R import com.chwl.app.base.BaseViewBindingActivity +import com.chwl.app.common.widget.dialog.DialogManager import com.chwl.app.game.core.engine.GameEngineViewModel +import com.chwl.app.game.data.bean.GameInfoUiState import com.chwl.app.game.ui.game.GameViewModel import com.chwl.core.support.room.RoomContext import com.chwl.core.support.room.RoomView import com.chwl.core.support.room.RoomWidget import com.netease.nim.uikit.StatusBarUtil +import kotlinx.coroutines.flow.collectLatest +import kotlinx.coroutines.flow.zip +import kotlinx.coroutines.launch abstract class BaseGameActivity : BaseViewBindingActivity(), RoomView { @@ -23,25 +32,110 @@ abstract class BaseGameActivity : BaseViewBindingActivity(), protected val stateAbility get() = gameContext?.findAbility(GameStateAbility::class.java.simpleName) + private var gameInfoDialogManager: DialogManager? = null + protected var loadingDialogManager: DialogManager? = null + override fun init() { initView() initEvent() initObserver() initWidgets() + gameEngineViewModel.init(lifecycle) } protected open fun initView() { + gameInfoDialogManager = DialogManager(this) + loadingDialogManager = DialogManager(this) } protected open fun initEvent() { } protected open fun initObserver() { + viewModel.gameContextLiveData.observe(this) { + onGameContext(it) + } + gameEngineViewModel.gameViewLiveData.observe(this) { + onGameViewChanged(it) + } } protected open fun initWidgets() { } + protected open fun onGameContext(gameContext: GameContext) { + gameEngineViewModel.setGameContext(gameContext) + stateAbility?.let { + observeGameInfoUiState(it) + updateGameEngine(it) + } + } + + private fun observeGameInfoUiState(stateAbility: GameStateAbility) { + lifecycleScope.launch { + stateAbility.gameInfoUiStateFlow.collectLatest { + when (it) { + is GameInfoUiState.Loading -> { + gameInfoDialogManager?.showProgressDialog(context) + } + + is GameInfoUiState.Success -> { + gameInfoDialogManager?.dismissDialog() + } + + is GameInfoUiState.Failed -> { + gameInfoDialogManager?.dismissDialog() + it.throwable.message?.let { msg -> + toast(msg) + } + } + + is GameInfoUiState.Empty -> { + gameInfoDialogManager?.dismissDialog() + toast(R.string.empty_data) + finish() + } + } + } + } + } + + private fun updateGameEngine(stateAbility: GameStateAbility) { + lifecycleScope.launch { + stateAbility.gameIdFlow.zip(stateAbility.roomIdFlow) { gameId, roomId -> + if (gameId?.toLongOrNull() != null && roomId != null) { + Pair(gameId.toLong(), roomId) + } else { + null + } + }.collectLatest { + if (it != null) { + gameEngineViewModel.loadGame( + this@BaseGameActivity, + it.second.toString(), + it.first + ) + } + } + } + } + + protected open fun onGameViewChanged(view: View?) { + if (view == null) { + getGameViewGroup().removeAllViews() + } else { + getGameViewGroup().addView( + view, + FrameLayout.LayoutParams( + FrameLayout.LayoutParams.MATCH_PARENT, + FrameLayout.LayoutParams.MATCH_PARENT + ) + ) + } + } + + abstract fun getGameViewGroup(): FrameLayout + /** * 注册组件 */ @@ -93,4 +187,11 @@ abstract class BaseGameActivity : BaseViewBindingActivity(), return widgets[name] } + override fun onDestroy() { + super.onDestroy() + gameInfoDialogManager?.dismissDialog() + gameInfoDialogManager = null + loadingDialogManager?.dismissDialog() + loadingDialogManager = null + } } \ No newline at end of file diff --git a/app/src/module_game/java/com/chwl/app/game/core/GameIMEngineAbility.kt b/app/src/module_game/java/com/chwl/app/game/core/GameIMEngineAbility.kt index b95d48bc7..892f02b05 100644 --- a/app/src/module_game/java/com/chwl/app/game/core/GameIMEngineAbility.kt +++ b/app/src/module_game/java/com/chwl/app/game/core/GameIMEngineAbility.kt @@ -11,6 +11,7 @@ import com.netease.nimlib.sdk.StatusCode import com.netease.nimlib.sdk.chatroom.ChatRoomMessageBuilder import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage import io.reactivex.Single +import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.collectLatest import java.lang.IllegalStateException @@ -22,6 +23,8 @@ class GameIMEngineAbility(private val listenerOwner: ListenerOwner>() + private val stateAbility: GameStateAbility? get() = roomContext?.findAbility( GameStateAbility::class.java.simpleName diff --git a/app/src/module_game/java/com/chwl/app/game/core/GameQueueAbility.kt b/app/src/module_game/java/com/chwl/app/game/core/GameQueueAbility.kt index 6caaa8d04..7d7d8c981 100644 --- a/app/src/module_game/java/com/chwl/app/game/core/GameQueueAbility.kt +++ b/app/src/module_game/java/com/chwl/app/game/core/GameQueueAbility.kt @@ -1,7 +1,19 @@ package com.chwl.app.game.core +import com.chwl.core.bean.room.RoomMicBean import com.chwl.core.support.room.RoomAbility +import com.chwl.core.support.room.RoomContext +import kotlinx.coroutines.flow.MutableStateFlow class GameQueueAbility : RoomAbility() { + val queueFlow = MutableStateFlow?>(null) + + override fun onStart(context: RoomContext) { + super.onStart(context) + } + + suspend fun updateQueue(data: List?) { + queueFlow.value = data + } } \ No newline at end of file diff --git a/app/src/module_game/java/com/chwl/app/game/core/GameStateAbility.kt b/app/src/module_game/java/com/chwl/app/game/core/GameStateAbility.kt index 8a9d565b3..d3778781d 100644 --- a/app/src/module_game/java/com/chwl/app/game/core/GameStateAbility.kt +++ b/app/src/module_game/java/com/chwl/app/game/core/GameStateAbility.kt @@ -1,12 +1,18 @@ package com.chwl.app.game.core import com.chwl.app.game.data.GameModel2 -import com.chwl.app.game.data.bean.GameRoomInfo +import com.chwl.app.game.data.bean.GameInfoUiState +import com.chwl.core.bean.game.GameRoomInfo +import com.chwl.core.im.custom.bean.CustomAttachment +import com.chwl.core.im.custom.bean.GameQueueChangedAttachment import com.chwl.core.support.room.RoomAbility import com.chwl.core.support.room.RoomContext +import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage +import com.netease.nimlib.sdk.msg.constant.MsgTypeEnum +import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow -class GameStateAbility : RoomAbility() { +class GameStateAbility : RoomAbility(), GameIMEngineAbility.Listener { /** * 游戏状态: 本地定义状态+匹配状态 @@ -25,32 +31,98 @@ class GameStateAbility : RoomAbility() { val scoresFlow = MutableStateFlow?>(null) + @Deprecated("里面的属性有可能不是最新的,建议通过具体属性flow获取数据") + val gameInfoFlow = MutableStateFlow(null) + + val gameInfoUiStateFlow = MutableStateFlow(GameInfoUiState.Loading) + + val matchFailedFlow = MutableSharedFlow() + + private val queueAbility get() = roomContext?.findAbility(GameQueueAbility::class.java.simpleName) + override fun onStart(context: RoomContext) { super.onStart(context) requestRoomInfo() + val imEngineAbility = + context.findAbility(GameIMEngineAbility::class.java.simpleName) + imEngineAbility?.addListener(this) } private fun requestRoomInfo() { - safeLaunch { + gameInfoUiStateFlow.value = GameInfoUiState.Loading + safeLaunch(onError = { + gameInfoUiStateFlow.value = GameInfoUiState.Failed(it, gameInfoFlow.value) + }) { val info = GameModel2.getGameRoomInfo() if (info != null) { + gameInfoUiStateFlow.value = GameInfoUiState.Success syncRoomInfo(info) } else { + gameInfoUiStateFlow.value = GameInfoUiState.Empty(gameInfoFlow.value) syncGameState(null) } } } - private fun syncRoomInfo(info: GameRoomInfo) { + private suspend fun syncRoomInfo(info: GameRoomInfo) { + roomContext?.roomId = info.chatRoomId ?: 0 + gameInfoFlow.value = info roomIdFlow.value = info.chatRoomId imIdFlow.value = info.roomId gameIdFlow.value = info.data?.mgId gameIconFlow.value = info.data?.gameRoomIcon scoresFlow.value = info.data?.scores syncGameState(info.data?.matchStatus) + syncQueue(info) } private fun syncGameState(matchStatus: Int?) { gameStateFlow.value = matchStatus } + + private suspend fun syncQueue(info: GameRoomInfo) { + queueAbility?.updateQueue(info.roomMics) + syncGameState(info.data?.matchStatus) + } + + override fun onReceiveMessage(messages: List) { + messages.forEach { + onReceiveMessage(it) + } + } + + private fun onReceiveMessage(message: ChatRoomMessage) { + if (message.msgType == MsgTypeEnum.custom) { + val attachment: CustomAttachment = (message.attachment as? CustomAttachment) ?: return + when (attachment.first) { + CustomAttachment.CUSTOM_MSG_MINI_GAME -> { + when (attachment.second) { + // 麦位变更 + CustomAttachment.CUSTOM_MSG_MINI_GAME_QUEUE_CHANGED -> { + val gameInfo = + (attachment as? GameQueueChangedAttachment)?.gameInfo ?: return + safeLaunch { + syncQueue(gameInfo) + } + } + + // 匹配失败 + CustomAttachment.CUSTOM_MSG_MINI_GAME_MATCH_FAILED -> { + safeLaunch { + gameStateFlow.value = 3 + matchFailedFlow.emit(true) + } + } + + // 提前结束 + CustomAttachment.CUSTOM_MSG_MINI_GAME_FORCED_END -> { + safeLaunch { + gameStateFlow.value = 2 + } + } + } + } + } + } + } } \ No newline at end of file diff --git a/app/src/module_game/java/com/chwl/app/game/core/engine/GameEngineViewModel.kt b/app/src/module_game/java/com/chwl/app/game/core/engine/GameEngineViewModel.kt index d8c2151fc..4e1199072 100644 --- a/app/src/module_game/java/com/chwl/app/game/core/engine/GameEngineViewModel.kt +++ b/app/src/module_game/java/com/chwl/app/game/core/engine/GameEngineViewModel.kt @@ -8,45 +8,60 @@ import android.widget.FrameLayout import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleEventObserver import androidx.lifecycle.LifecycleOwner +import androidx.lifecycle.MutableLiveData import com.chwl.app.R import com.chwl.app.avroom.game.AppConfig import com.chwl.app.base.BaseViewModel -import com.chwl.app.game.core.engine.model.GameStateResponse -import com.chwl.app.game.core.engine.model.GameViewInfoModel -import com.chwl.app.game.core.engine.model.GameViewInfoModel.GameViewRectModel +import com.chwl.app.game.core.GameContext +import com.chwl.app.game.core.GameQueueAbility +import com.chwl.app.game.core.GameStateAbility import com.chwl.core.auth.AuthModel import com.chwl.core.room.game.GameModel import com.chwl.core.room.game.bean.GameCfg +import com.chwl.core.sud.decorator.SudFSMMGDecorator +import com.chwl.core.sud.decorator.SudFSMMGListener +import com.chwl.core.sud.decorator.SudFSTAPPDecorator +import com.chwl.core.sud.model.GameViewInfoModel +import com.chwl.core.sud.state.MGStateResponse +import com.chwl.core.sud.state.SudMGPMGState import com.chwl.library.language.LanguageHelper import com.chwl.library.utils.SingleToastUtil import com.chwl.library.utils.json.JsonUtils import com.example.lib_utils.log.ILog +import kotlinx.coroutines.flow.MutableStateFlow import tech.sud.mgp.core.ISudFSMStateHandle import tech.sud.mgp.core.ISudListenerInitSDK import tech.sud.mgp.core.SudMGP import java.lang.IllegalStateException @SuppressLint("StaticFieldLeak") -open class GameEngineViewModel : BaseViewModel(), ILog, LifecycleEventObserver { +open class GameEngineViewModel : BaseViewModel(), SudFSMMGListener, ILog, + LifecycleEventObserver { + val gameViewLiveData = MutableLiveData(null) private var isRunning = true - - private val gameFSMMG = GameSudFSMMG(this) - - private val gameFSTAPP = GameSudFSTAPP(this) - + private val sudFSMMG = SudFSMMGDecorator().apply { + setSudFSMMGListener(this@GameEngineViewModel) + } + private val sudFSTAPP = SudFSTAPPDecorator() private var lifecycle: Lifecycle? = null - private var gameLayout: FrameLayout? = null - private var gameViewRect: GameViewRectModel = GameViewRectModel() + private var gameViewRect: GameViewInfoModel.GameViewRectModel = + GameViewInfoModel.GameViewRectModel() private var roomId: String = "" - fun init(lifecycle: Lifecycle, gameLayout: FrameLayout) { + private var gameContext: GameContext? = null + + fun init(lifecycle: Lifecycle) { this.lifecycle = lifecycle - this.gameLayout = gameLayout lifecycle.addObserver(this) } + fun setGameContext(gameContext: GameContext) { + this.gameContext = gameContext + } + fun loadGame(activity: Activity, roomId: String, gameId: Long) { + logD("loadGame() roomId:$roomId gameId:$gameId") if (!this.isRunning) { return } @@ -85,21 +100,14 @@ open class GameEngineViewModel : BaseViewModel(), ILog, LifecycleEventObserver { return } val userId = AuthModel.get().currentUid.toString() - gameFSTAPP.destroyMG() + sudFSTAPP.destroyMG() val iSudFSTAPP = - SudMGP.loadMG(activity, userId, getRoomId(), code, gameId, getGameLanguage(), gameFSMMG) - gameFSTAPP.updateSudFSTAPP(iSudFSTAPP) - updateGameView(iSudFSTAPP.gameView) + SudMGP.loadMG(activity, userId, getRoomId(), code, gameId, getGameLanguage(), sudFSMMG) + sudFSTAPP.setISudFSTAPP(iSudFSTAPP) + gameViewLiveData.value = iSudFSTAPP.gameView } - private fun updateGameView(view: View?) { - gameLayout?.removeAllViews() - if (view != null) { - gameLayout?.addView(view) - } - } - - fun setGameViewRect(rect: GameViewRectModel) { + fun setGameViewRect(rect: GameViewInfoModel.GameViewRectModel) { this.gameViewRect = rect } @@ -120,40 +128,6 @@ open class GameEngineViewModel : BaseViewModel(), ILog, LifecycleEventObserver { } } - fun onExpireCode(handle: ISudFSMStateHandle) { - getGameCode({ - handle.success(GameStateResponse.success().toJson()) - gameFSTAPP.updateCode(it, null) - }, { - logE(it) - }) - } - - fun onGetGameCfg(handle: ISudFSMStateHandle) { - handle.success(JsonUtils.toJson(GameCfg())) - } - - fun onGetGameViewInfo(handle: ISudFSMStateHandle) { - val gameLayout = gameLayout - if (gameLayout == null) { - handle.failure("gameLayout is NULL") - return - } - val gameViewWidth = gameLayout.measuredWidth - val gameViewHeight = gameLayout.measuredHeight - if (gameViewWidth > 0 && gameViewHeight > 0) { - notifyGameViewInfo(handle, gameViewWidth, gameViewHeight) - return - } - gameLayout.viewTreeObserver.addOnGlobalLayoutListener(object : - ViewTreeObserver.OnGlobalLayoutListener { - override fun onGlobalLayout() { - gameLayout.viewTreeObserver.removeOnGlobalLayoutListener(this) - notifyGameViewInfo(handle, gameLayout.measuredWidth, gameLayout.measuredHeight) - } - }) - } - private fun notifyGameViewInfo(handle: ISudFSMStateHandle, width: Int, height: Int) { val response = GameViewInfoModel() response.ret_code = 0 @@ -203,4 +177,76 @@ open class GameEngineViewModel : BaseViewModel(), ILog, LifecycleEventObserver { lifecycle?.removeObserver(this) lifecycle = null } + + override fun onGameStarted() { + autoJoinGame() + } + + override fun onGameDestroyed() { + } + + private fun autoJoinGame() { + sudFSTAPP.notifyAPPCommonSelfIn(true, -1, true, 1) + sudFSTAPP.notifyAPPCommonSelfReady(true) + } + + override fun onExpireCode(handle: ISudFSMStateHandle, p1: String?) { + getGameCode({ + handle.success(MGStateResponse.success().toJson()) + sudFSTAPP.updateCode(it, null) + }, { + logE(it) + }) + } + + override fun onGetGameViewInfo(handle: ISudFSMStateHandle, p1: String?) { + val gameLayout = gameViewLiveData.value + if (gameLayout == null) { + handle.failure("gameLayout is NULL") + return + } + val gameViewWidth = gameLayout.measuredWidth + val gameViewHeight = gameLayout.measuredHeight + if (gameViewWidth > 0 && gameViewHeight > 0) { + notifyGameViewInfo(handle, gameViewWidth, gameViewHeight) + return + } + gameLayout.viewTreeObserver.addOnGlobalLayoutListener(object : + ViewTreeObserver.OnGlobalLayoutListener { + override fun onGlobalLayout() { + gameLayout.viewTreeObserver.removeOnGlobalLayoutListener(this) + notifyGameViewInfo(handle, gameLayout.measuredWidth, gameLayout.measuredHeight) + } + }) + } + + override fun onGetGameCfg(handle: ISudFSMStateHandle, p1: String?) { + handle.success(JsonUtils.toJson(GameCfg())) + } + + override fun onGameMGCommonSelfClickJoinBtn( + handle: ISudFSMStateHandle?, + model: SudMGPMGState.MGCommonSelfClickJoinBtn? + ) { + sudFSTAPP.notifyAPPCommonSelfIn(true, -1, true, 1) + } + + override fun onPlayerMGCommonPlayerReady( + handle: ISudFSMStateHandle?, + userId: String?, + model: SudMGPMGState.MGCommonPlayerReady? + ) { + super.onPlayerMGCommonPlayerReady(handle, userId, model) + val queueAbility = + gameContext?.findAbility(GameQueueAbility::class.java.simpleName) + ?: return + val queueSize = queueAbility.queueFlow.value?.size ?: 0 + if (queueSize == 0) { + return + } + logD("onPlayerMGCommonPlayerReady queueSize:$queueSize size:${sudFSMMG.sudFSMMGCache.playerReadySet.size}") + if (sudFSMMG.sudFSMMGCache.playerReadySet.size >= queueSize) { + sudFSTAPP.notifyAPPCommonSelfPlaying(true, null, null) + } + } } \ No newline at end of file diff --git a/app/src/module_game/java/com/chwl/app/game/core/engine/GameSudFSMMG.kt b/app/src/module_game/java/com/chwl/app/game/core/engine/GameSudFSMMG.kt deleted file mode 100644 index 8e2c32dca..000000000 --- a/app/src/module_game/java/com/chwl/app/game/core/engine/GameSudFSMMG.kt +++ /dev/null @@ -1,48 +0,0 @@ -package com.chwl.app.game.core.engine - -import com.chwl.app.game.core.engine.model.GameStateResponse -import com.example.lib_utils.log.ILog -import tech.sud.mgp.core.ISudFSMMG -import tech.sud.mgp.core.ISudFSMStateHandle - -class GameSudFSMMG(private val engineViewModel: GameEngineViewModel) : ISudFSMMG, ILog { - override fun onGameLog(p0: String?) { - if (p0 != null) { - logD(p0) - } - } - - override fun onGameLoadingProgress(p0: Int, p1: Int, p2: Int) { - } - - override fun onGameStarted() { - } - - override fun onGameDestroyed() { - } - - override fun onExpireCode(p0: ISudFSMStateHandle, p1: String?) { - engineViewModel.onExpireCode(p0) - } - - override fun onGetGameViewInfo(p0: ISudFSMStateHandle, p1: String?) { - engineViewModel.onGetGameViewInfo(p0) - } - - override fun onGetGameCfg(p0: ISudFSMStateHandle, p1: String?) { - engineViewModel.onGetGameCfg(p0) - } - - override fun onGameStateChange(p0: ISudFSMStateHandle, p1: String?, p2: String?) { - p0.success(GameStateResponse.success().toJson()) - } - - override fun onPlayerStateChange( - p0: ISudFSMStateHandle, - p1: String?, - p2: String?, - p3: String? - ) { - p0.success(GameStateResponse.success().toJson()) - } -} \ No newline at end of file diff --git a/app/src/module_game/java/com/chwl/app/game/core/engine/GameSudFSTAPP.kt b/app/src/module_game/java/com/chwl/app/game/core/engine/GameSudFSTAPP.kt deleted file mode 100644 index 806a62c57..000000000 --- a/app/src/module_game/java/com/chwl/app/game/core/engine/GameSudFSTAPP.kt +++ /dev/null @@ -1,37 +0,0 @@ -package com.chwl.app.game.core.engine - -import tech.sud.mgp.core.ISudFSTAPP -import tech.sud.mgp.core.ISudListenerNotifyStateChange - -class GameSudFSTAPP(private val engineViewModel: GameEngineViewModel) { - private var sudFSTAPP: ISudFSTAPP? = null - - fun updateSudFSTAPP(iSudFSTAPP: ISudFSTAPP) { - this.sudFSTAPP = iSudFSTAPP - } - - fun updateCode(code: String, listener: ISudListenerNotifyStateChange?) { - this.sudFSTAPP?.updateCode(code, listener) - } - - fun startMG() { - this.sudFSTAPP?.startMG() - } - - fun playMG() { - this.sudFSTAPP?.playMG() - } - - fun pauseMG() { - this.sudFSTAPP?.pauseMG() - } - - fun stopMG() { - this.sudFSTAPP?.stopMG() - } - - fun destroyMG() { - sudFSTAPP?.destroyMG() - sudFSTAPP = null - } -} \ No newline at end of file diff --git a/app/src/module_game/java/com/chwl/app/game/core/engine/model/GameStateResponse.kt b/app/src/module_game/java/com/chwl/app/game/core/engine/model/GameStateResponse.kt deleted file mode 100644 index 0e7b91391..000000000 --- a/app/src/module_game/java/com/chwl/app/game/core/engine/model/GameStateResponse.kt +++ /dev/null @@ -1,25 +0,0 @@ -package com.chwl.app.game.core.engine.model - -import androidx.annotation.Keep -import com.chwl.library.utils.json.JsonUtils -import java.io.Serializable - -@Keep -data class GameStateResponse( - var ret_code: Int = CODE_SUCCESS, // 返回码 - var ret_msg: String? = null // 返回消息 -) : Serializable { - - fun toJson(): String { - return JsonUtils.toJson(this) - } - - // 返回码,成功 - companion object { - val CODE_SUCCESS = 0 - - fun success(): GameStateResponse { - return GameStateResponse(CODE_SUCCESS, "success") - } - } -} \ No newline at end of file diff --git a/app/src/module_game/java/com/chwl/app/game/data/GameModel2.kt b/app/src/module_game/java/com/chwl/app/game/data/GameModel2.kt index b6ad064a1..f76d6b5f8 100644 --- a/app/src/module_game/java/com/chwl/app/game/data/GameModel2.kt +++ b/app/src/module_game/java/com/chwl/app/game/data/GameModel2.kt @@ -1,7 +1,7 @@ package com.chwl.app.game.data -import com.chwl.app.game.data.bean.GameConfigBean -import com.chwl.app.game.data.bean.GameRoomInfo +import com.chwl.core.bean.game.GameConfigBean +import com.chwl.core.bean.game.GameRoomInfo import com.chwl.core.base.BaseModel import com.chwl.core.bean.response.ServiceResult import com.chwl.core.bean.room.BaseRoomInfo @@ -33,11 +33,16 @@ object GameModel2 : BaseModel() { api.startGame(gameId, gameMode) } + suspend fun closeGame(roomId: Long): String? = + launchRequest { + api.closeGame(roomId) + } + private interface Api { /** * 房间信息 */ - @GET("chatRoom/get") + @GET("chatRoom/getByType") suspend fun getChatRoomInfo(@Query("roomType") roomType: Int): ServiceResult /** @@ -55,6 +60,12 @@ object GameModel2 : BaseModel() { @Field("mgId") mgId: String, @Field("gameMode") gameMode: Int ): ServiceResult + + /** + * 关闭游戏 + */ + @GET("miniGame/nav/close") + suspend fun closeGame(@Query("roomId") roomId: Long): ServiceResult } } \ No newline at end of file diff --git a/app/src/module_game/java/com/chwl/app/game/data/bean/GameInfoUiState.kt b/app/src/module_game/java/com/chwl/app/game/data/bean/GameInfoUiState.kt new file mode 100644 index 000000000..3cf924770 --- /dev/null +++ b/app/src/module_game/java/com/chwl/app/game/data/bean/GameInfoUiState.kt @@ -0,0 +1,15 @@ +package com.chwl.app.game.data.bean + +import com.chwl.core.bean.game.GameRoomInfo + + +sealed class GameInfoUiState { + + object Loading : GameInfoUiState() + + object Success : GameInfoUiState() + + data class Failed(val throwable: Throwable, val gameInfo: GameRoomInfo?) : GameInfoUiState() + + data class Empty(val gameInfo: GameRoomInfo?) : GameInfoUiState() +} \ No newline at end of file diff --git a/app/src/module_game/java/com/chwl/app/game/ui/buy/GameBuyDialog.kt b/app/src/module_game/java/com/chwl/app/game/ui/buy/GameBuyDialog.kt index 1e24268ac..8d4171ae2 100644 --- a/app/src/module_game/java/com/chwl/app/game/ui/buy/GameBuyDialog.kt +++ b/app/src/module_game/java/com/chwl/app/game/ui/buy/GameBuyDialog.kt @@ -12,8 +12,8 @@ import androidx.lifecycle.repeatOnLifecycle import com.chwl.app.R import com.chwl.app.common.widget.dialog.DialogManager import com.chwl.app.databinding.GameBuyDialogBinding -import com.chwl.app.game.data.bean.GameConfigBean -import com.chwl.app.game.data.bean.GameModeBean +import com.chwl.core.bean.game.GameConfigBean +import com.chwl.core.bean.game.GameModeBean import com.chwl.app.game.ui.game.GameActivity import com.chwl.app.game.ui.game.GameIntent import com.chwl.app.game.ui.home.GameHomeViewModel diff --git a/app/src/module_game/java/com/chwl/app/game/ui/game/GameActivity.kt b/app/src/module_game/java/com/chwl/app/game/ui/game/GameActivity.kt index 0a72f556b..bf91bdd7a 100644 --- a/app/src/module_game/java/com/chwl/app/game/ui/game/GameActivity.kt +++ b/app/src/module_game/java/com/chwl/app/game/ui/game/GameActivity.kt @@ -2,6 +2,8 @@ package com.chwl.app.game.ui.game import android.content.Context import android.content.Intent +import android.widget.FrameLayout +import androidx.core.view.isVisible import androidx.lifecycle.lifecycleScope import com.chwl.app.R import com.chwl.app.common.widget.dialog.DialogManager.OkCancelDialogListener @@ -9,18 +11,17 @@ import com.chwl.app.databinding.GameActivityBinding import com.chwl.app.game.core.BaseGameActivity import com.chwl.app.game.core.GameContext import com.chwl.app.game.core.GameStateAbility -import com.chwl.app.game.core.engine.model.GameViewInfoModel.GameViewRectModel import com.chwl.app.game.ui.game.widgets.bottom.GameBottomWidget import com.chwl.app.game.ui.game.widgets.message.GameMessageWidget import com.chwl.app.game.ui.game.widgets.queue.GameQueueWidget -import com.chwl.app.ui.utils.ImageLoadUtilsV2 -import com.chwl.app.ui.utils.load import com.chwl.app.ui.utils.loadImage +import com.chwl.core.sud.model.GameViewInfoModel import com.chwl.core.support.room.RoomView +import com.example.lib_utils.ktx.getColorById import com.example.lib_utils.ktx.singleClick import com.example.lib_utils.log.ILog +import com.example.lib_utils.spannable.SpannableTextBuilder import kotlinx.coroutines.flow.collectLatest -import kotlinx.coroutines.flow.zip import kotlinx.coroutines.launch class GameActivity : BaseGameActivity(), RoomView, ILog { @@ -41,14 +42,13 @@ class GameActivity : BaseGameActivity(), RoomView, ILog { return } super.init() - initGameEngine() viewModel.init(intentData) } - private fun initGameEngine() { - gameEngineViewModel.init(lifecycle, binding.layoutGame) + override fun initView() { + super.initView() binding.spaceGameRect.post { - val rect = GameViewRectModel().apply { + val rect = GameViewInfoModel.GameViewRectModel().apply { top = binding.spaceGameRect.top bottom = binding.root.height - binding.spaceGameRect.bottom } @@ -65,14 +65,8 @@ class GameActivity : BaseGameActivity(), RoomView, ILog { } } - override fun initObserver() { - super.initObserver() - viewModel.gameContextLiveData.observe(this) { - updateGameContext(it) - } - } - - private fun updateGameContext(gameContext: GameContext) { + override fun onGameContext(gameContext: GameContext) { + super.onGameContext(gameContext) val stateAbility = gameContext.findAbility(GameStateAbility::class.java.simpleName) ?: return @@ -80,30 +74,49 @@ class GameActivity : BaseGameActivity(), RoomView, ILog { stateAbility.gameIconFlow.collectLatest { binding.ivLogo.loadImage(it) } + } + lifecycleScope.launch { stateAbility.scoresFlow.collectLatest { - val number = it?.first()?.toString() ?: "" - binding.tvAwardValue.text = number - binding.tvAwardTips.text = getString(R.string.game_award_tips_format, number) + updateAward(it?.first()) + } + } + + lifecycleScope.launch { + stateAbility.matchFailedFlow.collectLatest { + showMatchFailed() } - updateGameEngine(stateAbility) } } - private suspend fun updateGameEngine(stateAbility: GameStateAbility) { - stateAbility.imIdFlow.zip(stateAbility.roomIdFlow) { imId, roomId -> - if (imId != null && roomId != null) { - Pair(imId, roomId) - } else { - null + private fun updateAward(number: Double?) { + val numberStr = number?.toInt()?.toString() ?: "" + if (numberStr.isEmpty()) { + binding.layoutAward.isVisible = false + binding.tvAwardTips.isVisible = false + } else { + binding.layoutAward.isVisible = true + binding.tvAwardTips.isVisible = true + binding.tvAwardValue.text = numberStr + val awardTips = getString(R.string.game_award_tips_format, numberStr) + SpannableTextBuilder(binding.tvAwardTips).appendText(awardTips) + .setTextStyle(numberStr, textColor = getColorById(R.color.color_FF6629)).apply() + } + } + + override fun initObserver() { + super.initObserver() + lifecycleScope.launch { + viewModel.closeRoomFlow.collectLatest { + loadingDialogManager?.dismissDialog() + finish() } - }.collectLatest { - if (it != null) { - gameEngineViewModel.loadGame( - this@GameActivity, - it.second.toString(), - it.first - ) + } + + lifecycleScope.launch { + viewModel.restartFlow.collectLatest { + loadingDialogManager?.dismissDialog() + // TODO 待完善 } } } @@ -120,17 +133,41 @@ class GameActivity : BaseGameActivity(), RoomView, ILog { showExitTips() } - private fun showExitTips() { - dialogManager.showOkCancelDialog( - getString(R.string.game_exit_tips), - getString(R.string.layout_dialog_game_exit_04), - getString(R.string.exit_text), object : OkCancelDialogListener { + override fun getGameViewGroup(): FrameLayout { + return binding.layoutGame + } + + private fun showMatchFailed() { + dialogManager.showOkCancelDialog(null, + getString(R.string.game_match_failed), + getString(R.string.game_rematch), + getString(R.string.exit_text), false, false, object : OkCancelDialogListener { override fun onOk() { + loadingDialogManager?.showProgressDialog(this@GameActivity) + viewModel.restart() } override fun onCancel() { super.onCancel() - this@GameActivity.finish() + loadingDialogManager?.showProgressDialog(this@GameActivity) + viewModel.closeRoom() + } + }) + } + + private fun showExitTips() { + dialogManager.showOkCancelDialog(null, + getString(R.string.game_exit_tips), + getString(R.string.layout_dialog_game_exit_04), + getString(R.string.exit_text), false, false, object : OkCancelDialogListener { + override fun onOk() { + dialogManager.dismissDialog() + } + + override fun onCancel() { + super.onCancel() + loadingDialogManager?.showProgressDialog(this@GameActivity) + viewModel.closeRoom() } }) } diff --git a/app/src/module_game/java/com/chwl/app/game/ui/game/GameViewModel.kt b/app/src/module_game/java/com/chwl/app/game/ui/game/GameViewModel.kt index 4568e32e5..76f6de027 100644 --- a/app/src/module_game/java/com/chwl/app/game/ui/game/GameViewModel.kt +++ b/app/src/module_game/java/com/chwl/app/game/ui/game/GameViewModel.kt @@ -1,14 +1,26 @@ package com.chwl.app.game.ui.game import androidx.lifecycle.MutableLiveData +import com.chwl.app.R import com.chwl.app.base.BaseViewModel import com.chwl.app.game.core.GameContext +import com.chwl.app.game.data.GameModel2 +import com.chwl.core.bean.response.BeanResult +import com.chwl.library.utils.ResUtil +import kotlinx.coroutines.flow.MutableSharedFlow class GameViewModel : BaseViewModel() { val gameContextLiveData = MutableLiveData() + val closeRoomFlow = MutableSharedFlow>() + + val restartFlow = MutableSharedFlow>() + + private var gameIntent: GameIntent? = null + fun init(intent: GameIntent) { + this.gameIntent = intent val gameContext = GameContext(intent.roomId) gameContext.performStart() gameContextLiveData.value = gameContext @@ -18,4 +30,34 @@ class GameViewModel : BaseViewModel() { super.onCleared() gameContextLiveData.value?.performStop() } + + fun restart() { + val intent = gameIntent + if (intent == null) { + safeLaunch { + restartFlow.emit(BeanResult.failed(NullPointerException(ResUtil.getString(R.string.utils_net_beanobserver_05)))) + } + return + } + safeLaunch { + val result = GameModel2.startGame(intent.gameId.toString(), intent.gameMode) + // TODO 待完善 + } + } + + fun closeRoom() { + val roomId = gameContextLiveData.value?.roomId + if (roomId != null) { + safeLaunch(onError = { + closeRoomFlow.emit(BeanResult.failed(it)) + }) { + GameModel2.closeGame(roomId) + closeRoomFlow.emit(BeanResult.success(null)) + } + } else { + safeLaunch { + closeRoomFlow.emit(BeanResult.success(null)) + } + } + } } \ No newline at end of file diff --git a/app/src/module_game/java/com/chwl/app/game/ui/game/widgets/queue/GameQueueWidget.kt b/app/src/module_game/java/com/chwl/app/game/ui/game/widgets/queue/GameQueueWidget.kt index d9808863d..ac6ae078c 100644 --- a/app/src/module_game/java/com/chwl/app/game/ui/game/widgets/queue/GameQueueWidget.kt +++ b/app/src/module_game/java/com/chwl/app/game/ui/game/widgets/queue/GameQueueWidget.kt @@ -6,7 +6,15 @@ import android.view.LayoutInflater import androidx.databinding.DataBindingUtil import com.chwl.app.R import com.chwl.app.databinding.GameQueueWidgetBinding +import com.chwl.app.game.core.GameQueueAbility +import com.chwl.app.game.core.GameStateAbility +import com.chwl.app.ui.utils.loadAvatar +import com.chwl.core.auth.AuthModel +import com.chwl.core.bean.room.RoomMicBean import com.chwl.core.support.room.FrameLayoutRoomWidget +import com.chwl.core.support.room.RoomContext +import com.chwl.core.support.room.RoomView +import kotlinx.coroutines.flow.collectLatest class GameQueueWidget : FrameLayoutRoomWidget { @@ -32,11 +40,52 @@ class GameQueueWidget : FrameLayoutRoomWidget { defStyleRes: Int ) : super(context, attrs, defStyleAttr, defStyleRes) - init { - binding.tvState.setText("AAAA") + override fun onInitialize(roomView: RoomView, roomContext: RoomContext) { + super.onInitialize(roomView, roomContext) + val stateAbility = + roomContext.findAbility(GameStateAbility::class.java.simpleName) + val queueAbility = + roomContext.findAbility(GameQueueAbility::class.java.simpleName) + queueAbility?.let { + safeLaunch { + it.queueFlow.collectLatest { + updateQueue(it) + } + } + } + stateAbility?.let { + safeLaunch { + it.gameStateFlow.collectLatest { + updateState(it) + } + } + } } - private fun updateState() { + private fun updateQueue(list: List?) { + val selfInfo = list?.firstOrNull { + it.micUser?.uid == AuthModel.get().currentUid + } + val targetInfo = list?.firstOrNull { + it.micUser?.uid != AuthModel.get().currentUid + } + + binding.ivQueue1.loadAvatar(selfInfo?.micUser?.avatar) + binding.ivQueue2.loadAvatar(targetInfo?.micUser?.avatar) + } + + private fun updateState(gameState: Int?) { + when (gameState) { + 1, 2 -> { + binding.tvState.setText(R.string.match_successfully) + binding.ivState.setImageResource(R.drawable.game_ic_vs) + } + + else -> { + binding.tvState.setText(R.string.matchmaking) + binding.ivState.setImageResource(R.drawable.game_ic_link) + } + } } } \ No newline at end of file diff --git a/app/src/module_game/java/com/chwl/app/game/ui/home/GameHomeAdapter.kt b/app/src/module_game/java/com/chwl/app/game/ui/home/GameHomeAdapter.kt index 1799942f3..1fe8ae31e 100644 --- a/app/src/module_game/java/com/chwl/app/game/ui/home/GameHomeAdapter.kt +++ b/app/src/module_game/java/com/chwl/app/game/ui/home/GameHomeAdapter.kt @@ -4,7 +4,7 @@ import android.widget.ImageView import com.chad.library.adapter.base.BaseQuickAdapter import com.chad.library.adapter.base.BaseViewHolder import com.chwl.app.R -import com.chwl.app.game.data.bean.GameModeBean +import com.chwl.core.bean.game.GameModeBean import com.chwl.app.ui.utils.load class GameHomeAdapter : BaseQuickAdapter(R.layout.game_home_item) { diff --git a/app/src/module_game/java/com/chwl/app/game/ui/home/GameHomeFragment.kt b/app/src/module_game/java/com/chwl/app/game/ui/home/GameHomeFragment.kt index 2873c3cbe..9d144f851 100644 --- a/app/src/module_game/java/com/chwl/app/game/ui/home/GameHomeFragment.kt +++ b/app/src/module_game/java/com/chwl/app/game/ui/home/GameHomeFragment.kt @@ -4,7 +4,7 @@ import androidx.fragment.app.activityViewModels import com.chwl.app.MainTabContentView import com.chwl.app.base.BaseViewBindingFragment import com.chwl.app.databinding.GameHomeFragmentBinding -import com.chwl.app.game.data.bean.GameConfigBean +import com.chwl.core.bean.game.GameConfigBean import com.chwl.app.game.ui.buy.GameBuyDialog import com.chwl.app.support.FragmentVisibleStateHelper import com.chwl.app.ui.pay.ChargeActivity diff --git a/app/src/module_game/java/com/chwl/app/game/ui/home/GameHomeViewModel.kt b/app/src/module_game/java/com/chwl/app/game/ui/home/GameHomeViewModel.kt index f67be5f61..cebfcfd98 100644 --- a/app/src/module_game/java/com/chwl/app/game/ui/home/GameHomeViewModel.kt +++ b/app/src/module_game/java/com/chwl/app/game/ui/home/GameHomeViewModel.kt @@ -3,7 +3,7 @@ package com.chwl.app.game.ui.home import androidx.lifecycle.MutableLiveData import com.chwl.app.base.BaseViewModel import com.chwl.app.game.data.GameModel2 -import com.chwl.app.game.data.bean.GameConfigBean +import com.chwl.core.bean.game.GameConfigBean import com.chwl.core.bean.response.BeanResult import com.chwl.core.pay.PayModel import kotlinx.coroutines.flow.MutableSharedFlow diff --git a/app/src/module_game/res/layout/game_activity.xml b/app/src/module_game/res/layout/game_activity.xml index d52e2412b..4ea3af516 100644 --- a/app/src/module_game/res/layout/game_activity.xml +++ b/app/src/module_game/res/layout/game_activity.xml @@ -60,10 +60,12 @@ android:layout_marginTop="@dimen/dp_9" android:textColor="@color/white" android:textSize="@dimen/dp_14" + android:visibility="gone" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/queue_widget" - tools:text="@string/game_award_tips_format" /> + tools:text="@string/game_award_tips_format" + tools:visibility="visible" /> + app:layout_constraintTop_toBottomOf="@id/tv_award_tips" + tools:visibility="visible"> diff --git a/app/src/module_game/res/values-ar/strings.xml b/app/src/module_game/res/values-ar/strings.xml index 1a7db2b34..6083af2fe 100644 --- a/app/src/module_game/res/values-ar/strings.xml +++ b/app/src/module_game/res/values-ar/strings.xml @@ -1,8 +1,11 @@ 匹配中 + 匹配成功 獲勝獎勵%s金幣 开始 入场费(%s) 遊戲已經開始,退出房間將默認遊戲失敗,確認退出房間? + 匹配失敗,是否重新開始? + 重新匹配 \ No newline at end of file diff --git a/app/src/module_game/res/values-zh-rTW/strings.xml b/app/src/module_game/res/values-zh-rTW/strings.xml index aa13bfd44..357daa137 100644 --- a/app/src/module_game/res/values-zh-rTW/strings.xml +++ b/app/src/module_game/res/values-zh-rTW/strings.xml @@ -2,8 +2,11 @@ 匹配中 + 匹配成功 獲勝獎勵%s金幣 開始 入场费(%s) 遊戲已經開始,退出房間將默認遊戲失敗,確認退出房間? + 匹配失敗,是否重新開始? + 重新匹配 \ No newline at end of file diff --git a/app/src/module_game/res/values/strings.xml b/app/src/module_game/res/values/strings.xml index 1a7db2b34..6083af2fe 100644 --- a/app/src/module_game/res/values/strings.xml +++ b/app/src/module_game/res/values/strings.xml @@ -1,8 +1,11 @@ 匹配中 + 匹配成功 獲勝獎勵%s金幣 开始 入场费(%s) 遊戲已經開始,退出房間將默認遊戲失敗,確認退出房間? + 匹配失敗,是否重新開始? + 重新匹配 \ No newline at end of file diff --git a/core/build.gradle b/core/build.gradle index 12e3cb5df..5e901ed91 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -44,7 +44,8 @@ android { 'src/model_treasure_box/java', 'src/model_community/java', 'src/model_channel_page/java', - 'src/model_treasure_box/java' + 'src/model_treasure_box/java', + 'src/model_sud_wrapper/java' ] jniLibs.srcDirs = ['libs', 'umeng-app-libs/jniLibs'] } @@ -98,6 +99,8 @@ dependencies { implementation 'com.tencent.liteav:LiteAVSDK_TRTC:11.7.0.13946' api project(':modules:module_base') + + api 'tech.sud.mgp:SudMGP-static:1.3.3.1158' } repositories { mavenCentral() diff --git a/app/src/module_game/java/com/chwl/app/game/data/bean/GameConfigBean.kt b/core/src/main/java/com/chwl/core/bean/game/GameConfigBean.kt similarity index 86% rename from app/src/module_game/java/com/chwl/app/game/data/bean/GameConfigBean.kt rename to core/src/main/java/com/chwl/core/bean/game/GameConfigBean.kt index e871463c8..0b69238c8 100644 --- a/app/src/module_game/java/com/chwl/app/game/data/bean/GameConfigBean.kt +++ b/core/src/main/java/com/chwl/core/bean/game/GameConfigBean.kt @@ -1,4 +1,4 @@ -package com.chwl.app.game.data.bean +package com.chwl.core.bean.game import androidx.annotation.Keep diff --git a/app/src/module_game/java/com/chwl/app/game/data/bean/GameModeBean.kt b/core/src/main/java/com/chwl/core/bean/game/GameModeBean.kt similarity index 89% rename from app/src/module_game/java/com/chwl/app/game/data/bean/GameModeBean.kt rename to core/src/main/java/com/chwl/core/bean/game/GameModeBean.kt index 55dd8877f..121d2521c 100644 --- a/app/src/module_game/java/com/chwl/app/game/data/bean/GameModeBean.kt +++ b/core/src/main/java/com/chwl/core/bean/game/GameModeBean.kt @@ -1,4 +1,4 @@ -package com.chwl.app.game.data.bean +package com.chwl.core.bean.game import androidx.annotation.Keep import java.io.Serializable diff --git a/app/src/module_game/java/com/chwl/app/game/data/bean/GameRoomData.kt b/core/src/main/java/com/chwl/core/bean/game/GameRoomData.kt similarity index 92% rename from app/src/module_game/java/com/chwl/app/game/data/bean/GameRoomData.kt rename to core/src/main/java/com/chwl/core/bean/game/GameRoomData.kt index ea34e81ab..69c777728 100644 --- a/app/src/module_game/java/com/chwl/app/game/data/bean/GameRoomData.kt +++ b/core/src/main/java/com/chwl/core/bean/game/GameRoomData.kt @@ -1,4 +1,4 @@ -package com.chwl.app.game.data.bean +package com.chwl.core.bean.game import androidx.annotation.Keep import java.io.Serializable diff --git a/app/src/module_game/java/com/chwl/app/game/data/bean/GameRoomInfo.kt b/core/src/main/java/com/chwl/core/bean/game/GameRoomInfo.kt similarity index 79% rename from app/src/module_game/java/com/chwl/app/game/data/bean/GameRoomInfo.kt rename to core/src/main/java/com/chwl/core/bean/game/GameRoomInfo.kt index 098fca780..9cbb27735 100644 --- a/app/src/module_game/java/com/chwl/app/game/data/bean/GameRoomInfo.kt +++ b/core/src/main/java/com/chwl/core/bean/game/GameRoomInfo.kt @@ -1,4 +1,4 @@ -package com.chwl.app.game.data.bean +package com.chwl.core.bean.game import androidx.annotation.Keep import com.chwl.core.bean.room.BaseRoomInfo diff --git a/core/src/main/java/com/chwl/core/bean/room/RoomMicUserInfo.kt b/core/src/main/java/com/chwl/core/bean/room/RoomMicUserInfo.kt index 801f116ab..eae9c9017 100644 --- a/core/src/main/java/com/chwl/core/bean/room/RoomMicUserInfo.kt +++ b/core/src/main/java/com/chwl/core/bean/room/RoomMicUserInfo.kt @@ -8,5 +8,5 @@ class RoomMicUserInfo : Serializable { val avatar: String? = null val erbanNo: Long? = null val nick: String? = null - val uid: String? = null + val uid: Long? = null } \ No newline at end of file diff --git a/core/src/main/java/com/chwl/core/im/custom/bean/CustomAttachParser.java b/core/src/main/java/com/chwl/core/im/custom/bean/CustomAttachParser.java index e207a0950..b04426789 100644 --- a/core/src/main/java/com/chwl/core/im/custom/bean/CustomAttachParser.java +++ b/core/src/main/java/com/chwl/core/im/custom/bean/CustomAttachParser.java @@ -714,6 +714,19 @@ public class CustomAttachParser implements MsgAttachmentParser { break; } break; + case CustomAttachment.CUSTOM_MSG_MINI_GAME: + switch (second) { + case CustomAttachment.CUSTOM_MSG_MINI_GAME_QUEUE_CHANGED: + attachment = new GameQueueChangedAttachment(first, second); + break; + case CustomAttachment.CUSTOM_MSG_MINI_GAME_MATCH_FAILED: + attachment = new GameMatchFailedAttachment(first, second); + break; + case CustomAttachment.CUSTOM_MSG_MINI_GAME_FORCED_END: + attachment = new GameForcedEndAttachment(first, second); + break; + } + break; default: LogUtils.e(ResUtil.getString(R.string.custom_bean_customattachparser_01) + first + " second=" + second); break; diff --git a/core/src/main/java/com/chwl/core/im/custom/bean/CustomAttachment.java b/core/src/main/java/com/chwl/core/im/custom/bean/CustomAttachment.java index 4d19ed46b..0aafbcf5b 100644 --- a/core/src/main/java/com/chwl/core/im/custom/bean/CustomAttachment.java +++ b/core/src/main/java/com/chwl/core/im/custom/bean/CustomAttachment.java @@ -504,6 +504,16 @@ public class CustomAttachment implements MsgAttachment { public static final int CUSTOM_MSG_HEADLINE_CHANGED = 108; public static final int CUSTOM_MSG_HEADLINE_CHANGED_SUB = 1081; + + // 游戏-麦位更新 + public static final int CUSTOM_MSG_MINI_GAME = 109; + // 麦位变更 + public static final int CUSTOM_MSG_MINI_GAME_QUEUE_CHANGED = 1091; + // 匹配失败 + public static final int CUSTOM_MSG_MINI_GAME_MATCH_FAILED = 1092; + // 提前结束 + public static final int CUSTOM_MSG_MINI_GAME_FORCED_END = 1093; + /** * 家族 */ diff --git a/core/src/main/java/com/chwl/core/im/custom/bean/GameForcedEndAttachment.kt b/core/src/main/java/com/chwl/core/im/custom/bean/GameForcedEndAttachment.kt new file mode 100644 index 000000000..7c764ff8e --- /dev/null +++ b/core/src/main/java/com/chwl/core/im/custom/bean/GameForcedEndAttachment.kt @@ -0,0 +1,14 @@ +package com.chwl.core.im.custom.bean + +import androidx.annotation.Keep +import com.alibaba.fastjson.JSONObject + +@Keep +class GameForcedEndAttachment : CustomAttachment { + + constructor() : super() + constructor(first: Int, second: Int) : super(first, second) + + override fun parseData(data: JSONObject?) { + } +} \ No newline at end of file diff --git a/core/src/main/java/com/chwl/core/im/custom/bean/GameMatchFailedAttachment.kt b/core/src/main/java/com/chwl/core/im/custom/bean/GameMatchFailedAttachment.kt new file mode 100644 index 000000000..4d1a48862 --- /dev/null +++ b/core/src/main/java/com/chwl/core/im/custom/bean/GameMatchFailedAttachment.kt @@ -0,0 +1,16 @@ +package com.chwl.core.im.custom.bean + +import androidx.annotation.Keep +import com.alibaba.fastjson.JSONObject +import com.chwl.core.bean.game.GameRoomInfo +import com.google.gson.Gson + +@Keep +class GameMatchFailedAttachment : CustomAttachment { + + constructor() : super() + constructor(first: Int, second: Int) : super(first, second) + + override fun parseData(data: JSONObject?) { + } +} \ No newline at end of file diff --git a/core/src/main/java/com/chwl/core/im/custom/bean/GameQueueChangedAttachment.kt b/core/src/main/java/com/chwl/core/im/custom/bean/GameQueueChangedAttachment.kt new file mode 100644 index 000000000..ea98fc278 --- /dev/null +++ b/core/src/main/java/com/chwl/core/im/custom/bean/GameQueueChangedAttachment.kt @@ -0,0 +1,22 @@ +package com.chwl.core.im.custom.bean + +import androidx.annotation.Keep +import com.alibaba.fastjson.JSONObject +import com.chwl.core.bean.game.GameRoomInfo +import com.google.gson.Gson + +@Keep +class GameQueueChangedAttachment : CustomAttachment { + var gameInfo: GameRoomInfo? = null + + constructor() : super() + constructor(first: Int, second: Int) : super(first, second) + + override fun parseData(data: JSONObject?) { + try { + gameInfo = Gson().fromJson(data?.toJSONString(), GameRoomInfo::class.java) + } catch (e: Exception) { + e.printStackTrace() + } + } +} \ No newline at end of file diff --git a/core/src/model_sud_wrapper/java/com/chwl/core/sud/decorator/SudFSMMGCache.java b/core/src/model_sud_wrapper/java/com/chwl/core/sud/decorator/SudFSMMGCache.java new file mode 100644 index 000000000..7ee3f97e7 --- /dev/null +++ b/core/src/model_sud_wrapper/java/com/chwl/core/sud/decorator/SudFSMMGCache.java @@ -0,0 +1,231 @@ +/* + * Copyright © Sud.Tech + * https://sud.tech + */ + +package com.chwl.core.sud.decorator; + +import androidx.annotation.Keep; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Objects; + +import com.chwl.core.sud.state.SudMGPMGState; + +/** + * 游戏回调数据缓存 + * Game callback data cache. + */ +public class SudFSMMGCache { + + /** + * 记录当前队长的用户id + * Record the user ID of the current team captain. + */ + private String captainUserId; + + /** + * 全局游戏状态 + * Global game state. + */ + private SudMGPMGState.MGCommonGameState mgCommonGameStateModel; + + /** + * 是否数字炸弹 + * Is it a numeric bomb? + */ + private boolean isHitBomb = false; + + /** + * 记录已经加入了游戏的玩家 + * Record the players who have already joined the game. + */ + private final HashSet playerInSet = new HashSet<>(); + + /** + * 记录已经准备好的游戏玩家 + * Keep track of the game players who are already ready. + */ + private final HashSet playerReadySet = new HashSet<>(); + + /** + * 记录玩家的游戏状态 + * Record the game state of the player. + */ + private final HashMap playerPlayingMap = new HashMap<>(); + + /** + * 队长状态 处理 + * Captain's status handling. + */ + public void onPlayerMGCommonPlayerCaptain(String userId, SudMGPMGState.MGCommonPlayerCaptain model) { + if (model != null) { + if (model.isCaptain) { + captainUserId = userId; + } else { + if (Objects.equals(captainUserId, userId)) { + captainUserId = null; + } + } + } + } + + /** + * 游戏状态 处理 + * Game state processing. + */ + public void onGameMGCommonGameState(SudMGPMGState.MGCommonGameState model) { + mgCommonGameStateModel = model; + } + + /** + * 玩家加入状态处理 + * Player join status processing. + */ + public void onPlayerMGCommonPlayerIn(String userId, SudMGPMGState.MGCommonPlayerIn model) { + if (model != null) { + if (model.isIn) { + playerInSet.add(userId); + } else { + playerInSet.remove(userId); + playerReadySet.remove(userId); + } + } + } + + /** + * 玩家准备状态 + * Player readiness status. + */ + public void onPlayerMGCommonPlayerReady(String userId, SudMGPMGState.MGCommonPlayerReady model) { + if (model != null) { + if (model.isReady) { + playerReadySet.add(userId); + } else { + playerReadySet.remove(userId); + } + } + } + + /** + * 玩家游戏状态 + * Player game status. + */ + public void onPlayerMGCommonPlayerPlaying(String userId, SudMGPMGState.MGCommonPlayerPlaying model) { + if (model != null) { + playerPlayingMap.put(userId, model); + } + } + + /** + * 关键词状态 + * Keyword status. + */ + public void onGameMGCommonKeyWordToHit(SudMGPMGState.MGCommonKeyWordToHit model) { + if (model != null) { + isHitBomb = model.wordType.equals("number"); + } + } + + /** + * 返回该玩家是否正在游戏中 + * Return whether the player is currently in-game. + */ + public boolean playerIsPlaying(String userId) { + SudMGPMGState.MGCommonPlayerPlaying mgCommonPlayerPlaying = playerPlayingMap.get(userId); + if (mgCommonPlayerPlaying != null) { + return mgCommonPlayerPlaying.isPlaying; + } + return false; + } + + /** + * 返回该玩家是否已准备 + * Return whether the player is ready. + */ + public boolean playerIsReady(String userId) { + return playerReadySet.contains(userId); + } + + /** + * 返回该玩家是否已加入了游戏 + * Return whether the player has joined the game. + */ + public boolean playerIsIn(String userId) { + return playerInSet.contains(userId); + } + + /** + * 获取当前游戏中的人数 + * Retrieve the current number of players in the game. + */ + public int getPlayerInNumber() { + return playerInSet.size(); + } + + /** + * 是否数字炸弹 + * Is it a numeric bomb? + */ + public boolean isHitBomb() { + return isHitBomb; + } + + /** + * 销毁游戏 + * Destroy the game. + */ + public void destroyMG() { + captainUserId = null; + mgCommonGameStateModel = null; + isHitBomb = false; + playerInSet.clear(); + playerReadySet.clear(); + playerPlayingMap.clear(); + } + + /** + * 获取队长userId + * Get the captain's user ID. + */ + public String getCaptainUserId() { + return captainUserId; + } + + /** + * 获取当前已加入游戏的玩家集合 + * Retrieve the current set of players who have joined the game. + */ + public HashSet getPlayerInSet() { + return new HashSet<>(playerInSet); + } + + /** + * 获取当前已准备的玩家集合 + * Retrieve the current set of players who are ready. + */ + public HashSet getPlayerReadySet() { + return new HashSet<>(playerReadySet); + } + + /** + * 获取玩家游戏状态集合 + * Retrieve the set of player game states. + */ + public HashMap getPlayerPlayingMap() { + return new HashMap<>(playerPlayingMap); + } + + /** + * 返回当前游戏的状态,数值参数{@link SudMGPMGState.MGCommonGameState} + * Return the current game state, numerical parameter {@link SudMGPMGState.MGCommonGameState}. + */ + public int getGameState() { + if (mgCommonGameStateModel != null) { + return mgCommonGameStateModel.gameState; + } + return SudMGPMGState.MGCommonGameState.UNKNOW; + } + +} diff --git a/core/src/model_sud_wrapper/java/com/chwl/core/sud/decorator/SudFSMMGDecorator.java b/core/src/model_sud_wrapper/java/com/chwl/core/sud/decorator/SudFSMMGDecorator.java new file mode 100644 index 000000000..b3e6bca37 --- /dev/null +++ b/core/src/model_sud_wrapper/java/com/chwl/core/sud/decorator/SudFSMMGDecorator.java @@ -0,0 +1,1126 @@ +/* + * Copyright © Sud.Tech + * https://sud.tech + */ + +package com.chwl.core.sud.decorator; + +import androidx.annotation.Keep; + +import com.chwl.core.sud.state.SudMGPMGState; +import com.chwl.core.sud.utils.ISudFSMStateHandleUtils; +import com.chwl.core.sud.utils.SudJsonUtils; +import tech.sud.mgp.core.ISudFSMMG; +import tech.sud.mgp.core.ISudFSMStateHandle; + +/** + * ISudFSMMG 游戏调APP回调装饰类 + * 参考文档:https://docs.sud.tech/zh-CN/app/Client/API/ISudFSMMG.html + */ +public class SudFSMMGDecorator implements ISudFSMMG { + + // 回调 + private SudFSMMGListener sudFSMMGListener; + + // 数据状态封装 + private final SudFSMMGCache sudFSMMGCache = new SudFSMMGCache(); + + /** + * 设置回调 + * + * @param listener 监听器 + */ + public void setSudFSMMGListener(SudFSMMGListener listener) { + sudFSMMGListener = listener; + } + + /** + * 游戏日志 + * 最低版本:v1.1.30.xx + */ + @Override + public void onGameLog(String dataJson) { + SudFSMMGListener listener = sudFSMMGListener; + if (listener != null) { + listener.onGameLog(dataJson); + } + } + + /** + * 游戏加载进度 + * + * @param stage 阶段:start=1,loading=2,end=3 + * @param retCode 错误码:0成功 + * @param progress 进度:[0, 100] + */ + @Override + public void onGameLoadingProgress(int stage, int retCode, int progress) { + SudFSMMGListener listener = sudFSMMGListener; + if (listener != null) { + listener.onGameLoadingProgress(stage, retCode, progress); + } + } + + /** + * 游戏开始 + * 最低版本:v1.1.30.xx + */ + @Override + public void onGameStarted() { + SudFSMMGListener listener = sudFSMMGListener; + if (listener != null) { + listener.onGameStarted(); + } + } + + /** + * 游戏销毁 + * 最低版本:v1.1.30.xx + */ + @Override + public void onGameDestroyed() { + SudFSMMGListener listener = sudFSMMGListener; + if (listener != null) { + listener.onGameDestroyed(); + } + } + + /** + * Code过期,需要实现 + * APP接入方需要调用handle.success或handle.fail + * + * @param dataJson {"code":"value"} + */ + @Override + public void onExpireCode(ISudFSMStateHandle handle, String dataJson) { + SudFSMMGListener listener = sudFSMMGListener; + if (listener != null) { + listener.onExpireCode(handle, dataJson); + } + } + + /** + * 获取游戏View信息,需要实现 + * APP接入方需要调用handle.success或handle.fail + * + * @param handle 操作 + * @param dataJson {} + */ + @Override + public void onGetGameViewInfo(ISudFSMStateHandle handle, String dataJson) { + SudFSMMGListener listener = sudFSMMGListener; + if (listener != null) { + listener.onGetGameViewInfo(handle, dataJson); + } + } + + /** + * 获取游戏Config,需要实现 + * APP接入方需要调用handle.success或handle.fail + * + * @param handle 操作 + * @param dataJson {} + * 最低版本:v1.1.30.xx + */ + @Override + public void onGetGameCfg(ISudFSMStateHandle handle, String dataJson) { + SudFSMMGListener listener = sudFSMMGListener; + if (listener != null) { + listener.onGetGameCfg(handle, dataJson); + } + } + + /** + * 游戏状态变化 + * APP接入方需要调用handle.success或handle.fail + * + * @param handle 操作 + * @param state 状态命令 + * @param dataJson 状态值 + */ + @Override + public void onGameStateChange(ISudFSMStateHandle handle, String state, String dataJson) { + SudFSMMGListener listener = sudFSMMGListener; + if (listener != null && listener.onGameStateChange(handle, state, dataJson)) { + return; + } + switch (state) { + case SudMGPMGState.MG_COMMON_PUBLIC_MESSAGE: // 1. 公屏消息 + SudMGPMGState.MGCommonPublicMessage mgCommonPublicMessage = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonPublicMessage.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonPublicMessage(handle, mgCommonPublicMessage); + } + break; + case SudMGPMGState.MG_COMMON_KEY_WORD_TO_HIT: // 2. 关键词状态 + SudMGPMGState.MGCommonKeyWordToHit mgCommonKeyWordToHit = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonKeyWordToHit.class); + sudFSMMGCache.onGameMGCommonKeyWordToHit(mgCommonKeyWordToHit); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonKeyWordToHit(handle, mgCommonKeyWordToHit); + } + break; + case SudMGPMGState.MG_COMMON_GAME_SETTLE: // 3. 游戏结算状态 + SudMGPMGState.MGCommonGameSettle mgCommonGameSettle = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonGameSettle.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonGameSettle(handle, mgCommonGameSettle); + } + break; + case SudMGPMGState.MG_COMMON_SELF_CLICK_JOIN_BTN: // 4. 加入游戏按钮点击状态 + SudMGPMGState.MGCommonSelfClickJoinBtn mgCommonSelfClickJoinBtn = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonSelfClickJoinBtn.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonSelfClickJoinBtn(handle, mgCommonSelfClickJoinBtn); + } + break; + case SudMGPMGState.MG_COMMON_SELF_CLICK_CANCEL_JOIN_BTN: // 5. 取消加入(退出)游戏按钮点击状态 + SudMGPMGState.MGCommonSelfClickCancelJoinBtn selfClickCancelJoinBtn = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonSelfClickCancelJoinBtn.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonSelfClickCancelJoinBtn(handle, selfClickCancelJoinBtn); + } + break; + case SudMGPMGState.MG_COMMON_SELF_CLICK_READY_BTN: // 6. 准备按钮点击状态 + SudMGPMGState.MGCommonSelfClickReadyBtn mgCommonSelfClickReadyBtn = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonSelfClickReadyBtn.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonSelfClickReadyBtn(handle, mgCommonSelfClickReadyBtn); + } + break; + case SudMGPMGState.MG_COMMON_SELF_CLICK_CANCEL_READY_BTN: // 7. 取消准备按钮点击状态 + SudMGPMGState.MGCommonSelfClickCancelReadyBtn mgCommonSelfClickCancelReadyBtn = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonSelfClickCancelReadyBtn.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonSelfClickCancelReadyBtn(handle, mgCommonSelfClickCancelReadyBtn); + } + break; + case SudMGPMGState.MG_COMMON_SELF_CLICK_START_BTN: // 8. 开始游戏按钮点击状态 + SudMGPMGState.MGCommonSelfClickStartBtn mgCommonSelfClickStartBtn = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonSelfClickStartBtn.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonSelfClickStartBtn(handle, mgCommonSelfClickStartBtn); + } + break; + case SudMGPMGState.MG_COMMON_SELF_CLICK_SHARE_BTN: // 9. 分享按钮点击状态 + SudMGPMGState.MGCommonSelfClickShareBtn mgCommonSelfClickShareBtn = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonSelfClickShareBtn.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonSelfClickShareBtn(handle, mgCommonSelfClickShareBtn); + } + break; + case SudMGPMGState.MG_COMMON_GAME_STATE: // 10. 游戏状态 + SudMGPMGState.MGCommonGameState mgCommonGameState = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonGameState.class); + sudFSMMGCache.onGameMGCommonGameState(mgCommonGameState); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonGameState(handle, mgCommonGameState); + } + break; + case SudMGPMGState.MG_COMMON_SELF_CLICK_GAME_SETTLE_CLOSE_BTN: // 11. 结算界面关闭按钮点击状态(2021-12-27新增) + SudMGPMGState.MGCommonSelfClickGameSettleCloseBtn mgCommonSelfClickGameSettleCloseBtn = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonSelfClickGameSettleCloseBtn.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonSelfClickGameSettleCloseBtn(handle, mgCommonSelfClickGameSettleCloseBtn); + } + break; + case SudMGPMGState.MG_COMMON_SELF_CLICK_GAME_SETTLE_AGAIN_BTN: // 12. 结算界面再来一局按钮点击状态(2021-12-27新增) + SudMGPMGState.MGCommonSelfClickGameSettleAgainBtn mgCommonSelfClickGameSettleAgainBtn = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonSelfClickGameSettleAgainBtn.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonSelfClickGameSettleAgainBtn(handle, mgCommonSelfClickGameSettleAgainBtn); + } + break; + case SudMGPMGState.MG_COMMON_GAME_SOUND_LIST: // 13. 游戏上报游戏中的声音列表(2021-12-30新增,现在只支持碰碰我最强) + SudMGPMGState.MGCommonGameSoundList mgCommonGameSoundList = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonGameSoundList.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonGameSoundList(handle, mgCommonGameSoundList); + } + break; + case SudMGPMGState.MG_COMMON_GAME_SOUND: // 14. 游通知app层播放声音(2021-12-30新增,现在只支持碰碰我最强) + SudMGPMGState.MGCommonGameSound mgCommonGameSound = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonGameSound.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonGameSound(handle, mgCommonGameSound); + } + break; + case SudMGPMGState.MG_COMMON_GAME_BG_MUSIC_STATE: // 15. 游戏通知app层播放背景音乐状态(2022-01-07新增,现在只支持碰碰我最强) + SudMGPMGState.MGCommonGameBgMusicState mgCommonGameBgMusicState = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonGameBgMusicState.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonGameBgMusicState(handle, mgCommonGameBgMusicState); + } + break; + case SudMGPMGState.MG_COMMON_GAME_SOUND_STATE: // 16. 游戏通知app层播放音效的状态(2022-01-07新增,现在只支持碰碰我最强) + SudMGPMGState.MGCommonGameSoundState mgCommonGameSoundState = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonGameSoundState.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonGameSoundState(handle, mgCommonGameSoundState); + } + break; + case SudMGPMGState.MG_COMMON_GAME_ASR: // 17. ASR状态(开启和关闭语音识别状态,v1.1.45.xx 版本新增) + SudMGPMGState.MGCommonGameASR mgCommonGameASR = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonGameASR.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonGameASR(handle, mgCommonGameASR); + } + break; + case SudMGPMGState.MG_COMMON_SELF_MICROPHONE: // 18. 麦克风状态(2022-02-08新增) + SudMGPMGState.MGCommonSelfMicrophone mgCommonSelfMicrophone = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonSelfMicrophone.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonSelfMicrophone(handle, mgCommonSelfMicrophone); + } + break; + case SudMGPMGState.MG_COMMON_SELF_HEADPHONE: // 19. 耳机(听筒,扬声器)状态(2022-02-08新增) + SudMGPMGState.MGCommonSelfHeadphone mgCommonSelfHeadphone = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonSelfHeadphone.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonSelfHeadphone(handle, mgCommonSelfHeadphone); + } + break; + case SudMGPMGState.MG_COMMON_APP_COMMON_SELF_X_RESP: // 20. App通用状态操作结果错误码(2022-05-10新增) + SudMGPMGState.MGCommonAPPCommonSelfXResp mgCommonAPPCommonSelfXResp = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonAPPCommonSelfXResp.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonAPPCommonSelfXResp(handle, mgCommonAPPCommonSelfXResp); + } + break; + case SudMGPMGState.MG_COMMON_GAME_ADD_AI_PLAYERS: // 21. 游戏通知app层添加陪玩机器人是否成功(2022-05-17新增) + SudMGPMGState.MGCommonGameAddAIPlayers mgCommonGameAddAIPlayers = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonGameAddAIPlayers.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonGameAddAIPlayers(handle, mgCommonGameAddAIPlayers); + } + break; + case SudMGPMGState.MG_COMMON_GAME_NETWORK_STATE: // 22. 游戏通知app层添当前网络连接状态(2022-06-21新增) + SudMGPMGState.MGCommonGameNetworkState mgCommonGameNetworkState = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonGameNetworkState.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonGameNetworkState(handle, mgCommonGameNetworkState); + } + break; + case SudMGPMGState.MG_COMMON_GAME_GET_SCORE: // 23. 游戏通知app获取积分 + SudMGPMGState.MGCommonGameGetScore mgCommonGameScore = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonGameGetScore.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonGameGetScore(handle, mgCommonGameScore); + } + break; + case SudMGPMGState.MG_COMMON_GAME_SET_SCORE: // 24. 游戏通知app带入积分 + SudMGPMGState.MGCommonGameSetScore mgCommonGameSetScore = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonGameSetScore.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonGameSetScore(handle, mgCommonGameSetScore); + } + break; + case SudMGPMGState.MG_COMMON_GAME_CREATE_ORDER: // 25. 创建订单 + SudMGPMGState.MGCommonGameCreateOrder mgCommonGameCreateOrder = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonGameCreateOrder.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonGameCreateOrder(handle, mgCommonGameCreateOrder); + } + break; + case SudMGPMGState.MG_COMMON_PLAYER_ROLE_ID: // 26. 游戏通知app玩家角色(仅对狼人杀有效) + SudMGPMGState.MGCommonPlayerRoleId mgCommonPlayerRoleId = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonPlayerRoleId.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonPlayerRoleId(handle, mgCommonPlayerRoleId); + } + break; + case SudMGPMGState.MG_COMMON_SELF_CLICK_POOP: // 27. 游戏通知app玩家被扔便便(你画我猜,你说我猜,友尽闯关有效) + SudMGPMGState.MGCommonSelfClickPoop mgCommonSelfClickPoop = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonSelfClickPoop.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonSelfClickPoop(handle, mgCommonSelfClickPoop); + } + break; + case SudMGPMGState.MG_COMMON_SELF_CLICK_GOOD: // 28. 游戏通知app玩家被点赞(你画我猜,你说我猜,友尽闯关有效) + SudMGPMGState.MGCommonSelfClickGood mgCommonSelfClickGood = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonSelfClickGood.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonSelfClickGood(handle, mgCommonSelfClickGood); + } + break; + case SudMGPMGState.MG_COMMON_GAME_FPS: // 29. 游戏通知app游戏FPS(仅对碰碰,多米诺骨牌,飞镖达人生效) + SudMGPMGState.MGCommonGameFps mgCommonGameFps = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonGameFps.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonGameFps(handle, mgCommonGameFps); + } + break; + case SudMGPMGState.MG_COMMON_ALERT: // 30. 游戏通知app游戏弹框 + SudMGPMGState.MGCommonAlert mgCommonAlert = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonAlert.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonAlert(handle, mgCommonAlert); + } + break; + case SudMGPMGState.MG_COMMON_WORST_TEAMMATE: // 31. 游戏通知app最坑队友(只支持友尽闯关) + SudMGPMGState.MGCommonWorstTeammate mgCommonWorstTeammate = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonWorstTeammate.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonWorstTeammate(handle, mgCommonWorstTeammate); + } + break; + case SudMGPMGState.MG_COMMON_GAME_OVER_TIP: // 32. 游戏通知app因玩家逃跑导致游戏结束(只支持友尽闯关) + SudMGPMGState.MGCommonGameOverTip mgCommonGameOverTip = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonGameOverTip.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonGameOverTip(handle, mgCommonGameOverTip); + } + break; + case SudMGPMGState.MG_COMMON_GAME_PLAYER_COLOR: // 33. 游戏通知app玩家颜色(只支持友尽闯关) + SudMGPMGState.MGCommonGamePlayerColor mgCommonGamePlayerColor = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonGamePlayerColor.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonGamePlayerColor(handle, mgCommonGamePlayerColor); + } + break; + case SudMGPMGState.MG_COMMON_GAME_PLAYER_ICON_POSITION: // 34. 游戏通知app玩家头像的坐标(只支持ludo) + SudMGPMGState.MGCommonGamePlayerIconPosition mgCommonGamePlayerIconPosition = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonGamePlayerIconPosition.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonGamePlayerIconPosition(handle, mgCommonGamePlayerIconPosition); + } + break; + case SudMGPMGState.MG_COMMON_SELF_CLICK_EXIT_GAME_BTN: // 35. 游戏通知app退出游戏(只支持teenpattipro 与 德州pro) + SudMGPMGState.MGCommonSelfClickExitGameBtn mgCommonSelfClickExitGameBtn = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonSelfClickExitGameBtn.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonSelfClickExitGameBtn(handle, mgCommonSelfClickExitGameBtn); + } + break; + case SudMGPMGState.MG_COMMON_GAME_IS_APP_CHIP: // 36. 游戏通知app是否要开启带入积分(只支持teenpattipro 与 德州pro) + SudMGPMGState.MGCommonGameIsAppChip mgCommonGameIsAppChip = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonGameIsAppChip.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonGameIsAppChip(handle, mgCommonGameIsAppChip); + } + break; + case SudMGPMGState.MG_COMMON_GAME_RULE: // 37. 游戏通知app当前游戏的设置信息(只支持德州pro,teenpatti pro) + SudMGPMGState.MGCommonGameRule mgCommonGameRule = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonGameRule.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonGameRule(handle, mgCommonGameRule); + } + break; + case SudMGPMGState.MG_COMMON_GAME_SETTINGS: // 38. 游戏通知app进行玩法设置(只支持德州pro,teenpatti pro) + SudMGPMGState.MGCommonGameSettings mgCommonGameSettings = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonGameSettings.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonGameSettings(handle, mgCommonGameSettings); + } + break; + case SudMGPMGState.MG_COMMON_GAME_MONEY_NOT_ENOUGH: // 39. 游戏通知app钱币不足(只支持德州pro,teenpatti pro) + SudMGPMGState.MGCommonGameMoneyNotEnough mgCommonGameMoneyNotEnough = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonGameMoneyNotEnough.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonGameMoneyNotEnough(handle, mgCommonGameMoneyNotEnough); + } + break; + case SudMGPMGState.MG_COMMON_GAME_UI_CUSTOM_CONFIG: // 40. 游戏通知app下发定制ui配置表(只支持ludo) + SudMGPMGState.MGCommonGameUiCustomConfig mgCommonGameUiCustomConfig = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonGameUiCustomConfig.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonGameUiCustomConfig(handle, mgCommonGameUiCustomConfig); + } + break; + case SudMGPMGState.MG_COMMON_SET_CLICK_RECT: // 41. 设置app提供给游戏可点击区域(赛车) + SudMGPMGState.MGCommonSetClickRect mgCommonSetClickRect = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonSetClickRect.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonSetClickRect(handle, mgCommonSetClickRect); + } + break; + case SudMGPMGState.MG_COMMON_USERS_INFO: // 42. 通知app提供对应uids列表玩家的数据(赛车) + SudMGPMGState.MGCommonUsersInfo mgCommonUsersInfo = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonUsersInfo.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonUsersInfo(handle, mgCommonUsersInfo); + } + break; + case SudMGPMGState.MG_COMMON_GAME_PREPARE_FINISH: // 43. 通知app游戏前期准备完成(赛车) + SudMGPMGState.MGCommonGamePrepareFinish mgCommonGamePrepareFinish = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonGamePrepareFinish.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonGamePrepareFinish(handle, mgCommonGamePrepareFinish); + } + break; + case SudMGPMGState.MG_COMMON_SHOW_GAME_SCENE: // 44. 通知app游戏主界面已显示(赛车) + SudMGPMGState.MGCommonShowGameScene mgCommonShowGameScene = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonShowGameScene.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonShowGameScene(handle, mgCommonShowGameScene); + } + break; + case SudMGPMGState.MG_COMMON_HIDE_GAME_SCENE: // 45. 通知app游戏主界面已隐藏(赛车) + SudMGPMGState.MGCommonHideGameScene mgCommonHideGameScene = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonHideGameScene.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonHideGameScene(handle, mgCommonHideGameScene); + } + break; + case SudMGPMGState.MG_COMMON_SELF_CLICK_GOLD_BTN: // 46. 通知app点击了游戏的金币按钮(赛车) + SudMGPMGState.MGCommonSelfClickGoldBtn mgCommonSelfClickGoldBtn = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonSelfClickGoldBtn.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonSelfClickGoldBtn(handle, mgCommonSelfClickGoldBtn); + } + break; + case SudMGPMGState.MG_COMMON_GAME_PIECE_ARRIVE_END: // 47. 通知app棋子到达终点(ludo) + SudMGPMGState.MGCommonGamePieceArriveEnd mgCommonGamePieceArriveEnd = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonGamePieceArriveEnd.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonGamePieceArriveEnd(handle, mgCommonGamePieceArriveEnd); + } + break; + case SudMGPMGState.MG_COMMON_GAME_PLAYER_MANAGED_STATE: // 48. 通知app玩家是否托管 + SudMGPMGState.MGCommonGamePlayerManagedState mgCommonGamePlayerManagedState = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonGamePlayerManagedState.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonGamePlayerManagedState(handle, mgCommonGamePlayerManagedState); + } + break; + case SudMGPMGState.MG_COMMON_GAME_SEND_BURST_WORD: // 49. 游戏向app发送爆词 + SudMGPMGState.MGCommonGameSendBurstWord mgCommonGameSendBurstWord = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonGameSendBurstWord.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonGameSendBurstWord(handle, mgCommonGameSendBurstWord); + } + break; + case SudMGPMGState.MG_COMMON_GAME_PLAYER_RANKS: // 50. 游戏向app发送玩家实时排名(只支持怪物消消乐) + SudMGPMGState.MGCommonGamePlayerRanks mgCommonGamePlayerRanks = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonGamePlayerRanks.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonGamePlayerRanks(handle, mgCommonGamePlayerRanks); + } + break; + case SudMGPMGState.MG_COMMON_GAME_PLAYER_PAIR_SINGULAR: // 51. 游戏向app发送玩家即时变化的单双牌(只支持okey101) + SudMGPMGState.MGCommonGamePlayerPairSingular mgCommonGamePlayerPairSingular = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonGamePlayerPairSingular.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonGamePlayerPairSingular(handle, mgCommonGamePlayerPairSingular); + } + break; + case SudMGPMGState.MG_COMMON_GAME_PLAYER_MONOPOLY_CARDS: // 52. 游戏向app发送获取玩家持有的道具卡(只支持大富翁) + SudMGPMGState.MGCommonGamePlayerMonopolyCards mgCommonGamePlayerMonopolyCards = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonGamePlayerMonopolyCards.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonGamePlayerMonopolyCards(handle, mgCommonGamePlayerMonopolyCards); + } + break; + case SudMGPMGState.MG_COMMON_GAME_PLAYER_SCORES: // 53. 游戏向app发送玩家实时积分(只支持怪物消消乐) + SudMGPMGState.MGCommonGamePlayerScores mgCommonGamePlayerScores = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonGamePlayerScores.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonGamePlayerScores(handle, mgCommonGamePlayerScores); + } + break; + case SudMGPMGState.MG_COMMON_DESTROY_GAME_SCENE: // 54. 游戏通知app销毁游戏(只支持部分概率类游戏) + SudMGPMGState.MGCommonDestroyGameScene mgCommonDestroyGameScene = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonDestroyGameScene.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonDestroyGameScene(handle, mgCommonDestroyGameScene); + } + break; + case SudMGPMGState.MG_COMMON_GAME_BILLIARDS_HIT_STATE: // 55. 游戏通知app击球状态(只支持桌球) + SudMGPMGState.MGCommonGameBilliardsHitState mgCommonGameBilliardsHitState = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonGameBilliardsHitState.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonGameBilliardsHitState(handle, mgCommonGameBilliardsHitState); + } + break; + case SudMGPMGState.MG_COMMON_GAME_PLAYER_PROPS_CARDS: // 56. 游戏向app发送获取玩家持有的指定点数道具卡(只支持飞行棋) + SudMGPMGState.MGCommonGamePlayerPropsCards mgCommonGamePlayerPropsCards = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonGamePlayerPropsCards.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonGamePlayerPropsCards(handle, mgCommonGamePlayerPropsCards); + } + break; + case SudMGPMGState.MG_COMMON_GAME_DISCO_ACTION: // 1. 元宇宙砂砂舞指令回调 + SudMGPMGState.MGCommonGameDiscoAction mgCommonGameDiscoAction = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonGameDiscoAction.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonGameDiscoAction(handle, mgCommonGameDiscoAction); + } + break; + case SudMGPMGState.MG_COMMON_GAME_DISCO_ACTION_END: // 2. 元宇宙砂砂舞指令动作结束通知 + SudMGPMGState.MGCommonGameDiscoActionEnd mgCommonGameDiscoActionEnd = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonGameDiscoActionEnd.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCommonGameDiscoActionEnd(handle, mgCommonGameDiscoActionEnd); + } + break; + case SudMGPMGState.MG_CUSTOM_ROCKET_CONFIG: // 1. 礼物配置文件(火箭) + SudMGPMGState.MGCustomRocketConfig mgCustomRocketConfig = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCustomRocketConfig.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCustomRocketConfig(handle, mgCustomRocketConfig); + } + break; + case SudMGPMGState.MG_CUSTOM_ROCKET_MODEL_LIST: // 2. 拥有模型列表(火箭) + SudMGPMGState.MGCustomRocketModelList mgCustomRocketModelList = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCustomRocketModelList.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCustomRocketModelList(handle, mgCustomRocketModelList); + } + break; + case SudMGPMGState.MG_CUSTOM_ROCKET_COMPONENT_LIST: // 3. 拥有组件列表(火箭) + SudMGPMGState.MGCustomRocketComponentList mgCustomRocketComponentList = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCustomRocketComponentList.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCustomRocketComponentList(handle, mgCustomRocketComponentList); + } + break; + case SudMGPMGState.MG_CUSTOM_ROCKET_USER_INFO: // 4. 获取用户信息(火箭) + SudMGPMGState.MGCustomRocketUserInfo mgCustomRocketUserInfo = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCustomRocketUserInfo.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCustomRocketUserInfo(handle, mgCustomRocketUserInfo); + } + break; + case SudMGPMGState.MG_CUSTOM_ROCKET_ORDER_RECORD_LIST: // 5. 订单记录列表(火箭) + SudMGPMGState.MGCustomRocketOrderRecordList mgCustomRocketOrderRecordList = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCustomRocketOrderRecordList.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCustomRocketOrderRecordList(handle, mgCustomRocketOrderRecordList); + } + break; + case SudMGPMGState.MG_CUSTOM_ROCKET_ROOM_RECORD_LIST: // 6. 展馆内列表(火箭) + SudMGPMGState.MGCustomRocketRoomRecordList mgCustomRocketRoomRecordList = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCustomRocketRoomRecordList.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCustomRocketRoomRecordList(handle, mgCustomRocketRoomRecordList); + } + break; + case SudMGPMGState.MG_CUSTOM_ROCKET_USER_RECORD_LIST: // 7. 展馆内玩家送出记录(火箭) + SudMGPMGState.MGCustomRocketUserRecordList mgCustomRocketUserRecordList = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCustomRocketUserRecordList.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCustomRocketUserRecordList(handle, mgCustomRocketUserRecordList); + } + break; + case SudMGPMGState.MG_CUSTOM_ROCKET_SET_DEFAULT_MODEL: // 8. 设置默认模型(火箭) + SudMGPMGState.MGCustomRocketSetDefaultModel mgCustomRocketSetDefaultSeat = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCustomRocketSetDefaultModel.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCustomRocketSetDefaultModel(handle, mgCustomRocketSetDefaultSeat); + } + break; + case SudMGPMGState.MG_CUSTOM_ROCKET_DYNAMIC_FIRE_PRICE: // 9. 动态计算一键发送价格(火箭) + SudMGPMGState.MGCustomRocketDynamicFirePrice mgCustomRocketDynamicFirePrice = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCustomRocketDynamicFirePrice.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCustomRocketDynamicFirePrice(handle, mgCustomRocketDynamicFirePrice); + } + break; + case SudMGPMGState.MG_CUSTOM_ROCKET_FIRE_MODEL: // 10. 一键发送(火箭) + SudMGPMGState.MGCustomRocketFireModel mGCustomRocketFireModel = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCustomRocketFireModel.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCustomRocketFireModel(handle, mGCustomRocketFireModel); + } + break; + case SudMGPMGState.MG_CUSTOM_ROCKET_CREATE_MODEL: // 11. 新组装模型(火箭) + SudMGPMGState.MGCustomRocketCreateModel mgCustomRocketCreateModel = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCustomRocketCreateModel.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCustomRocketCreateModel(handle, mgCustomRocketCreateModel); + } + break; + case SudMGPMGState.MG_CUSTOM_ROCKET_REPLACE_COMPONENT: // 12. 模型更换组件(火箭) + SudMGPMGState.MGCustomRocketReplaceComponent mgCustomRocketReplaceComponent = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCustomRocketReplaceComponent.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCustomRocketReplaceComponent(handle, mgCustomRocketReplaceComponent); + } + break; + case SudMGPMGState.MG_CUSTOM_ROCKET_BUY_COMPONENT: // 13. 购买组件(火箭) + SudMGPMGState.MGCustomRocketBuyComponent mgCustomRocketBuyComponent = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCustomRocketBuyComponent.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCustomRocketBuyComponent(handle, mgCustomRocketBuyComponent); + } + break; + case SudMGPMGState.MG_CUSTOM_ROCKET_PLAY_EFFECT_START: // 14. 播放效果开始(火箭) + SudMGPMGState.MGCustomRocketPlayEffectStart mgCustomRocketPlayEffectStart = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCustomRocketPlayEffectStart.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCustomRocketPlayEffectStart(handle, mgCustomRocketPlayEffectStart); + } + break; + case SudMGPMGState.MG_CUSTOM_ROCKET_PLAY_EFFECT_FINISH: // 15. 播放效果完成(火箭) + SudMGPMGState.MGCustomRocketPlayEffectFinish mgCustomRocketPlayEffectFinish = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCustomRocketPlayEffectFinish.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCustomRocketPlayEffectFinish(handle, mgCustomRocketPlayEffectFinish); + } + break; + case SudMGPMGState.MG_CUSTOM_ROCKET_VERIFY_SIGN: // 16. 验证签名合规(火箭) + SudMGPMGState.MGCustomRocketVerifySign mgCustomRocketVerifySign = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCustomRocketVerifySign.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCustomRocketVerifySign(handle, mgCustomRocketVerifySign); + } + break; + case SudMGPMGState.MG_CUSTOM_ROCKET_UPLOAD_MODEL_ICON: // 17. 上传icon(火箭) + SudMGPMGState.MGCustomRocketUploadModelIcon mgCustomRocketUploadModelIcon = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCustomRocketUploadModelIcon.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCustomRocketUploadModelIcon(handle, mgCustomRocketUploadModelIcon); + } + break; + case SudMGPMGState.MG_CUSTOM_ROCKET_PREPARE_FINISH: // 18. 前期准备完成(火箭) + SudMGPMGState.MGCustomRocketPrepareFinish mgCustomRocketPrepareFinish = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCustomRocketPrepareFinish.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCustomRocketPrepareFinish(handle, mgCustomRocketPrepareFinish); + } + break; + case SudMGPMGState.MG_CUSTOM_ROCKET_SHOW_GAME_SCENE: // 19. 火箭主界面已显示(火箭) + SudMGPMGState.MGCustomRocketShowGameScene mgCustomRocketShowGameScene = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCustomRocketShowGameScene.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCustomRocketShowGameScene(handle, mgCustomRocketShowGameScene); + } + break; + case SudMGPMGState.MG_CUSTOM_ROCKET_HIDE_GAME_SCENE: // 20. 火箭主界面已隐藏(火箭) + SudMGPMGState.MGCustomRocketHideGameScene mgCustomRocketHideGameScene = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCustomRocketHideGameScene.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCustomRocketHideGameScene(handle, mgCustomRocketHideGameScene); + } + break; + case SudMGPMGState.MG_CUSTOM_ROCKET_CLICK_LOCK_COMPONENT: // 21. 点击锁住组件(火箭) + SudMGPMGState.MGCustomRocketClickLockComponent mgCustomRocketClickLockComponent = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCustomRocketClickLockComponent.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCustomRocketClickLockComponent(handle, mgCustomRocketClickLockComponent); + } + break; + case SudMGPMGState.MG_CUSTOM_ROCKET_FLY_CLICK: // 22. 火箭效果飞行点击(火箭) + SudMGPMGState.MGCustomRocketFlyClick mgCustomRocketFlyClick = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCustomRocketFlyClick.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCustomRocketFlyClick(handle, mgCustomRocketFlyClick); + } + break; + case SudMGPMGState.MG_CUSTOM_ROCKET_FLY_END: // 23. 火箭效果飞行结束(火箭) + SudMGPMGState.MGCustomRocketFlyEnd mgCustomRocketFlyEnd = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCustomRocketFlyEnd.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCustomRocketFlyEnd(handle, mgCustomRocketFlyEnd); + } + break; + case SudMGPMGState.MG_CUSTOM_ROCKET_SET_CLICK_RECT: // 24. 设置点击区域(火箭) + SudMGPMGState.MGCustomRocketSetClickRect mgCustomRocketSetClickRect = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCustomRocketSetClickRect.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCustomRocketSetClickRect(handle, mgCustomRocketSetClickRect); + } + break; + case SudMGPMGState.MG_CUSTOM_ROCKET_SAVE_SIGN_COLOR: // 25. 颜色和签名自定义改到装配间的模式,保存颜色或签名 模型 + SudMGPMGState.MGCustomRocketSaveSignColor mgCustomRocketSaveSignColor = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCustomRocketSaveSignColor.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCustomRocketSaveSignColor(handle, mgCustomRocketSaveSignColor); + } + break; + case SudMGPMGState.MG_BASEBALL_DEFUALT_STATE: // 1. 设置界面默认状态(棒球) + SudMGPMGState.MGBaseballDefaultState mgBaseballDefaultState = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGBaseballDefaultState.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGBaseballDefaultState(handle, mgBaseballDefaultState); + } + break; + case SudMGPMGState.MG_BASEBALL_PREPARE_FINISH: // 2. 前期准备完成(棒球) + SudMGPMGState.MGBaseballPrepareFinish mgBaseballPrepareFinish = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGBaseballPrepareFinish.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGBaseballPrepareFinish(handle, mgBaseballPrepareFinish); + } + break; + case SudMGPMGState.MG_BASEBALL_SHOW_GAME_SCENE: // 3. 主界面已显示(棒球) + SudMGPMGState.MGBaseballShowGameScene mgBaseballShowGameScene = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGBaseballShowGameScene.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGBaseballShowGameScene(handle, mgBaseballShowGameScene); + } + break; + case SudMGPMGState.MG_BASEBALL_HIDE_GAME_SCENE: // 4. 主界面已隐藏(棒球) + SudMGPMGState.MGBaseballHideGameScene mgBaseballHideGameScene = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGBaseballHideGameScene.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGBaseballHideGameScene(handle, mgBaseballHideGameScene); + } + break; + case SudMGPMGState.MG_BASEBALL_RANKING: // 5. 查询排行榜数据(棒球) + SudMGPMGState.MGBaseballRanking mgBaseballRanking = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGBaseballRanking.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGBaseballRanking(handle, mgBaseballRanking); + } + break; + case SudMGPMGState.MG_BASEBALL_MY_RANKING: // 6. 查询我的排名(棒球) + SudMGPMGState.MGBaseballMyRanking mgBaseballMyRanking = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGBaseballMyRanking.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGBaseballMyRanking(handle, mgBaseballMyRanking); + } + break; + case SudMGPMGState.MG_BASEBALL_RANGE_INFO: // 7. 查询当前距离我的前后玩家数据(棒球) + SudMGPMGState.MGBaseballRangeInfo mgBaseballRangeInfo = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGBaseballRangeInfo.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGBaseballRangeInfo(handle, mgBaseballRangeInfo); + } + break; + case SudMGPMGState.MG_BASEBALL_SET_CLICK_RECT: // 8. 设置app提供给游戏可点击区域(棒球) + SudMGPMGState.MGBaseballSetClickRect mgBaseballSetClickRect = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGBaseballSetClickRect.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGBaseballSetClickRect(handle, mgBaseballSetClickRect); + } + break; + case SudMGPMGState.MG_BASEBALL_TEXT_CONFIG: // 9. 获取文本配置数据(棒球) + SudMGPMGState.MGBaseballTextConfig mgBaseballTextConfig = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGBaseballTextConfig.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGBaseballTextConfig(handle, mgBaseballTextConfig); + } + break; + case SudMGPMGState.MG_BASEBALL_SEND_DISTANCE: // 10. 球落地, 通知距离(棒球) + SudMGPMGState.MGBaseballSendDistance mgBaseballSendDistance = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGBaseballSendDistance.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGBaseballSendDistance(handle, mgBaseballSendDistance); + } + break; + case SudMGPMGState.MG_CUSTOM_CR_ROOM_INIT_DATA: // 1. 请求房间数据 + SudMGPMGState.MGCustomCrRoomInitData mgCustomCrRoomInitData = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCustomCrRoomInitData.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCustomCrRoomInitData(handle, mgCustomCrRoomInitData); + } + break; + case SudMGPMGState.MG_CUSTOM_CR_CLICK_SEAT: // 2. 点击主播位或老板位通知 + SudMGPMGState.MGCustomCrClickSeat mgCustomCrClickSeat = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCustomCrClickSeat.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onGameMGCustomCrClickSeat(handle, mgCustomCrClickSeat); + } + break; + default: + ISudFSMStateHandleUtils.handleSuccess(handle); + break; + } + } + + /** + * 游戏玩家状态变化 + * APP接入方需要调用handle.success或handle.fail + * + * @param handle 操作 + * @param userId 用户id + * @param state 状态命令 + * @param dataJson 状态值 + */ + @Override + public void onPlayerStateChange(ISudFSMStateHandle handle, String userId, String state, String dataJson) { + SudFSMMGListener listener = sudFSMMGListener; + if (listener != null && listener.onPlayerStateChange(handle, userId, state, dataJson)) { + return; + } + switch (state) { + case SudMGPMGState.MG_COMMON_PLAYER_IN: // 1.加入状态(已修改) + SudMGPMGState.MGCommonPlayerIn mgCommonPlayerIn = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonPlayerIn.class); + sudFSMMGCache.onPlayerMGCommonPlayerIn(userId, mgCommonPlayerIn); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onPlayerMGCommonPlayerIn(handle, userId, mgCommonPlayerIn); + } + break; + case SudMGPMGState.MG_COMMON_PLAYER_READY: // 2.准备状态(已修改) + SudMGPMGState.MGCommonPlayerReady mgCommonPlayerReady = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonPlayerReady.class); + sudFSMMGCache.onPlayerMGCommonPlayerReady(userId, mgCommonPlayerReady); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onPlayerMGCommonPlayerReady(handle, userId, mgCommonPlayerReady); + } + break; + case SudMGPMGState.MG_COMMON_PLAYER_CAPTAIN: // 3.队长状态(已修改) + SudMGPMGState.MGCommonPlayerCaptain mgCommonPlayerCaptain = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonPlayerCaptain.class); + sudFSMMGCache.onPlayerMGCommonPlayerCaptain(userId, mgCommonPlayerCaptain); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onPlayerMGCommonPlayerCaptain(handle, userId, mgCommonPlayerCaptain); + } + break; + case SudMGPMGState.MG_COMMON_PLAYER_PLAYING: // 4.游戏状态(已修改) + SudMGPMGState.MGCommonPlayerPlaying mgCommonPlayerPlaying = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonPlayerPlaying.class); + sudFSMMGCache.onPlayerMGCommonPlayerPlaying(userId, mgCommonPlayerPlaying); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onPlayerMGCommonPlayerPlaying(handle, userId, mgCommonPlayerPlaying); + } + break; + case SudMGPMGState.MG_COMMON_PLAYER_ONLINE: // 5.玩家在线状态 + SudMGPMGState.MGCommonPlayerOnline mgCommonPlayerOnline = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonPlayerOnline.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onPlayerMGCommonPlayerOnline(handle, userId, mgCommonPlayerOnline); + } + break; + case SudMGPMGState.MG_COMMON_PLAYER_CHANGE_SEAT: // 6.玩家换游戏位状态 + SudMGPMGState.MGCommonPlayerChangeSeat mgCommonPlayerChangeSeat = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonPlayerChangeSeat.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onPlayerMGCommonPlayerChangeSeat(handle, userId, mgCommonPlayerChangeSeat); + } + break; + case SudMGPMGState.MG_COMMON_SELF_CLICK_GAME_PLAYER_ICON: // 7. 游戏通知app点击玩家头像 + SudMGPMGState.MGCommonSelfClickGamePlayerIcon mgCommonSelfClickGamePlayerIcon = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonSelfClickGamePlayerIcon.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onPlayerMGCommonSelfClickGamePlayerIcon(handle, userId, mgCommonSelfClickGamePlayerIcon); + } + break; + case SudMGPMGState.MG_COMMON_SELF_DIE_STATUS: // 8. 游戏通知app玩家死亡状态(2022-04-24新增) + SudMGPMGState.MGCommonSelfDieStatus mgCommonSelfDieStatus = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonSelfDieStatus.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onPlayerMGCommonSelfDieStatus(handle, userId, mgCommonSelfDieStatus); + } + break; + case SudMGPMGState.MG_COMMON_SELF_TURN_STATUS: // 9. 游戏通知app轮到玩家出手状态(2022-04-24新增) + SudMGPMGState.MGCommonSelfTurnStatus mgCommonSelfTurnStatus = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonSelfTurnStatus.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onPlayerMGCommonSelfTurnStatus(handle, userId, mgCommonSelfTurnStatus); + } + break; + case SudMGPMGState.MG_COMMON_SELF_SELECT_STATUS: // 10. 游戏通知app玩家选择状态(2022-04-24新增) + SudMGPMGState.MGCommonSelfSelectStatus mgCommonSelfSelectStatus = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonSelfSelectStatus.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onPlayerMGCommonSelfSelectStatus(handle, userId, mgCommonSelfSelectStatus); + } + break; + case SudMGPMGState.MG_COMMON_GAME_COUNTDOWN_TIME: // 11. 游戏通知app层当前游戏剩余时间(2022-05-23新增,目前UMO生效) + SudMGPMGState.MGCommonGameCountdownTime mgCommonGameCountdownTime = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonGameCountdownTime.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onPlayerMGCommonGameCountdownTime(handle, userId, mgCommonGameCountdownTime); + } + break; + case SudMGPMGState.MG_COMMON_SELF_OB_STATUS: // 12. 游戏通知app层当前玩家死亡后变成ob视角(2022-08-23新增,目前狼人杀生效) + SudMGPMGState.MGCommonSelfObStatus mgCommonSelfObStatus = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonSelfObStatus.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onPlayerMGCommonSelfObStatus(handle, userId, mgCommonSelfObStatus); + } + break; + case SudMGPMGState.MG_DG_SELECTING: // 1. 选词中状态(已修改) + SudMGPMGState.MGDGSelecting mgdgSelecting = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGDGSelecting.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onPlayerMGDGSelecting(handle, userId, mgdgSelecting); + } + break; + case SudMGPMGState.MG_DG_PAINTING: // 2. 作画中状态(已修改) + SudMGPMGState.MGDGPainting mgdgPainting = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGDGPainting.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onPlayerMGDGPainting(handle, userId, mgdgPainting); + } + break; + case SudMGPMGState.MG_DG_ERRORANSWER: // 3. 显示错误答案状态(已修改) + SudMGPMGState.MGDGErroranswer mgdgErroranswer = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGDGErroranswer.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onPlayerMGDGErroranswer(handle, userId, mgdgErroranswer); + } + break; + case SudMGPMGState.MG_DG_TOTALSCORE: // 4. 显示总积分状态(已修改) + SudMGPMGState.MGDGTotalscore mgdgTotalscore = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGDGTotalscore.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onPlayerMGDGTotalscore(handle, userId, mgdgTotalscore); + } + break; + case SudMGPMGState.MG_DG_SCORE: // 5. 本次获得积分状态(已修改) + SudMGPMGState.MGDGScore mgdgScore = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGDGScore.class); + if (listener == null) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } else { + listener.onPlayerMGDGScore(handle, userId, mgdgScore); + } + break; + default: + ISudFSMStateHandleUtils.handleSuccess(handle); + break; + } + } + + /** 获取队长userId */ + public String getCaptainUserId() { + return sudFSMMGCache.getCaptainUserId(); + } + + // 返回该玩家是否正在游戏中 + public boolean playerIsPlaying(String userId) { + return sudFSMMGCache.playerIsPlaying(userId); + } + + // 返回该玩家是否已准备 + public boolean playerIsReady(String userId) { + return sudFSMMGCache.playerIsReady(userId); + } + + // 返回该玩家是否已加入了游戏 + public boolean playerIsIn(String userId) { + return sudFSMMGCache.playerIsIn(userId); + } + + // 获取当前游戏中的人数 + public int getPlayerInNumber() { + return sudFSMMGCache.getPlayerInNumber(); + } + + // 是否数字炸弹 + public boolean isHitBomb() { + return sudFSMMGCache.isHitBomb(); + } + + // 销毁游戏 + public void destroyMG() { + sudFSMMGCache.destroyMG(); + sudFSMMGListener = null; + } + + /** + * 返回当前游戏的状态,数值参数{@link SudMGPMGState.MGCommonGameState} + */ + public int getGameState() { + return sudFSMMGCache.getGameState(); + } + + /** 获取缓存的状态 */ + public SudFSMMGCache getSudFSMMGCache() { + return sudFSMMGCache; + } + +} diff --git a/core/src/model_sud_wrapper/java/com/chwl/core/sud/decorator/SudFSMMGListener.java b/core/src/model_sud_wrapper/java/com/chwl/core/sud/decorator/SudFSMMGListener.java new file mode 100644 index 000000000..1a0c937d2 --- /dev/null +++ b/core/src/model_sud_wrapper/java/com/chwl/core/sud/decorator/SudFSMMGListener.java @@ -0,0 +1,1154 @@ +/* + * Copyright © Sud.Tech + * https://sud.tech + */ + +package com.chwl.core.sud.decorator; + +import com.chwl.core.sud.state.SudMGPMGState; +import com.chwl.core.sud.utils.ISudFSMStateHandleUtils; +import tech.sud.mgp.core.ISudFSMStateHandle; + +/** + * {@link SudFSMMGDecorator} 回调定义 + * {@link SudFSMMGDecorator} Callback definition. + */ +public interface SudFSMMGListener { + + /** + * 游戏日志回调 + * 最低版本:v1.1.30.xx + *

+ * Game log + * Minimum version: v1.1.30.xx + */ + default void onGameLog(String str) { + } + + /** + * 游戏加载进度回调 + * Game loading progress + * + * @param stage 阶段:start=1,loading=2,end=3 + * Stage: start=1, loading=2, end=3 + * @param retCode 错误码:0成功 + * Error code: 0 for success + * @param progress 进度:[0, 100] + * Progress: [0, 100] + */ + default void onGameLoadingProgress(int stage, int retCode, int progress) { + } + + /** + * 游戏开始的回调 + * 最低版本:v1.1.30.xx + *

+ * Callback for game start + * Minimum version: v1.1.30.xx + */ + void onGameStarted(); + + /** + * 游戏销毁的回调 + * 最低版本:v1.1.30.xx + *

+ * Callback for game destruction + * Minimum version: v1.1.30.xx + */ + void onGameDestroyed(); + + /** + * Code过期的回调 + * APP接入方需要调用handle.success或handle.fail + *

+ * Callback for expired code + * The APP integration partner needs to call handle.success or handle.fail + * + * @param dataJson {"code":"value"} + */ + void onExpireCode(ISudFSMStateHandle handle, String dataJson); + + /** + * 获取游戏View信息的回调 + * APP接入方需要调用handle.success或handle.fail + *

+ * Callback for obtaining game View information + * The APP integration partner needs to call handle.success or handle.fail + */ + void onGetGameViewInfo(ISudFSMStateHandle handle, String dataJson); + + /** + * 获取游戏配置的回调 + * APP接入方需要调用handle.success或handle.fail + *

+ * Callback for obtaining game configuration + * The APP integration partner needs to call handle.success or handle.fail + */ + void onGetGameCfg(ISudFSMStateHandle handle, String dataJson); + + // region 游戏回调APP 通用状态 English: Game callback to APP for general state. + // 参考文档:https://docs.sud.tech/zh-CN/app/Client/MGFSM/CommonStateGame.html + // Reference documentation:https://docs.sud.tech/en-US/app/Client/MGFSM/CommonStateGame.html + + /** + * 1.游戏公屏消息 + * 1. Public screen messages (modified) + * mg_common_public_message + */ + default void onGameMGCommonPublicMessage(ISudFSMStateHandle handle, SudMGPMGState.MGCommonPublicMessage model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 2. 关键词状态 + * 2. Keyword + * mg_common_key_word_to_hit + */ + default void onGameMGCommonKeyWordToHit(ISudFSMStateHandle handle, SudMGPMGState.MGCommonKeyWordToHit model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 3. 游戏结算状态 + * 3. Post-game + * mg_common_game_settle + */ + default void onGameMGCommonGameSettle(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameSettle model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 4. 加入游戏按钮点击状态 + * 4. Tapping the Join button + * mg_common_self_click_join_btn + */ + default void onGameMGCommonSelfClickJoinBtn(ISudFSMStateHandle handle, SudMGPMGState.MGCommonSelfClickJoinBtn model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 5. 取消加入(退出)游戏按钮点击状态 + * 5. Tapping the Cancel Join button + * mg_common_self_click_cancel_join_btn + */ + default void onGameMGCommonSelfClickCancelJoinBtn(ISudFSMStateHandle handle, SudMGPMGState.MGCommonSelfClickCancelJoinBtn model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 6. 准备按钮点击状态 + * 6. Tapping the Ready button + * mg_common_self_click_ready_btn + */ + default void onGameMGCommonSelfClickReadyBtn(ISudFSMStateHandle handle, SudMGPMGState.MGCommonSelfClickReadyBtn model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 7. 取消准备按钮点击状态 + * 7. Tapping the Cancel Ready button + * mg_common_self_click_cancel_ready_btn + */ + default void onGameMGCommonSelfClickCancelReadyBtn(ISudFSMStateHandle handle, SudMGPMGState.MGCommonSelfClickCancelReadyBtn model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 8. 开始游戏按钮点击状态 + * 8. Tapping the Start button + * mg_common_self_click_start_btn + */ + default void onGameMGCommonSelfClickStartBtn(ISudFSMStateHandle handle, SudMGPMGState.MGCommonSelfClickStartBtn model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 9. 分享按钮点击状态 + * 9. Tapping the Share button + * mg_common_self_click_share_btn + */ + default void onGameMGCommonSelfClickShareBtn(ISudFSMStateHandle handle, SudMGPMGState.MGCommonSelfClickShareBtn model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 10. 游戏状态 + * 10. Gaming + * mg_common_game_state + */ + default void onGameMGCommonGameState(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameState model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 11. 结算界面关闭按钮点击状态(2021-12-27新增) + * 11. Tapping the Close button on the post-game screen (added on December 27, 2021) + * mg_common_self_click_game_settle_close_btn + */ + default void onGameMGCommonSelfClickGameSettleCloseBtn(ISudFSMStateHandle handle, SudMGPMGState.MGCommonSelfClickGameSettleCloseBtn model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 12. 结算界面再来一局按钮点击状态(2021-12-27新增) + * 12. Tapping the Play Again button on the post-game screen (added on December 27, 2021) + * mg_common_self_click_game_settle_again_btn + */ + default void onGameMGCommonSelfClickGameSettleAgainBtn(ISudFSMStateHandle handle, SudMGPMGState.MGCommonSelfClickGameSettleAgainBtn model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 13. 游戏上报游戏中的声音列表(2021-12-30新增,现在只支持碰碰我最强) + * 13. Reporting the sound list in a game (added on December 30, 2021) + * mg_common_game_sound_list + */ + default void onGameMGCommonGameSoundList(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameSoundList model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 14. 游通知app层播放声音(2021-12-30新增,现在只支持碰碰我最强) + * 14. Notifying the app layer of playing sound (added on December 30, 2021) + * mg_common_game_sound + */ + default void onGameMGCommonGameSound(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameSound model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 15. 游戏通知app层播放背景音乐状态(2022-01-07新增,现在只支持碰碰我最强) + * 15. Notifying the app layer of playing background music (added on January 7, 2022) + * mg_common_game_bg_music_state + */ + default void onGameMGCommonGameBgMusicState(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameBgMusicState model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 16. 游戏通知app层播放音效的状态(2022-01-07新增,现在只支持碰碰我最强) + * 16. Notifying the app layer of playing sound effect (added on January 7, 2022) + * mg_common_game_sound_state + */ + default void onGameMGCommonGameSoundState(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameSoundState model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 17. ASR状态(开启和关闭语音识别状态,v1.1.45.xx 版本新增) + * 17. ASR (enabling/disabling voice recognition, added in SudMGP V1.1.45.xx) + * mg_common_game_asr + */ + default void onGameMGCommonGameASR(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameASR model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 18. 麦克风状态(2022-02-08新增) + * 18. Microphone (added on March 4, 2022) + * mg_common_self_microphone + */ + default void onGameMGCommonSelfMicrophone(ISudFSMStateHandle handle, SudMGPMGState.MGCommonSelfMicrophone model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 19. 耳机(听筒,扬声器)状态(2022-02-08新增) + * 19. Headphone (receiver and speaker) (added on March 4, 2022) + * mg_common_self_headphone + */ + default void onGameMGCommonSelfHeadphone(ISudFSMStateHandle handle, SudMGPMGState.MGCommonSelfHeadphone model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 20. App通用状态操作结果错误码(2022-05-10新增) + * 20. app_common_self_x response error code(added on May 10, 2022) + * mg_common_app_common_self_x_resp + */ + default void onGameMGCommonAPPCommonSelfXResp(ISudFSMStateHandle handle, SudMGPMGState.MGCommonAPPCommonSelfXResp model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 21. 游戏通知app层添加陪玩机器人是否成功(2022-05-17新增) + * 21. Whether the game notifies the app layer of the success of adding the robot players (added on May 17, 2022) + * mg_common_game_add_ai_players + */ + default void onGameMGCommonGameAddAIPlayers(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameAddAIPlayers model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 22. 游戏通知app层添当前网络连接状态(2022-06-21新增) + * 22. The game notifies the app layer to add the current network connection status (added on June 21, 2022) + * mg_common_game_network_state + */ + default void onGameMGCommonGameNetworkState(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameNetworkState model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 23. 游戏通知app获取积分 + * 23. Game notification app to get score + * mg_common_game_score + */ + default void onGameMGCommonGameGetScore(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameGetScore model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 24. 游戏通知app带入积分 + * 24. score brought in by game notification app + * mg_common_game_set_score + */ + default void onGameMGCommonGameSetScore(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameSetScore model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 25. 创建订单 + * 25. create order in game + * mg_common_game_create_order + */ + default void onGameMGCommonGameCreateOrder(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameCreateOrder model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 26. 游戏通知app玩家角色(仅对狼人杀有效) + * 26. Game notification app player role (only valid for werewolf killing) + * mg_common_player_role_id + */ + default void onGameMGCommonPlayerRoleId(ISudFSMStateHandle handle, SudMGPMGState.MGCommonPlayerRoleId model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 27. 游戏通知app玩家被扔便便(你画我猜,你说我猜,友尽闯关有效) + * 27. The game notifies app players that they are thrown poop (only valid for you to draw, I guess) + * mg_common_self_click_poop + */ + default void onGameMGCommonSelfClickPoop(ISudFSMStateHandle handle, SudMGPMGState.MGCommonSelfClickPoop model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 28. 游戏通知app玩家被点赞(你画我猜,你说我猜,友尽闯关有效) + * 28. The game notifies app players that they are liked (only valid for you to draw and guess) + * mg_common_self_click_good + */ + default void onGameMGCommonSelfClickGood(ISudFSMStateHandle handle, SudMGPMGState.MGCommonSelfClickGood model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 29. 游戏通知app游戏FPS(仅对碰碰,多米诺骨牌,飞镖达人生效) + * 29. Game Notification App Game FPS (Only effective for bumper, Dominoes, and knifeMasters) + * mg_common_game_fps + */ + default void onGameMGCommonGameFps(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameFps model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 30. 游戏通知app游戏弹框 + * 30. Game Notification App Game Pop-up + * mg_common_alert + */ + default void onGameMGCommonAlert(ISudFSMStateHandle handle, SudMGPMGState.MGCommonAlert model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 31. 游戏通知app最坑队友(只支持友尽闯关) + * 31. Game Notification App: Most Annoying Teammate (Supports only pickpark) + * mg_common_worst_teammate + */ + default void onGameMGCommonWorstTeammate(ISudFSMStateHandle handle, SudMGPMGState.MGCommonWorstTeammate model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 32. 游戏通知app因玩家逃跑导致游戏结束(只支持友尽闯关) + * 32. Game Notification App: Game Ended Due to Player Quitting(Supports only pickpark) + * mg_common_game_over_tip + */ + default void onGameMGCommonGameOverTip(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameOverTip model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 33. 游戏通知app玩家颜色(只支持友尽闯关) + * 33. Game Notification App: Player Color(Supports pickpark and ludo) + * mg_common_game_player_color + */ + default void onGameMGCommonGamePlayerColor(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGamePlayerColor model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 34. 游戏通知app玩家头像的坐标(只支持ludo) + * 34. Game Notification App: Player Avatar Coordinates (ludo, knife, umo, dominos, teenpatti, texasholdem, drawAndGuess) + * mg_common_game_player_icon_position + */ + default void onGameMGCommonGamePlayerIconPosition(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGamePlayerIconPosition model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 35. 游戏通知app退出游戏(只支持teenpattipro 与 德州pro) + * 35. Game Notification App: click exit game button (Only supports Teen Patti Pro and Texas Hold'em Pro) + * mg_common_self_click_exit_game_btn + */ + default void onGameMGCommonSelfClickExitGameBtn(ISudFSMStateHandle handle, SudMGPMGState.MGCommonSelfClickExitGameBtn model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 36. 游戏通知app是否要开启带入积分(只支持teenpattipro 与 德州pro) + * 36. Game Notification App: Enable Buy-in Points (Only supports Teen Patti Pro and Texas Hold'em Pro) + * mg_common_game_is_app_chip + */ + default void onGameMGCommonGameIsAppChip(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameIsAppChip model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 37. 游戏通知app当前游戏的设置信息(只支持德州pro,teenpatti pro) + * 37. Game Notification App: Current Game Settings Information (Only supports Texas Hold'em Pro and Teen Patti Pro) + * mg_common_game_rule + */ + default void onGameMGCommonGameRule(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameRule model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 38. 游戏通知app进行玩法设置(只支持德州pro,teenpatti pro) + * 38. Game Notification App: Game Mode Settings (Only supports Texas Hold'em Pro and Teen Patti Pro) + * mg_common_game_settings + */ + default void onGameMGCommonGameSettings(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameSettings model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 39. 游戏通知app钱币不足(只支持德州pro,teenpatti pro) + * 39. Game Notification App: Insufficient Coins (Only supports Texas Hold'em Pro and Teen Patti Pro) + * mg_common_game_money_not_enough + */ + default void onGameMGCommonGameMoneyNotEnough(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameMoneyNotEnough model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 40. 游戏通知app下发定制ui配置表(只支持ludo) + * 40. Game Notification App: Send Custom UI Configuration Table (supports Ludo, fir) + * mg_common_game_ui_custom_config + */ + default void onGameMGCommonGameUiCustomConfig(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameUiCustomConfig model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 41. 设置app提供给游戏可点击区域(赛车) + * 41. Set clickable areas provided by the app for the game (crazyracing) + * mg_common_set_click_rect + */ + default void onGameMGCommonSetClickRect(ISudFSMStateHandle handle, SudMGPMGState.MGCommonSetClickRect model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 42. 通知app提供对应uids列表玩家的数据(赛车) + * 42. Notify the app to provide data for the corresponding list of UIDs' players (crazyracing). + * mg_common_users_info + */ + default void onGameMGCommonUsersInfo(ISudFSMStateHandle handle, SudMGPMGState.MGCommonUsersInfo model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 43. 通知app游戏前期准备完成(赛车) + * 43. Notify the app that the game's preliminary preparations are complete.(crazyracing) + * mg_common_game_prepare_finish + */ + default void onGameMGCommonGamePrepareFinish(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGamePrepareFinish model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 44. 通知app游戏主界面已显示(赛车) + * 44. Notify the app that the game's main interface has been displayed.(crazyracing) + * mg_common_show_game_scene + */ + default void onGameMGCommonShowGameScene(ISudFSMStateHandle handle, SudMGPMGState.MGCommonShowGameScene model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 45. 通知app游戏主界面已隐藏(赛车) + * 45. Notify the app that the game's main interface has been hidden.(crazyracing) + * mg_common_hide_game_scene + */ + default void onGameMGCommonHideGameScene(ISudFSMStateHandle handle, SudMGPMGState.MGCommonHideGameScene model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 46. 通知app点击了游戏的金币按钮(赛车) + * 46. Notify the app that the game's coin button has been clicked.(crazyracing) + * mg_common_self_click_gold_btn + */ + default void onGameMGCommonSelfClickGoldBtn(ISudFSMStateHandle handle, SudMGPMGState.MGCommonSelfClickGoldBtn model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 47. 通知app棋子到达终点(ludo) + * 47. Notify app reaches the destination (ludo) + * mg_common_game_piece_arrive_end + */ + default void onGameMGCommonGamePieceArriveEnd(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGamePieceArriveEnd model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 48. 通知app玩家是否托管 + * 48. Notify App the player is auto Managed + * mg_common_game_player_managed_state + */ + default void onGameMGCommonGamePlayerManagedState(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGamePlayerManagedState model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 49. 游戏向app发送爆词 + * 49. Notify App the baochi (whoisspy) + * mg_common_game_send_burst_word + */ + default void onGameMGCommonGameSendBurstWord(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameSendBurstWord model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 50. 游戏向app发送玩家实时排名(只支持怪物消消乐) + * 50. Game sends real-time player rankings to the app (only supported in Monster Smash). + * mg_common_game_player_ranks + */ + default void onGameMGCommonGamePlayerRanks(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGamePlayerRanks model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 51. 游戏向app发送玩家即时变化的单双牌(只支持okey101) + * 51. Game sends real-time changes of odd and even cards to the app (only supported in Okey101). + * mg_common_game_player_pair_singular + */ + default void onGameMGCommonGamePlayerPairSingular(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGamePlayerPairSingular model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 52. 游戏向app发送获取玩家持有的道具卡(只支持大富翁) + * 52. Game sends the app a request for obtaining the player's held property cards (only supported in Monopoly). + * mg_common_game_player_monopoly_cards + */ + default void onGameMGCommonGamePlayerMonopolyCards(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGamePlayerMonopolyCards model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 53. 游戏向app发送玩家实时积分(只支持怪物消消乐) + * 53. Game sends real-time player scores to the app (only supported in Monster Smash). + * mg_common_game_player_scores + */ + default void onGameMGCommonGamePlayerScores(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGamePlayerScores model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 54. 游戏通知app销毁游戏(只支持部分概率类游戏) + * 54. The game informs the app to destroy the game + * mg_common_destroy_game_scene + */ + default void onGameMGCommonDestroyGameScene(ISudFSMStateHandle handle, SudMGPMGState.MGCommonDestroyGameScene model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 55. 游戏通知app击球状态(只支持桌球) + * 55. Game notification app Batting status (only table tennis is supported) + * mg_common_game_billiards_hit_state + */ + default void onGameMGCommonGameBilliardsHitState(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameBilliardsHitState model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 56. 游戏向app发送获取玩家持有的指定点数道具卡(只支持飞行棋) + * 56. The game sends the item card to the app to obtain the specified points held by the player (only flying chess is supported) + * mg_common_game_player_props_cards + */ + default void onGameMGCommonGamePlayerPropsCards(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGamePlayerPropsCards model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + // endregion 游戏回调APP 通用状态 English: Game callback to APP for general state. + + // region 游戏回调APP 玩家状态 English: Game callback to APP for player state. + // 参考文档:https://docs.sud.tech/zh-CN/app/Client/MGFSM/CommonStatePlayer.html + // Reference documentation:https://docs.sud.tech/en-US/app/Client/MGFSM/CommonStatePlayer.html + + /** + * 1.加入状态(已修改) + * 1. Joining (modified) + * mg_common_player_in + */ + default void onPlayerMGCommonPlayerIn(ISudFSMStateHandle handle, String userId, SudMGPMGState.MGCommonPlayerIn model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 2.准备状态(已修改) + * 2. Ready (modified) + * mg_common_player_ready + */ + default void onPlayerMGCommonPlayerReady(ISudFSMStateHandle handle, String userId, SudMGPMGState.MGCommonPlayerReady model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 3.队长状态(已修改) + * 3. Captain (modified) + * mg_common_player_captain + */ + default void onPlayerMGCommonPlayerCaptain(ISudFSMStateHandle handle, String userId, SudMGPMGState.MGCommonPlayerCaptain model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 4.游戏状态(已修改) + * 4. Gaming (modified) + * mg_common_player_playing + */ + default void onPlayerMGCommonPlayerPlaying(ISudFSMStateHandle handle, String userId, SudMGPMGState.MGCommonPlayerPlaying model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 5.玩家在线状态 + * 5. Changing the game seat + * mg_common_player_online + */ + default void onPlayerMGCommonPlayerOnline(ISudFSMStateHandle handle, String userId, SudMGPMGState.MGCommonPlayerOnline model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 6.玩家换游戏位状态 + * 6. Notifying the app of tapping a player's avatar (Added on February 9, 2022. This state applies only to player avatars in game scenes.) + * mg_common_player_change_seat + */ + default void onPlayerMGCommonPlayerChangeSeat(ISudFSMStateHandle handle, String userId, SudMGPMGState.MGCommonPlayerChangeSeat model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 7. 游戏通知app点击玩家头像 + * 7. Click the player's Avatar on the game notification app + * mg_common_self_click_game_player_icon + */ + default void onPlayerMGCommonSelfClickGamePlayerIcon(ISudFSMStateHandle handle, String userId, SudMGPMGState.MGCommonSelfClickGamePlayerIcon model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 8. 游戏通知app玩家死亡状态(2022-04-24新增) + * 8. Game notification app player death status (added on April 24, 2022) + * mg_common_self_die_status + */ + default void onPlayerMGCommonSelfDieStatus(ISudFSMStateHandle handle, String userId, SudMGPMGState.MGCommonSelfDieStatus model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 9. 游戏通知app轮到玩家出手状态(2022-04-24新增) + * 9. Game notification app player's turn (added on April 24, 2022) + * mg_common_self_turn_status + */ + default void onPlayerMGCommonSelfTurnStatus(ISudFSMStateHandle handle, String userId, SudMGPMGState.MGCommonSelfTurnStatus model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 10. 游戏通知app玩家选择状态(2022-04-24新增) + * 10. Game notification app player selection status (added on April 24, 2022) + * mg_common_self_select_status + */ + default void onPlayerMGCommonSelfSelectStatus(ISudFSMStateHandle handle, String userId, SudMGPMGState.MGCommonSelfSelectStatus model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 11. 游戏通知app层当前游戏剩余时间(2022-05-23新增,目前UMO生效) + * 11. The game notifies the app layer of the remaining time of the current game (added on May 23, 2022, and UMO takes effect at present) + * mg_common_game_countdown_time + */ + default void onPlayerMGCommonGameCountdownTime(ISudFSMStateHandle handle, String userId, SudMGPMGState.MGCommonGameCountdownTime model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 12. 游戏通知app层当前玩家死亡后变成ob视角(2022-08-23新增,目前狼人杀生效) + * 12. The game notifies the app layer that the current player will become an OB perspective after death (added on August 23, 2022, and now the werewolf ) + * mg_common_self_ob_status + */ + default void onPlayerMGCommonSelfObStatus(ISudFSMStateHandle handle, String userId, SudMGPMGState.MGCommonSelfObStatus model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + // endregion 游戏回调APP 玩家状态 English: Game callback to APP for player state. + + // region 游戏回调APP 玩家状态 你画我猜 English: Game callback to APP for player state in 'You Draw, I Guess'. + // 参考文档:https://docs.sud.tech/zh-CN/app/Client/MGFSM/DrawGuess.html + // Reference documentation:https://docs.sud.tech/en-US/app/Client/MGFSM/DrawGuess.html + + /** + * 1. 选词中状态(已修改) + * 1. Selecting words (modified) + * mg_dg_selecting + */ + default void onPlayerMGDGSelecting(ISudFSMStateHandle handle, String userId, SudMGPMGState.MGDGSelecting model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 2. 作画中状态(已修改) + * 2. Drawing (modified) + * mg_dg_painting + */ + default void onPlayerMGDGPainting(ISudFSMStateHandle handle, String userId, SudMGPMGState.MGDGPainting model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 3. 显示错误答案状态(已修改) + * 3. Displaying incorrect answers (modified) + * mg_dg_erroranswer + */ + default void onPlayerMGDGErroranswer(ISudFSMStateHandle handle, String userId, SudMGPMGState.MGDGErroranswer model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 4. 显示总积分状态(已修改) + * 4. Displaying the total points (modified) + * mg_dg_totalscore + */ + default void onPlayerMGDGTotalscore(ISudFSMStateHandle handle, String userId, SudMGPMGState.MGDGTotalscore model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 5. 本次获得积分状态(已修改) + * 5. Displaying the points obtained from this round (modified) + * mg_dg_score + */ + default void onPlayerMGDGScore(ISudFSMStateHandle handle, String userId, SudMGPMGState.MGDGScore model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + // endregion 游戏回调APP 玩家状态 你画我猜 English: Game callback to APP for player state in 'You Draw, I Guess'. + + // region 游戏回调APP 通用状态 元宇宙砂砂舞 English: Game callback to APP for general state in Metaverse Sand Dance. + + /** + * 1. 元宇宙砂砂舞指令回调 + * 1. Callback for instructions in the Metaverse Sand Dance game. + * mg_common_game_disco_action + */ + default void onGameMGCommonGameDiscoAction(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameDiscoAction model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 2. 元宇宙砂砂舞指令动作结束通知 + * 2. Notification for the completion of actions in the Metaverse Sand Dance game. + * mg_common_game_disco_action_end + */ + default void onGameMGCommonGameDiscoActionEnd(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameDiscoActionEnd model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + // endregion 游戏回调APP 通用状态 元宇宙砂砂舞 English: Game callback to APP for general state in Metaverse Sand Dance. + + // region 游戏回调APP 通用状态 定制火箭 English: Game callback to APP for general state in Custom Rocket. + + /** + * 1. 礼物配置文件(火箭) + * 1. Gift Configuration File (Rocket) + * mg_custom_rocket_config + */ + default void onGameMGCustomRocketConfig(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketConfig model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 2. 拥有模型列表(火箭) + * 2. List of Owned Models (Rocket) + * mg_custom_rocket_model_list + */ + default void onGameMGCustomRocketModelList(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketModelList model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 3. 拥有组件列表(火箭) + * 3. List of Owned Components (Rocket) + * mg_custom_rocket_component_list + */ + default void onGameMGCustomRocketComponentList(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketComponentList model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 4. 获取用户信息(火箭) + * 4. Get User Information (Rocket) + * mg_custom_rocket_user_info + */ + default void onGameMGCustomRocketUserInfo(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketUserInfo model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 5. 订单记录列表(火箭) + * 5. Order History List (Rocket) + * mg_custom_rocket_order_record_list + */ + default void onGameMGCustomRocketOrderRecordList(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketOrderRecordList model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 6. 展馆内列表(火箭) + * 6. Exhibition Hall List (Rocket) + * mg_custom_rocket_room_record_list + */ + default void onGameMGCustomRocketRoomRecordList(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketRoomRecordList model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 7. 展馆内玩家送出记录(火箭) + * 7. Game client notifies the app to fetch the player gifting records in the exhibition hall.(Rocket) + * mg_custom_rocket_user_record_list + */ + default void onGameMGCustomRocketUserRecordList(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketUserRecordList model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 8. 设置默认模型(火箭) + * 8. Set default model (Rocket) + * mg_custom_rocket_set_default_model + */ + default void onGameMGCustomRocketSetDefaultModel(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketSetDefaultModel model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 9. 动态计算一键发送价格(火箭) + * 9. Dynamic calculation of one-click sending price(Rocket) + * mg_custom_rocket_dynamic_fire_price + */ + default void onGameMGCustomRocketDynamicFirePrice(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketDynamicFirePrice model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 10. 一键发送(火箭) + * 10. One-click sending(Rocket) + * mg_custom_rocket_fire_model + */ + default void onGameMGCustomRocketFireModel(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketFireModel model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 11. 新组装模型(火箭) + * 11. Newly assembled model.(Rocket) + * mg_custom_rocket_create_model + */ + default void onGameMGCustomRocketCreateModel(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketCreateModel model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 12. 模型更换组件(火箭) + * 12. Model Component Replacement(Rocket) + * mg_custom_rocket_replace_component + */ + default void onGameMGCustomRocketReplaceComponent(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketReplaceComponent model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 13. 购买组件(火箭) + * 13. Buy component(Rocket) + * mg_custom_rocket_buy_component + */ + default void onGameMGCustomRocketBuyComponent(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketBuyComponent model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 14. 播放效果开始(火箭) + * 14. Play effect start(Rocket) + * mg_custom_rocket_play_effect_start + */ + default void onGameMGCustomRocketPlayEffectStart(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketPlayEffectStart model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 15. 播放效果完成(火箭) + * 15. Play effect finished(Rocket) + * mg_custom_rocket_play_effect_finish + */ + default void onGameMGCustomRocketPlayEffectFinish(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketPlayEffectFinish model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 16. 验证签名合规(火箭) + * 16. To verify the compliance of a signature(Rocket) + * mg_custom_rocket_verify_sign + */ + default void onGameMGCustomRocketVerifySign(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketVerifySign model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 17. 上传icon(火箭) + * 17. upload icon(Rocket) + * mg_custom_rocket_upload_model_icon + */ + default void onGameMGCustomRocketUploadModelIcon(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketUploadModelIcon model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 18. 前期准备完成(火箭) + * 18. Preparation is complete.(Rocket) + * mg_custom_rocket_prepare_finish + */ + default void onGameMGCustomRocketPrepareFinish(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketPrepareFinish model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 19. 火箭主界面已显示(火箭) + * 19. Rocket main interface has been displayed(Rocket) + * mg_custom_rocket_show_game_scene + */ + default void onGameMGCustomRocketShowGameScene(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketShowGameScene model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 20. 火箭主界面已隐藏(火箭) + * 20. The rocket main interface has been hidden(Rocket) + * mg_custom_rocket_hide_game_scene + */ + default void onGameMGCustomRocketHideGameScene(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketHideGameScene model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 21. 点击锁住组件(火箭) + * 21. Click to lock the component(Rocket) + * mg_custom_rocket_click_lock_component + */ + default void onGameMGCustomRocketClickLockComponent(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketClickLockComponent model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 22. 火箭效果飞行点击(火箭) + * 22. Rocket effect fly click(Rocket) + * mg_custom_rocket_fly_click + */ + default void onGameMGCustomRocketFlyClick(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketFlyClick model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 23. 火箭效果飞行结束(火箭) + * 23. Rocket effect fly finished(Rocket) + * mg_custom_rocket_fly_end + */ + default void onGameMGCustomRocketFlyEnd(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketFlyEnd model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 24. 设置点击区域(火箭) + * 24. Set clickable area provided by the app for the game(Rocket) + * mg_custom_rocket_set_click_rect + */ + default void onGameMGCustomRocketSetClickRect(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketSetClickRect model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 25. 颜色和签名自定义改到装配间的模式,保存颜色或签名 + * 25. Save rocket signature or color.(Rocket) + * mg_custom_rocket_save_sign_color + */ + default void onGameMGCustomRocketSaveSignColor(ISudFSMStateHandle handle, SudMGPMGState.MGCustomRocketSaveSignColor model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + // endregion 游戏回调APP 通用状态 定制火箭 English: Game callback to APP for general state in Custom Rocket. + + // region 游戏回调APP 通用状态 棒球 English: Game callback to APP for general state in Baseball. + + /** + * 1. 设置界面默认状态(棒球) + * 1. Set Default State of Interface (Baseball) + * mg_baseball_defualt_state + */ + default void onGameMGBaseballDefaultState(ISudFSMStateHandle handle, SudMGPMGState.MGBaseballDefaultState model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 2. 前期准备完成(棒球) + * 2. Preparation is complete (Baseball) + * mg_baseball_prepare_finish + */ + default void onGameMGBaseballPrepareFinish(ISudFSMStateHandle handle, SudMGPMGState.MGBaseballPrepareFinish model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 3. 主界面已显示(棒球) + * 3. The main interface is now displayed (Baseball) + * mg_baseball_show_game_scene + */ + default void onGameMGBaseballShowGameScene(ISudFSMStateHandle handle, SudMGPMGState.MGBaseballShowGameScene model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 4. 主界面已隐藏(棒球) + * 4. The game client has notified the app that the main interface is now hidden (Baseball) + * mg_baseball_hide_game_scene + */ + default void onGameMGBaseballHideGameScene(ISudFSMStateHandle handle, SudMGPMGState.MGBaseballHideGameScene model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 5. 查询排行榜数据(棒球) + * 5. To query the ranks data (Baseball) + * mg_baseball_ranking + */ + default void onGameMGBaseballRanking(ISudFSMStateHandle handle, SudMGPMGState.MGBaseballRanking model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 6. 查询我的排名(棒球) + * 6. Querying my ranking (baseball) + * mg_baseball_my_ranking + */ + default void onGameMGBaseballMyRanking(ISudFSMStateHandle handle, SudMGPMGState.MGBaseballMyRanking model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 7. 查询当前距离我的前后玩家数据(棒球) + * 7. The game client notifies the app to query the data of players before and after me in the current distance (Baseball) + * mg_baseball_range_info + */ + default void onGameMGBaseballRangeInfo(ISudFSMStateHandle handle, SudMGPMGState.MGBaseballRangeInfo model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 8. 设置app提供给游戏可点击区域(棒球) + * 8. Set the clickable area provided by the app for the game (baseball) + * mg_baseball_set_click_rect + */ + default void onGameMGBaseballSetClickRect(ISudFSMStateHandle handle, SudMGPMGState.MGBaseballSetClickRect model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 9. 获取文本配置数据(棒球) + * 9. Retrieve Text Configuration Data (Baseball) + * mg_baseball_text_config + */ + default void onGameMGBaseballTextConfig(ISudFSMStateHandle handle, SudMGPMGState.MGBaseballTextConfig model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 10. 球落地, 通知距离(棒球) + * 10. Ball landed, notify distance (Baseball) + * mg_baseball_send_distance + */ + default void onGameMGBaseballSendDistance(ISudFSMStateHandle handle, SudMGPMGState.MGBaseballSendDistance model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + // endregion 游戏回调APP 通用状态 棒球 English: Game callback to APP for general state in Baseball. + + // region 游戏回调APP 3D语聊房 + + /** + * 1. 请求房间数据 + * mg_custom_cr_room_init_data + */ + default void onGameMGCustomCrRoomInitData(ISudFSMStateHandle handle, SudMGPMGState.MGCustomCrRoomInitData model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + + /** + * 2. 点击主播位或老板位通知 + * mg_custom_cr_click_seat + */ + default void onGameMGCustomCrClickSeat(ISudFSMStateHandle handle, SudMGPMGState.MGCustomCrClickSeat model) { + ISudFSMStateHandleUtils.handleSuccess(handle); + } + // endregion 游戏回调APP 3D语聊房 + + /** + * 游戏状态变化 + * 透传游戏向App发送的游戏通用状态消息 + * **********使用此方法可先看下此方法的使用逻辑************* + * + * @param handle 回调操作 + * @param state 状态命令 + * @param dataJson 状态值 + * @return 返回true,表示由此方法接管该状态处理,此时需注意调用:ISudFSMStateHandleUtils.handleSuccess(handle); + */ + default boolean onGameStateChange(ISudFSMStateHandle handle, String state, String dataJson) { + return false; + } + + /** + * 游戏玩家状态变化 + * 透传游戏向App发送的玩家状态变化 + * **********使用此方法可先看下此方法的使用逻辑************* + * + * @param handle 回调操作 + * @param userId 用户Id + * @param state 状态命令 + * @param dataJson 状态值 + * @return 返回true,表示由此方法接管该状态处理,此时需注意调用:ISudFSMStateHandleUtils.handleSuccess(handle); + */ + default boolean onPlayerStateChange(ISudFSMStateHandle handle, String userId, String state, String dataJson) { + return false; + } + +} diff --git a/core/src/model_sud_wrapper/java/com/chwl/core/sud/decorator/SudFSTAPPDecorator.java b/core/src/model_sud_wrapper/java/com/chwl/core/sud/decorator/SudFSTAPPDecorator.java new file mode 100644 index 000000000..5f76c4386 --- /dev/null +++ b/core/src/model_sud_wrapper/java/com/chwl/core/sud/decorator/SudFSTAPPDecorator.java @@ -0,0 +1,415 @@ +/* + * Copyright © Sud.Tech + * https://sud.tech + */ + +package com.chwl.core.sud.decorator; + +import java.nio.ByteBuffer; +import java.util.List; + +import com.chwl.core.sud.state.SudMGPAPPState; +import com.chwl.core.sud.utils.SudJsonUtils; +import tech.sud.mgp.core.ISudFSTAPP; +import tech.sud.mgp.core.ISudListenerNotifyStateChange; + +/** + * ISudFSTAPP的装饰类,接近于业务 + * 参考文档:https://docs.sud.tech/zh-CN/app/Client/API/ISudFSTAPP.html + * 注意: + * 1,向游戏侧发送状态之后,不能立即调用destroyMG()方法,也不能立即finish Activity。例如:{@link SudFSTAPPDecorator#notifyAPPCommonSelfEnd()} + */ +public class SudFSTAPPDecorator { + + /** + * APP调用游戏的接口 + */ + private ISudFSTAPP iSudFSTAPP; + private OnNotifyStateChangeListener onNotifyStateChangeListener; + + /** + * 设置app调用sdk的对象 + * + * @param iSudFSTAPP + */ + public void setISudFSTAPP(ISudFSTAPP iSudFSTAPP) { + this.iSudFSTAPP = iSudFSTAPP; + } + + // region 状态通知,ISudFSTAPP.notifyStateChange + + /** + * 发送 + * 1. 加入状态 + * + * @param isIn true 加入游戏,false 退出游戏 + * @param seatIndex 加入的游戏位(座位号) 默认传seatIndex = -1 随机加入,seatIndex 从0开始,不可大于座位数 + * @param isSeatRandom 默认为ture, 带有游戏位(座位号)的时候,如果游戏位(座位号)已经被占用,是否随机分配一个空位坐下 isSeatRandom=true 随机分配空位坐下,isSeatRandom=false 不随机分配 + * @param teamId 不支持分队的游戏:数值填1;支持分队的游戏:数值填1或2(两支队伍); + */ + public void notifyAPPCommonSelfIn(boolean isIn, int seatIndex, boolean isSeatRandom, int teamId) { + SudMGPAPPState.APPCommonSelfIn state = new SudMGPAPPState.APPCommonSelfIn(); + state.isIn = isIn; + state.seatIndex = seatIndex; + state.isSeatRandom = isSeatRandom; + state.teamId = teamId; + notifyStateChange(SudMGPAPPState.APP_COMMON_SELF_IN, state); + } + + /** + * 发送 + * 2. 准备状态 + * 用户(本人)准备/取消准备 + * + * @param isReady true 准备,false 取消准备 + */ + public void notifyAPPCommonSelfReady(boolean isReady) { + SudMGPAPPState.APPCommonSelfReady state = new SudMGPAPPState.APPCommonSelfReady(); + state.isReady = isReady; + notifyStateChange(SudMGPAPPState.APP_COMMON_SELF_READY, state); + } + + /** + * 发送 + * 3. 游戏状态 模型 + * 用户游戏状态,如果用户在游戏中,建议: + * a.空出屏幕中心区: + * 关闭全屏礼物特效; + * b.部分强操作类小游戏(spaceMax为true),尽量收缩原生UI,给游戏留出尽量大的操作空间: + * 收缩公屏; + * 收缩麦位; + * 如果不在游戏中,则恢复。 + * + * @param isPlaying true 开始游戏,false 结束游戏 + * @param reportGameInfoExtras string类型,Https服务回调report_game_info参数,最大长度1024字节,超过则截断(2022-01-21) + */ + public void notifyAPPCommonSelfPlaying(boolean isPlaying, String reportGameInfoExtras, String reportGameInfoKey) { + SudMGPAPPState.APPCommonSelfPlaying state = new SudMGPAPPState.APPCommonSelfPlaying(); + state.isPlaying = isPlaying; + state.reportGameInfoExtras = reportGameInfoExtras; + state.reportGameInfoKey = reportGameInfoKey; + notifyStateChange(SudMGPAPPState.APP_COMMON_SELF_PLAYING, state); + } + + /** + * 发送 + * 4. 队长状态 + * 用户是否为队长,队长在游戏中会有开始游戏的权利。 + * 发送此状态后,会把队长身份转移到另一名用户身上。 + * 注意:必须是队长发送才有效果。可通过{@link SudFSMMGDecorator#getCaptainUserId()}拿到当前队长id + * + * @param curCaptainUID 必填,指定队长uid + */ + public void notifyAPPCommonSelfCaptain(String curCaptainUID) { + SudMGPAPPState.APPCommonSelfCaptain state = new SudMGPAPPState.APPCommonSelfCaptain(); + state.curCaptainUID = curCaptainUID; + notifyStateChange(SudMGPAPPState.APP_COMMON_SELF_CAPTAIN, state); + } + + /** + * 发送 + * 5. 踢人 + * 用户(本人,队长)踢其他玩家; + * 队长才能踢人; + * + * @param kickedUID 被踢用户uid + */ + public void notifyAPPCommonSelfKick(String kickedUID) { + SudMGPAPPState.APPCommonSelfKick state = new SudMGPAPPState.APPCommonSelfKick(); + state.kickedUID = kickedUID; + notifyStateChange(SudMGPAPPState.APP_COMMON_SELF_KICK, state); + } + + /** + * 发送 + * 6. 结束游戏 + * 用户(本人,队长)结束(本局)游戏 + * 注意:必须是队长发送才有效果。可通过{@link SudFSMMGDecorator#getCaptainUserId()}拿到当前队长id + */ + public void notifyAPPCommonSelfEnd() { + SudMGPAPPState.APPCommonSelfEnd state = new SudMGPAPPState.APPCommonSelfEnd(); + // 使用iSudFSTAPP.notifyStateChange方法向游戏侧发送状态时,因为大部分状态都需要通过网络向后端发送状态指令 + // 所以如果发送状态后,马上就销毁游戏或者Activity,那么状态指令大概率会不生效 + // *** 如果要确保指令能到达后端,那么发送指令后不要立即destroyMG()或finish Activity,可在发送后delay一定时间(如300 or 500 ms)再销毁 + // *** 如果不在乎指令是否能成功到达,可忽略delay + notifyStateChange(SudMGPAPPState.APP_COMMON_SELF_END, state); + } + + /** + * 发送 + * 9. 麦克风状态 + * 用户(本人)麦克风状态,建议: + * 进入房间后初始通知一次; + * 每次变更(开麦/闭麦/禁麦/解麦)通知一次; + * + * @param isOn true 开麦,false 闭麦 + * @param isDisabled true 被禁麦,false 未被禁麦 + */ + public void notifyAPPCommonSelfMicrophone(boolean isOn, boolean isDisabled) { + SudMGPAPPState.APPCommonSelfMicrophone state = new SudMGPAPPState.APPCommonSelfMicrophone(); + state.isOn = isOn; + state.isDisabled = isDisabled; + notifyStateChange(SudMGPAPPState.APP_COMMON_SELF_MICROPHONE, state); + } + + /** + * 发送 + * 10. 文字命中状态 + * 用户(本人)聊天信息命中关键词状态,建议: + * 精确匹配; + * 首次聊天内容命中关键词之后,后续聊天内容不翻转成未命中; + * 直至小游戏侧关键词更新,再将状态翻转为未命中; + * + * @param isHit true 命中,false 未命中 + * @param keyWord 关键词 + * @param text 聊天原始内容 + */ + public void notifyAPPCommonSelfTextHitState(boolean isHit, String keyWord, String text) { + SudMGPAPPState.APPCommonSelfTextHitState state = new SudMGPAPPState.APPCommonSelfTextHitState(); + state.isHit = isHit; + state.keyWord = keyWord; + state.text = text; + notifyStateChange(SudMGPAPPState.APP_COMMON_SELF_TEXT_HIT, state); + } + + /** + * 发送 + * 11. 打开或关闭背景音乐(2021-12-27新增) + * + * @param isOpen true 打开背景音乐,false 关闭背景音乐 + */ + public void notifyAPPCommonOpenBgMusic(boolean isOpen) { + SudMGPAPPState.APPCommonOpenBgMusic state = new SudMGPAPPState.APPCommonOpenBgMusic(); + state.isOpen = isOpen; + notifyStateChange(SudMGPAPPState.APP_COMMON_OPEN_BG_MUSIC, state); + } + + /** + * 发送 + * 12. 打开或关闭音效(2021-12-27新增) + * + * @param isOpen true 打开音效,false 关闭音效 + */ + public void notifyAPPCommonOpenSound(boolean isOpen) { + SudMGPAPPState.APPCommonOpenSound state = new SudMGPAPPState.APPCommonOpenSound(); + state.isOpen = isOpen; + notifyStateChange(SudMGPAPPState.APP_COMMON_OPEN_SOUND, state); + } + + /** + * 发送 + * 13. 打开或关闭游戏中的振动效果(2021-12-27新增) + * + * @param isOpen 打开振动效果,false 关闭振动效果 + */ + public void notifyAPPCommonOpenVibrate(boolean isOpen) { + SudMGPAPPState.APPCommonOpenVibrate state = new SudMGPAPPState.APPCommonOpenVibrate(); + state.isOpen = isOpen; + notifyStateChange(SudMGPAPPState.APP_COMMON_OPEN_VIBRATE, state); + } + + /** + * 发送 + * 14. 设置游戏的音量大小(2021-12-31新增) + * + * @param volume 音量大小 0 到 100 + */ + public void notifyAPPCommonGameSoundVolume(int volume) { + SudMGPAPPState.APPCommonGameSoundVolume state = new SudMGPAPPState.APPCommonGameSoundVolume(); + state.volume = volume; + notifyStateChange(SudMGPAPPState.APP_COMMON_GAME_SOUND_VOLUME, state); + } + + /** + * 发送 + * 15. 设置游戏玩法选项(2022-05-10新增) + * + * @param ludo ludo游戏 + */ + public void notifyAPPCommonGameSettingSelectInfo(SudMGPAPPState.Ludo ludo) { + SudMGPAPPState.APPCommonGameSettingSelectInfo state = new SudMGPAPPState.APPCommonGameSettingSelectInfo(); + state.ludo = ludo; + notifyStateChange(SudMGPAPPState.APP_COMMON_GAME_SETTING_SELECT_INFO, state); + } + + /** + * 发送 + * 16. 设置游戏中的AI玩家(2022-05-11新增) + * + * @param aiPlayers AI玩家 + * @param isReady 机器人加入后是否自动准备 1:自动准备,0:不自动准备 默认为1 + */ + public void notifyAPPCommonGameAddAIPlayers(List aiPlayers, int isReady) { + SudMGPAPPState.APPCommonGameAddAIPlayers state = new SudMGPAPPState.APPCommonGameAddAIPlayers(); + state.aiPlayers = aiPlayers; + state.isReady = isReady; + notifyStateChange(SudMGPAPPState.APP_COMMON_GAME_ADD_AI_PLAYERS, state); + } + + /** + * 发送 + * 17. app在收到游戏断开连接通知后,通知游戏重试连接(2022-06-21新增,暂时支持ludo) + */ + public void notifyAPPCommonGameReconnect() { + SudMGPAPPState.APPCommonGameReconnect state = new SudMGPAPPState.APPCommonGameReconnect(); + notifyStateChange(SudMGPAPPState.APP_COMMON_GAME_RECONNECT, state); + } + + /** + * 发送 + * 18. app返回玩家当前积分 + */ + public void notifyAPPCommonGameScore(long score) { + SudMGPAPPState.APPCommonGameScore state = new SudMGPAPPState.APPCommonGameScore(); + state.score = score; + notifyStateChange(SudMGPAPPState.APP_COMMON_GAME_SCORE, state); + } + // endregion 状态通知,ISudFSTAPP.notifyStateChange + + // region 生命周期 + public void startMG() { + ISudFSTAPP iSudFSTAPP = this.iSudFSTAPP; + if (iSudFSTAPP != null) { + iSudFSTAPP.startMG(); + } + } + + public void pauseMG() { + ISudFSTAPP iSudFSTAPP = this.iSudFSTAPP; + if (iSudFSTAPP != null) { + iSudFSTAPP.pauseMG(); + } + } + + public void playMG() { + ISudFSTAPP iSudFSTAPP = this.iSudFSTAPP; + if (iSudFSTAPP != null) { + iSudFSTAPP.playMG(); + } + } + + public void stopMG() { + ISudFSTAPP iSudFSTAPP = this.iSudFSTAPP; + if (iSudFSTAPP != null) { + iSudFSTAPP.stopMG(); + } + } + + public void destroyMG() { + ISudFSTAPP iSudFSTAPP = this.iSudFSTAPP; + if (iSudFSTAPP != null) { + iSudFSTAPP.destroyMG(); + this.iSudFSTAPP = null; + } + } + + // endregion 生命周期 + + /** + * 更新code + * + * @param code + * @param listener + */ + public void updateCode(String code, ISudListenerNotifyStateChange listener) { + ISudFSTAPP iSudFSTAPP = this.iSudFSTAPP; + if (iSudFSTAPP != null) { + iSudFSTAPP.updateCode(code, listener); + } + } + + /** + * 音频流数据 + */ + public void pushAudio(ByteBuffer buffer, int bufferLength) { + ISudFSTAPP iSudFSTAPP = this.iSudFSTAPP; + if (iSudFSTAPP != null) { + iSudFSTAPP.pushAudio(buffer, bufferLength); + } + } + + // region 元宇宙砂砂舞 + + /** + * 发送 + * 1. 元宇宙砂砂舞相关设置 + * 参考文档:https://docs.sud.tech/zh-CN/app/Client/APPFST/CommonStateForDisco.html + * + * @param actionId 必传的参数,用于指定类型的序号,不同序号用于区分游戏内的不同功能,不传则会判断为无效指令,具体序号代表的功能见下表 + * @param cooldown 持续时间,单位秒,部分功能有持续时间就需要传对应的数值,不传或传错则会按各自功能的默认值处理(见下表) + * @param isTop 是否置顶,针对部分功能可排队置顶(false:不置顶;true:置顶;默认为false) + * @param field1 额外参数1,针对部分功能有具体的意义 + * @param field2 额外参数2,针对部分功能有具体的意义 + */ + public void notifyAppCommonGameDiscoAction(int actionId, Integer cooldown, Boolean isTop, String field1, String field2) { + SudMGPAPPState.AppCommonGameDiscoAction state = new SudMGPAPPState.AppCommonGameDiscoAction(); + state.actionId = actionId; + state.cooldown = cooldown; + state.isTop = isTop; + state.field1 = field1; + state.field2 = field2; + notifyStateChange(SudMGPAPPState.APP_COMMON_GAME_DISCO_ACTION, state); + } + // endregion 元宇宙砂砂舞 + + /** + * APP状态通知给小游戏 + * + * @param state 状态标识 + * @param dataJson 数据 + * @param listener 回调监听 + */ + public void notifyStateChange(String state, String dataJson, ISudListenerNotifyStateChange listener) { + ISudFSTAPP iSudFSTAPP = this.iSudFSTAPP; + if (iSudFSTAPP != null) { + iSudFSTAPP.notifyStateChange(state, dataJson, listener); + if (onNotifyStateChangeListener != null) { + onNotifyStateChangeListener.onNotifyStateChange(state, dataJson); + } + } + } + + /** + * APP状态通知给小游戏 + * + * @param state 状态标识 + * @param dataJson 数据 + */ + public void notifyStateChange(String state, String dataJson) { + notifyStateChange(state, dataJson, null); + } + + /** + * APP状态通知给小游戏 + * + * @param state 状态标识 + * @param obj 数据 + */ + public void notifyStateChange(String state, Object obj) { + notifyStateChange(state, SudJsonUtils.toJson(obj), null); + } + + /** + * 自定义进度条 + * 在游戏加载失败时,调用此方法可重新加载游戏 + */ + public void reloadMG() { + ISudFSTAPP iSudFSTAPP = this.iSudFSTAPP; + if (iSudFSTAPP != null) { + iSudFSTAPP.reloadMG(); + } + } + + public void setOnNotifyStateChangeListener(OnNotifyStateChangeListener onNotifyStateChangeListener) { + this.onNotifyStateChangeListener = onNotifyStateChangeListener; + } + + /** + * 此接口是监听{iSudFSTAPP.notifyStateChange}的接口调用 + */ + public interface OnNotifyStateChangeListener { + /** 此接口回调用于监控app向游戏发送的消息,可将其打印到控制台,尽量不要在此做其他业务性的操作 */ + void onNotifyStateChange(String state, String dataJson); + } + +} diff --git a/core/src/model_sud_wrapper/java/com/chwl/core/sud/model/GameConfigModel.java b/core/src/model_sud_wrapper/java/com/chwl/core/sud/model/GameConfigModel.java new file mode 100644 index 000000000..00a5a02c9 --- /dev/null +++ b/core/src/model_sud_wrapper/java/com/chwl/core/sud/model/GameConfigModel.java @@ -0,0 +1,351 @@ +/* + * Copyright © Sud.Tech + * https://sud.tech + */ + +package com.chwl.core.sud.model; + +import androidx.annotation.Keep; + +import java.io.Serializable; + +/** + * 游戏配置模型 + * 参考文档:https://docs.sud.tech/zh-CN/app/Client/API/ISudFSMMG/onGetGameCfg.html + */ +@Keep +public class GameConfigModel implements Serializable { + + public int gameMode = 1; // 游戏模式(每个游戏默认模式是1,不填是1) + public int gameCPU = 0; // 游戏CPU(值为0和1;0:CPU正常功耗,1:CPU低功耗;默认是0,CPU正常功耗) + public int gameSoundControl = 0; // 游戏中声音的播放是否被app层接管(值为0和1;0:游戏播放声音,1:app层播放声音,游戏中不播放任何声音;默认是0) + public int gameSoundVolume = 100; // 游戏中音量的大小(值为0到100;默认是100) + public GameUi ui = new GameUi(); // 对游戏ui界面的配置,可定制ui界面的显示与不显示 + + // 游戏配置中,ui部分 + @Keep + public static class GameUi implements Serializable { + public GameSettle gameSettle = new GameSettle(); // 结算界面 + public GamePing ping = new GamePing(); // 界面中的ping值 + public GameVersion version = new GameVersion(); // 界面中的版本信息值 + public GameLevel level = new GameLevel(); // 大厅中的段位信息 + public GameLobbySettingBtn lobby_setting_btn = new GameLobbySettingBtn(); // 大厅的设置按钮 + public GameLobbyHelpBtn lobby_help_btn = new GameLobbyHelpBtn(); // 大厅的帮助按钮 + public GameLobbyPlayers lobby_players = new GameLobbyPlayers(); // 大厅玩家展示位 + public GameLobbyPlayerCaptainIcon lobby_player_captain_icon = new GameLobbyPlayerCaptainIcon(); // 大厅玩家展示位上队长标识 + public GameLobbyPlayerKickoutIcon lobby_player_kickout_icon = new GameLobbyPlayerKickoutIcon(); // 大厅玩家展示位上踢人标识 + public GameLobbyRule lobby_rule = new GameLobbyRule(); // 大厅的玩法规则描述文字 + public GameLobbyGameSetting lobby_game_setting = new GameLobbyGameSetting(); // 玩法设置 + public GameJoinBtn join_btn = new GameJoinBtn(); // 加入按钮 + public GameCancelJoinBtn cancel_join_btn = new GameCancelJoinBtn(); // 取消加入按钮 + public GameReadyBtn ready_btn = new GameReadyBtn(); // 准备按钮 + public GameCancelReadyBtn cancel_ready_btn = new GameCancelReadyBtn(); // 取消准备按钮 + public GameStartBtn start_btn = new GameStartBtn(); // 开始按钮 + public GameShareBtn share_btn = new GameShareBtn(); // 分享 + public GameSttingBtn game_setting_btn = new GameSttingBtn(); // 游戏场景中的设置按钮 + public GameHelpBtn game_help_btn = new GameHelpBtn(); // 游戏场景中的帮助按钮 + public GameSettleCloseBtn game_settle_close_btn = new GameSettleCloseBtn(); // 游戏结算界面中的关闭按钮 + public GameSettleAgainBtn game_settle_again_btn = new GameSettleAgainBtn(); // 游戏结算界面中的再来一局按钮 + public GameBg game_bg = new GameBg();// 是否隐藏背景图,包括大厅和战斗 + public BlockChangeSeat block_change_seat = new BlockChangeSeat(); // 自定义阻止换座位 + public GameSettingSelectPnl game_setting_select_pnl = new GameSettingSelectPnl(); // 大厅中的玩法选择设置面板 + public GameManagedImage game_managed_image = new GameManagedImage(); // 游戏中的托管图标 + public GameTableImage game_table_image = new GameTableImage(); // 游戏中牌桌背景图 (注:只对某些带牌桌类游戏有作用) + public GameCountdownTime game_countdown_time = new GameCountdownTime(); // 游戏中游戏倒计时显示 (注:现在只针对umo生效) + public GameSelectedTips game_selected_tips = new GameSelectedTips(); // 游戏中所选择的玩法提示文字 (注:现在只针对ludo生效) + public NFTAvatar nft_avatar = new NFTAvatar(); // 控制NFT头像的开关 + public GameOpening game_opening = new GameOpening(); // 控制开场动画的开关 + public GameMvp game_mvp = new GameMvp(); // 游戏结算前的mvp动画 + public UmoIcon umo_icon = new UmoIcon(); // 游戏中动画和头像右上角的UMO图标 + public Logo logo = new Logo(); // 大厅中的logo + public GamePlayers game_players = new GamePlayers(); // 游戏中的游戏位 + public BulletScreensBtn bullet_screens_btn = new BulletScreensBtn(); // 你画我猜,你说我猜『弹幕开关』按钮 + public RoundOverPoopBtn round_over_poop_btn = new RoundOverPoopBtn(); // 你画我猜,小局结算界面点击扔大便按钮 + public RoundOverGoodBtn round_over_good_btn = new RoundOverGoodBtn(); // 你画我猜,小局结算界面点击点赞按钮 + public Mask mask = new Mask(); // 游戏中所有蒙版 + public WorstTeammateTip worst_teammate_tip = new WorstTeammateTip(); // 友尽闯关中最坑队友的弹框 + public GameOverTip game_over_tip = new GameOverTip(); // 友尽闯关中玩家逃跑导致游戏结束弹框 + public LobbyAnimation lobby_animation = new LobbyAnimation(); // 碰碰我最强大厅动画 + } + + // 结算界面 + @Keep + public static class GameSettle implements Serializable { + public boolean hide = false; // 是否隐藏结算界面(false: 显示; true: 隐藏,默认为 false) + } + + // 界面中的ping值 + @Keep + public static class GamePing implements Serializable { + public boolean hide = false; // 是否隐藏ping值(false: 显示;true: 隐藏,默认为false) + } + + // 界面中的版本信息值 + @Keep + public static class GameVersion implements Serializable { + public boolean hide = false; // 是否隐藏版本信息(false: 显示; true: 隐藏,默认为false) + } + + // 大厅中的段位信息 + @Keep + public static class GameLevel implements Serializable { + public boolean hide = false; // 是否隐藏段位信息(false: 显示; true: 隐藏,默认为false) + } + + // 大厅的设置按钮 + @Keep + public static class GameLobbySettingBtn implements Serializable { + public boolean hide = false; // 是否隐藏大厅的设置按钮(false: 显示; true: 隐藏,默认为false) + } + + // 大厅的帮助按钮 + @Keep + public static class GameLobbyHelpBtn implements Serializable { + public boolean hide = false; // 是否隐藏大厅的帮助按钮(false: 显示; true: 隐藏,默认为false) + } + + // 大厅玩家展示位 + @Keep + public static class GameLobbyPlayers implements Serializable { + public boolean custom = false; // 大厅玩家展示位头像点击加入(false: 游戏处理逻辑; true: 游戏只通知按钮点击事件,不处理;默认为false) + public boolean hide = false; // 是否隐藏大厅玩家展示位(false: 显示; true: 隐藏,默认为false) + } + + // 大厅玩家展示位上队长标识 + @Keep + public static class GameLobbyPlayerCaptainIcon implements Serializable { + public boolean hide = false; // 是否隐藏大厅玩家展示位上队长标识(false: 显示; true: 隐藏,默认为false) + } + + // 大厅玩家展示位上踢人标识 + @Keep + public static class GameLobbyPlayerKickoutIcon implements Serializable { + public boolean hide = false; // 是否隐藏大厅玩家展示位上踢人标识(false: 显示; true: 隐藏,默认为false) + } + + // 大厅的玩法规则描述文字 + @Keep + public static class GameLobbyRule implements Serializable { + public boolean hide = false; // 是否隐藏大厅的玩法规则描述文字(false: 显示; true: 隐藏,默认为false) + } + + // 玩法设置 + @Keep + public static class GameLobbyGameSetting implements Serializable { + public boolean hide = false; // 是否隐藏玩法设置(false: 显示; true: 隐藏,默认为false) + } + + // 加入按钮 + @Keep + public static class GameJoinBtn implements Serializable { + public boolean custom = false; // 加入按钮(false: 游戏处理逻辑; true: 游戏只通知按钮点击事件,不处理;默认为false) + public boolean hide = false; // 是否隐藏加入按钮(false: 显示; true: 隐藏,默认为false) + } + + // 取消加入按钮 + @Keep + public static class GameCancelJoinBtn implements Serializable { + public boolean custom = false; // 取消加入按钮(false: 游戏处理逻辑; true: 游戏只通知按钮点击事件,不处理;默认为false) + public boolean hide = false; // 是否隐藏取消加入按钮(false: 显示; true: 隐藏,默认为false) + } + + // 准备按钮 + @Keep + public static class GameReadyBtn implements Serializable { + public boolean custom = false; // 准备按钮(false: 游戏处理逻辑; true: 游戏只通知按钮点击事件,不处理;默认为false) + public boolean hide = false; // 是否隐藏准备按钮(false: 显示; true: 隐藏,默认为false) + } + + // 取消准备按钮 + @Keep + public static class GameCancelReadyBtn implements Serializable { + public boolean custom = false; // 取消准备按钮(false: 游戏处理逻辑; true: 游戏只通知按钮点击事件,不处理;默认为false) + public boolean hide = false; // 是否隐藏取消准备按钮(false: 显示; true: 隐藏,默认为false) + } + + // 开始游戏按钮 + @Keep + public static class GameStartBtn implements Serializable { + public boolean custom = false; // 开始游戏按钮(false: 游戏处理逻辑; true: 游戏只通知按钮点击事件,不处理;默认为false) + public boolean hide = false; // 是否隐藏开始游戏按钮(false: 显示; true: 隐藏,默认为false) + } + + // 分享按钮 + @Keep + public static class GameShareBtn implements Serializable { + public boolean custom = false; // 分享按钮(false: 游戏处理逻辑; true: 游戏只通知按钮点击事件,不处理;默认为false) + public boolean hide = true; // 是否隐藏分享按钮(false: 显示; true: 隐藏,默认为true) + } + + // 游戏场景中的设置按钮 + @Keep + public static class GameSttingBtn implements Serializable { + public boolean hide = false; // 是否隐藏游戏场景中的设置按钮(false: 显示; true: 隐藏,默认为false) + } + + // 游戏场景中的帮助按钮 + @Keep + public static class GameHelpBtn implements Serializable { + public boolean hide = false; // 是否隐藏游戏场景中的帮助按钮(false: 显示; true: 隐藏,默认为false) + } + + // 游戏结算界面中的关闭按钮 + @Keep + public static class GameSettleCloseBtn implements Serializable { + public boolean custom = false; // 游戏结算界面中的关闭按钮(false: 关闭结算界面返回大厅; true: 游戏通知按钮点击事件,并关闭结算界面返回大厅;默认为false) + public boolean hide = false; // 是否隐藏结算界面中的『关闭』按钮(false: 显示; true: 隐藏,默认为true) + } + + // 游戏结算界面中的再来一局按钮 + @Keep + public static class GameSettleAgainBtn implements Serializable { + // 游戏结算界面中的再来一局按钮 + // (false: 关闭结算界面返回大厅并将玩家设置为准备状态; true: 游戏通知按钮点击事件,并关闭结算界面返回大厅(不将玩家设置为准备状态);默认为false) + public boolean custom = false; + + // 是否隐藏结算界面中的『再来一局』按钮(false: 显示; true: 隐藏,默认为false) + public boolean hide = false; + } + + // 是否隐藏背景图,包括大厅和战斗 + // !!!这里只隐藏加载完成后的背景图,加载中背景图如需隐藏则调用:{SudMGP.getCfg().setShowLoadingGameBg(false); } + @Keep + public static class GameBg implements Serializable { + //(false: 显示; true: 隐藏,默认为false) + public boolean hide = false; + } + + // 自定义阻止换座位 + @Keep + public static class BlockChangeSeat implements Serializable { + //(false: 可以换座位; true: 不可以换座位;默认为false) + public boolean custom = false; + } + + // 大厅中的玩法选择设置面板 + @Keep + public static class GameSettingSelectPnl implements Serializable { + // 是否隐藏大厅中的玩法选择设置面板(false: 显示; true: 隐藏,默认为false) + public boolean hide = false; + } + + // 游戏中的托管图标 + @Keep + public static class GameManagedImage implements Serializable { + // 是否隐藏游戏中的托管图标(false: 显示; true: 隐藏,默认为false) + public boolean hide = false; + } + + // 游戏中牌桌背景图 (注:只对某些带牌桌类游戏有作用) + @Keep + public static class GameTableImage implements Serializable { + // 是否隐藏游戏牌桌背景图(false: 显示; true: 隐藏,默认为false) + public boolean hide = false; + } + + // 游戏中游戏倒计时显示 (注:现在只针对umo生效) + @Keep + public static class GameCountdownTime implements Serializable { + // 是否隐藏游戏中游戏倒计时显示(false: 显示; true: 隐藏,默认为false) + public boolean hide = false; + } + + // 游戏中所选择的玩法提示文字 (注:现在只针对ludo生效) + @Keep + public static class GameSelectedTips implements Serializable { + // 是否隐藏游戏中所选择的玩法提示文字显示(false: 显示; true: 隐藏,默认为false) + public boolean hide = false; + } + + // 控制NFT头像的开关 + @Keep + public static class NFTAvatar implements Serializable { + // true隐藏 false显示 + public boolean hide = true; + } + + // 控制开场动画的开关 + @Keep + public static class GameOpening implements Serializable { + // true隐藏 false显示 + public boolean hide = true; + } + + // 游戏结算前的mvp动画 + @Keep + public static class GameMvp implements Serializable { + // true隐藏 false显示 + public boolean hide = true; + } + + // 游戏中动画和头像右上角的UMO图标 + @Keep + public static class UmoIcon implements Serializable { + // 是否隐藏游戏中动画和头像右上角的UMO图标并改为UNO(false: 不隐藏,依然显示UMO; true: 隐藏,改为显示UNO,默认为false) + public boolean hide = false; + } + + // 大厅中的logo + @Keep + public static class Logo implements Serializable { + // 是否隐藏大厅中的logo(false: 不隐藏; true: 隐藏,默认为false) + public boolean hide = false; + } + + // 游戏中的游戏位 + @Keep + public static class GamePlayers implements Serializable { + // 是否隐藏游戏中的游戏位(false: 不隐藏; true: 隐藏,默认为false,暂时只支持你画我猜) + public boolean hide = false; + } + + // 你画我猜,你说我猜『弹幕开关』按钮 + @Keep + public static class BulletScreensBtn implements Serializable { + // 是否隐藏 你画我猜,你说我猜『弹幕开关』按钮(false: 显示; true: 隐藏;默认为true) + public boolean hide = true; + } + + // 你画我猜,小局结算界面点击扔大便按钮 + @Keep + public static class RoundOverPoopBtn implements Serializable { + // 你画我猜,小局结算点击扔大便按钮抛事件(false: 正常点击; true: 游戏通知app按钮点击事件;默认为false) + public boolean custom = false; + } + + // 你画我猜,小局结算界面点击点赞按钮 + @Keep + public static class RoundOverGoodBtn implements Serializable { + // 你画我猜,小局结算点击点赞按钮抛事件(false: 正常点击; true: 游戏通知app按钮点击事件;默认为false) + public boolean custom = false; + } + + // 游戏中所有蒙版 + @Keep + public static class Mask implements Serializable { + // 游戏中的所有蒙版是否透明(false: 不透明,按默认显示; true: 完全透明,默认为false;暂时只支持部分游戏) + public boolean transparent = false; + } + + // 友尽闯关中最坑队友的弹框 + @Keep + public static class WorstTeammateTip implements Serializable { + // 是否隐藏最坑队友弹框(false: 显示; true: 隐藏,默认为false;)只支持友尽闯关 + public boolean hide = false; + } + + // 友尽闯关中玩家逃跑导致游戏结束弹框 + @Keep + public static class GameOverTip implements Serializable { + // 是否隐藏玩家逃跑导致游戏结束弹框(false: 显示; true: 隐藏,默认为false;)只支持友尽闯关 + public boolean hide = false; + } + + // 碰碰我最强大厅动画 + @Keep + public static class LobbyAnimation implements Serializable { + // 是否隐藏碰碰我最强大厅动画(false: 显示; true: 隐藏,默认为false;)只支持碰碰我最强 + public boolean hide = false; + } + +} diff --git a/app/src/module_game/java/com/chwl/app/game/core/engine/model/GameViewInfoModel.java b/core/src/model_sud_wrapper/java/com/chwl/core/sud/model/GameViewInfoModel.java similarity index 96% rename from app/src/module_game/java/com/chwl/app/game/core/engine/model/GameViewInfoModel.java rename to core/src/model_sud_wrapper/java/com/chwl/core/sud/model/GameViewInfoModel.java index 236012c5e..b6d95fe71 100644 --- a/app/src/module_game/java/com/chwl/app/game/core/engine/model/GameViewInfoModel.java +++ b/core/src/model_sud_wrapper/java/com/chwl/core/sud/model/GameViewInfoModel.java @@ -3,7 +3,7 @@ * https://sud.tech */ -package com.chwl.app.game.core.engine.model; +package com.chwl.core.sud.model; import androidx.annotation.Keep; @@ -24,6 +24,7 @@ public class GameViewInfoModel { // 游戏安全操作区域 public GameViewRectModel view_game_rect = new GameViewRectModel(); + @Keep public static class GameViewSizeModel { // 游戏View的宽 (单位像素) @@ -32,6 +33,7 @@ public class GameViewInfoModel { // 游戏View的高 (单位像素) public int height; } + @Keep public static class GameViewRectModel { // 相对于view_size左边框偏移(单位像素) diff --git a/core/src/model_sud_wrapper/java/com/chwl/core/sud/state/MGStateResponse.java b/core/src/model_sud_wrapper/java/com/chwl/core/sud/state/MGStateResponse.java new file mode 100644 index 000000000..73b4055ff --- /dev/null +++ b/core/src/model_sud_wrapper/java/com/chwl/core/sud/state/MGStateResponse.java @@ -0,0 +1,35 @@ +/* + * Copyright © Sud.Tech + * https://sud.tech + */ + +package com.chwl.core.sud.state; + +import androidx.annotation.Keep; + +import com.chwl.core.sud.utils.SudJsonUtils; + +/** + * mg2app,状态响应 + */ +@Keep +public class MGStateResponse { + + // 返回码,成功 + public static final int SUCCESS = 0; + + public static MGStateResponse success() { + MGStateResponse response = new MGStateResponse(); + response.ret_code = SUCCESS; + response.ret_msg = "success"; + return new MGStateResponse(); + } + + + public int ret_code; // 返回码 + public String ret_msg; // 返回消息 + + public String toJson() { + return SudJsonUtils.toJson(this); + } +} diff --git a/core/src/model_sud_wrapper/java/com/chwl/core/sud/state/SudMGPAPPState.java b/core/src/model_sud_wrapper/java/com/chwl/core/sud/state/SudMGPAPPState.java new file mode 100644 index 000000000..5974f4eba --- /dev/null +++ b/core/src/model_sud_wrapper/java/com/chwl/core/sud/state/SudMGPAPPState.java @@ -0,0 +1,1321 @@ +/* + * Copyright © Sud.Tech + * https://sud.tech + */ + +package com.chwl.core.sud.state; + +import androidx.annotation.Keep; + +import java.io.Serializable; +import java.util.List; + +/** + * APP to MG 的通用状态定义 + * 参考文档:https://docs.sud.tech/zh-CN/app/Client/APPFST/ + */ +@Keep +public class SudMGPAPPState implements Serializable { + + // region 通用状态 + /** + * 1. 加入状态 + * 最低版本: v1.1.30.xx + */ + public static final String APP_COMMON_SELF_IN = "app_common_self_in"; + + /** + * 1. 加入状态 模型 + * 用户(本人)加入游戏/退出游戏 + * 正确流程: + * 1.isIn=true: 加入游戏=>准备游戏=>开始游戏; + * 2.isIn=false: 结束=>取消准备=>退出游戏; + */ + @Keep + public static class APPCommonSelfIn implements Serializable { + // rue 加入游戏,false 退出游戏 + public boolean isIn; + + // 加入的游戏位(座位号) 默认传seatIndex = -1 随机加入,seatIndex 从0开始,不可大于座位数 + public int seatIndex; + + // 默认为ture, 带有游戏位(座位号)的时候,如果游戏位(座位号)已经被占用,是否随机分配一个空位坐下 isSeatRandom=true 随机分配空位坐下,isSeatRandom=false 不随机分配 + public boolean isSeatRandom; + + // 不支持分队的游戏:数值填1;支持分队的游戏:数值填1或2(两支队伍); + public int teamId; + } + + /** + * 2. 准备状态 + * 最低版本: v1.1.30.xx + */ + public static final String APP_COMMON_SELF_READY = "app_common_self_ready"; + + /** + * 2. 准备状态 模型 + * 用户(本人)准备/取消准备 + */ + @Keep + public static class APPCommonSelfReady implements Serializable { + // true 准备,false 取消准备 + public boolean isReady; + } + + /** + * 3. 游戏状态 + * 最低版本: v1.1.30.xx + */ + public static final String APP_COMMON_SELF_PLAYING = "app_common_self_playing"; + + /** + * 3. 游戏状态 模型 + * 用户游戏状态,如果用户在游戏中,建议: + * a.空出屏幕中心区: + * 关闭全屏礼物特效; + * b.部分强操作类小游戏(spaceMax为true),尽量收缩原生UI,给游戏留出尽量大的操作空间: + * 收缩公屏; + * 收缩麦位; + * 如果不在游戏中,则恢复。 + */ + @Keep + public static class APPCommonSelfPlaying implements Serializable { + // true 开始游戏,false 结束游戏 + public boolean isPlaying; + + // string类型,Https服务回调report_game_info参数,最大长度1024字节,超过则截断(2022-01-21) + public String reportGameInfoExtras; + + // string类型,最大长度64字节,接入方服务端,可以根据这个字段来查询一局游戏的数据 + public String reportGameInfoKey; + } + + /** + * 4. 队长状态 + * 最低版本: v1.1.30.xx + */ + public static final String APP_COMMON_SELF_CAPTAIN = "app_common_self_captain"; + + /** + * 4. 队长状态 模型 + * 用户是否为队长,队长在游戏中会有开始游戏的权利。 + */ + @Keep + public static class APPCommonSelfCaptain implements Serializable { + // 必填,指定队长uid + public String curCaptainUID; + } + + /** + * 5. 踢人 + * v1.1.30.xx + */ + public static final String APP_COMMON_SELF_KICK = "app_common_self_kick"; + + /** + * 5. 踢人 模型 + * 用户(本人,队长)踢其他玩家; + * 队长才能踢人; + */ + @Keep + public static class APPCommonSelfKick implements Serializable { + // 被踢用户uid + public String kickedUID; + } + + /** + * 6. 结束游戏 + * v1.1.30.xx + */ + public static final String APP_COMMON_SELF_END = "app_common_self_end"; + + /** + * 6. 结束游戏 模型 + * 用户(本人,队长)结束(本局)游戏 + */ + @Keep + public static class APPCommonSelfEnd implements Serializable { + // 当前不需要传参 + } + + /** + * 7. 房间状态(depreated 已废弃v1.1.30.xx) + */ + public static final String APP_COMMON_SELF_ROOM = "app_common_self_room"; + + /** + * 8. 麦位状态(depreated 已废弃v1.1.30.xx) + */ + public static final String APP_COMMON_SELF_SEAT = "app_common_self_seat"; + + /** + * 9. 麦克风状态 + */ + public static final String APP_COMMON_SELF_MICROPHONE = "app_common_self_microphone"; + + /** + * 9. 麦克风状态 模型 + * 用户(本人)麦克风状态,建议: + * 进入房间后初始通知一次; + * 每次变更(开麦/闭麦/禁麦/解麦)通知一次; + */ + @Keep + public static class APPCommonSelfMicrophone implements Serializable { + // true 开麦,false 闭麦 + public boolean isOn; + + // true 被禁麦,false 未被禁麦 + public boolean isDisabled; + } + + /** + * 10. 文字命中状态 + */ + public static final String APP_COMMON_SELF_TEXT_HIT = "app_common_self_text_hit"; + + /** + * 10. 文字命中状态 模型 + * 用户(本人)聊天信息命中关键词状态,建议: + * 精确匹配; + * 首次聊天内容命中关键词之后,后续聊天内容不翻转成未命中; + * 直至小游戏侧关键词更新,再将状态翻转为未命中; + */ + @Keep + public static class APPCommonSelfTextHitState implements Serializable { + // true 命中,false 未命中 + public boolean isHit; + + // 关键词 + public String keyWord; + + // 聊天原始内容 + public String text; + } + + /** + * 11. 打开或关闭背景音乐(2021-12-27新增) + */ + public static final String APP_COMMON_OPEN_BG_MUSIC = "app_common_open_bg_music"; + + /** + * 11. 打开或关闭背景音乐(2021-12-27新增) 模型 + */ + @Keep + public static class APPCommonOpenBgMusic implements Serializable { + // true 打开背景音乐,false 关闭背景音乐 + public boolean isOpen; + } + + /** + * 12. 打开或关闭音效(2021-12-27新增) + */ + public static final String APP_COMMON_OPEN_SOUND = "app_common_open_sound"; + + /** + * 12. 打开或关闭音效(2021-12-27新增) 模型 + */ + @Keep + public static class APPCommonOpenSound implements Serializable { + // true 打开音效,false 关闭音效 + public boolean isOpen; + } + + /** + * 13. 打开或关闭游戏中的振动效果(2021-12-27新增) + */ + public static final String APP_COMMON_OPEN_VIBRATE = "app_common_open_vibrate"; + + /** + * 13. 打开或关闭游戏中的振动效果(2021-12-27新增)模型 + */ + @Keep + public static class APPCommonOpenVibrate implements Serializable { + // true 打开振动效果,false 关闭振动效果 + public boolean isOpen; + } + + /** + * 14. 设置游戏的音量大小(2021-12-31新增) + */ + public static final String APP_COMMON_GAME_SOUND_VOLUME = "app_common_game_sound_volume"; + + /** + * 14. 设置游戏的音量大小(2021-12-31新增)模型 + */ + @Keep + public static class APPCommonGameSoundVolume implements Serializable { + // 音量大小 0 到 100 + public int volume; + } + + /** + * 15. 设置游戏玩法选项(2022-05-10新增) + */ + public static final String APP_COMMON_GAME_SETTING_SELECT_INFO = "app_common_game_setting_select_info"; + + /** + * 15. 设置游戏玩法选项(2022-05-10新增) 模型 + */ + @Keep + public static class APPCommonGameSettingSelectInfo implements Serializable { + public Ludo ludo; // 游戏名称 + } + + @Keep + public static class Ludo implements Serializable { + public int mode; // mode: 默认赛制,0: 快速, 1: 经典; + public int chessNum; // chessNum: 默认棋子数量, 2: 对应2颗棋子; 4: 对应4颗棋子; + public int item; // item: 默认道具, 1: 有道具, 0: 没有道具 + } + + /** + * 16. 设置游戏中的AI玩家(2022-05-11新增) + */ + public static final String APP_COMMON_GAME_ADD_AI_PLAYERS = "app_common_game_add_ai_players"; + + /** + * 16. 设置游戏中的AI玩家(2022-05-11新增) 模型 + */ + @Keep + public static class APPCommonGameAddAIPlayers implements Serializable { + public List aiPlayers; // AI玩家 + public int isReady = 1; // 机器人加入后是否自动准备 1:自动准备,0:不自动准备 默认为1 + } + + @Keep + public static class AIPlayers implements Serializable { + public static final int LEVEL_SIMPLE = 1; // 机器人等级:简单 + public static final int LEVEL_MODERATE = 2; // 机器人等级:适中 + public static final int LEVEL_DIFFICULTY = 3; // 机器人等级:困难 + + public String userId; // 玩家id + public String avatar; // 头像url + public String name; // 名字 + public String gender; // 性别 male:男,female:女 + public int level; // 机器人等级 1:简单 2:适中 3:困难 + } + + /** + * 17. app在收到游戏断开连接通知后,通知游戏重试连接(2022-06-21新增,暂时支持ludo) + */ + public static final String APP_COMMON_GAME_RECONNECT = "app_common_game_reconnect"; + + /** + * 17. app在收到游戏断开连接通知后,通知游戏重试连接(2022-06-21新增,暂时支持ludo) 模型 + */ + @Keep + public static class APPCommonGameReconnect implements Serializable { + } + + /** + * 18. app返回玩家当前积分 + */ + public static final String APP_COMMON_GAME_SCORE = "app_common_game_score"; + + /** + * 18. app返回玩家当前积分 模型 + */ + @Keep + public static class APPCommonGameScore implements Serializable { + public long score; // 玩家当前积分 + } + + /** + * 23. app通知游戏创建订单的结果 + */ + public static final String APP_COMMON_GAME_CREATE_ORDER_RESULT = "app_common_game_create_order_result"; + + /** + * 23. app通知游戏创建订单的结果 模型 + */ + @Keep + public static class APPCommonGameCreateOrderResult implements Serializable { + public int result; // app通知游戏创建订单的结果0:失败 1:成功 + } + + /** + * 24. app通知游戏设置玩法(只支持 德州pro和teenpattipro) + */ + public static final String APP_COMMON_GAME_SETTINGS = "app_common_game_settings"; + + /** + * 24. app通知游戏设置玩法(只支持 德州pro和teenpattipro) 模型 + */ + @Keep + public static class APPCommonGameSettings implements Serializable { + public int smallBlind; // 1 配置小盲,大盲为小盲的2倍[1,2,5,10,20,50,100,200,500,1000] + public int ante; // 0 前注 + public int sBuyIn; // 100 带入值/最小带入配置[100,200,100,200,500,1000,2000,5000,100000] + public int bBuyIn; // 200 最大带入,无限(0) + public int isAutoStart; // 2 0表示关闭自动开始 [0,2,6,7,8,9] + public int isStraddle; // 0 0:关闭,1自由,2强制 + public double tableDuration; // 0.05 牌桌时长配置(小时)[0.5,1,2,4,6,8] + public int thinkTime; // 20 思考时间(秒)[10,15,20] + } + + /** + * 25. app通知返回大厅 + */ + public static final String APP_COMMON_GAME_BACK_LOBBY = "app_common_game_back_lobby"; + + /** + * 25. app通知返回大厅 模型 + */ + @Keep + public static class APPCommonGameBackLobby implements Serializable { + } + + /** + * 26. app通知游戏定制UI配置表 (仅支持ludo) + */ + public static final String APP_COMMON_GAME_UI_CUSTOM_CONFIG = "app_common_game_ui_custom_config"; + + /** + * 26. app通知游戏定制UI配置表 (仅支持ludo) 模型 + */ + @Keep + public static class APPCommonGameUiCustomConfig implements Serializable { + public String gameBoard01; // 棋盘底 + public String gameBoard02; // 棋盘 + public String diceBg; // 骰子白底 + public String diceBgGold; // 黄金骰子底 + public String dice01; // 骰子1 + public String dice02; // 骰子2 + public String dice03; // 骰子3 + public String dice04; // 骰子4 + public String dice05; // 骰子5 + public String dice06; // 骰子6 + public String diceCrown; // 骰子皇冠 + public String chessYellow; // 黄色棋子 + public String chessBlue; // 蓝色棋子 + public String chessGreen; // 绿色棋子 + public String chessRed; // 红色棋子 + } + + /** + * 27. app通知游戏玩家信息列表 (赛车) + */ + public static final String APP_COMMON_USERS_INFO = "app_common_users_info"; + + /** + * 27. app通知游戏玩家信息列表 (赛车) 模型 + */ + @Keep + public static class APPCommonUsersInfo implements Serializable { + public List infos; + + @Keep + public static class UserInfoModel { + public String uid; // 玩家id + public String avatar; // 玩家头像url + public String name; // 玩家名字 + } + } + + /** + * 28. app通知游戏自定义帮助内容 (赛车) + */ + public static final String APP_COMMON_CUSTOM_HELP_INFO = "app_common_custom_help_info"; + + /** + * 28. app通知游戏自定义帮助内容 (赛车) 模型 + */ + @Keep + public static class APPCommonCustomHelpInfo implements Serializable { + public List content; + } + + /** + * 29. app主动调起主界面(赛车) + */ + public static final String APP_COMMON_SHOW_GAME_SCENE = "app_common_show_game_scene"; + + /** + * 29. app主动调起主界面(赛车) 模型 + */ + @Keep + public static class APPCommonShowGameScene implements Serializable { + } + + /** + * 30. app主动隐藏主界面(赛车) + */ + public static final String APP_COMMON_HIDE_GAME_SCENE = "app_common_hide_game_scene"; + + /** + * 30. app主动隐藏主界面(赛车) 模型 + */ + @Keep + public static class APPCommonHideGameScene implements Serializable { + } + + /** + * 31. app通知游戏爆词内容(谁是卧底) + */ + public static final String APP_COMMON_GAME_SEND_BURST_WORD = "app_common_game_send_burst_word"; + + /** + * 31. app通知游戏爆词内容(谁是卧底) 模型 + */ + @Keep + public static class APPCommonGameSendBurstWord implements Serializable { + public String text; // 爆词内容 + } + + /** + * 32. app通知游戏玩家所持有的道具卡(大富翁) + */ + public static final String APP_COMMON_GAME_PLAYER_MONOPOLY_CARDS = "app_common_game_player_monopoly_cards"; + + /** + * 32. app通知游戏玩家所持有的道具卡(大富翁) 模型 + */ + @Keep + public static class APPCommonGamePlayerMonopolyCards implements Serializable { + public int reroll_card_count; // 重摇卡的数量 + public int free_rent_card_count; // 免租卡的数量 + public int ctrl_dice_card_count; // 购买指定骰子点数卡的数量 + } + + /** + * 33. app通知游戏获取到道具卡(大富翁) + */ + public static final String APP_COMMON_GAME_SHOW_MONOPOLY_CARD_EFFECT = "app_common_game_show_monopoly_card_effect"; + + /** + * 33. app通知游戏获取到道具卡(大富翁) 模型 + */ + @Keep + public static class APPCommonGameShowMonopolyCardEffect implements Serializable { + public int type; // 1:重摇卡,2:免租卡,3:指定点数卡 + public String fromUid; // 发送的玩家id + public String toUid; // 接收方玩家id + public int count; // 数量 + } + + /** + * 34. app通知游戏侧更新游戏币(概率游戏相关玩法) + */ + public static final String APP_COMMON_UPDATE_GAME_MONEY = "app_common_update_game_money"; + + /** + * 34. app通知游戏侧更新游戏币(概率游戏相关玩法) 模型 + */ + @Keep + public static class AppCommonUpdateGameMoney implements Serializable { + } + + /** + * 35. app通知游戏玩家所持有的道具卡(只支持飞行棋) + */ + public static final String APP_COMMON_GAME_PLAYER_PROPS_CARDS = "app_common_game_player_props_cards"; + + /** + * 35. app通知游戏玩家所持有的道具卡(只支持飞行棋) 模型 + */ + @Keep + public static class AppCommonGamePlayerPropsCards implements Serializable { + /** + * 道具卡数量结构的json字符串 + *

+ * ludo 返回字符串结构说明 + * 注:返回的是一个json数据的字符串,specify_dice_roll是遥控骰子字段对应的数量 + * {"props": "{"specify_dice_roll":0}"} + */ + public String props; + } + + /** + * 36. app通知游戏播放玩家所获得的道具卡的特效(只支持飞行棋) + */ + public static final String APP_COMMON_GAME_PLAYER_PROPS_CARDS_EFFECT = "app_common_game_player_props_cards_effect"; + + /** + * 36. app通知游戏播放玩家所获得的道具卡的特效(只支持飞行棋) 模型 + */ + @Keep + public static class AppCommonGamePlayerPropsCardsEffect implements Serializable { + /** + * 获得的道具卡名字 + *

+ * 飞行棋(ludo) + * paid_events_type: "specify_dice_roll" // 控制指定摇出骰子点数的道具 + */ + public String paid_events_type; + public String fromUid; // 发送的玩家id + public String toUid; // 接收方玩家id + public int count; // 数量 + } + // endregion 通用状态 + + // region 元宇宙砂砂舞 + /** + * 1. 元宇宙砂砂舞相关设置 + * 参考文档:https://docs.sud.tech/zh-CN/app/Client/APPFST/CommonStateForDisco.html + */ + public static final String APP_COMMON_GAME_DISCO_ACTION = "app_common_game_disco_action"; + + /** + * 1. 元宇宙砂砂舞相关设置 模型 + */ + @Keep + public static class AppCommonGameDiscoAction implements Serializable { + public int actionId; // 必传的参数,用于指定类型的序号,不同序号用于区分游戏内的不同功能,不传则会判断为无效指令,具体序号代表的功能见下表 + public Integer cooldown; // 持续时间,单位秒,部分功能有持续时间就需要传对应的数值,不传或传错则会按各自功能的默认值处理(见下表) + public Boolean isTop; // 是否置顶,针对部分功能可排队置顶(false:不置顶;true:置顶;默认为false) + public String field1; // 额外参数1,针对部分功能有具体的意义 + public String field2; // 额外参数2,针对部分功能有具体的意义 + } + // endregion 元宇宙砂砂舞 + + // region 定制火箭 + /** + * 1. 礼物配置文件回调 + */ + public static final String APP_CUSTOM_ROCKET_CONFIG = "app_custom_rocket_config"; + + /** + * 1. 礼物配置文件回调 模型 + */ + @Keep + public static class AppCustomRocketConfig implements Serializable { + public int maxSeat; // 最大机位 + public double firePrice; // 发射的静态价格 + public int isDynamicPrice; // 发射价格是否动态开关 0:静态 1动态 + public String gameIntroduce; // 玩法介绍 + public String monetaryUnit; // 货币的单位 + public long serverTime; // 服务器时间戳,单位秒 + public List filterModel; // 过滤不显示的模块(默认是为空) + public List filterLayer; // 过滤不显示的页面(默认是为空) + public List componentList; // 组件列表 1套装,2主仓,3尾翼,4头像,5签名,6颜色 + public List headList; // 组件列表 + public List extraList; // 专属配置 + + @Keep + public static class ComponentModel { + public String componentId; // 组件的ID + public int type; // 1套装,2主仓,3尾翼 + public String name; // 显示名称(商城+装配间+购买记录+...) + public double price; // 价格 + public int isForever; // 永久:0非永久 1永久 + public long validTime; // 有效期:单位是秒 + public String imageId; // 图片ID + public int isLock; // 锁:0不锁 1锁 + public int isShow; // 展示:0不展示 1展示 + } + + @Keep + public static class HeadModel { + public String componentId; // 组件的ID + public int type; // 4头像(商城+装配间+购买记录+...) + public String name; // 显示名称 + public double price; // 价格 暂时不考虑小数 + public int isForever; // 永久:0非永久 1永久 + public long validTime; // 有效期:单位是秒 + public String userId; // 用户的userId + public String nickname; // 昵称 + public int sex; // 性别 0:男 1:女 + public String url; // 头像URL + } + + @Keep + public static class ExtraModel { + public String componentId; // 组件的ID + public int type; // 5签名,6颜色 + public String name; // 显示名称(商城+装配间+购买记录+...) + public double price; // 价格 + public int isForever; // 永久:0非永久 1永久 + public long validTime; // 有效期:单位是秒 + public String desc; // 描述 + } + } + + /** + * 2. 拥有模型列表回调(火箭) + */ + public static final String APP_CUSTOM_ROCKET_MODEL_LIST = "app_custom_rocket_model_list"; + + /** + * 2. 拥有模型列表回调(火箭) 模型 + */ + @Keep + public static class AppCustomRocketModelList implements Serializable { + public String defaultModelId; // 默认模型 + public int isScreenshot; // 截图:0不截图 1截图(app上传失败或者过期时,被动截图) + public List list; + + @Keep + public static class Model { + public String modelId; // 模型Id + public int isAvatar; // 可以换装:0不可以 1可以 + public String serviceFlag; // 服务标识 + public List componentList; // 列表 + + @Keep + public static class ComponentModel { + public String itemId; // 唯一标识 + public int type; // 类型 + public String value; // 值 + public int isForever; // 永久:0非永久 1永久 + public long validTime; // 有效期时间戳:单位是秒 + } + } + } + + /** + * 3. 拥有组件列表回调(火箭) + */ + public static final String APP_CUSTOM_ROCKET_COMPONENT_LIST = "app_custom_rocket_component_list"; + + /** + * 3. 拥有组件列表回调(火箭) 模型 + */ + @Keep + public static class AppCustomRocketComponentList implements Serializable { + public List defaultList; // 默认组件列表 + public List list; // 组件列表 + + @Keep + public static class ComponentModel { + public String itemId; // 唯一标识 + public int type; // 类型 + public String value; // 值 + public int isForever; // 永久:0非永久 1永久 + public long validTime; // 有效期时间戳:单位是秒 + public long date; // 购买时间:1970年1月1日开始。时间戳:单位是秒 + public String extra; // (可选择) 字段存在显示内容,字段不存在显示时间或者永久 + } + } + + /** + * 4. 获取用户信息回调(火箭) + */ + public static final String APP_CUSTOM_ROCKET_USER_INFO = "app_custom_rocket_user_info"; + + /** + * 4. 获取用户信息回调(火箭) 模型 + */ + @Keep + public static class AppCustomRocketUserInfo implements Serializable { + public int resultCode; // 0: 请求成功,1:请求失败 + public String error; // 错误描述 + public List userList; // 用户信息列表 + } + + /** + * 5. 订单记录列表回调 + */ + public static final String APP_CUSTOM_ROCKET_ORDER_RECORD_LIST = "app_custom_rocket_order_record_list"; + + /** + * 5. 订单记录列表回调 模型 + */ + @Keep + public static class AppCustomRocketOrderRecordList implements Serializable { + public int pageIndex; // 第几页 + public int pageCount; // 总页数 + public List list; // 列表 + + /** + * 定制火箭,订单组件 模型 + */ + @Keep + public static class ComponentModel { + public int type; // 类型 + public String value; // 值 + public int isForever; // 永久:0非永久 1永久 + public long validTime; // 有效期时间戳:单位是秒 + public long date; // 有效期时间戳:单位是秒 + } + } + + /** + * 6. 展馆内列表回调 + */ + public static final String APP_CUSTOM_ROCKET_ROOM_RECORD_LIST = "app_custom_rocket_room_record_list"; + + /** + * 6. 展馆内列表回调 模型 + */ + @Keep + public static class AppCustomRocketRoomRecordList implements Serializable { + public int pageIndex; // 第几页 + public int pageCount; // 总页数 + public List list; // 列表 + + @Keep + public static class RoomRecordModel { + public CustomRocketUserInfoModel fromUser; // 送礼人 + public int number; // 火箭数量 + } + } + + /** + * 7. 展馆内玩家送出记录回调 + */ + public static final String APP_CUSTOM_ROCKET_USER_RECORD_LIST = "app_custom_rocket_user_record_list"; + + /** + * 7. 展馆内玩家送出记录回调 模型 + */ + @Keep + public static class AppCustomRocketUserRecordList implements Serializable { + public int pageIndex; // 第几页 + public int pageCount; // 总页数 + public CustomRocketUserInfoModel fromUser; // 送礼人 + public List list; // 列表 + + @Keep + public static class UserRecordModel { + public long date; // 订单时间戳: 单位是秒 + public int number; // 个数 + public CustomRocketUserInfoModel toUser; // 收礼人 + public List componentList; // 列表 + + @Keep + public static class ComponentModel { + public int type; // 类型 + public String value; // 值 + public int isForever; // 永久:0非永久 1永久 + public long validTime; // 有效期时间戳:单位是秒 + } + } + } + + /** + * 8. 设置默认模型(火箭) + */ + public static final String APP_CUSTOM_ROCKET_SET_DEFAULT_MODEL = "app_custom_rocket_set_default_model"; + + /** + * 8. 设置默认模型(火箭) 模型 + */ + @Keep + public static class AppCustomRocketSetDefaultModel implements Serializable { + public int resultCode; // 0: 请求成功,1:请求失败 + public String error; // 错误描述 + public Data data; // 数据 + + @Keep + public static class Data { + public String modelId; // 默认模型 + } + } + + /** + * 9. 动态计算一键发送价格回调 + */ + public static final String APP_CUSTOM_ROCKET_DYNAMIC_FIRE_PRICE = "app_custom_rocket_dynamic_fire_price"; + + /** + * 9. 动态计算一键发送价格回调 模型 + */ + @Keep + public static class AppCustomRocketDynamicFirePrice implements Serializable { + public int resultCode; // 0: 请求成功,1:请求失败 + public String error; // 错误描述 + public Data data; // 数据 + + @Keep + public static class Data { + public double price; // 发送的价格 + } + } + + /** + * 10. 一键发送回调 + */ + public static final String APP_CUSTOM_ROCKET_FIRE_MODEL = "app_custom_rocket_fire_model"; + + /** + * 10. 一键发送回调 模型 + */ + @Keep + public static class AppCustomRocketFireModel implements Serializable { + public int resultCode; // 0: 请求成功,1:请求失败 + public String error; // 错误描述 + } + + /** + * 11. 新组装模型 回调 + */ + public static final String APP_CUSTOM_ROCKET_CREATE_MODEL = "app_custom_rocket_create_model"; + + /** + * 11. 新组装模型 回调 模型 + */ + @Keep + public static class AppCustomRocketCreateModel implements Serializable { + public int resultCode; // 0: 请求成功,1:请求失败 + public String error; // 错误描述 + public Data data; + + @Keep + public static class Data { + public String modelId; // 模型Id + public int isAvatar; // 可以换装:0不可以 1可以 + public String serviceFlag; // 服务标识 + public List componentList; + + @Keep + public static class ComponentModel { + public String itemId; // 模型Id + } + } + } + + /** + * 12. 更换组件 回调 + */ + public static final String APP_CUSTOM_ROCKET_REPLACE_COMPONENT = "app_custom_rocket_replace_component"; + + /** + * 12. 更换组件 回调 模型 + */ + @Keep + public static class AppCustomRocketReplaceComponent implements Serializable { + public int resultCode; // 0: 请求成功,1:请求失败 + public String error; // 错误描述 + public Data data; + + @Keep + public static class Data { + public String modelId; // 模型Id + public List componentList; + + @Keep + public static class ComponentModel { + public String itemId; + } + } + } + + /** + * 13. 购买组件 回调 + */ + public static final String APP_CUSTOM_ROCKET_BUY_COMPONENT = "app_custom_rocket_buy_component"; + + /** + * 13. 购买组件 回调 模型 + */ + @Keep + public static class AppCustomRocketBuyComponent implements Serializable { + public int resultCode; // 0: 请求成功,1:请求失败 + public String error; // 错误描述 + public Data data; + + @Keep + public static class Data { + public List componentList; + + @Keep + public static class ComponentModel { + public String itemId; // 唯一标识 + public int type; // 类型 + public String value; // 值 + public int isForever; // 永久:0非永久 1永久 + public long validTime; // 有效期时间戳:单位是秒 + public long date; // 有效期时间戳:单位是秒 + } + } + } + + /** + * 14. app播放火箭发射动效(火箭) + */ + public static final String APP_CUSTOM_ROCKET_PLAY_MODEL_LIST = "app_custom_rocket_play_model_list"; + + /** + * 14. app播放火箭发射动效(火箭) 模型 + */ + @Keep + public static class AppCustomRocketPlayModelList implements Serializable { + public String orderId; // 订单号 + public InteractConfigModel interactConfig; // 可选配置 + public List componentList; // 组件列表 + + @Keep + public static class ComponentModel { + public int type; // 类型 + public String value; // 值 + } + + @Keep + public static class InteractConfigModel { + public int interactivePlay; // 互动玩法默认状态,1是关闭,0是打开,默认打开; + public List gear; // 每个档位需要点击的次数; + public int nicknameTips; // 昵称飘字是否显示,1是隐藏,0是显示,默认0; + public int uiSwitche; // 左上角UI信息是否显示,1是隐藏,0是显示,默认0; + public int guide; // 新手引导是否显示,1是隐藏,0是显示,默认0; + } + } + + /** + * 15. app推送主播信息(火箭) + */ + public static final String APP_CUSTOM_ROCKET_NEW_USER_INFO = "app_custom_rocket_new_user_info"; + + /** + * 15. app推送主播信息(火箭) 模型 + */ + @Keep + public static class AppCustomRocketNewUserInfo implements Serializable { + public List userList; // 用户信息列表 + } + + /** + * 16. 验证签名合规(火箭) + */ + public static final String APP_CUSTOM_ROCKET_VERIFY_SIGN = "app_custom_rocket_verify_sign"; + + /** + * 16. 验证签名合规(火箭) 回调 模型 + */ + @Keep + public static class AppCustomRocketVerifySign implements Serializable { + public int resultCode; // 0: 请求成功,1:请求失败 + public String error; // 错误描述 + public Data data; + + @Keep + public static class Data { + public String sign; // 验证的签名 + } + } + + /** + * 17. app主动调起火箭主界面(火箭) + */ + public static final String APP_CUSTOM_ROCKET_SHOW_GAME_SCENE = "app_custom_rocket_show_game_scene"; + + /** + * 17. app主动调起火箭主界面(火箭) 模型 + */ + @Keep + public static class AppCustomRocketShowGameScene implements Serializable { + } + + /** + * 18. app主动隐藏火箭主界面(火箭) + */ + public static final String APP_CUSTOM_ROCKET_HIDE_GAME_SCENE = "app_custom_rocket_hide_game_scene"; + + /** + * 18. app主动隐藏火箭主界面(火箭) 模型 + */ + @Keep + public static class AppCustomRocketHideGameScene implements Serializable { + } + + /** + * 19. app推送解锁组件(火箭) + */ + public static final String APP_CUSTOM_ROCKET_UNLOCK_COMPONENT = "app_custom_rocket_unlock_component"; + + /** + * 19. app推送解锁组件(火箭) 模型 + */ + @Keep + public static class AppCustomRocketUnlockComponent implements Serializable { + public int type; // 组件类型 + public String componentId; // 组件ID + } + + /** + * 20. app推送火箭效果飞行点击(火箭) + */ + public static final String APP_CUSTOM_ROCKET_FLY_CLICK = "app_custom_rocket_fly_click"; + + /** + * 20. app推送火箭效果飞行点击(火箭) 模型 + */ + @Keep + public static class AppCustomRocketFlyClick implements Serializable { + } + + /** + * 21. app推送关闭火箭播放效果(火箭) + */ + public static final String APP_CUSTOM_ROCKET_CLOSE_PLAY_EFFECT = "app_custom_rocket_close_play_effect"; + + /** + * 21. app推送关闭火箭播放效果(火箭) 模型 + */ + @Keep + public static class AppCustomRocketClosePlayEffect implements Serializable { + } + + /** + * 22. 颜色和签名自定义改到装配间的模式,保存颜色或签名回调 + */ + public static final String APP_CUSTOM_ROCKET_SAVE_SIGN_COLOR = "app_custom_rocket_save_sign_color"; + + /** + * 22. 颜色和签名自定义改到装配间的模式,保存颜色或签名回调 模型 + */ + @Keep + public static final class AppCustomRocketSaveSignColor implements Serializable { + public int resultCode; // 0: 请求成功,1:请求失败 + public String error; // 错误描述 + public Data data; // 数据 + + @Keep + public static class Data { + public List componentList; + } + + @Keep + public static class ComponentModel { + public String itemId; // 唯一标识 + public int type; // 签名 + public String value; // 签名的值 + public int isForever; // 永久:0非永久 1永久 + public long validTime; // 有效期时间戳:单位是秒 + } + } + + /** + * 定制火箭,用户信息 模型 + */ + @Keep + public static class CustomRocketUserInfoModel { + public String userId; // 用户的userId + public String nickname; // 昵称 + public int sex; // 性别 0:男 1:女 + public String url; // 头像URL + } + // endregion 定制火箭 + + // region 棒球 + /** + * 1. 下发游戏客户端查询排行榜数据(棒球) + */ + public static final String APP_BASEBALL_RANKING = "app_baseball_ranking"; + + /** + * 1. 下发游戏客户端查询排行榜数据(棒球) 模型 + */ + @Keep + public static class AppBaseballRanking implements Serializable { + public List data; + } + + /** + * 2. 下发游戏客户端查询我的排名数据(棒球) + */ + public static final String APP_BASEBALL_MY_RANKING = "app_baseball_my_ranking"; + + /** + * 2. 下发游戏客户端查询我的排名数据(棒球) 模型 + */ + @Keep + public static class AppBaseballMyRanking implements Serializable { + public AppBaseballPlayerInfo data; + } + + /** + * 3. 下发游戏客户端查询排在自己前后的玩家数据(棒球) + */ + public static final String APP_BASEBALL_RANGE_INFO = "app_baseball_range_info"; + + /** + * 3. 下发游戏客户端查询排在自己前后的玩家数据(棒球) 模型 + */ + @Keep + public static class AppBaseballRangeInfo implements Serializable { + public AppBaseballPlayerInfo before; // 前一名 + public AppBaseballPlayerInfo after; // 后一名 + } + + /** + * 4. app主动调起主界面(棒球) + */ + public static final String APP_BASEBALL_SHOW_GAME_SCENE = "app_baseball_show_game_scene"; + + /** + * 4. app主动调起主界面(棒球) 模型 + */ + @Keep + public static class AppBaseballShowGameScene implements Serializable { + } + + /** + * 5. app主动隐藏主界面(棒球) + */ + public static final String APP_BASEBALL_HIDE_GAME_SCENE = "app_baseball_hide_game_scene"; + + /** + * 5. app主动隐藏主界面(棒球) 模型 + */ + @Keep + public static class AppBaseballHideGameScene implements Serializable { + } + + /** + * 6. app推送需要的文本数据(棒球) + */ + public static final String APP_BASEBALL_TEXT_CONFIG = "app_baseball_text_config"; + + /** + * 6. app推送需要的文本数据(棒球) 模型 + */ + @Keep + public static class AppBaseballTextConfig implements Serializable { + public String mode1; + public String mode2; + public String mode3; + } + + @Keep + public static class AppBaseballPlayerInfo implements Serializable { + public String playerId; // 玩家Id + public String name; // 玩家昵称 + public String avatar; // 头像 + public long distance; // 距离 + public int rank; // 排名 + } + // endregion 棒球 + + // region 3D语聊房 + /** + * 1. 设置房间配置 + * 收到游戏发过来的mg_custom_cr_room_init_data状态后 + * App把房间配置以及主播位数据发送给游戏 + */ + public static final String APP_CUSTOM_CR_SET_ROOM_CONFIG = "app_custom_cr_set_room_config"; + + /** + * 1. 设置房间配置 模型 + */ + @Keep + public static class AppCustomCrSetRoomConfig implements Serializable { + public int platformRotate; // 立方体是否自转 0:不旋转 1:旋转 + public int rotateDir; // 立方体自转方向 0:从右往左转 1:从左往右转 + public int rotateSpeed; // 立方体自转速度(整形类型)0:使用默认速度每秒6度 x>0:每秒旋转x度 + public int gameMusic; // 音乐控制 0:关 1:开 + public int gameSound; // 音效控制 0:关 1:开 + public int flashVFX; // 是否开启爆灯边框效果 0:关 1:开 + public int micphoneWave; // 是否开启麦浪边框效果 0:关 1:开 + public int showGiftValue; // 是否显示心动值 0:隐藏 1:显示 + } + + /** + * 2. 设置主播位数据 + * 收到游戏发过来的mg_custom_cr_room_init_data状态后 + * App把房间配置以及主播位数据发送给游戏 + *

+ * 初始化时,需要发送5个主播位的全量数据 + * 后续如果某个主播位有变化,可只传一个或多个主播位的数据(需要该主播位的全量数据) + */ + public static final String APP_CUSTOM_CR_SET_SEATS = "app_custom_cr_set_seats"; + + /** + * 2. 设置主播位数据 模型 + */ + @Keep + public static class AppCustomCrSetSeats implements Serializable { + public List seats; // 主播位数据 + + /** + * 3D语聊房主播位 模型 + */ + @Keep + public static class CrSeatModel implements Serializable { + public static final int MICRO_STATE_SOMEONE = 1; + public static final int MICRO_STATE_NO_ONE = 2; + public static final int MICRO_STATE_LOCKED = 3; + + public int seatIndex; // 0~4一共5个麦位,0为老板位,1~4为四个面主播位 + public int level; // 四个面场景等级 0~2 + public int microState; // 麦位状态 1:有人 2:空位 3:麦位被锁 + public String userId; // 当前麦位用户id(如果有) + public int gender; // 性别 0:男 1:女 + public String name; // 名字 + public String photoUrl; // 头像链接 + public int micphoneState; // 麦克风状态 -1:禁麦 0:闭麦 1:开麦 + public int giftValue; // 心动值 + } + } + + /** + * 3. 播放收礼效果 + */ + public static final String APP_CUSTOM_CR_PLAY_GIFT_EFFECT = "app_custom_cr_play_gift_effect"; + + /** + * 3. 播放收礼效果 模型 + */ + @Keep + public static class AppCustomCrPlayGiftEffect implements Serializable { + public String giverUserId; // 送礼人的userId + public boolean isAllSeat; // 标识是否是全麦 + public List giftList; // 礼物列表,可送给一个或者多个主播 + + @Keep + public static class CrGiftModel implements Serializable { + public int seatIndex; // 0~4一共5个麦位,0为老板位,1~4为四个面主播位 + public int level; // 礼物档位,1 ~ 30 + public int count; // 礼物数量 + } + } + + /** + * 4. 通知播放爆灯特效 + */ + public static final String APP_CUSTOM_CR_SET_LIGHT_FLASH = "app_custom_cr_set_light_flash"; + + /** + * 4. 通知播放爆灯特效 模型 + */ + @Keep + public static class AppCustomCrSetLightFlash implements Serializable { + public int seatIndex; // 主播位index + } + + /** + * 5. 通知主播播放指定动作 + */ + public static final String APP_CUSTOM_CR_PLAY_ANIM = "app_custom_cr_play_anim"; + + /** + * 5. 通知主播播放指定动作 模型 + */ + @Keep + public static class AppCustomCrPlayAnim implements Serializable { + public int seatIndex; // 主播位index + public int animId; // 动作id 1:跳舞 2:飞吻 3:感谢 4:鼓掌 5:害羞 6:欢呼 7:伤心 8:生气 + } + + /** + * 6. 通知麦浪值变化 + */ + public static final String APP_CUSTOM_CR_MICPHONE_VALUE_SEAT = "app_custom_cr_micphone_value_seat"; + + /** + * 6. 通知麦浪值变化 模型 + */ + @Keep + public static class AppCustomCrMicphoneValueSeat implements Serializable { + public int seatIndex; // 主播位index + public int value; // 麦浪值,请映射到区间0~100 + } + + /** + * 7. 通知暂停或恢复立方体自转 + */ + public static final String APP_CUSTOM_CR_PAUSE_ROTATE = "app_custom_cr_pause_rotate"; + + /** + * 7. 通知暂停或恢复立方体自转 模型 + */ + @Keep + public static class AppCustomCrPauseRotate implements Serializable { + /** + * 0:恢复自转(若旋转配置启用自转,则收到0时恢复自转,若旋转配置不启用自转,则无效果) + * 1:暂停自转(若旋转配置启用自转,则收到1时暂定自转,若旋转配置不启用自转,则无效果) + */ + public int pause; + } + // endregion 3D语聊房 + +} diff --git a/core/src/model_sud_wrapper/java/com/chwl/core/sud/state/SudMGPMGState.java b/core/src/model_sud_wrapper/java/com/chwl/core/sud/state/SudMGPMGState.java new file mode 100644 index 000000000..c34c0c906 --- /dev/null +++ b/core/src/model_sud_wrapper/java/com/chwl/core/sud/state/SudMGPMGState.java @@ -0,0 +1,1870 @@ +/* + * Copyright © Sud.Tech + * https://sud.tech + */ + +package com.chwl.core.sud.state; + +import androidx.annotation.Keep; + +import com.google.gson.annotations.SerializedName; + +import java.io.Serializable; +import java.util.List; + +/** + * MG to APP 的状态定义 + * 参考文档:https://docs.sud.tech/zh-CN/app/Client/MGFSM/ + */ +@Keep +public class SudMGPMGState implements Serializable { + + // region MG状态机-通用状态-游戏 + // 参考文档:https://docs.sud.tech/zh-CN/app/Client/MGFSM/CommonStateGame.html + /** + * 1. 公屏消息(已修改) + * 最低版本: v1.1.30.xx + */ + public static final String MG_COMMON_PUBLIC_MESSAGE = "mg_common_public_message"; + + /** + * 1. 公屏消息(已修改) + * 向公屏发送消息,字段含义如下 + * type + * 0 通知 + * 1 提醒 + * 2 结算 + * 3 其他 + * msg + * 内为转义字段: + * + * 其中name/uid/color均为可选字段,字段为空的情况如下: + * + * SDK仅会缓存最新一条。 + */ + @Keep + public static class MGCommonPublicMessage implements Serializable { + // 0 通知 + // 1 提醒 + // 2 结算 + // 3 其他 + public int type; + + // 消息内容 + public List msg; + + @Keep + public static class MGCommonPublicMessageMsg implements Serializable { + // 词组类型 当phrase=1时,会返回text; 当phrase=2时,会返回user + public int phrase; + public MGCommonPublicMessageMsgText text; + public MGCommonPublicMessageMsgUser user; + } + + @Keep + public static class MGCommonPublicMessageMsgText implements Serializable { + @SerializedName(value = "default") + public String defaultStr; // 默认文本 + + @SerializedName(value = "zh-CN") + public String zh_CN; // 中文(简体) + + @SerializedName(value = "zh-HK") + public String zh_HK; // 中文(香港) + + @SerializedName(value = "zh-MO") + public String zh_MO; // 中文(澳门) + + @SerializedName(value = "zh-SG") + public String zh_SG; // 中文(新加坡) + + @SerializedName(value = "zh-TW") + public String zh_TW; // 中文(繁体) + + @SerializedName(value = "en-US") + public String en_US; // 英语(美国) + + @SerializedName(value = "en-GB") + public String en_GB; // 英语(英国) + + @SerializedName(value = "ms-BN") + public String ms_BN; // 马来语(文莱达鲁萨兰) + + @SerializedName(value = "ms-MY") + public String ms_MY; // 马来语(马来西亚) + + @SerializedName(value = "vi-VN") + public String vi_VN; // 越南语 + + @SerializedName(value = "id-ID") + public String id_ID; // 印度尼西亚语 + + @SerializedName(value = "es-ES") + public String es_ES; // 西班牙语(传统) + + @SerializedName(value = "ja-JP") + public String ja_JP; // 日语 + + @SerializedName(value = "ko-KR") + public String ko_KR; // 朝鲜语 + + @SerializedName(value = "th-TH") + public String th_TH; // 泰语 + + @SerializedName(value = "ar-SA") + public String ar_SA; // 阿拉伯语(沙特阿拉伯) + + @SerializedName(value = "ur-PK") + public String ur_PK; // 乌都语 + + @SerializedName(value = "tr-TR") + public String tr_TR; // 土耳其语 + + @SerializedName(value = "pt-PT") + public String pt_PT; // 葡萄语 + + @SerializedName(value = "hi-IN") + public String hi_IN; // 印地语 + + @SerializedName(value = "bn-BD") + public String bn_BD; // 孟加拉语 + + @SerializedName(value = "tl-PH") + public String tl_PH; // 塔加路语(菲律宾) + + @SerializedName(value = "fa-IR") + public String fa_IR; // 波斯语(伊朗) + + @SerializedName(value = "ru-RU") + public String ru_RU; // 俄罗斯语 + } + + @Keep + public static class MGCommonPublicMessageMsgUser implements Serializable { + // 默认内容 + public String defaultStr; + // 用户名称 + public String name; + // 用户id + public String uid; + // 颜色值 + public String color; + } + } + + /** + * 2. 关键词状态 + */ + public static final String MG_COMMON_KEY_WORD_TO_HIT = "mg_common_key_word_to_hit"; + + /** + * 2. 关键词状态 + */ + @Keep + public static class MGCommonKeyWordToHit implements Serializable { + // 必填字段;text:文本包含匹配; number:数字等于匹配(必填字段);默认:text(你画我猜、你说我猜);数字炸弹填number; + public String wordType; + + // 单个关键词,兼容老版本。轮到自己猜词时才有值,否则为null + public String word; + + // 关键词,每一轮都会下发,不区分角色 + public String realWord; + + // 必填字段;关键词列表,可以传送多个关键词。轮到自己猜词时才有值,否则为null + public List wordList; + + // 必填字段;关键词语言,默认:zh-CN; + public String wordLanguage; + } + + /** + * 3. 游戏结算状态 + */ + public static final String MG_COMMON_GAME_SETTLE = "mg_common_game_settle"; + + /** + * 3. 游戏结算状态 + */ + @Keep + public static class MGCommonGameSettle implements Serializable { + // 游戏模式默认为1 + public int gameMode; + + // 本局游戏的id + public String gameRoundId; + + // 游戏结果玩家列表 + public List results; + + /** + * 游戏结果玩家定义 + */ + @Keep + public static class PlayerResult implements Serializable { + public String uid; // 用户id + public int rank; // 排名 从 1 开始 + public int award; // 奖励 + public int score; // 积分 + public int isEscaped; // 是否逃跑 1:逃跑 0:非逃跑 + public String killerId; // 杀自己的玩家的id + public int isAI; // 是否是AI玩家,1为AI + } + } + + /** + * 4. 加入游戏按钮点击状态 + */ + public static final String MG_COMMON_SELF_CLICK_JOIN_BTN = "mg_common_self_click_join_btn"; + + /** + * 4. 加入游戏按钮点击状态 模型 + * 用户(本人)点击加入按钮,或者点击头像加入 + */ + @Keep + public static class MGCommonSelfClickJoinBtn implements Serializable { + // 点击头像加入游戏对应的座位号,int 类型,从0开始, 如果seatIndex=-1,则是随机加入一个空位,如果seatIndex 大于座位数,则加入不成功 + public int seatIndex; + } + + /** + * 5. 取消加入(退出)游戏按钮点击状态 + */ + public static final String MG_COMMON_SELF_CLICK_CANCEL_JOIN_BTN = "mg_common_self_click_cancel_join_btn"; + + /** + * 5. 取消加入(退出)游戏按钮点击状态 模型 + * 用户(本人)点击取消加入按钮 + */ + @Keep + public static class MGCommonSelfClickCancelJoinBtn implements Serializable { + } + + /** + * 6. 准备按钮点击状态 + */ + public static final String MG_COMMON_SELF_CLICK_READY_BTN = "mg_common_self_click_ready_btn"; + + /** + * 6. 准备按钮点击状态 模型 + */ + @Keep + public static class MGCommonSelfClickReadyBtn implements Serializable { + } + + /** + * 7. 取消准备按钮点击状态 + */ + public static final String MG_COMMON_SELF_CLICK_CANCEL_READY_BTN = "mg_common_self_click_cancel_ready_btn"; + + /** + * 7. 取消准备按钮点击状态 模型 + */ + @Keep + public static class MGCommonSelfClickCancelReadyBtn implements Serializable { + } + + /** + * 8. 开始游戏按钮点击状态 + */ + public static final String MG_COMMON_SELF_CLICK_START_BTN = "mg_common_self_click_start_btn"; + + /** + * 8. 开始游戏按钮点击状态 模型 + */ + @Keep + public static class MGCommonSelfClickStartBtn implements Serializable { + } + + /** + * 9. 分享按钮点击状态 + */ + public static final String MG_COMMON_SELF_CLICK_SHARE_BTN = "mg_common_self_click_share_btn"; + + /** + * 9. 分享按钮点击状态 模型 + * 用户(本人)点击分享按钮 + */ + @Keep + public static class MGCommonSelfClickShareBtn implements Serializable { + } + + /** + * 10. 游戏状态 + */ + public static final String MG_COMMON_GAME_STATE = "mg_common_game_state"; + + /** + * 10. 游戏状态 模型 + */ + @Keep + public static class MGCommonGameState implements Serializable { + public static final int UNKNOW = -1; // 未知 + public static final int IDLE = 0; + public static final int LOADING = 1; + public static final int PLAYING = 2; + + // gameState=0 (idle 状态,游戏未开始,空闲状态); + // gameState=1(loading 状态,所有玩家都准备好,队长点击了开始游戏按钮,等待加载游戏场景开始游戏,游戏即将开始提示阶段); + // gameState=2(playing状态,游戏进行中状态) + public int gameState; + } + + /** + * 11. 结算界面关闭按钮点击状态(2021-12-27新增) + */ + public static final String MG_COMMON_SELF_CLICK_GAME_SETTLE_CLOSE_BTN = "mg_common_self_click_game_settle_close_btn"; + + /** + * 11. 结算界面关闭按钮点击状态(2021-12-27新增) 模型 + * 用户(本人)点击结算界面关闭按钮 + */ + @Keep + public static class MGCommonSelfClickGameSettleCloseBtn implements Serializable { + } + + /** + * 12. 结算界面再来一局按钮点击状态(2021-12-27新增) + */ + public static final String MG_COMMON_SELF_CLICK_GAME_SETTLE_AGAIN_BTN = "mg_common_self_click_game_settle_again_btn"; + + /** + * 12. 结算界面再来一局按钮点击状态(2021-12-27新增)模型 + * 用户(本人)点击结算界面再来一局按钮 + */ + @Keep + public static class MGCommonSelfClickGameSettleAgainBtn implements Serializable { + } + + /** + * 13. 游戏上报游戏中的声音列表(2021-12-30新增,现在只支持碰碰我最强) + */ + public static final String MG_COMMON_GAME_SOUND_LIST = "mg_common_game_sound_list"; + + /** + * 13. 游戏上报游戏中的声音列表(2021-12-30新增,现在只支持碰碰我最强) 模型 + * 游戏上报本游戏中所有的声音资源列表 + */ + @Keep + public static class MGCommonGameSoundList implements Serializable { + // 声音资源列表 + public List list; + + @Keep + public static class MGCommonGameSound implements Serializable { + // 声音资源的名字 + public String name; + // 声音资源的URL链接 + public String url; + // 声音资源类型 + public String type; + } + } + + /** + * 14. 游通知app层播放声音(2021-12-30新增,现在只支持碰碰我最强) + */ + public static final String MG_COMMON_GAME_SOUND = "mg_common_game_sound"; + + /** + * 14. 游通知app层播放声音(2021-12-30新增,现在只支持碰碰我最强) 模型 + * 游戏通知app层播放背景音乐的开关状态 + */ + @Keep + public static class MGCommonGameSound implements Serializable { + // 是否播放 isPlay==true(播放),isPlay==false(停止) + public boolean isPlay; + // 要播放的声音文件名,不带后缀 + public String name; + // 声音资源类型 + public String type; + // 播放次数;注:times == 0 为循环播放 + public String times; + // https://www.xxxx.xx/xxx.mp3" 声音资源的url链接 + public String url; + } + + /** + * 15. 游戏通知app层播放背景音乐状态(2022-01-07新增,现在只支持碰碰我最强) + */ + public static final String MG_COMMON_GAME_BG_MUSIC_STATE = "mg_common_game_bg_music_state"; + + /** + * 15. 游戏通知app层播放背景音乐状态(2022-01-07新增,现在只支持碰碰我最强) 模型 + * 游戏通知app层播放背景音乐的开关状态 + */ + @Keep + public static class MGCommonGameBgMusicState implements Serializable { + // 背景音乐的开关状态 true: 开,false: 关 + public boolean state; + } + + /** + * 16. 游戏通知app层播放音效的状态(2022-01-07新增,现在只支持碰碰我最强) + */ + public static final String MG_COMMON_GAME_SOUND_STATE = "mg_common_game_sound_state"; + + /** + * 16. 游戏通知app层播放音效的状态(2022-01-07新增,现在只支持碰碰我最强) 模型 + * 游戏通知app层播放音效的状态 + */ + @Keep + public static class MGCommonGameSoundState implements Serializable { + // 背景音乐的开关状态 true: 开,false: 关 + public boolean state; + } + + /** + * 17. ASR状态(开启和关闭语音识别状态,v1.1.45.xx 版本新增) + */ + public static final String MG_COMMON_GAME_ASR = "mg_common_game_asr"; + + /** + * 17. ASR状态(开启和关闭语音识别状态,v1.1.45.xx 版本新增) 模型 + */ + @Keep + public static class MGCommonGameASR implements Serializable { + // true:打开语音识别 false:关闭语音识别 + public boolean isOpen; + } + + /** + * 18. 麦克风状态(2022-02-08新增) + */ + public static final String MG_COMMON_SELF_MICROPHONE = "mg_common_self_microphone"; + + /** + * 18. 麦克风状态(2022-02-08新增) 模型 + * 游戏通知app麦克风状态 + */ + @Keep + public static class MGCommonSelfMicrophone implements Serializable { + // 麦克风开关状态 true: 开,false: 关 + public boolean isOn; + } + + /** + * 19. 耳机(听筒,扬声器)状态(2022-02-08新增) + */ + public static final String MG_COMMON_SELF_HEADPHONE = "mg_common_self_headphone"; + + /** + * 19. 耳机(听筒,扬声器)状态(2022-02-08新增) 模型 + */ + @Keep + public static class MGCommonSelfHeadphone implements Serializable { + // 耳机(听筒,喇叭)开关状态 true: 开,false: 关 + public boolean isOn; + } + + /** + * 20. App通用状态操作结果错误码(2022-05-10新增) + */ + public static final String MG_COMMON_APP_COMMON_SELF_X_RESP = "mg_common_app_common_self_x_resp"; + + /** + * 20. App通用状态操作结果错误码(2022-05-10新增) 模型 + */ + @Keep + public static class MGCommonAPPCommonSelfXResp implements Serializable { + public String state; // 字段必填, 参考:游戏业务错误 https://docs.sud.tech/zh-CN/app/Client/APPFST/CommonState.html + public int resultCode; // 字段必填,参考:游戏业务错误 https://docs.sud.tech/zh-CN/app/Server/ErrorCode.html + public boolean isIn; // 当state=app_common_self_in时,字段必填 + public boolean isReady; // 当state=app_common_self_ready时,字段必填 + public boolean isPlaying; // 当state=app_common_self_playing时,字段必填 + public String reportGameInfoExtras; // 当state=app_common_self_playing时,字段必填 + public String curCaptainUID; // 当state=app_common_self_captain时,字段必填 + public String kickedUID; // 当state=app_common_self_kick时,字段必填 + } + + /** + * 21. 游戏通知app层添加陪玩机器人是否成功(2022-05-17新增) + */ + public static final String MG_COMMON_GAME_ADD_AI_PLAYERS = "mg_common_game_add_ai_players"; + + /** + * 21. 游戏通知app层添加陪玩机器人是否成功(2022-05-17新增) 模型 + */ + @Keep + public static class MGCommonGameAddAIPlayers implements Serializable { + public int resultCode; // 返回码 0:成功,非0:不成功 + public List userIds; // 加入成功的playerId列表 + } + + /** + * 22. 游戏通知app层添当前网络连接状态(2022-06-21新增) + */ + public static final String MG_COMMON_GAME_NETWORK_STATE = "mg_common_game_network_state"; + + /** + * 22. 游戏通知app层添当前网络连接状态(2022-06-21新增) 模型 + */ + @Keep + public static class MGCommonGameNetworkState implements Serializable { + public int state; // 0:closed, 1: connected + } + + /** + * 23. 游戏通知app获取积分 + */ + public static final String MG_COMMON_GAME_GET_SCORE = "mg_common_game_get_score"; + + /** + * 23. 游戏通知app获取积分 模型 + */ + @Keep + public static class MGCommonGameGetScore implements Serializable { + } + + /** + * 24. 游戏通知app带入积分 + */ + public static final String MG_COMMON_GAME_SET_SCORE = "mg_common_game_set_score"; + + /** + * 24. 游戏通知app带入积分 模型 + */ + @Keep + public static class MGCommonGameSetScore implements Serializable { + public String roundId; // 局id + public long lastRoundScore; // 本人当前积分 + public long incrementalScore; // 充值积分 + public long totalScore; // 充值后总积分 + } + + /** + * 25. 创建订单 + */ + public static final String MG_COMMON_GAME_CREATE_ORDER = "mg_common_game_create_order"; + + /** + * 25. 创建订单 模型 + */ + @Keep + public static class MGCommonGameCreateOrder implements Serializable { + public String cmd; // 触发的行为动作,比如打赏,购买等 + public String fromUid; // 付费用户uid + public String toUid; // 目标用户uid + public long value; // 所属的游戏价值 + public String payload; // 扩展数据 json 字符串, 特殊可选 + } + + /** + * 26. 游戏通知app玩家角色(仅对狼人杀有效) + */ + public static final String MG_COMMON_PLAYER_ROLE_ID = "mg_common_player_role_id"; + + /** + * 26. 游戏通知app玩家角色(仅对狼人杀有效) 模型 + */ + @Keep + public static class MGCommonPlayerRoleId implements Serializable { + public List playersRoleId; // 列表 + + @Keep + public static class MGCommonPlayerModel implements Serializable { + public String uid; // 玩家id + public int roleId; // 角色id + } + } + + /** + * 27. 游戏通知app玩家被扔便便(你画我猜,你说我猜,友尽闯关有效) + */ + public static final String MG_COMMON_SELF_CLICK_POOP = "mg_common_self_click_poop"; + + /** + * 27. 游戏通知app玩家被扔便便(你画我猜,你说我猜,友尽闯关有效) 模型 + */ + @Keep + public static class MGCommonSelfClickPoop implements Serializable { + } + + /** + * 28. 游戏通知app玩家被点赞(你画我猜,你说我猜,友尽闯关有效) + */ + public static final String MG_COMMON_SELF_CLICK_GOOD = "mg_common_self_click_good"; + + /** + * 28. 游戏通知app玩家被点赞(你画我猜,你说我猜,友尽闯关有效) 模型 + */ + @Keep + public static class MGCommonSelfClickGood implements Serializable { + } + + /** + * 29. 游戏通知app游戏FPS(仅对碰碰,多米诺骨牌,飞镖达人生效) + */ + public static final String MG_COMMON_GAME_FPS = "mg_common_game_fps"; + + /** + * 29. 游戏通知app游戏FPS(仅对碰碰,多米诺骨牌,飞镖达人生效) 模型 + */ + @Keep + public static class MGCommonGameFps implements Serializable { + public int fps; + } + + /** + * 30. 游戏通知app游戏弹框 + */ + public static final String MG_COMMON_ALERT = "mg_common_alert"; + + /** + * 30. 游戏通知app游戏弹框 模型 + */ + @Keep + public static class MGCommonAlert implements Serializable { + public String state; // show:显示,close:关闭 + } + + /** + * 31. 游戏通知app最坑队友(只支持友尽闯关) + */ + public static final String MG_COMMON_WORST_TEAMMATE = "mg_common_worst_teammate"; + + /** + * 31. 游戏通知app最坑队友(只支持友尽闯关) 模型 + */ + @Keep + public static class MGCommonWorstTeammate implements Serializable { + public String uid; // 最坑队友的uid + } + + /** + * 32. 游戏通知app因玩家逃跑导致游戏结束(只支持友尽闯关) + */ + public static final String MG_COMMON_GAME_OVER_TIP = "mg_common_game_over_tip"; + + /** + * 32. 游戏通知app因玩家逃跑导致游戏结束(只支持友尽闯关) 模型 + */ + @Keep + public static class MGCommonGameOverTip implements Serializable { + public List uids; // 逃跑玩家的uid数组 + } + + /** + * 33. 游戏通知app玩家颜色(只支持友尽闯关) + */ + public static final String MG_COMMON_GAME_PLAYER_COLOR = "mg_common_game_player_color"; + + /** + * 33. 游戏通知app玩家颜色(只支持友尽闯关) 模型 + */ + @Keep + public static class MGCommonGamePlayerColor implements Serializable { + public List players; + + @Keep + public static class PlayerColorModel { + public String uid; // 用户id + public int color; // color:1是粉色,2是紫色,3是绿色,4是蓝色,5是黄色,6是橙色 + } + } + + /** + * 34. 游戏通知app玩家头像的坐标(只支持ludo) + */ + public static final String MG_COMMON_GAME_PLAYER_ICON_POSITION = "mg_common_game_player_icon_position"; + + /** + * 34. 游戏通知app玩家头像的坐标(只支持ludo) 模型 + */ + @Keep + public static class MGCommonGamePlayerIconPosition implements Serializable { + public String uid; + public PlayerIconPositionModel position; + + @Keep + public static class PlayerIconPositionModel { + // 头像坐标和宽高,坐标为头像中心 + public double x; + public double y; + public double width; + public double height; + } + } + + /** + * 35. 游戏通知app退出游戏(只支持teenpattipro 与 德州pro) + */ + public static final String MG_COMMON_SELF_CLICK_EXIT_GAME_BTN = "mg_common_self_click_exit_game_btn"; + + /** + * 35. 游戏通知app退出游戏(只支持teenpattipro 与 德州pro) 模型 + */ + @Keep + public static class MGCommonSelfClickExitGameBtn implements Serializable { + } + + /** + * 36. 游戏通知app是否要开启带入积分(只支持teenpattipro 与 德州pro) + */ + public static final String MG_COMMON_GAME_IS_APP_CHIP = "mg_common_game_is_app_chip"; + + /** + * 36. 游戏通知app是否要开启带入积分(只支持teenpattipro 与 德州pro) 模型 + */ + @Keep + public static class MGCommonGameIsAppChip implements Serializable { + public int isAppChip; // 0:不开启,1:开启 + } + + /** + * 37. 游戏通知app当前游戏的设置信息(只支持德州pro,teenpatti pro) + */ + public static final String MG_COMMON_GAME_RULE = "mg_common_game_rule"; + + /** + * 37. 游戏通知app当前游戏的设置信息(只支持德州pro,teenpatti pro) 模型 + */ + @Keep + public static class MGCommonGameRule implements Serializable { + public GameRuleModel gameMode; + + // 德州与teenpatti的结构融合在一起 + @Keep + public static class GameRuleModel { + public Integer smallBlind; // 小盲 + public Integer ante; // 前注 + public Integer isStraddle; // 0:关闭,1自由,2强制 + public Integer sBuyIn; // 带入值/最小带入配置 + public Integer bBuyIn; // 最大带入,无限(0) + public Integer isAutoStart; // 是否自动开始 + public Double tableDuration; // 牌桌时长配置(小时) + public Integer thinkTime; // 思考时间(秒) + public Integer darkCard; // 暗牌回合 + public Integer potLimit; // 最大带入 + public Integer round; // 最大回合 + public Integer singleLimit; // 单注限 + } + } + + /** + * 38. 游戏通知app进行玩法设置(只支持德州pro,teenpatti pro) + */ + public static final String MG_COMMON_GAME_SETTINGS = "mg_common_game_settings"; + + /** + * 38. 游戏通知app进行玩法设置(只支持德州pro,teenpatti pro) 模型 + */ + @Keep + public static class MGCommonGameSettings implements Serializable { + } + + /** + * 39. 游戏通知app钱币不足(只支持德州pro,teenpatti pro) + */ + public static final String MG_COMMON_GAME_MONEY_NOT_ENOUGH = "mg_common_game_money_not_enough"; + + /** + * 39. 游戏通知app钱币不足(只支持德州pro,teenpatti pro) 模型 + */ + @Keep + public static class MGCommonGameMoneyNotEnough implements Serializable { + } + + /** + * 40. 游戏通知app下发定制ui配置表(只支持ludo) + */ + public static final String MG_COMMON_GAME_UI_CUSTOM_CONFIG = "mg_common_game_ui_custom_config"; + + /** + * 40. 游戏通知app下发定制ui配置表(只支持ludo) 模型 + */ + @Keep + public static class MGCommonGameUiCustomConfig implements Serializable { + } + + /** + * 41. 设置app提供给游戏可点击区域(赛车) + */ + public static final String MG_COMMON_SET_CLICK_RECT = "mg_common_set_click_rect"; + + /** + * 41. 设置app提供给游戏可点击区域(赛车) 模型 + */ + @Keep + public static class MGCommonSetClickRect implements Serializable { + public List list; // 游戏的点击区域 + } + + /** + * 42. 通知app提供对应uids列表玩家的数据(赛车) + */ + public static final String MG_COMMON_USERS_INFO = "mg_common_users_info"; + + /** + * 42. 通知app提供对应uids列表玩家的数据(赛车) 模型 + */ + @Keep + public static class MGCommonUsersInfo implements Serializable { + public List uids; + } + + /** + * 43. 通知app游戏前期准备完成(赛车) + */ + public static final String MG_COMMON_GAME_PREPARE_FINISH = "mg_common_game_prepare_finish"; + + /** + * 43. 通知app游戏前期准备完成(赛车) 模型 + */ + @Keep + public static class MGCommonGamePrepareFinish implements Serializable { + } + + /** + * 44. 通知app游戏主界面已显示(赛车) + */ + public static final String MG_COMMON_SHOW_GAME_SCENE = "mg_common_show_game_scene"; + + /** + * 44. 通知app游戏主界面已显示(赛车) 模型 + */ + @Keep + public static class MGCommonShowGameScene implements Serializable { + } + + /** + * 45. 通知app游戏主界面已隐藏(赛车) + */ + public static final String MG_COMMON_HIDE_GAME_SCENE = "mg_common_hide_game_scene"; + + /** + * 45. 通知app游戏主界面已隐藏(赛车) 模型 + */ + @Keep + public static class MGCommonHideGameScene implements Serializable { + } + + /** + * 46. 通知app点击了游戏的金币按钮(赛车) + */ + public static final String MG_COMMON_SELF_CLICK_GOLD_BTN = "mg_common_self_click_gold_btn"; + + /** + * 46. 通知app点击了游戏的金币按钮(赛车) 模型 + */ + @Keep + public static class MGCommonSelfClickGoldBtn implements Serializable { + } + + /** + * 47. 通知app棋子到达终点(ludo) + */ + public static final String MG_COMMON_GAME_PIECE_ARRIVE_END = "mg_common_game_piece_arrive_end"; + + /** + * 47. 通知app棋子到达终点(ludo) 模型 + */ + @Keep + public static class MGCommonGamePieceArriveEnd implements Serializable { + public String uid; // 玩家id + public int pieceIndex; // 棋子编号 0 ~ 3 + } + + /** + * 48. 通知app玩家是否托管 + */ + public static final String MG_COMMON_GAME_PLAYER_MANAGED_STATE = "mg_common_game_player_managed_state"; + + /** + * 48. 通知app玩家是否托管 模型 + */ + @Keep + public static class MGCommonGamePlayerManagedState implements Serializable { + public String uid; // 玩家id + public int managed; // 0: 未托管 1:托管 + } + + /** + * 49. 游戏向app发送爆词 + */ + public static final String MG_COMMON_GAME_SEND_BURST_WORD = "mg_common_game_send_burst_word"; + + /** + * 49. 游戏向app发送爆词 模型 + */ + @Keep + public static class MGCommonGameSendBurstWord implements Serializable { + public String text; // 爆词 + } + + /** + * 50. 游戏向app发送玩家实时排名(只支持怪物消消乐) + */ + public static final String MG_COMMON_GAME_PLAYER_RANKS = "mg_common_game_player_ranks"; + + /** + * 50. 游戏向app发送玩家实时排名(只支持怪物消消乐) 模型 + */ + @Keep + public static class MGCommonGamePlayerRanks implements Serializable { + public List ranks; // 所有玩家排名变化推送 + + @Keep + public static class RanksModel implements Serializable { + public String uid; // 用户id + public int rank; // 排名 + } + } + + /** + * 51. 游戏向app发送玩家即时变化的单双牌(只支持okey101) + */ + public static final String MG_COMMON_GAME_PLAYER_PAIR_SINGULAR = "mg_common_game_player_pair_singular"; + + /** + * 51. 游戏向app发送玩家即时变化的单双牌(只支持okey101) 模型 + */ + @Keep + public static class MGCommonGamePlayerPairSingular implements Serializable { + public List pairs; // 玩家单双牌推送 + + @Keep + public static class SingularModel implements Serializable { + public String uid; // 用户id + public int pair; // pair: 1 双,0 单 + } + } + + /** + * 52. 游戏向app发送获取玩家持有的道具卡(只支持大富翁) + */ + public static final String MG_COMMON_GAME_PLAYER_MONOPOLY_CARDS = "mg_common_game_player_monopoly_cards"; + + /** + * 52. 游戏向app发送获取玩家持有的道具卡(只支持大富翁) 模型 + */ + @Keep + public static class MGCommonGamePlayerMonopolyCards implements Serializable { + } + + /** + * 53. 游戏向app发送玩家实时积分(只支持怪物消消乐) + */ + public static final String MG_COMMON_GAME_PLAYER_SCORES = "mg_common_game_player_scores"; + + /** + * 53. 游戏向app发送玩家实时积分(只支持怪物消消乐) 模型 + */ + @Keep + public static class MGCommonGamePlayerScores implements Serializable { + public List scores; // 所有玩家积分变化推送 + + @Keep + public static class ScoresModel implements Serializable { + public String uid; // 用户id + public int score; // 积分 + } + } + + /** + * 54. 游戏通知app销毁游戏(只支持部分概率类游戏) + */ + public static final String MG_COMMON_DESTROY_GAME_SCENE = "mg_common_destroy_game_scene"; + + /** + * 54. 游戏通知app销毁游戏(只支持部分概率类游戏) 模型 + */ + @Keep + public static class MGCommonDestroyGameScene implements Serializable { + } + + /** + * 55. 游戏通知app击球状态(只支持桌球) + */ + public static final String MG_COMMON_GAME_BILLIARDS_HIT_STATE = "mg_common_game_billiards_hit_state"; + + /** + * 55. 游戏通知app击球状态(只支持桌球) 模型 + */ + @Keep + public static class MGCommonGameBilliardsHitState implements Serializable { + public String uid; // 操作玩家的id + /** + * state状态说明: + * 0: 母球击空或者第一击没击中目标球 + * 2-7: 连杆 + * 8: 白球进洞 + * 9: 没有足够的撞库数量 + * 10: 开球时进了黑八 + * 11: 提前进了黑八 + * 12: 没有有效进球 + * 13: 有有效进球 + * 14: 超时 + */ + public int state; + } + + /** + * 56. 游戏向app发送获取玩家持有的指定点数道具卡(只支持飞行棋) + */ + public static final String MG_COMMON_GAME_PLAYER_PROPS_CARDS = "mg_common_game_player_props_cards"; + + /** + * 56. 游戏向app发送获取玩家持有的指定点数道具卡(只支持飞行棋) 模型 + */ + @Keep + public static class MGCommonGamePlayerPropsCards implements Serializable { + } + + // endregion 通用状态-游戏 + + // region MG状态机-通用状态-玩家 + // 参考:https://docs.sud.tech/zh-CN/app/Client/MGFSM/CommonStatePlayer.html + + /** + * 1.加入状态(已修改) + * 最低版本: v1.1.30.xx + */ + public static final String MG_COMMON_PLAYER_IN = "mg_common_player_in"; + + /** + * 1.加入状态(已修改) 模型 + * 用户是否加入游戏; + * 游戏开始后,未加入的用户为OB视角。 + */ + @Keep + public static class MGCommonPlayerIn implements Serializable { + // true 已加入,false 未加入 + public boolean isIn; + + // 加入哪支队伍 + public int teamId; + + // 当isIn==false时有效;0 主动退出,1 被踢;(reason默认-1,无意义便于处理) + public int reason; + + // 当reason==1时有效;kickUID为踢人的用户uid;判断被踢的人是本人条件(onPlayerStateChange(userId==kickedUID == selfUID);(kickUID默认"",无意义便于处理) + public String kickUID; + } + + /** + * 2.准备状态(已修改) + * 最低版本: v1.1.30.xx + */ + public static final String MG_COMMON_PLAYER_READY = "mg_common_player_ready"; + + /** + * 2.准备状态(已修改) 模型 + * 用户是否为队长,队长在游戏中会有开始游戏的权利。 + */ + @Keep + public static class MGCommonPlayerReady implements Serializable { + // 当retCode==0时有效;true 已准备,false 未准备 + public boolean isReady; + } + + /** + * 3.队长状态(已修改) + * 最低版本: v1.1.30.xx + */ + public static final String MG_COMMON_PLAYER_CAPTAIN = "mg_common_player_captain"; + + /** + * 3.队长状态(已修改) 模型 + * 用户是否为队长,队长在游戏中会有开始游戏的权利。 + */ + @Keep + public static class MGCommonPlayerCaptain implements Serializable { + // true 是队长,false 不是队长; + public boolean isCaptain; + } + + /** + * 4.游戏状态(已修改) + * 最低版本: v1.1.30.xx + */ + public static final String MG_COMMON_PLAYER_PLAYING = "mg_common_player_playing"; + + /** + * 4.游戏状态(已修改)模型 + * 用户游戏状态,如果用户在游戏中,建议: + * a.空出屏幕中心区: + * 关闭全屏礼物特效; + * b.部分强操作类小游戏(spaceMax为true),尽量收缩原生UI,给游戏留出尽量大的操作空间: + * 收缩公屏; + * 收缩麦位; + * 如果不在游戏中,则恢复。 + */ + @Keep + public static class MGCommonPlayerPlaying implements Serializable { + // true 游戏中,false 未在游戏中; + public boolean isPlaying; + // 本轮游戏id,当isPlaying==true时有效 + public String gameRoundId; + // 当isPlaying==false时有效;isPlaying=false, 0:正常结束 1:提前结束(自己不玩了)2:无真人可以提前结束(无真人,只有机器人) 3:所有人都提前结束;(reason默认-1,无意义便于处理) + public int reason; + // true 建议尽量收缩原生UI,给游戏留出尽量大的操作空间 false 初始状态; + public Boolean spaceMax; + } + + /** + * 5.玩家在线状态 + */ + public static final String MG_COMMON_PLAYER_ONLINE = "mg_common_player_online"; + + /** + * 5.玩家在线状态 模型 + */ + @Keep + public static class MGCommonPlayerOnline implements Serializable { + // true:在线,false: 离线 + public boolean isOnline; + } + + /** + * 6.玩家换游戏位状态 + */ + public static final String MG_COMMON_PLAYER_CHANGE_SEAT = "mg_common_player_change_seat"; + + /** + * 6.玩家换游戏位状态 模型 + */ + @Keep + public static class MGCommonPlayerChangeSeat implements Serializable { + // 换位前的游戏位(座位号) + public int preSeatIndex; + // 换位成功后的游戏位(座位号) + public int currentSeatIndex; + } + + /** + * 7. 游戏通知app点击玩家头像 + */ + public static final String MG_COMMON_SELF_CLICK_GAME_PLAYER_ICON = "mg_common_self_click_game_player_icon"; + + /** + * 7. 游戏通知app点击玩家头像 模型 + */ + @Keep + public static class MGCommonSelfClickGamePlayerIcon implements Serializable { + // 被点击头像的用户id + public String uid; + } + + /** + * 8. 游戏通知app玩家死亡状态(2022-04-24新增) + */ + public static final String MG_COMMON_SELF_DIE_STATUS = "mg_common_self_die_status"; + + /** + * 8. 游戏通知app玩家死亡状态(2022-04-24新增)模型 + */ + @Keep + public static class MGCommonSelfDieStatus implements Serializable { + public String uid; // 用户id + public boolean isDeath; // 玩家是否死亡 true:死亡, false: 未死亡;默认 false + } + + /** + * 9. 游戏通知app轮到玩家出手状态(2022-04-24新增) + */ + public static final String MG_COMMON_SELF_TURN_STATUS = "mg_common_self_turn_status"; + + /** + * 9. 游戏通知app轮到玩家出手状态(2022-04-24新增)模型 + */ + @Keep + public static class MGCommonSelfTurnStatus implements Serializable { + public String uid; // 用户id + public boolean isTurn; // 是否轮到玩家出手 true:是上面uid玩家的出手回合, false: 不是上面uid玩家的出手回合;默认false + } + + /** + * 10. 游戏通知app玩家选择状态(2022-04-24新增) + */ + public static final String MG_COMMON_SELF_SELECT_STATUS = "mg_common_self_select_status"; + + /** + * 10. 游戏通知app玩家选择状态(2022-04-24新增)模型 + */ + @Keep + public static class MGCommonSelfSelectStatus implements Serializable { + public String uid; // 用户id + public boolean isSelected; // 玩家是否选择 true:选择, false: 未选择; 默认false + } + + /** + * 11. 游戏通知app层当前游戏剩余时间(2022-05-23新增,目前UMO生效) + */ + public static final String MG_COMMON_GAME_COUNTDOWN_TIME = "mg_common_game_countdown_time"; + + /** + * 11. 游戏通知app层当前游戏剩余时间(2022-05-23新增,目前UMO生效)模型 + */ + @Keep + public static class MGCommonGameCountdownTime implements Serializable { + public int countdown;// 剩余时间,单位为秒 + } + + /** + * 12. 游戏通知app层当前玩家死亡后变成ob视角(2022-08-23新增,目前狼人杀生效) + */ + public static final String MG_COMMON_SELF_OB_STATUS = "mg_common_self_ob_status"; + + /** + * 12. 游戏通知app层当前玩家死亡后变成ob视角(2022-08-23新增,目前狼人杀生效)模型 + */ + @Keep + public static class MGCommonSelfObStatus implements Serializable { + public boolean isOb;// 是否成为ob视角 + } + + // endregion 通用状态-玩家 + + + // region 碰碰我最强 + // endregion 碰碰我最强 + + // region 飞刀达人 + // endregion 飞刀达人 + + // region 你画我猜 + // 参考文档:https://docs.sud.tech/zh-CN/app/Client/MGFSM/DrawGuess.html + + /** + * 1. 选词中状态(已修改) + */ + public static final String MG_DG_SELECTING = "mg_dg_selecting"; + + /** + * 1. 选词中状态(已修改) 模型 + * 选词中,头像正下方 + */ + @Keep + public static class MGDGSelecting implements Serializable { + // bool 类型 true:正在选词中,false: 不在选词中 + public boolean isSelecting; + } + + /** + * 2. 作画中状态(已修改) + */ + public static final String MG_DG_PAINTING = "mg_dg_painting"; + + /** + * 2. 作画中状态(已修改) 模型 + * 作画中,头像正下方 + */ + @Keep + public static class MGDGPainting implements Serializable { + // true: 绘画中,false: 取消绘画 + public boolean isPainting; + } + + /** + * 3. 显示错误答案状态(已修改) + */ + public static final String MG_DG_ERRORANSWER = "mg_dg_erroranswer"; + + /** + * 3. 显示错误答案状态(已修改) 模型 + * 错误的答案,最多6中文,头像正下方 + */ + @Keep + public static class MGDGErroranswer implements Serializable { + // 字符串类型,展示错误答案 + public String msg; + } + + /** + * 4. 显示总积分状态(已修改) + */ + public static final String MG_DG_TOTALSCORE = "mg_dg_totalscore"; + + /** + * 4. 显示总积分状态(已修改) 模型 + * 总积分,位于头像右上角 + */ + @Keep + public static class MGDGTotalscore implements Serializable { + // 字符串类型 总积分 + public String msg; + } + + /** + * 5. 本次获得积分状态(已修改) + */ + public static final String MG_DG_SCORE = "mg_dg_score"; + + /** + * 5. 本次获得积分状态(已修改) 模型 + * 本次积分,头像正下方 + */ + @Keep + public static final class MGDGScore implements Serializable { + // string类型,展示本次获得积分 + public String msg; + } + + // endregion 你画我猜 + + // region 元宇宙砂砂舞 + /** + * 1. 元宇宙砂砂舞指令回调 + */ + public static final String MG_COMMON_GAME_DISCO_ACTION = "mg_common_game_disco_action"; + + /** + * 1. 元宇宙砂砂舞指令回调 模型 + * app指令请求游戏客户端成功与否的回调 + */ + @Keep + public static final class MGCommonGameDiscoAction implements Serializable { + public int actionId; // 指令序号类型 + public boolean isSuccess; // true 指令成功,false 指令失败 + } + + /** + * 2. 元宇宙砂砂舞指令动作结束通知 + */ + public static final String MG_COMMON_GAME_DISCO_ACTION_END = "mg_common_game_disco_action_end"; + + /** + * 2. 元宇宙砂砂舞指令动作结束通知 模型 + * 游戏客户端通知APP指令动作结束 + */ + @Keep + public static final class MGCommonGameDiscoActionEnd implements Serializable { + public int actionId; // 指令序号类型 + public String playerId; // // 玩家ID string 类型 + } + // endregion 元宇宙砂砂舞 + + // region 定制火箭 + /** + * 1. 礼物配置文件(火箭) + */ + public static final String MG_CUSTOM_ROCKET_CONFIG = "mg_custom_rocket_config"; + + /** + * 1. 礼物配置文件(火箭) 模型 + */ + @Keep + public static final class MGCustomRocketConfig implements Serializable { + } + + /** + * 2. 拥有模型列表(火箭) + */ + public static final String MG_CUSTOM_ROCKET_MODEL_LIST = "mg_custom_rocket_model_list"; + + /** + * 2. 拥有模型列表(火箭) 模型 + */ + @Keep + public static final class MGCustomRocketModelList implements Serializable { + } + + /** + * 3. 拥有组件列表(火箭) + */ + public static final String MG_CUSTOM_ROCKET_COMPONENT_LIST = "mg_custom_rocket_component_list"; + + /** + * 3. 拥有组件列表(火箭) 模型 + */ + @Keep + public static final class MGCustomRocketComponentList implements Serializable { + } + + /** + * 4. 获取用户信息(火箭) + */ + public static final String MG_CUSTOM_ROCKET_USER_INFO = "mg_custom_rocket_user_info"; + + /** + * 4. 获取用户信息 模型 + */ + @Keep + public static final class MGCustomRocketUserInfo implements Serializable { + public List userIdList; + } + + /** + * 5. 订单记录列表(火箭) + */ + public static final String MG_CUSTOM_ROCKET_ORDER_RECORD_LIST = "mg_custom_rocket_order_record_list"; + + /** + * 5. 订单记录列表(火箭) 模型 + */ + @Keep + public static final class MGCustomRocketOrderRecordList implements Serializable { + public int pageIndex; // 第几页 + public int pageSize; // 每页多少条数据 + } + + /** + * 6. 展馆内列表(火箭) + */ + public static final String MG_CUSTOM_ROCKET_ROOM_RECORD_LIST = "mg_custom_rocket_room_record_list"; + + /** + * 6. 展馆内列表(火箭) 模型 + */ + @Keep + public static final class MGCustomRocketRoomRecordList implements Serializable { + public int pageIndex; // 第几页 + public int pageSize; // 每页多少条数据 + } + + /** + * 7. 展馆内玩家送出记录(火箭) + */ + public static final String MG_CUSTOM_ROCKET_USER_RECORD_LIST = "mg_custom_rocket_user_record_list"; + + /** + * 7. 展馆内玩家送出记录(火箭) 模型 + */ + @Keep + public static final class MGCustomRocketUserRecordList implements Serializable { + public String userId; // 用户id + public int pageIndex; // 第几页 + public int pageSize; // 每页多少条数据 + } + + /** + * 8. 设置默认模型(火箭) + */ + public static final String MG_CUSTOM_ROCKET_SET_DEFAULT_MODEL = "mg_custom_rocket_set_default_model"; + + /** + * 8. 设置默认模型(火箭) 模型 + */ + @Keep + public static final class MGCustomRocketSetDefaultModel implements Serializable { + public String modelId; // 默认模型 + } + + /** + * 9. 动态计算一键发送价格(火箭) + */ + public static final String MG_CUSTOM_ROCKET_DYNAMIC_FIRE_PRICE = "mg_custom_rocket_dynamic_fire_price"; + + /** + * 9. 动态计算一键发送价格(火箭) 模型 + */ + @Keep + public static final class MGCustomRocketDynamicFirePrice implements Serializable { + public List componentList; // 组件列表 + + @Keep + public static class ComponentModel { + public String itemId; // 已购买的唯一标识 + } + } + + /** + * 10. 一键发送(火箭) + */ + public static final String MG_CUSTOM_ROCKET_FIRE_MODEL = "mg_custom_rocket_fire_model"; + + /** + * 10. 一键发送(火箭) 模型 + */ + @Keep + public static final class MGCustomRocketFireModel implements Serializable { + public List componentList; // 组件列表 + + @Keep + public static class ComponentModel { + public int type; // 类型 + public String itemId; // 已购买的唯一标识 + } + } + + /** + * 11. 新组装模型(火箭) + */ + public static final String MG_CUSTOM_ROCKET_CREATE_MODEL = "mg_custom_rocket_create_model"; + + /** + * 11. 新组装模型(火箭) 模型 + */ + @Keep + public static final class MGCustomRocketCreateModel implements Serializable { + public List componentList; // 组件列表 + + @Keep + public static class ComponentModel { + public String itemId; // 模型Id + } + } + + /** + * 12. 模型更换组件(火箭) + */ + public static final String MG_CUSTOM_ROCKET_REPLACE_COMPONENT = "mg_custom_rocket_replace_component"; + + /** + * 12. 模型更换组件(火箭) 模型 + */ + @Keep + public static final class MGCustomRocketReplaceComponent implements Serializable { + public String modelId; // 模型ID + public List componentList; // 组件列表 + + @Keep + public static class ComponentModel { + public String itemId; // 已购买的唯一标识 + } + } + + /** + * 13. 购买组件(火箭) + */ + public static final String MG_CUSTOM_ROCKET_BUY_COMPONENT = "mg_custom_rocket_buy_component"; + + /** + * 13. 购买组件(火箭) 模型 + */ + @Keep + public static final class MGCustomRocketBuyComponent implements Serializable { + public List componentList; // 组件列表 + + @Keep + public static class ComponentModel { + public String componentId; // 已购买的唯一标识 + public String value; // 值 + } + } + + /** + * 14. 播放效果开始(火箭) + */ + public static final String MG_CUSTOM_ROCKET_PLAY_EFFECT_START = "mg_custom_rocket_play_effect_start"; + + /** + * 14. 播放效果开始(火箭) 模型 + */ + @Keep + public static final class MGCustomRocketPlayEffectStart implements Serializable { + } + + /** + * 15. 播放效果完成(火箭) + */ + public static final String MG_CUSTOM_ROCKET_PLAY_EFFECT_FINISH = "mg_custom_rocket_play_effect_finish"; + + /** + * 15. 播放效果完成(火箭) 模型 + */ + @Keep + public static final class MGCustomRocketPlayEffectFinish implements Serializable { + } + + /** + * 16. 验证签名合规(火箭) + */ + public static final String MG_CUSTOM_ROCKET_VERIFY_SIGN = "mg_custom_rocket_verify_sign"; + + /** + * 16. 验证签名合规(火箭) 模型 + */ + @Keep + public static final class MGCustomRocketVerifySign implements Serializable { + public String sign; // 验证的内容 + } + + /** + * 17. 上传icon(火箭) + */ + public static final String MG_CUSTOM_ROCKET_UPLOAD_MODEL_ICON = "mg_custom_rocket_upload_model_icon"; + + /** + * 17. 上传icon(火箭) 模型 + */ + @Keep + public static final class MGCustomRocketUploadModelIcon implements Serializable { + public String data; // 图片base64数据 + } + + /** + * 18. 前期准备完成(火箭) + * 表示app此时可以向火箭发出指令了 + */ + public static final String MG_CUSTOM_ROCKET_PREPARE_FINISH = "mg_custom_rocket_prepare_finish"; + + /** + * 18. 前期准备完成(火箭) 模型 + */ + @Keep + public static final class MGCustomRocketPrepareFinish implements Serializable { + } + + /** + * 19. 火箭主界面已显示(火箭) + */ + public static final String MG_CUSTOM_ROCKET_SHOW_GAME_SCENE = "mg_custom_rocket_show_game_scene"; + + /** + * 19. 火箭主界面已显示(火箭) 模型 + */ + @Keep + public static final class MGCustomRocketShowGameScene implements Serializable { + } + + /** + * 20. 火箭主界面已隐藏(火箭) + */ + public static final String MG_CUSTOM_ROCKET_HIDE_GAME_SCENE = "mg_custom_rocket_hide_game_scene"; + + /** + * 20. 火箭主界面已隐藏(火箭) 模型 + */ + @Keep + public static final class MGCustomRocketHideGameScene implements Serializable { + } + + /** + * 21. 点击锁住组件(火箭) + */ + public static final String MG_CUSTOM_ROCKET_CLICK_LOCK_COMPONENT = "mg_custom_rocket_click_lock_component"; + + /** + * 21. 点击锁住组件(火箭) 模型 + */ + @Keep + public static final class MGCustomRocketClickLockComponent implements Serializable { + public int type; // 组件类型 + public String componentId; // 组件ID + } + + /** + * 22. 火箭效果飞行点击(火箭) + */ + public static final String MG_CUSTOM_ROCKET_FLY_CLICK = "mg_custom_rocket_fly_click"; + + /** + * 22. 火箭效果飞行点击(火箭) 模型 + */ + @Keep + public static final class MGCustomRocketFlyClick implements Serializable { + } + + /** + * 23. 火箭效果飞行结束(火箭) + */ + public static final String MG_CUSTOM_ROCKET_FLY_END = "mg_custom_rocket_fly_end"; + + /** + * 23. 火箭效果飞行结束(火箭) 模型 + */ + @Keep + public static final class MGCustomRocketFlyEnd implements Serializable { + public long clickNumber; // 点击多少次 + public long flyNumber; // 飞行多远 + } + + /** + * 24. 设置点击区域(火箭) + */ + public static final String MG_CUSTOM_ROCKET_SET_CLICK_RECT = "mg_custom_rocket_set_click_rect"; + + /** + * 24. 设置点击区域(火箭) 模型 + */ + @Keep + public static final class MGCustomRocketSetClickRect implements Serializable { + public List list; // 游戏的点击区域 + } + + /** + * 25. 颜色和签名自定义改到装配间的模式,保存颜色或签名 + */ + public static final String MG_CUSTOM_ROCKET_SAVE_SIGN_COLOR = "mg_custom_rocket_save_sign_color"; + + /** + * 25. 颜色和签名自定义改到装配间的模式,保存颜色或签名 模型 + */ + @Keep + public static final class MGCustomRocketSaveSignColor implements Serializable { + public List componentList; + + @Keep + public static class ComponentModel { + public String componentId; // 组件的ID + public String value; // 颜色值,采用十六进制 + public String modelId; // 模型id (更新模型时使用) + } + } + // endregion 定制火箭 + + // region 棒球 + /** + * 1. 设置界面默认状态(棒球) + */ + public static final String MG_BASEBALL_DEFUALT_STATE = "mg_baseball_defualt_state"; + + /** + * 1. 设置界面默认状态(棒球) 模型 + */ + @Keep + public static final class MGBaseballDefaultState implements Serializable { + } + + /** + * 2. 前期准备完成(棒球) + * 游戏客户端通知APP指令动作前期准备完成 + */ + public static final String MG_BASEBALL_PREPARE_FINISH = "mg_baseball_prepare_finish"; + + /** + * 2. 前期准备完成(棒球) 模型 + */ + @Keep + public static final class MGBaseballPrepareFinish implements Serializable { + } + + /** + * 3. 主界面已显示(棒球) + * 游戏客户端通知APP指令动作主界面已显示 + */ + public static final String MG_BASEBALL_SHOW_GAME_SCENE = "mg_baseball_show_game_scene"; + + /** + * 3. 主界面已显示(棒球) 模型 + */ + @Keep + public static final class MGBaseballShowGameScene implements Serializable { + } + + /** + * 4. 主界面已隐藏(棒球) + * 游戏客户端通知APP指令动作主界面已隐藏 + */ + public static final String MG_BASEBALL_HIDE_GAME_SCENE = "mg_baseball_hide_game_scene"; + + /** + * 4. 主界面已隐藏(棒球) 模型 + */ + @Keep + public static final class MGBaseballHideGameScene implements Serializable { + } + + /** + * 5. 查询排行榜数据(棒球) + * 游戏客户端通知APP查询排行榜数据 + */ + public static final String MG_BASEBALL_RANKING = "mg_baseball_ranking"; + + /** + * 5. 查询排行榜数据(棒球) 模型 + */ + @Keep + public static final class MGBaseballRanking implements Serializable { + public int page; // 页数 + public int size; // 每页显示的数量 + } + + /** + * 6. 查询我的排名(棒球) + * 游戏客户端通知APP查询我的排名 + */ + public static final String MG_BASEBALL_MY_RANKING = "mg_baseball_my_ranking"; + + /** + * 6. 查询我的排名(棒球) 模型 + */ + @Keep + public static final class MGBaseballMyRanking implements Serializable { + } + + /** + * 7. 查询当前距离我的前后玩家数据(棒球) + * 游戏客户端通知APP查询当前距离我的前后玩家数据(需要排除自己) + */ + public static final String MG_BASEBALL_RANGE_INFO = "mg_baseball_range_info"; + + /** + * 7. 查询当前距离我的前后玩家数据(棒球) 模型 + */ + @Keep + public static final class MGBaseballRangeInfo implements Serializable { + public long distance; // 自己当前的距离 + } + + /** + * 8. 设置app提供给游戏可点击区域(棒球) + * 游戏客户端通知APP指令动作设置点击区域 + */ + public static final String MG_BASEBALL_SET_CLICK_RECT = "mg_baseball_set_click_rect"; + + /** + * 8. 设置app提供给游戏可点击区域(棒球) 模型 + */ + @Keep + public static final class MGBaseballSetClickRect implements Serializable { + public List list; + } + + /** + * 9. 获取文本配置数据(棒球) + */ + public static final String MG_BASEBALL_TEXT_CONFIG = "mg_baseball_text_config"; + + /** + * 9. 获取文本配置数据(棒球) 模型 + */ + @Keep + public static final class MGBaseballTextConfig implements Serializable { + } + + /** + * 10. 球落地, 通知距离(棒球) + */ + public static final String MG_BASEBALL_SEND_DISTANCE = "mg_baseball_send_distance"; + + /** + * 10. 球落地, 通知距离(棒球) 模型 + */ + @Keep + public static final class MGBaseballSendDistance implements Serializable { + public int[] distances; + } + // endregion 棒球 + + /** + * 点击区域定义 + */ + @Keep + public static class InteractionClickRect { + public float x; // 区域的x + public float y; // 区域的y + public float width; // 区域的width + public float height; // 区域的height + } + + // region 3D语聊房 + /** + * 1. 请求房间数据 + */ + public static final String MG_CUSTOM_CR_ROOM_INIT_DATA = "mg_custom_cr_room_init_data"; + + /** + * 1. 请求房间数据 模型 + */ + @Keep + public static final class MGCustomCrRoomInitData implements Serializable { + } + + /** + * 2. 点击主播位或老板位通知 + */ + public static final String MG_CUSTOM_CR_CLICK_SEAT = "mg_custom_cr_click_seat"; + + /** + * 2. 点击主播位或老板位通知 模型 + */ + @Keep + public static final class MGCustomCrClickSeat implements Serializable { + public int seatIndex; // 0~4一共5个麦位,0为老板位,1~4为四个面主播位 + } + // endregion 3D语聊房 + +} diff --git a/core/src/model_sud_wrapper/java/com/chwl/core/sud/utils/GameCommonStateUtils.java b/core/src/model_sud_wrapper/java/com/chwl/core/sud/utils/GameCommonStateUtils.java new file mode 100644 index 000000000..0c61571d1 --- /dev/null +++ b/core/src/model_sud_wrapper/java/com/chwl/core/sud/utils/GameCommonStateUtils.java @@ -0,0 +1,138 @@ +/* + * Copyright © Sud.Tech + * https://sud.tech + */ + +package com.chwl.core.sud.utils; + +import android.text.TextUtils; + +import com.chwl.core.sud.state.SudMGPMGState; + +/** + * 游戏通用状态工具类 + */ +public class GameCommonStateUtils { + + /** + * 解析公屏消息 + * + * @param publicMessage 游戏发送过来的公屏消息对象 + * @param languageCode 需要提取的语言,比如zh-CN、en-US等等 + * @return 拼接起来的公屏文本 + */ + public static String parseMGCommonPublicMessage(SudMGPMGState.MGCommonPublicMessage publicMessage, String languageCode) { + if (publicMessage == null || publicMessage.msg == null || publicMessage.msg.size() == 0) { + return null; + } + StringBuilder sb = new StringBuilder(); + // 解析数组,拼接消息 + for (SudMGPMGState.MGCommonPublicMessage.MGCommonPublicMessageMsg msgModel : publicMessage.msg) { + switch (msgModel.phrase) { // 词组类型 当phrase=1时,会返回text; 当phrase=2时,会返回user + case 1: // 文本 + String text = parseI18nText(languageCode, msgModel.text); + if (text != null) { + sb.append(text); + } + break; + case 2: // 用户 + if (msgModel.user != null && msgModel.user.name != null) { + sb.append(msgModel.user.name); + } + break; + } + } + return sb.toString(); + } + + /** + * 根据当前的语言码,选择对应语言的文字 + * + * @param languageCode 语言代码 + * @param model 游戏发过来的文本对象 + * @return 返回选择的字符串 + */ + public static String parseI18nText(String languageCode, SudMGPMGState.MGCommonPublicMessage.MGCommonPublicMessageMsgText model) { + if (model == null) return null; + if (languageCode == null) return model.defaultStr; + + // 精准匹配 + String text = i18nPrecise(languageCode, model); + + if (TextUtils.isEmpty(text)) { + // 如果未匹配到,则尝试模糊匹配 + if (isMatchLanguage(languageCode, "zh")) { + return model.zh_CN; + } + return model.en_US; + } else { + return text; + } + } + + /** 精准匹配 */ + private static String i18nPrecise(String languageCode, SudMGPMGState.MGCommonPublicMessage.MGCommonPublicMessageMsgText model) { + switch (languageCode) { + case "zh-CN": + return model.zh_CN; + case "zh-HK": + return model.zh_HK; + case "zh-MO": + return model.zh_MO; + case "zh-SG": + return model.zh_SG; + case "zh-TW": + return model.zh_TW; + case "en-US": + return model.en_US; + case "en-GB": + return model.en_GB; + case "ms-BN": + return model.ms_BN; + case "ms-MY": + return model.ms_MY; + case "vi-VN": + return model.vi_VN; + case "id-ID": + return model.id_ID; + case "es-ES": + return model.es_ES; + case "ja-JP": + return model.ja_JP; + case "ko-KR": + return model.ko_KR; + case "th-TH": + return model.th_TH; + case "ar-SA": + return model.ar_SA; + case "ur-PK": + return model.ur_PK; + case "tr-TR": + return model.tr_TR; + case "pt-PT": + return model.pt_PT; + case "hi-IN": + return model.hi_IN; + case "bn-BD": + return model.bn_BD; + case "tl-PH": + return model.tl_PH; + case "fa-IR": + return model.fa_IR; + case "ru-RU": + return model.ru_RU; + } + return null; + } + + /** + * 判断是否是该语言 + */ + private static boolean isMatchLanguage(String languageCode, String matchLanguageCode) { + if (languageCode != null && matchLanguageCode != null) { + return matchLanguageCode.equals(languageCode) || languageCode.startsWith(matchLanguageCode + "-"); + } + return false; + } + +} diff --git a/core/src/model_sud_wrapper/java/com/chwl/core/sud/utils/ISudFSMStateHandleUtils.java b/core/src/model_sud_wrapper/java/com/chwl/core/sud/utils/ISudFSMStateHandleUtils.java new file mode 100644 index 000000000..844e14aa0 --- /dev/null +++ b/core/src/model_sud_wrapper/java/com/chwl/core/sud/utils/ISudFSMStateHandleUtils.java @@ -0,0 +1,25 @@ +/* + * Copyright © Sud.Tech + * https://sud.tech + */ + +package com.chwl.core.sud.utils; + +import tech.sud.mgp.core.ISudFSMStateHandle; +import com.chwl.core.sud.state.MGStateResponse; + +public class ISudFSMStateHandleUtils { + + /** + * 回调游戏,成功 + * + * @param handle + */ + public static void handleSuccess(ISudFSMStateHandle handle) { + MGStateResponse response = new MGStateResponse(); + response.ret_code = MGStateResponse.SUCCESS; + response.ret_msg = "success"; + handle.success(SudJsonUtils.toJson(response)); + } + +} diff --git a/core/src/model_sud_wrapper/java/com/chwl/core/sud/utils/SudJsonUtils.java b/core/src/model_sud_wrapper/java/com/chwl/core/sud/utils/SudJsonUtils.java new file mode 100644 index 000000000..7c71578cc --- /dev/null +++ b/core/src/model_sud_wrapper/java/com/chwl/core/sud/utils/SudJsonUtils.java @@ -0,0 +1,43 @@ +package com.chwl.core.sud.utils; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +/** + * json解析工具 + */ +public class SudJsonUtils { + + /** + * 解析json + * + * @return 如果解析出错,则返回空对象 + */ + public static T fromJson(final String json, final Class type) { + try { + return getGson().fromJson(json, type); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + /** + * 对象解析成json + * + * @param object + * @return + */ + public static String toJson(final Object object) { + return getGson().toJson(object); + } + + public static Gson getGson() { + return InnerClass.gson; + } + + public static class InnerClass { + public static Gson gson = new GsonBuilder().disableHtmlEscaping().create(); + } + +} diff --git a/library/src/main/java/com/chwl/library/utils/json/JsonUtils.java b/library/src/main/java/com/chwl/library/utils/json/JsonUtils.java index ca7f4d90d..0d66c680b 100644 --- a/library/src/main/java/com/chwl/library/utils/json/JsonUtils.java +++ b/library/src/main/java/com/chwl/library/utils/json/JsonUtils.java @@ -7,16 +7,37 @@ import com.google.gson.Gson; */ public class JsonUtils { - public static Gson gson; + private static Gson gson; - public static String toJson(Object object) { + public static Gson getGson() { if (gson == null) { gson = new Gson(); } + return gson; + } + + /** + * 解析json + * + * @return 如果解析出错,则返回空对象 + */ + public static T fromJson(final String json, final Class type) { + try { + if (json == null || type == null) { + return null; + } + return getGson().fromJson(json, type); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + public static String toJson(Object object) { String result = null; try { if (object != null) { - result = gson.toJson(object); + result = getGson().toJson(object); } } catch (Exception ex) { ex.printStackTrace();