feat:初步完成百顺游戏接入

This commit is contained in:
max
2024-04-30 19:45:48 +08:00
parent 5e634b1fda
commit 01f3418f43
29 changed files with 799 additions and 204 deletions

View File

@@ -2,6 +2,7 @@ package com.chwl.core.room.bean
import androidx.annotation.Keep
import com.chwl.core.bean.IRouterData
import com.chwl.core.room.game.bean.BaiShunGameConfig
/**
* Created by Max on 2024/2/20 11:49
@@ -40,6 +41,7 @@ data class RoomIcon(
fun isSeizeTreasure(): Boolean = code == "SEIZE_TREASURE"
fun isFindLove(): Boolean = code == "FIND_LOVE"
fun isNauticalAdventure(): Boolean = code == "NAUTICAL_ADVENTURE"
fun isBaiShunGame() = code == "BAISHUN"
override fun getSkipUri(): String? {
return skipContent
@@ -56,4 +58,9 @@ data class RoomIcon(
override fun getRouterValue(): String? {
return null
}
@Keep
class RuleValueBean {
val RESERVE: String? = null
}
}

View File

@@ -1,10 +1,55 @@
package com.chwl.core.room.core
import com.chwl.core.support.room.RoomContext
import com.chwl.core.support.room.RoomService
import java.util.concurrent.ConcurrentHashMap
/**
* Created by Max on 2023/10/26 12:36
* Desc:房间数据服务
**/
class RoomDataService : RoomService() {
/**
* 数据存储器
*/
private val dataMap: ConcurrentHashMap<String, Any> = ConcurrentHashMap()
/**
* 获取数据
*/
fun getData(key: String): Any? {
return dataMap.get(key)
}
/**
* 获取数据
* @param key
*/
fun getData(key: String, factory: (() -> Any)): Any {
val data = dataMap.get(key)
return if (data != null) {
data
} else {
val newData = factory.invoke()
dataMap.put(key, newData)
newData
}
}
/**
* 设置数据
*/
fun putData(key: String, data: Any?) {
if (data == null) {
dataMap.remove(key)
} else {
dataMap.put(key, data)
}
}
override fun onStop(context: RoomContext) {
super.onStop(context)
dataMap.clear()
}
}

View File

@@ -0,0 +1,50 @@
package com.chwl.core.room.game.bean
import androidx.annotation.Keep
import com.chwl.core.auth.AuthModel
import com.chwl.core.manager.AvRoomDataManager
import com.chwl.core.user.UserModel
import com.chwl.library.language.LanguageHelper
import java.io.Serializable
@Keep
class BaiShunGameConfig : Serializable {
val appChannel: String? = null
val appId: Long? = null
var userId: String? = null
val code: String? = null
var roomId: String? = null
// 游戏场景 2:半屏(秀场) 3: 全屏(游戏场)
val gameMode: String? = null
var language: String? = null
val gameConfig: Config? = null
val gsp: Int? = null
@Keep
class Config : Serializable {
val sceneMode: Int? = null
//货币图标(外⽹可访问 URL60*60 ⼤⼩)
val currencyIcon: String? = null
}
fun reloadDynamicParams() {
roomId = AvRoomDataManager.get().roomId.toString()
userId = AuthModel.get().currentUid.toString()
language = when (LanguageHelper.getCurrentLanguageType()) {
LanguageHelper.AR -> {
"7"
}
LanguageHelper.ZH -> {
"1"
}
else -> {
"2"
}
}
}
}

View File

@@ -1,5 +1,7 @@
package com.chwl.core.room.game.bean
import java.io.Serializable
data class GameInfo(
val isShow: Boolean = false,
val mgId: String = "",
@@ -7,5 +9,13 @@ data class GameInfo(
val pic: String = "",
val remark: String = "",
val seq: Int = 0,
var isSelect: Boolean = false
)
var isSelect: Boolean = false,
// 本地自己维护的,为了区分普通房
private var isStandardRoom: Boolean? = null,
) : Serializable {
fun isStandardRoom() = isStandardRoom == true
fun asStandardRoom() {
isStandardRoom = true
}
}

View File

@@ -2,6 +2,7 @@ package com.chwl.core.support.room
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.chwl.core.room.core.RoomDataService
import com.example.lib_utils.log.ILog
import com.chwl.core.support.room.lifecycle.RoomLifecycle
import com.chwl.core.support.room.lifecycle.RoomLifecycleRegistry
@@ -77,6 +78,7 @@ abstract class RoomContext(val roomId: Long) : ILog {
* 装载能力组件
*/
open fun loadAbility(list: MutableMap<String, RoomAbility>) {
list.put(RoomDataService::class.java.simpleName, RoomDataService())
}
/**