From 914bc3923d4c9d1640d2efcdc2b19058ce26d1d5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E6=B3=BD=E5=B8=86?= <411641460@qq.com>
Date: Tue, 16 Dec 2025 14:40:09 +0800
Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E5=9E=9B=E5=9E=9B?=
=?UTF-8?q?=E7=89=8C?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
data_cache/config/log4j.properties | 20 +
data_cache/config/mpnet-tools.xml | 93 +
data_cache/pom.xml | 63 +
.../main/java/com/data/bean/AccountBean.java | 37 +
.../src/main/java/com/data/bean/BaseBean.java | 34 +
.../src/main/java/com/data/bean/GameBean.java | 105 +
.../main/java/com/data/bean/GroupBean.java | 113 +
.../java/com/data/bean/GroupMemberBean.java | 50 +
.../java/com/data/bean/GroupPlayBean.java | 141 +
.../java/com/data/cache/AccountCache.java | 43 +
.../main/java/com/data/cache/BaseCache.java | 229 +
.../main/java/com/data/cache/GameCache.java | 44 +
.../main/java/com/data/cache/GroupCache.java | 125 +
.../java/com/data/cache/GroupMemberCache.java | 32 +
.../java/com/data/cache/GroupPlayCache.java | 106 +
.../main/java/com/data/util/ConsumeCode.java | 51 +
.../main/java/com/data/util/CountUtil.java | 262 +
.../main/java/com/data/util/ErrorCode.java | 172 +
.../main/java/com/data/util/EventType.java | 60 +
.../src/main/java/com/data/util/Utility.java | 399 ++
event_mgr/build/local/taurus-core.xml | 96 +
event_mgr/build/pro/log4j.properties | 20 +
event_mgr/build/pro/taurus-core.xml | 96 +
event_mgr/build/test/log4j.properties | 20 +
event_mgr/build/test/taurus-core.xml | 96 +
event_mgr/pom.xml | 117 +
.../java/com/evt/mgr/EventController.java | 149 +
.../main/java/com/evt/mgr/EventReceiver.java | 101 +
.../main/java/com/evt/mgr/EventServer.java | 105 +
.../com/evt/mgr/GroupPublisherService.java | 75 +
.../src/main/java/com/evt/mgr/IHandler.java | 10 +
.../src/main/java/com/evt/mgr/Utils.java | 221 +
.../mgr/handler/HandlerGroupMemberRound.java | 104 +
.../evt/mgr/handler/HandlerGroupRound.java | 72 +
.../com/evt/mgr/handler/HandlerHpConsume.java | 551 ++
.../java/com/evt/mgr/handler/HandlerLose.java | 18 +
.../java/com/evt/mgr/handler/HandlerOver.java | 90 +
.../java/com/evt/mgr/handler/HandlerPay.java | 84 +
.../java/com/evt/mgr/handler/HandlerWin.java | 18 +
.../com/evt/mgr/job/CleanGroupLogJob.java | 94 +
.../com/evt/mgr/job/CleanTimeOutRoomJob.java | 323 +
event_mgr/src/main/webapp/WEB-INF/web.xml | 19 +
.../src/main/webapp/config/log4j.properties | 20 +
.../src/main/webapp/config/taurus-core.xml | 98 +
event_mgr/src/test/java/MainEventMgr.java | 12 +
game_common/.idea/compiler.xml | 13 +
game_common/.idea/encodings.xml | 7 +
game_common/.idea/jarRepositories.xml | 20 +
game_common/.idea/misc.xml | 12 +
game_common/.idea/vcs.xml | 6 +
game_common/pom.xml | 85 +
.../src/main/java/com/game/ActionEvent.java | 51 +
.../src/main/java/com/game/Constant.java | 62 +
.../main/java/com/game/EventController.java | 376 ++
.../src/main/java/com/game/GPSUtil.java | 63 +
.../main/java/com/game/GameController.java | 1022 +++
.../main/java/com/game/GameInterceptor.java | 55 +
.../src/main/java/com/game/Global.java | 104 +
.../java/com/game/GroupPublisherService.java | 95 +
.../src/main/java/com/game/MainServer.java | 172 +
.../src/main/java/com/game/Router.java | 183 +
game_common/src/main/java/com/game/Util.java | 302 +
.../main/java/com/game/data/BasePlayBack.java | 108 +
.../src/main/java/com/game/data/Hp.java | 24 +
.../main/java/com/game/data/JoinRoomData.java | 12 +
.../src/main/java/com/game/data/Player.java | 614 ++
.../src/main/java/com/game/data/Room.java | 2202 ++++++
.../main/java/com/game/data/RoomDismiss.java | 158 +
.../src/main/java/com/game/data/Score.java | 54 +
.../src/main/java/com/game/data/Timer.java | 75 +
.../java/com/game/manager/RoomManager.java | 302 +
.../java/com/game/manager/SessionManager.java | 114 +
.../com/game/player/state/PlayerEndState.java | 53 +
.../game/player/state/PlayerInitState.java | 51 +
.../game/player/state/PlayerPauseState.java | 21 +
.../game/player/state/PlayerPopupState.java | 35 +
.../game/player/state/PlayerReadyState.java | 31 +
.../game/player/state/PlayerReloadState.java | 25 +
.../player/state/PlayerSpectatorState.java | 44 +
.../game/player/state/PlayerWaitState.java | 11 +
.../game/room/state/RoomDestoryGameState.java | 17 +
.../com/game/room/state/RoomEndState.java | 42 +
.../com/game/room/state/RoomInitState.java | 42 +
.../com/game/room/state/RoomReloadState.java | 39 +
.../game/room/state/RoomStartGameState.java | 12 +
.../com/game/room/state/RoomWaitState.java | 31 +
.../main/java/com/game/state/StateBase.java | 51 +
.../java/com/game/state/StateMachine.java | 64 +
game_mj_hongzhong/config/game-config.xml | 11 +
game_mj_hongzhong/config/log4j.properties | 20 +
game_mj_hongzhong/config/taurus-core.xml | 50 +
game_mj_hongzhong/config/taurus-permanent.xml | 75 +
game_mj_hongzhong/pom.xml | 44 +
.../src/main/java/extend/mj/CardNiao.java | 19 +
.../src/main/java/extend/mj/Config.java | 120 +
.../main/java/extend/mj/EXActionEvent.java | 18 +
.../main/java/extend/mj/EXGameController.java | 279 +
.../src/main/java/extend/mj/EXMainServer.java | 98 +
.../src/main/java/extend/mj/EXPlayBack.java | 68 +
.../src/main/java/extend/mj/EXPlayer.java | 142 +
.../src/main/java/extend/mj/EXRoom.java | 694 ++
.../src/main/java/extend/mj/EXScore.java | 47 +
.../src/main/java/extend/mj/OpCard.java | 19 +
.../java/extend/mj/PlayerRuleManager.java | 103 +
.../src/main/java/extend/mj/RoomCard.java | 190 +
.../src/main/java/extend/mj/RuleWeight.java | 20 +
.../src/main/java/extend/mj/SettleLog.java | 44 +
.../extend/mj/player/rule/RuleOtherKong.java | 50 +
.../extend/mj/player/rule/RuleOtherWin.java | 61 +
.../java/extend/mj/player/rule/RulePong.java | 53 +
.../extend/mj/player/rule/RulePongKong.java | 59 +
.../extend/mj/player/rule/RuleSelfKong.java | 56 +
.../extend/mj/player/rule/RuleSelfWin.java | 49 +
.../mj/player/rulestate/PROtherKongState.java | 89 +
.../mj/player/rulestate/PROtherWinState.java | 73 +
.../mj/player/rulestate/PRPongKongState.java | 77 +
.../mj/player/rulestate/PRPongState.java | 67 +
.../mj/player/rulestate/PRSelfKongState.java | 53 +
.../mj/player/rulestate/PRSelfWinState.java | 93 +
.../player/state/EXPlayerDisCardTipState.java | 54 +
.../mj/player/state/EXPlayerDiscardState.java | 146 +
.../mj/player/state/EXPlayerDrawState.java | 232 +
.../mj/player/state/EXPlayerDrawTipState.java | 43 +
.../mj/player/state/EXPlayerKongWinState.java | 42 +
.../state/EXPlayerPiaoNiaoTipState.java | 54 +
.../mj/player/state/EXPlayerTipState.java | 49 +
.../state/EXPlayerWaitKongWinState.java | 24 +
.../mj/player/state/EXPlayerWaitState.java | 39 +
.../extend/mj/room/state/EXRoomDealState.java | 147 +
.../extend/mj/room/state/EXRoomSetpState.java | 42 +
.../mj/room/state/EXRoomStartGameState.java | 33 +
.../src/main/java/extend/mj/tip/Action.java | 27 +
.../main/java/extend/mj/tip/IRuleBase.java | 27 +
.../src/main/java/extend/mj/tip/Tip.java | 40 +
.../main/java/extend/mj/tip/TipManager.java | 125 +
.../main/java/extend/mj/uitl/CardUtil.java | 32 +
.../src/main/java/extend/mj/uitl/WinCard.java | 363 +
.../java/game_mj_hongzhong/MainHongzhong.java | 9 +
game_pk_duoduo/.idea/compiler.xml | 13 +
game_pk_duoduo/.idea/encodings.xml | 7 +
game_pk_duoduo/.idea/jarRepositories.xml | 20 +
game_pk_duoduo/.idea/misc.xml | 12 +
game_pk_duoduo/.idea/vcs.xml | 6 +
game_pk_duoduo/config/game-config.xml | 10 +
game_pk_duoduo/config/log4j.properties | 20 +
game_pk_duoduo/config/taurus-core.xml | 95 +
game_pk_duoduo/config/taurus-permanent.xml | 75 +
game_pk_duoduo/pom.xml | 44 +
.../src/main/java/extend/pk/CardGroup.java | 45 +
.../src/main/java/extend/pk/CardObj.java | 21 +
.../src/main/java/extend/pk/Config.java | 140 +
.../main/java/extend/pk/EXActionEvent.java | 10 +
.../main/java/extend/pk/EXGameController.java | 878 +++
.../src/main/java/extend/pk/EXMainServer.java | 59 +
.../src/main/java/extend/pk/EXPlayBack.java | 61 +
.../src/main/java/extend/pk/EXPlayer.java | 137 +
.../src/main/java/extend/pk/EXRoom.java | 430 ++
.../src/main/java/extend/pk/EXScore.java | 18 +
.../src/main/java/extend/pk/RoomCard.java | 1192 ++++
.../src/main/java/extend/pk/SettleLog.java | 44 +
.../pk/player/state/EXPlayerDiscardState.java | 394 ++
.../pk/player/state/EXPlayerPassState.java | 52 +
.../extend/pk/room/state/EXRoomDealState.java | 112 +
.../extend/pk/room/state/EXRoomSetpState.java | 35 +
.../pk/room/state/EXRoomStartGameState.java | 38 +
.../main/java/extend/pk/uitl/CardCheck.java | 859 +++
.../main/java/extend/pk/uitl/CardConfig.java | 39 +
.../main/java/extend/pk/uitl/CardUtil.java | 419 ++
.../java/game_pk_paodekuai/MainPaodekuai.java | 9 +
game_pk_paodekuai/.idea/compiler.xml | 13 +
game_pk_paodekuai/.idea/encodings.xml | 7 +
game_pk_paodekuai/.idea/jarRepositories.xml | 20 +
game_pk_paodekuai/.idea/misc.xml | 12 +
game_pk_paodekuai/.idea/vcs.xml | 6 +
game_pk_paodekuai/config/game-config.xml | 10 +
game_pk_paodekuai/config/log4j.properties | 20 +
game_pk_paodekuai/config/taurus-core.xml | 95 +
game_pk_paodekuai/config/taurus-permanent.xml | 75 +
game_pk_paodekuai/pom.xml | 44 +
.../src/main/java/extend/pk/CardGroup.java | 45 +
.../src/main/java/extend/pk/CardObj.java | 21 +
.../src/main/java/extend/pk/Config.java | 248 +
.../main/java/extend/pk/EXActionEvent.java | 10 +
.../main/java/extend/pk/EXGameController.java | 950 +++
.../src/main/java/extend/pk/EXMainServer.java | 66 +
.../src/main/java/extend/pk/EXPlayBack.java | 61 +
.../src/main/java/extend/pk/EXPlayer.java | 137 +
.../src/main/java/extend/pk/EXRoom.java | 455 ++
.../src/main/java/extend/pk/EXScore.java | 18 +
.../src/main/java/extend/pk/RoomCard.java | 1192 ++++
.../src/main/java/extend/pk/SettleLog.java | 44 +
.../pk/player/state/EXPlayerDiscardState.java | 427 ++
.../pk/player/state/EXPlayerPassState.java | 52 +
.../state/EXPlayerPiaoNiaoTipState.java | 64 +
.../extend/pk/room/state/EXRoomDealState.java | 112 +
.../extend/pk/room/state/EXRoomPiaoState.java | 31 +
.../extend/pk/room/state/EXRoomSetpState.java | 35 +
.../pk/room/state/EXRoomStartGameState.java | 43 +
.../main/java/extend/pk/uitl/CardCheck.java | 1429 ++++
.../main/java/extend/pk/uitl/CardConfig.java | 46 +
.../main/java/extend/pk/uitl/CardUtil.java | 419 ++
.../java/game_pk_paodekuai/MainPaodekuai.java | 9 +
group_mgr/build/local/log4j.properties | 20 +
group_mgr/build/local/mgr-config.xml | 6 +
group_mgr/build/local/taurus-core.xml | 99 +
group_mgr/build/local/taurus-permanent.xml | 75 +
group_mgr/build/pro/log4j.properties | 20 +
group_mgr/build/pro/mgr-config.xml | 6 +
group_mgr/build/pro/taurus-core.xml | 98 +
group_mgr/build/pro/taurus-permanent.xml | 75 +
group_mgr/build/test/log4j.properties | 20 +
group_mgr/build/test/mgr-config.xml | 6 +
group_mgr/build/test/taurus-core.xml | 98 +
group_mgr/build/test/taurus-permanent.xml | 75 +
group_mgr/pom.xml | 126 +
.../src/main/java/com/mgr/group/Config.java | 9 +
.../src/main/java/com/mgr/group/Global.java | 28 +
.../java/com/mgr/group/GroupController.java | 1805 +++++
.../java/com/mgr/group/GroupSubscriber.java | 314 +
.../main/java/com/mgr/group/MainServer.java | 184 +
.../src/main/java/com/mgr/group/Router.java | 155 +
.../java/com/mgr/group/SessionManager.java | 80 +
.../src/main/java/com/mgr/group/WebMain.java | 34 +
.../java/com/mgr/group/data/CommandData.java | 36 +
.../main/java/com/mgr/group/data/Group.java | 386 ++
.../main/java/com/mgr/group/data/Player.java | 38 +
.../java/com/mgr/group/data/PlayerCache.java | 25 +
.../main/java/com/mgr/group/data/Room.java | 175 +
.../java/com/mgr/group/data/RoomCache.java | 87 +
.../main/java/com/mgr/group/data/User.java | 131 +
group_mgr/src/main/webapp/WEB-INF/web.xml | 19 +
.../src/main/webapp/config/log4j.properties | 20 +
.../src/main/webapp/config/mgr-config.xml | 6 +
.../src/main/webapp/config/taurus-core.xml | 98 +
.../main/webapp/config/taurus-permanent.xml | 75 +
.../java/group_room_mgr/MainGroupMgr.java | 12 +
pack_tools/pom.xml | 119 +
.../src/main/java/com/pack/MainServer.java | 63 +
pack_tools/src/main/java/com/pack/Utils.java | 98 +
.../java/com/pack/service/CommandService.java | 69 +
.../com/pack/service/PackServerProject.java | 103 +
.../com/pack/service/PackUtilService.java | 289 +
.../java/com/pack/service/ServletAllGame.java | 56 +
pack_tools/src/main/webapp/WEB-INF/web.xml | 38 +
.../src/main/webapp/config/log4j.properties | 20 +
.../src/main/webapp/config/mpnet-tools.xml | 97 +
.../src/main/webapp/config/pack-config.xml | 28 +
.../src/main/webapp/config/taurus-core.xml | 94 +
pack_tools/src/test/java/pack_tools/Main.java | 9 +
pack_tools/src/test/java/pack_tools/TT.java | 9 +
taurus-permanent/config/log4j.properties | 20 +
taurus-permanent/config/taurus-core.xml | 96 +
taurus-permanent/config/taurus-permanent.xml | 75 +
taurus-permanent/pom.xml | 36 +
.../main/java/com/taurus/permanent/Main.java | 9 +
.../java/com/taurus/permanent/TPServer.java | 319 +
.../permanent/core/BaseCoreService.java | 46 +
.../taurus/permanent/core/BitSwarmEngine.java | 337 +
.../permanent/core/ConnectionFilter.java | 159 +
.../permanent/core/DefaultConstants.java | 20 +
.../permanent/core/IConnectionFilter.java | 61 +
.../taurus/permanent/core/ServerConfig.java | 181 +
.../taurus/permanent/core/ServerState.java | 11 +
.../taurus/permanent/core/SessionManager.java | 313 +
.../permanent/core/SystemController.java | 338 +
.../com/taurus/permanent/core/TPEvents.java | 28 +
.../taurus/permanent/data/BindableSocket.java | 37 +
.../taurus/permanent/data/IPacketQueue.java | 66 +
.../taurus/permanent/data/ISocketChannel.java | 21 +
.../data/NonBlockingPacketQueue.java | 82 +
.../taurus/permanent/data/PackDataType.java | 6 +
.../com/taurus/permanent/data/Packet.java | 94 +
.../com/taurus/permanent/data/Session.java | 467 ++
.../taurus/permanent/data/SessionType.java | 17 +
.../taurus/permanent/io/BinaryIoHandler.java | 242 +
.../com/taurus/permanent/io/IOHandler.java | 73 +
.../taurus/permanent/io/PacketReadState.java | 21 +
.../taurus/permanent/io/PendingPacket.java | 37 +
.../taurus/permanent/io/ProcessedPacket.java | 23 +
.../taurus/permanent/io/ProtocolHandler.java | 42 +
.../permanent/normal/NormalSocketChannel.java | 71 +
.../permanent/normal/SocketAcceptor.java | 259 +
.../taurus/permanent/normal/SocketReader.java | 233 +
.../taurus/permanent/normal/SocketWriter.java | 278 +
.../permanent/util/GhostUserHunter.java | 82 +
.../websocket/UndertowWebSocketChannel.java | 56 +
.../permanent/websocket/WebSocketService.java | 195 +
.../test/java/com/taurus/T1Controller.java | 16 +
.../test/java/com/taurus/T2Controller.java | 22 +
.../test/java/com/taurus/TestExtension.java | 43 +
taurus-server/pom.xml | 124 +
.../taurus-core/config/log4j.properties | 20 +
.../taurus-core/config/taurus-core.xml | 96 +
taurus-server/taurus-core/pom.xml | 117 +
.../java/com/taurus/core/entity/ITArray.java | 83 +
.../java/com/taurus/core/entity/ITObject.java | 87 +
.../java/com/taurus/core/entity/TArray.java | 226 +
.../com/taurus/core/entity/TArrayLite.java | 28 +
.../taurus/core/entity/TDataSerializer.java | 646 ++
.../com/taurus/core/entity/TDataType.java | 41 +
.../com/taurus/core/entity/TDataWrapper.java | 30 +
.../java/com/taurus/core/entity/TObject.java | 291 +
.../com/taurus/core/entity/TObjectLite.java | 33 +
.../java/com/taurus/core/events/Event.java | 60 +
.../taurus/core/events/EventDispatcher.java | 93 +
.../com/taurus/core/events/EventManager.java | 63 +
.../taurus/core/events/IEventDispatcher.java | 40 +
.../taurus/core/events/IEventListener.java | 14 +
.../java/com/taurus/core/plugin/IPlugin.java | 23 +
.../com/taurus/core/plugin/PluginService.java | 149 +
.../taurus/core/plugin/database/DataBase.java | 62 +
.../core/plugin/database/DataBasePlugin.java | 132 +
.../com/taurus/core/plugin/database/Db.java | 807 +++
.../com/taurus/core/plugin/redis/Cache.java | 1220 ++++
.../com/taurus/core/plugin/redis/Redis.java | 70 +
.../taurus/core/plugin/redis/RedisLock.java | 76 +
.../taurus/core/plugin/redis/RedisPlugin.java | 141 +
.../java/com/taurus/core/routes/Action.java | 68 +
.../com/taurus/core/routes/ActionKey.java | 23 +
.../com/taurus/core/routes/ActionMapping.java | 94 +
.../com/taurus/core/routes/Extension.java | 57 +
.../com/taurus/core/routes/IController.java | 11 +
.../com/taurus/core/routes/Interceptor.java | 10 +
.../java/com/taurus/core/routes/Routes.java | 155 +
.../taurus/core/service/AbstractService.java | 48 +
.../com/taurus/core/service/IService.java | 39 +
.../java/com/taurus/core/util/Base64.java | 239 +
.../java/com/taurus/core/util/ByteArray.java | 259 +
.../java/com/taurus/core/util/DateUtils.java | 191 +
.../java/com/taurus/core/util/FileUtil.java | 89 +
.../core/util/FixedIndexThreadPool.java | 136 +
.../java/com/taurus/core/util/ICallback.java | 13 +
.../java/com/taurus/core/util/Logger.java | 214 +
.../main/java/com/taurus/core/util/MD5.java | 48 +
.../main/java/com/taurus/core/util/SHA1.java | 54 +
.../java/com/taurus/core/util/StringUtil.java | 233 +
.../main/java/com/taurus/core/util/Utils.java | 313 +
.../com/taurus/core/util/json/JSONParser.java | 370 ++
.../com/taurus/core/util/json/JSONUtils.java | 15 +
.../com/taurus/core/util/json/JSONWriter.java | 314 +
.../taurus/core/util/task/ITaskHandler.java | 16 +
.../java/com/taurus/core/util/task/Task.java | 45 +
.../taurus/core/util/task/TaskScheduler.java | 139 +
.../taurus-core/src/test/java/Test.java | 221 +
.../taurus-permanent/config/log4j.properties | 20 +
.../taurus-permanent/config/taurus-core.xml | 96 +
.../config/taurus-permanent.xml | 75 +
taurus-server/taurus-permanent/pom.xml | 36 +
.../main/java/com/taurus/permanent/Main.java | 9 +
.../java/com/taurus/permanent/TPServer.java | 319 +
.../permanent/core/BaseCoreService.java | 46 +
.../taurus/permanent/core/BitSwarmEngine.java | 337 +
.../permanent/core/ConnectionFilter.java | 159 +
.../permanent/core/DefaultConstants.java | 20 +
.../permanent/core/IConnectionFilter.java | 61 +
.../taurus/permanent/core/ServerConfig.java | 181 +
.../taurus/permanent/core/ServerState.java | 11 +
.../taurus/permanent/core/SessionManager.java | 313 +
.../permanent/core/SystemController.java | 322 +
.../com/taurus/permanent/core/TPEvents.java | 28 +
.../taurus/permanent/data/BindableSocket.java | 37 +
.../taurus/permanent/data/IPacketQueue.java | 66 +
.../taurus/permanent/data/ISocketChannel.java | 21 +
.../data/NonBlockingPacketQueue.java | 82 +
.../taurus/permanent/data/PackDataType.java | 6 +
.../com/taurus/permanent/data/Packet.java | 94 +
.../com/taurus/permanent/data/Session.java | 467 ++
.../taurus/permanent/data/SessionType.java | 17 +
.../taurus/permanent/io/BinaryIoHandler.java | 242 +
.../com/taurus/permanent/io/IOHandler.java | 73 +
.../taurus/permanent/io/PacketReadState.java | 21 +
.../taurus/permanent/io/PendingPacket.java | 37 +
.../taurus/permanent/io/ProcessedPacket.java | 23 +
.../taurus/permanent/io/ProtocolHandler.java | 42 +
.../permanent/normal/NormalSocketChannel.java | 71 +
.../permanent/normal/SocketAcceptor.java | 259 +
.../taurus/permanent/normal/SocketReader.java | 233 +
.../taurus/permanent/normal/SocketWriter.java | 278 +
.../permanent/util/GhostUserHunter.java | 82 +
.../websocket/UndertowWebSocketChannel.java | 56 +
.../permanent/websocket/WebSocketService.java | 195 +
.../test/java/com/taurus/T1Controller.java | 16 +
.../test/java/com/taurus/T2Controller.java | 22 +
.../test/java/com/taurus/TestExtension.java | 43 +
taurus-server/taurus-web/pom.xml | 38 +
.../main/java/com/taurus/web/Controller.java | 133 +
.../main/java/com/taurus/web/JettyServer.java | 157 +
.../com/taurus/web/ServletHealthCheck.java | 23 +
.../main/java/com/taurus/web/SessionInfo.java | 11 +
.../java/com/taurus/web/StatusServlet.java | 66 +
.../main/java/com/taurus/web/TWebServer.java | 233 +
.../java/com/taurus/web/WebException.java | 17 +
.../main/java/com/taurus/web/WebFilter.java | 72 +
.../main/java/com/taurus/web/WebUtils.java | 42 +
.../src/test/java/com/taurus/Test.java | 14 +
web_group/build/local/taurus-core.xml | 100 +
web_group/build/pro/bank_hp.lua | 19 +
web_group/build/pro/log4j.properties | 20 +
web_group/build/pro/mgr.lua | 25 +
web_group/build/pro/take_hp.lua | 10 +
web_group/build/pro/taurus-core.xml | 100 +
web_group/build/pro/trade.lua | 12 +
web_group/build/test/bank_hp.lua | 19 +
web_group/build/test/log4j.properties | 20 +
web_group/build/test/mgr.lua | 25 +
web_group/build/test/take_hp.lua | 10 +
web_group/build/test/taurus-core.xml | 100 +
web_group/build/test/trade.lua | 12 +
web_group/pom.xml | 118 +
.../src/main/java/com/group/MainServer.java | 142 +
.../src/main/java/com/group/Protocol.java | 279 +
.../main/java/com/group/WebInterceptor.java | 241 +
.../com/group/controller/GroupController.java | 1775 +++++
.../group/controller/GroupLogController.java | 804 +++
.../group/controller/GroupRoomController.java | 114 +
.../java/com/group/job/UpdatePlayRoomJob.java | 889 +++
.../com/group/service/GroupLogService.java | 2722 ++++++++
.../group/service/GroupPublisherService.java | 328 +
.../com/group/service/GroupRoomService.java | 1596 +++++
.../java/com/group/service/GroupService.java | 5908 +++++++++++++++++
web_group/src/main/webapp/WEB-INF/web.xml | 19 +
web_group/src/main/webapp/config/bank_hp.lua | 19 +
.../src/main/webapp/config/log4j.properties | 20 +
web_group/src/main/webapp/config/mgr.lua | 25 +
web_group/src/main/webapp/config/take_hp.lua | 10 +
.../src/main/webapp/config/taurus-core.xml | 100 +
web_group/src/main/webapp/config/trade.lua | 12 +
web_group/src/test/java/etty-contexts.xml | 9 +
.../test/java/web_group/DataClearUtils.java | 146 +
.../src/test/java/web_group/MainWebGroup.java | 9 +
web_login/.idea/artifacts/web_login_war.xml | 14 +
.../artifacts/web_login_war_exploded.xml | 23 +
web_login/.idea/compiler.xml | 16 +
web_login/.idea/misc.xml | 14 +
web_login/.idea/modules.xml | 8 +
web_login/.idea/workspace.xml | 42 +
web_login/build/adduser | 0
web_login/build/local/log4j.properties | 20 +
web_login/build/local/taurus-core.xml | 96 +
web_login/build/pro/log4j.properties | 20 +
web_login/build/pro/taurus-core.xml | 96 +
web_login/build/test/log4j.properties | 20 +
web_login/build/test/taurus-core.xml | 96 +
web_login/config/log4j.properties | 20 +
web_login/config/taurus-core.xml | 96 +
web_login/god | 0
web_login/pom.xml | 130 +
.../src/main/java/com/mjlogin/MainServer.java | 73 +
.../src/main/java/com/mjlogin/Protocol.java | 78 +
.../main/java/com/mjlogin/WebInterceptor.java | 56 +
.../com/mjlogin/service/AccountService.java | 1625 +++++
.../com/mjlogin/service/IndexService.java | 69 +
.../com/mjlogin/service/MilitaryService.java | 118 +
.../java/com/mjlogin/service/RoomService.java | 338 +
.../java/com/mjlogin/util/sms/RedisKey.java | 8 +
.../java/com/mjlogin/util/sms/SMSThread.java | 64 +
.../com/mjlogin/util/sms/SMSVerification.java | 120 +
web_login/src/main/webapp/WEB-INF/web.xml | 19 +
.../src/main/webapp/config/log4j.properties | 20 +
.../src/main/webapp/config/taurus-core.xml | 96 +
.../src/test/java/web_login/MainWebLogin.java | 9 +
461 files changed, 70261 insertions(+)
create mode 100644 data_cache/config/log4j.properties
create mode 100644 data_cache/config/mpnet-tools.xml
create mode 100644 data_cache/pom.xml
create mode 100644 data_cache/src/main/java/com/data/bean/AccountBean.java
create mode 100644 data_cache/src/main/java/com/data/bean/BaseBean.java
create mode 100644 data_cache/src/main/java/com/data/bean/GameBean.java
create mode 100644 data_cache/src/main/java/com/data/bean/GroupBean.java
create mode 100644 data_cache/src/main/java/com/data/bean/GroupMemberBean.java
create mode 100644 data_cache/src/main/java/com/data/bean/GroupPlayBean.java
create mode 100644 data_cache/src/main/java/com/data/cache/AccountCache.java
create mode 100644 data_cache/src/main/java/com/data/cache/BaseCache.java
create mode 100644 data_cache/src/main/java/com/data/cache/GameCache.java
create mode 100644 data_cache/src/main/java/com/data/cache/GroupCache.java
create mode 100644 data_cache/src/main/java/com/data/cache/GroupMemberCache.java
create mode 100644 data_cache/src/main/java/com/data/cache/GroupPlayCache.java
create mode 100644 data_cache/src/main/java/com/data/util/ConsumeCode.java
create mode 100644 data_cache/src/main/java/com/data/util/CountUtil.java
create mode 100644 data_cache/src/main/java/com/data/util/ErrorCode.java
create mode 100644 data_cache/src/main/java/com/data/util/EventType.java
create mode 100644 data_cache/src/main/java/com/data/util/Utility.java
create mode 100644 event_mgr/build/local/taurus-core.xml
create mode 100644 event_mgr/build/pro/log4j.properties
create mode 100644 event_mgr/build/pro/taurus-core.xml
create mode 100644 event_mgr/build/test/log4j.properties
create mode 100644 event_mgr/build/test/taurus-core.xml
create mode 100644 event_mgr/pom.xml
create mode 100644 event_mgr/src/main/java/com/evt/mgr/EventController.java
create mode 100644 event_mgr/src/main/java/com/evt/mgr/EventReceiver.java
create mode 100644 event_mgr/src/main/java/com/evt/mgr/EventServer.java
create mode 100644 event_mgr/src/main/java/com/evt/mgr/GroupPublisherService.java
create mode 100644 event_mgr/src/main/java/com/evt/mgr/IHandler.java
create mode 100644 event_mgr/src/main/java/com/evt/mgr/Utils.java
create mode 100644 event_mgr/src/main/java/com/evt/mgr/handler/HandlerGroupMemberRound.java
create mode 100644 event_mgr/src/main/java/com/evt/mgr/handler/HandlerGroupRound.java
create mode 100644 event_mgr/src/main/java/com/evt/mgr/handler/HandlerHpConsume.java
create mode 100644 event_mgr/src/main/java/com/evt/mgr/handler/HandlerLose.java
create mode 100644 event_mgr/src/main/java/com/evt/mgr/handler/HandlerOver.java
create mode 100644 event_mgr/src/main/java/com/evt/mgr/handler/HandlerPay.java
create mode 100644 event_mgr/src/main/java/com/evt/mgr/handler/HandlerWin.java
create mode 100644 event_mgr/src/main/java/com/evt/mgr/job/CleanGroupLogJob.java
create mode 100644 event_mgr/src/main/java/com/evt/mgr/job/CleanTimeOutRoomJob.java
create mode 100644 event_mgr/src/main/webapp/WEB-INF/web.xml
create mode 100644 event_mgr/src/main/webapp/config/log4j.properties
create mode 100644 event_mgr/src/main/webapp/config/taurus-core.xml
create mode 100644 event_mgr/src/test/java/MainEventMgr.java
create mode 100644 game_common/.idea/compiler.xml
create mode 100644 game_common/.idea/encodings.xml
create mode 100644 game_common/.idea/jarRepositories.xml
create mode 100644 game_common/.idea/misc.xml
create mode 100644 game_common/.idea/vcs.xml
create mode 100644 game_common/pom.xml
create mode 100644 game_common/src/main/java/com/game/ActionEvent.java
create mode 100644 game_common/src/main/java/com/game/Constant.java
create mode 100644 game_common/src/main/java/com/game/EventController.java
create mode 100644 game_common/src/main/java/com/game/GPSUtil.java
create mode 100644 game_common/src/main/java/com/game/GameController.java
create mode 100644 game_common/src/main/java/com/game/GameInterceptor.java
create mode 100644 game_common/src/main/java/com/game/Global.java
create mode 100644 game_common/src/main/java/com/game/GroupPublisherService.java
create mode 100644 game_common/src/main/java/com/game/MainServer.java
create mode 100644 game_common/src/main/java/com/game/Router.java
create mode 100644 game_common/src/main/java/com/game/Util.java
create mode 100644 game_common/src/main/java/com/game/data/BasePlayBack.java
create mode 100644 game_common/src/main/java/com/game/data/Hp.java
create mode 100644 game_common/src/main/java/com/game/data/JoinRoomData.java
create mode 100644 game_common/src/main/java/com/game/data/Player.java
create mode 100644 game_common/src/main/java/com/game/data/Room.java
create mode 100644 game_common/src/main/java/com/game/data/RoomDismiss.java
create mode 100644 game_common/src/main/java/com/game/data/Score.java
create mode 100644 game_common/src/main/java/com/game/data/Timer.java
create mode 100644 game_common/src/main/java/com/game/manager/RoomManager.java
create mode 100644 game_common/src/main/java/com/game/manager/SessionManager.java
create mode 100644 game_common/src/main/java/com/game/player/state/PlayerEndState.java
create mode 100644 game_common/src/main/java/com/game/player/state/PlayerInitState.java
create mode 100644 game_common/src/main/java/com/game/player/state/PlayerPauseState.java
create mode 100644 game_common/src/main/java/com/game/player/state/PlayerPopupState.java
create mode 100644 game_common/src/main/java/com/game/player/state/PlayerReadyState.java
create mode 100644 game_common/src/main/java/com/game/player/state/PlayerReloadState.java
create mode 100644 game_common/src/main/java/com/game/player/state/PlayerSpectatorState.java
create mode 100644 game_common/src/main/java/com/game/player/state/PlayerWaitState.java
create mode 100644 game_common/src/main/java/com/game/room/state/RoomDestoryGameState.java
create mode 100644 game_common/src/main/java/com/game/room/state/RoomEndState.java
create mode 100644 game_common/src/main/java/com/game/room/state/RoomInitState.java
create mode 100644 game_common/src/main/java/com/game/room/state/RoomReloadState.java
create mode 100644 game_common/src/main/java/com/game/room/state/RoomStartGameState.java
create mode 100644 game_common/src/main/java/com/game/room/state/RoomWaitState.java
create mode 100644 game_common/src/main/java/com/game/state/StateBase.java
create mode 100644 game_common/src/main/java/com/game/state/StateMachine.java
create mode 100644 game_mj_hongzhong/config/game-config.xml
create mode 100644 game_mj_hongzhong/config/log4j.properties
create mode 100644 game_mj_hongzhong/config/taurus-core.xml
create mode 100644 game_mj_hongzhong/config/taurus-permanent.xml
create mode 100644 game_mj_hongzhong/pom.xml
create mode 100644 game_mj_hongzhong/src/main/java/extend/mj/CardNiao.java
create mode 100644 game_mj_hongzhong/src/main/java/extend/mj/Config.java
create mode 100644 game_mj_hongzhong/src/main/java/extend/mj/EXActionEvent.java
create mode 100644 game_mj_hongzhong/src/main/java/extend/mj/EXGameController.java
create mode 100644 game_mj_hongzhong/src/main/java/extend/mj/EXMainServer.java
create mode 100644 game_mj_hongzhong/src/main/java/extend/mj/EXPlayBack.java
create mode 100644 game_mj_hongzhong/src/main/java/extend/mj/EXPlayer.java
create mode 100644 game_mj_hongzhong/src/main/java/extend/mj/EXRoom.java
create mode 100644 game_mj_hongzhong/src/main/java/extend/mj/EXScore.java
create mode 100644 game_mj_hongzhong/src/main/java/extend/mj/OpCard.java
create mode 100644 game_mj_hongzhong/src/main/java/extend/mj/PlayerRuleManager.java
create mode 100644 game_mj_hongzhong/src/main/java/extend/mj/RoomCard.java
create mode 100644 game_mj_hongzhong/src/main/java/extend/mj/RuleWeight.java
create mode 100644 game_mj_hongzhong/src/main/java/extend/mj/SettleLog.java
create mode 100644 game_mj_hongzhong/src/main/java/extend/mj/player/rule/RuleOtherKong.java
create mode 100644 game_mj_hongzhong/src/main/java/extend/mj/player/rule/RuleOtherWin.java
create mode 100644 game_mj_hongzhong/src/main/java/extend/mj/player/rule/RulePong.java
create mode 100644 game_mj_hongzhong/src/main/java/extend/mj/player/rule/RulePongKong.java
create mode 100644 game_mj_hongzhong/src/main/java/extend/mj/player/rule/RuleSelfKong.java
create mode 100644 game_mj_hongzhong/src/main/java/extend/mj/player/rule/RuleSelfWin.java
create mode 100644 game_mj_hongzhong/src/main/java/extend/mj/player/rulestate/PROtherKongState.java
create mode 100644 game_mj_hongzhong/src/main/java/extend/mj/player/rulestate/PROtherWinState.java
create mode 100644 game_mj_hongzhong/src/main/java/extend/mj/player/rulestate/PRPongKongState.java
create mode 100644 game_mj_hongzhong/src/main/java/extend/mj/player/rulestate/PRPongState.java
create mode 100644 game_mj_hongzhong/src/main/java/extend/mj/player/rulestate/PRSelfKongState.java
create mode 100644 game_mj_hongzhong/src/main/java/extend/mj/player/rulestate/PRSelfWinState.java
create mode 100644 game_mj_hongzhong/src/main/java/extend/mj/player/state/EXPlayerDisCardTipState.java
create mode 100644 game_mj_hongzhong/src/main/java/extend/mj/player/state/EXPlayerDiscardState.java
create mode 100644 game_mj_hongzhong/src/main/java/extend/mj/player/state/EXPlayerDrawState.java
create mode 100644 game_mj_hongzhong/src/main/java/extend/mj/player/state/EXPlayerDrawTipState.java
create mode 100644 game_mj_hongzhong/src/main/java/extend/mj/player/state/EXPlayerKongWinState.java
create mode 100644 game_mj_hongzhong/src/main/java/extend/mj/player/state/EXPlayerPiaoNiaoTipState.java
create mode 100644 game_mj_hongzhong/src/main/java/extend/mj/player/state/EXPlayerTipState.java
create mode 100644 game_mj_hongzhong/src/main/java/extend/mj/player/state/EXPlayerWaitKongWinState.java
create mode 100644 game_mj_hongzhong/src/main/java/extend/mj/player/state/EXPlayerWaitState.java
create mode 100644 game_mj_hongzhong/src/main/java/extend/mj/room/state/EXRoomDealState.java
create mode 100644 game_mj_hongzhong/src/main/java/extend/mj/room/state/EXRoomSetpState.java
create mode 100644 game_mj_hongzhong/src/main/java/extend/mj/room/state/EXRoomStartGameState.java
create mode 100644 game_mj_hongzhong/src/main/java/extend/mj/tip/Action.java
create mode 100644 game_mj_hongzhong/src/main/java/extend/mj/tip/IRuleBase.java
create mode 100644 game_mj_hongzhong/src/main/java/extend/mj/tip/Tip.java
create mode 100644 game_mj_hongzhong/src/main/java/extend/mj/tip/TipManager.java
create mode 100644 game_mj_hongzhong/src/main/java/extend/mj/uitl/CardUtil.java
create mode 100644 game_mj_hongzhong/src/main/java/extend/mj/uitl/WinCard.java
create mode 100644 game_mj_hongzhong/src/test/java/game_mj_hongzhong/MainHongzhong.java
create mode 100644 game_pk_duoduo/.idea/compiler.xml
create mode 100644 game_pk_duoduo/.idea/encodings.xml
create mode 100644 game_pk_duoduo/.idea/jarRepositories.xml
create mode 100644 game_pk_duoduo/.idea/misc.xml
create mode 100644 game_pk_duoduo/.idea/vcs.xml
create mode 100644 game_pk_duoduo/config/game-config.xml
create mode 100644 game_pk_duoduo/config/log4j.properties
create mode 100644 game_pk_duoduo/config/taurus-core.xml
create mode 100644 game_pk_duoduo/config/taurus-permanent.xml
create mode 100644 game_pk_duoduo/pom.xml
create mode 100644 game_pk_duoduo/src/main/java/extend/pk/CardGroup.java
create mode 100644 game_pk_duoduo/src/main/java/extend/pk/CardObj.java
create mode 100644 game_pk_duoduo/src/main/java/extend/pk/Config.java
create mode 100644 game_pk_duoduo/src/main/java/extend/pk/EXActionEvent.java
create mode 100644 game_pk_duoduo/src/main/java/extend/pk/EXGameController.java
create mode 100644 game_pk_duoduo/src/main/java/extend/pk/EXMainServer.java
create mode 100644 game_pk_duoduo/src/main/java/extend/pk/EXPlayBack.java
create mode 100644 game_pk_duoduo/src/main/java/extend/pk/EXPlayer.java
create mode 100644 game_pk_duoduo/src/main/java/extend/pk/EXRoom.java
create mode 100644 game_pk_duoduo/src/main/java/extend/pk/EXScore.java
create mode 100644 game_pk_duoduo/src/main/java/extend/pk/RoomCard.java
create mode 100644 game_pk_duoduo/src/main/java/extend/pk/SettleLog.java
create mode 100644 game_pk_duoduo/src/main/java/extend/pk/player/state/EXPlayerDiscardState.java
create mode 100644 game_pk_duoduo/src/main/java/extend/pk/player/state/EXPlayerPassState.java
create mode 100644 game_pk_duoduo/src/main/java/extend/pk/room/state/EXRoomDealState.java
create mode 100644 game_pk_duoduo/src/main/java/extend/pk/room/state/EXRoomSetpState.java
create mode 100644 game_pk_duoduo/src/main/java/extend/pk/room/state/EXRoomStartGameState.java
create mode 100644 game_pk_duoduo/src/main/java/extend/pk/uitl/CardCheck.java
create mode 100644 game_pk_duoduo/src/main/java/extend/pk/uitl/CardConfig.java
create mode 100644 game_pk_duoduo/src/main/java/extend/pk/uitl/CardUtil.java
create mode 100644 game_pk_duoduo/src/test/java/game_pk_paodekuai/MainPaodekuai.java
create mode 100644 game_pk_paodekuai/.idea/compiler.xml
create mode 100644 game_pk_paodekuai/.idea/encodings.xml
create mode 100644 game_pk_paodekuai/.idea/jarRepositories.xml
create mode 100644 game_pk_paodekuai/.idea/misc.xml
create mode 100644 game_pk_paodekuai/.idea/vcs.xml
create mode 100644 game_pk_paodekuai/config/game-config.xml
create mode 100644 game_pk_paodekuai/config/log4j.properties
create mode 100644 game_pk_paodekuai/config/taurus-core.xml
create mode 100644 game_pk_paodekuai/config/taurus-permanent.xml
create mode 100644 game_pk_paodekuai/pom.xml
create mode 100644 game_pk_paodekuai/src/main/java/extend/pk/CardGroup.java
create mode 100644 game_pk_paodekuai/src/main/java/extend/pk/CardObj.java
create mode 100644 game_pk_paodekuai/src/main/java/extend/pk/Config.java
create mode 100644 game_pk_paodekuai/src/main/java/extend/pk/EXActionEvent.java
create mode 100644 game_pk_paodekuai/src/main/java/extend/pk/EXGameController.java
create mode 100644 game_pk_paodekuai/src/main/java/extend/pk/EXMainServer.java
create mode 100644 game_pk_paodekuai/src/main/java/extend/pk/EXPlayBack.java
create mode 100644 game_pk_paodekuai/src/main/java/extend/pk/EXPlayer.java
create mode 100644 game_pk_paodekuai/src/main/java/extend/pk/EXRoom.java
create mode 100644 game_pk_paodekuai/src/main/java/extend/pk/EXScore.java
create mode 100644 game_pk_paodekuai/src/main/java/extend/pk/RoomCard.java
create mode 100644 game_pk_paodekuai/src/main/java/extend/pk/SettleLog.java
create mode 100644 game_pk_paodekuai/src/main/java/extend/pk/player/state/EXPlayerDiscardState.java
create mode 100644 game_pk_paodekuai/src/main/java/extend/pk/player/state/EXPlayerPassState.java
create mode 100644 game_pk_paodekuai/src/main/java/extend/pk/player/state/EXPlayerPiaoNiaoTipState.java
create mode 100644 game_pk_paodekuai/src/main/java/extend/pk/room/state/EXRoomDealState.java
create mode 100644 game_pk_paodekuai/src/main/java/extend/pk/room/state/EXRoomPiaoState.java
create mode 100644 game_pk_paodekuai/src/main/java/extend/pk/room/state/EXRoomSetpState.java
create mode 100644 game_pk_paodekuai/src/main/java/extend/pk/room/state/EXRoomStartGameState.java
create mode 100644 game_pk_paodekuai/src/main/java/extend/pk/uitl/CardCheck.java
create mode 100644 game_pk_paodekuai/src/main/java/extend/pk/uitl/CardConfig.java
create mode 100644 game_pk_paodekuai/src/main/java/extend/pk/uitl/CardUtil.java
create mode 100644 game_pk_paodekuai/src/test/java/game_pk_paodekuai/MainPaodekuai.java
create mode 100644 group_mgr/build/local/log4j.properties
create mode 100644 group_mgr/build/local/mgr-config.xml
create mode 100644 group_mgr/build/local/taurus-core.xml
create mode 100644 group_mgr/build/local/taurus-permanent.xml
create mode 100644 group_mgr/build/pro/log4j.properties
create mode 100644 group_mgr/build/pro/mgr-config.xml
create mode 100644 group_mgr/build/pro/taurus-core.xml
create mode 100644 group_mgr/build/pro/taurus-permanent.xml
create mode 100644 group_mgr/build/test/log4j.properties
create mode 100644 group_mgr/build/test/mgr-config.xml
create mode 100644 group_mgr/build/test/taurus-core.xml
create mode 100644 group_mgr/build/test/taurus-permanent.xml
create mode 100644 group_mgr/pom.xml
create mode 100644 group_mgr/src/main/java/com/mgr/group/Config.java
create mode 100644 group_mgr/src/main/java/com/mgr/group/Global.java
create mode 100644 group_mgr/src/main/java/com/mgr/group/GroupController.java
create mode 100644 group_mgr/src/main/java/com/mgr/group/GroupSubscriber.java
create mode 100644 group_mgr/src/main/java/com/mgr/group/MainServer.java
create mode 100644 group_mgr/src/main/java/com/mgr/group/Router.java
create mode 100644 group_mgr/src/main/java/com/mgr/group/SessionManager.java
create mode 100644 group_mgr/src/main/java/com/mgr/group/WebMain.java
create mode 100644 group_mgr/src/main/java/com/mgr/group/data/CommandData.java
create mode 100644 group_mgr/src/main/java/com/mgr/group/data/Group.java
create mode 100644 group_mgr/src/main/java/com/mgr/group/data/Player.java
create mode 100644 group_mgr/src/main/java/com/mgr/group/data/PlayerCache.java
create mode 100644 group_mgr/src/main/java/com/mgr/group/data/Room.java
create mode 100644 group_mgr/src/main/java/com/mgr/group/data/RoomCache.java
create mode 100644 group_mgr/src/main/java/com/mgr/group/data/User.java
create mode 100644 group_mgr/src/main/webapp/WEB-INF/web.xml
create mode 100644 group_mgr/src/main/webapp/config/log4j.properties
create mode 100644 group_mgr/src/main/webapp/config/mgr-config.xml
create mode 100644 group_mgr/src/main/webapp/config/taurus-core.xml
create mode 100644 group_mgr/src/main/webapp/config/taurus-permanent.xml
create mode 100644 group_mgr/src/test/java/group_room_mgr/MainGroupMgr.java
create mode 100644 pack_tools/pom.xml
create mode 100644 pack_tools/src/main/java/com/pack/MainServer.java
create mode 100644 pack_tools/src/main/java/com/pack/Utils.java
create mode 100644 pack_tools/src/main/java/com/pack/service/CommandService.java
create mode 100644 pack_tools/src/main/java/com/pack/service/PackServerProject.java
create mode 100644 pack_tools/src/main/java/com/pack/service/PackUtilService.java
create mode 100644 pack_tools/src/main/java/com/pack/service/ServletAllGame.java
create mode 100644 pack_tools/src/main/webapp/WEB-INF/web.xml
create mode 100644 pack_tools/src/main/webapp/config/log4j.properties
create mode 100644 pack_tools/src/main/webapp/config/mpnet-tools.xml
create mode 100644 pack_tools/src/main/webapp/config/pack-config.xml
create mode 100644 pack_tools/src/main/webapp/config/taurus-core.xml
create mode 100644 pack_tools/src/test/java/pack_tools/Main.java
create mode 100644 pack_tools/src/test/java/pack_tools/TT.java
create mode 100644 taurus-permanent/config/log4j.properties
create mode 100644 taurus-permanent/config/taurus-core.xml
create mode 100644 taurus-permanent/config/taurus-permanent.xml
create mode 100644 taurus-permanent/pom.xml
create mode 100644 taurus-permanent/src/main/java/com/taurus/permanent/Main.java
create mode 100644 taurus-permanent/src/main/java/com/taurus/permanent/TPServer.java
create mode 100644 taurus-permanent/src/main/java/com/taurus/permanent/core/BaseCoreService.java
create mode 100644 taurus-permanent/src/main/java/com/taurus/permanent/core/BitSwarmEngine.java
create mode 100644 taurus-permanent/src/main/java/com/taurus/permanent/core/ConnectionFilter.java
create mode 100644 taurus-permanent/src/main/java/com/taurus/permanent/core/DefaultConstants.java
create mode 100644 taurus-permanent/src/main/java/com/taurus/permanent/core/IConnectionFilter.java
create mode 100644 taurus-permanent/src/main/java/com/taurus/permanent/core/ServerConfig.java
create mode 100644 taurus-permanent/src/main/java/com/taurus/permanent/core/ServerState.java
create mode 100644 taurus-permanent/src/main/java/com/taurus/permanent/core/SessionManager.java
create mode 100644 taurus-permanent/src/main/java/com/taurus/permanent/core/SystemController.java
create mode 100644 taurus-permanent/src/main/java/com/taurus/permanent/core/TPEvents.java
create mode 100644 taurus-permanent/src/main/java/com/taurus/permanent/data/BindableSocket.java
create mode 100644 taurus-permanent/src/main/java/com/taurus/permanent/data/IPacketQueue.java
create mode 100644 taurus-permanent/src/main/java/com/taurus/permanent/data/ISocketChannel.java
create mode 100644 taurus-permanent/src/main/java/com/taurus/permanent/data/NonBlockingPacketQueue.java
create mode 100644 taurus-permanent/src/main/java/com/taurus/permanent/data/PackDataType.java
create mode 100644 taurus-permanent/src/main/java/com/taurus/permanent/data/Packet.java
create mode 100644 taurus-permanent/src/main/java/com/taurus/permanent/data/Session.java
create mode 100644 taurus-permanent/src/main/java/com/taurus/permanent/data/SessionType.java
create mode 100644 taurus-permanent/src/main/java/com/taurus/permanent/io/BinaryIoHandler.java
create mode 100644 taurus-permanent/src/main/java/com/taurus/permanent/io/IOHandler.java
create mode 100644 taurus-permanent/src/main/java/com/taurus/permanent/io/PacketReadState.java
create mode 100644 taurus-permanent/src/main/java/com/taurus/permanent/io/PendingPacket.java
create mode 100644 taurus-permanent/src/main/java/com/taurus/permanent/io/ProcessedPacket.java
create mode 100644 taurus-permanent/src/main/java/com/taurus/permanent/io/ProtocolHandler.java
create mode 100644 taurus-permanent/src/main/java/com/taurus/permanent/normal/NormalSocketChannel.java
create mode 100644 taurus-permanent/src/main/java/com/taurus/permanent/normal/SocketAcceptor.java
create mode 100644 taurus-permanent/src/main/java/com/taurus/permanent/normal/SocketReader.java
create mode 100644 taurus-permanent/src/main/java/com/taurus/permanent/normal/SocketWriter.java
create mode 100644 taurus-permanent/src/main/java/com/taurus/permanent/util/GhostUserHunter.java
create mode 100644 taurus-permanent/src/main/java/com/taurus/permanent/websocket/UndertowWebSocketChannel.java
create mode 100644 taurus-permanent/src/main/java/com/taurus/permanent/websocket/WebSocketService.java
create mode 100644 taurus-permanent/src/test/java/com/taurus/T1Controller.java
create mode 100644 taurus-permanent/src/test/java/com/taurus/T2Controller.java
create mode 100644 taurus-permanent/src/test/java/com/taurus/TestExtension.java
create mode 100644 taurus-server/pom.xml
create mode 100644 taurus-server/taurus-core/config/log4j.properties
create mode 100644 taurus-server/taurus-core/config/taurus-core.xml
create mode 100644 taurus-server/taurus-core/pom.xml
create mode 100644 taurus-server/taurus-core/src/main/java/com/taurus/core/entity/ITArray.java
create mode 100644 taurus-server/taurus-core/src/main/java/com/taurus/core/entity/ITObject.java
create mode 100644 taurus-server/taurus-core/src/main/java/com/taurus/core/entity/TArray.java
create mode 100644 taurus-server/taurus-core/src/main/java/com/taurus/core/entity/TArrayLite.java
create mode 100644 taurus-server/taurus-core/src/main/java/com/taurus/core/entity/TDataSerializer.java
create mode 100644 taurus-server/taurus-core/src/main/java/com/taurus/core/entity/TDataType.java
create mode 100644 taurus-server/taurus-core/src/main/java/com/taurus/core/entity/TDataWrapper.java
create mode 100644 taurus-server/taurus-core/src/main/java/com/taurus/core/entity/TObject.java
create mode 100644 taurus-server/taurus-core/src/main/java/com/taurus/core/entity/TObjectLite.java
create mode 100644 taurus-server/taurus-core/src/main/java/com/taurus/core/events/Event.java
create mode 100644 taurus-server/taurus-core/src/main/java/com/taurus/core/events/EventDispatcher.java
create mode 100644 taurus-server/taurus-core/src/main/java/com/taurus/core/events/EventManager.java
create mode 100644 taurus-server/taurus-core/src/main/java/com/taurus/core/events/IEventDispatcher.java
create mode 100644 taurus-server/taurus-core/src/main/java/com/taurus/core/events/IEventListener.java
create mode 100644 taurus-server/taurus-core/src/main/java/com/taurus/core/plugin/IPlugin.java
create mode 100644 taurus-server/taurus-core/src/main/java/com/taurus/core/plugin/PluginService.java
create mode 100644 taurus-server/taurus-core/src/main/java/com/taurus/core/plugin/database/DataBase.java
create mode 100644 taurus-server/taurus-core/src/main/java/com/taurus/core/plugin/database/DataBasePlugin.java
create mode 100644 taurus-server/taurus-core/src/main/java/com/taurus/core/plugin/database/Db.java
create mode 100644 taurus-server/taurus-core/src/main/java/com/taurus/core/plugin/redis/Cache.java
create mode 100644 taurus-server/taurus-core/src/main/java/com/taurus/core/plugin/redis/Redis.java
create mode 100644 taurus-server/taurus-core/src/main/java/com/taurus/core/plugin/redis/RedisLock.java
create mode 100644 taurus-server/taurus-core/src/main/java/com/taurus/core/plugin/redis/RedisPlugin.java
create mode 100644 taurus-server/taurus-core/src/main/java/com/taurus/core/routes/Action.java
create mode 100644 taurus-server/taurus-core/src/main/java/com/taurus/core/routes/ActionKey.java
create mode 100644 taurus-server/taurus-core/src/main/java/com/taurus/core/routes/ActionMapping.java
create mode 100644 taurus-server/taurus-core/src/main/java/com/taurus/core/routes/Extension.java
create mode 100644 taurus-server/taurus-core/src/main/java/com/taurus/core/routes/IController.java
create mode 100644 taurus-server/taurus-core/src/main/java/com/taurus/core/routes/Interceptor.java
create mode 100644 taurus-server/taurus-core/src/main/java/com/taurus/core/routes/Routes.java
create mode 100644 taurus-server/taurus-core/src/main/java/com/taurus/core/service/AbstractService.java
create mode 100644 taurus-server/taurus-core/src/main/java/com/taurus/core/service/IService.java
create mode 100644 taurus-server/taurus-core/src/main/java/com/taurus/core/util/Base64.java
create mode 100644 taurus-server/taurus-core/src/main/java/com/taurus/core/util/ByteArray.java
create mode 100644 taurus-server/taurus-core/src/main/java/com/taurus/core/util/DateUtils.java
create mode 100644 taurus-server/taurus-core/src/main/java/com/taurus/core/util/FileUtil.java
create mode 100644 taurus-server/taurus-core/src/main/java/com/taurus/core/util/FixedIndexThreadPool.java
create mode 100644 taurus-server/taurus-core/src/main/java/com/taurus/core/util/ICallback.java
create mode 100644 taurus-server/taurus-core/src/main/java/com/taurus/core/util/Logger.java
create mode 100644 taurus-server/taurus-core/src/main/java/com/taurus/core/util/MD5.java
create mode 100644 taurus-server/taurus-core/src/main/java/com/taurus/core/util/SHA1.java
create mode 100644 taurus-server/taurus-core/src/main/java/com/taurus/core/util/StringUtil.java
create mode 100644 taurus-server/taurus-core/src/main/java/com/taurus/core/util/Utils.java
create mode 100644 taurus-server/taurus-core/src/main/java/com/taurus/core/util/json/JSONParser.java
create mode 100644 taurus-server/taurus-core/src/main/java/com/taurus/core/util/json/JSONUtils.java
create mode 100644 taurus-server/taurus-core/src/main/java/com/taurus/core/util/json/JSONWriter.java
create mode 100644 taurus-server/taurus-core/src/main/java/com/taurus/core/util/task/ITaskHandler.java
create mode 100644 taurus-server/taurus-core/src/main/java/com/taurus/core/util/task/Task.java
create mode 100644 taurus-server/taurus-core/src/main/java/com/taurus/core/util/task/TaskScheduler.java
create mode 100644 taurus-server/taurus-core/src/test/java/Test.java
create mode 100644 taurus-server/taurus-permanent/config/log4j.properties
create mode 100644 taurus-server/taurus-permanent/config/taurus-core.xml
create mode 100644 taurus-server/taurus-permanent/config/taurus-permanent.xml
create mode 100644 taurus-server/taurus-permanent/pom.xml
create mode 100644 taurus-server/taurus-permanent/src/main/java/com/taurus/permanent/Main.java
create mode 100644 taurus-server/taurus-permanent/src/main/java/com/taurus/permanent/TPServer.java
create mode 100644 taurus-server/taurus-permanent/src/main/java/com/taurus/permanent/core/BaseCoreService.java
create mode 100644 taurus-server/taurus-permanent/src/main/java/com/taurus/permanent/core/BitSwarmEngine.java
create mode 100644 taurus-server/taurus-permanent/src/main/java/com/taurus/permanent/core/ConnectionFilter.java
create mode 100644 taurus-server/taurus-permanent/src/main/java/com/taurus/permanent/core/DefaultConstants.java
create mode 100644 taurus-server/taurus-permanent/src/main/java/com/taurus/permanent/core/IConnectionFilter.java
create mode 100644 taurus-server/taurus-permanent/src/main/java/com/taurus/permanent/core/ServerConfig.java
create mode 100644 taurus-server/taurus-permanent/src/main/java/com/taurus/permanent/core/ServerState.java
create mode 100644 taurus-server/taurus-permanent/src/main/java/com/taurus/permanent/core/SessionManager.java
create mode 100644 taurus-server/taurus-permanent/src/main/java/com/taurus/permanent/core/SystemController.java
create mode 100644 taurus-server/taurus-permanent/src/main/java/com/taurus/permanent/core/TPEvents.java
create mode 100644 taurus-server/taurus-permanent/src/main/java/com/taurus/permanent/data/BindableSocket.java
create mode 100644 taurus-server/taurus-permanent/src/main/java/com/taurus/permanent/data/IPacketQueue.java
create mode 100644 taurus-server/taurus-permanent/src/main/java/com/taurus/permanent/data/ISocketChannel.java
create mode 100644 taurus-server/taurus-permanent/src/main/java/com/taurus/permanent/data/NonBlockingPacketQueue.java
create mode 100644 taurus-server/taurus-permanent/src/main/java/com/taurus/permanent/data/PackDataType.java
create mode 100644 taurus-server/taurus-permanent/src/main/java/com/taurus/permanent/data/Packet.java
create mode 100644 taurus-server/taurus-permanent/src/main/java/com/taurus/permanent/data/Session.java
create mode 100644 taurus-server/taurus-permanent/src/main/java/com/taurus/permanent/data/SessionType.java
create mode 100644 taurus-server/taurus-permanent/src/main/java/com/taurus/permanent/io/BinaryIoHandler.java
create mode 100644 taurus-server/taurus-permanent/src/main/java/com/taurus/permanent/io/IOHandler.java
create mode 100644 taurus-server/taurus-permanent/src/main/java/com/taurus/permanent/io/PacketReadState.java
create mode 100644 taurus-server/taurus-permanent/src/main/java/com/taurus/permanent/io/PendingPacket.java
create mode 100644 taurus-server/taurus-permanent/src/main/java/com/taurus/permanent/io/ProcessedPacket.java
create mode 100644 taurus-server/taurus-permanent/src/main/java/com/taurus/permanent/io/ProtocolHandler.java
create mode 100644 taurus-server/taurus-permanent/src/main/java/com/taurus/permanent/normal/NormalSocketChannel.java
create mode 100644 taurus-server/taurus-permanent/src/main/java/com/taurus/permanent/normal/SocketAcceptor.java
create mode 100644 taurus-server/taurus-permanent/src/main/java/com/taurus/permanent/normal/SocketReader.java
create mode 100644 taurus-server/taurus-permanent/src/main/java/com/taurus/permanent/normal/SocketWriter.java
create mode 100644 taurus-server/taurus-permanent/src/main/java/com/taurus/permanent/util/GhostUserHunter.java
create mode 100644 taurus-server/taurus-permanent/src/main/java/com/taurus/permanent/websocket/UndertowWebSocketChannel.java
create mode 100644 taurus-server/taurus-permanent/src/main/java/com/taurus/permanent/websocket/WebSocketService.java
create mode 100644 taurus-server/taurus-permanent/src/test/java/com/taurus/T1Controller.java
create mode 100644 taurus-server/taurus-permanent/src/test/java/com/taurus/T2Controller.java
create mode 100644 taurus-server/taurus-permanent/src/test/java/com/taurus/TestExtension.java
create mode 100644 taurus-server/taurus-web/pom.xml
create mode 100644 taurus-server/taurus-web/src/main/java/com/taurus/web/Controller.java
create mode 100644 taurus-server/taurus-web/src/main/java/com/taurus/web/JettyServer.java
create mode 100644 taurus-server/taurus-web/src/main/java/com/taurus/web/ServletHealthCheck.java
create mode 100644 taurus-server/taurus-web/src/main/java/com/taurus/web/SessionInfo.java
create mode 100644 taurus-server/taurus-web/src/main/java/com/taurus/web/StatusServlet.java
create mode 100644 taurus-server/taurus-web/src/main/java/com/taurus/web/TWebServer.java
create mode 100644 taurus-server/taurus-web/src/main/java/com/taurus/web/WebException.java
create mode 100644 taurus-server/taurus-web/src/main/java/com/taurus/web/WebFilter.java
create mode 100644 taurus-server/taurus-web/src/main/java/com/taurus/web/WebUtils.java
create mode 100644 taurus-server/taurus-web/src/test/java/com/taurus/Test.java
create mode 100644 web_group/build/local/taurus-core.xml
create mode 100644 web_group/build/pro/bank_hp.lua
create mode 100644 web_group/build/pro/log4j.properties
create mode 100644 web_group/build/pro/mgr.lua
create mode 100644 web_group/build/pro/take_hp.lua
create mode 100644 web_group/build/pro/taurus-core.xml
create mode 100644 web_group/build/pro/trade.lua
create mode 100644 web_group/build/test/bank_hp.lua
create mode 100644 web_group/build/test/log4j.properties
create mode 100644 web_group/build/test/mgr.lua
create mode 100644 web_group/build/test/take_hp.lua
create mode 100644 web_group/build/test/taurus-core.xml
create mode 100644 web_group/build/test/trade.lua
create mode 100644 web_group/pom.xml
create mode 100644 web_group/src/main/java/com/group/MainServer.java
create mode 100644 web_group/src/main/java/com/group/Protocol.java
create mode 100644 web_group/src/main/java/com/group/WebInterceptor.java
create mode 100644 web_group/src/main/java/com/group/controller/GroupController.java
create mode 100644 web_group/src/main/java/com/group/controller/GroupLogController.java
create mode 100644 web_group/src/main/java/com/group/controller/GroupRoomController.java
create mode 100644 web_group/src/main/java/com/group/job/UpdatePlayRoomJob.java
create mode 100644 web_group/src/main/java/com/group/service/GroupLogService.java
create mode 100644 web_group/src/main/java/com/group/service/GroupPublisherService.java
create mode 100644 web_group/src/main/java/com/group/service/GroupRoomService.java
create mode 100644 web_group/src/main/java/com/group/service/GroupService.java
create mode 100644 web_group/src/main/webapp/WEB-INF/web.xml
create mode 100644 web_group/src/main/webapp/config/bank_hp.lua
create mode 100644 web_group/src/main/webapp/config/log4j.properties
create mode 100644 web_group/src/main/webapp/config/mgr.lua
create mode 100644 web_group/src/main/webapp/config/take_hp.lua
create mode 100644 web_group/src/main/webapp/config/taurus-core.xml
create mode 100644 web_group/src/main/webapp/config/trade.lua
create mode 100644 web_group/src/test/java/etty-contexts.xml
create mode 100644 web_group/src/test/java/web_group/DataClearUtils.java
create mode 100644 web_group/src/test/java/web_group/MainWebGroup.java
create mode 100644 web_login/.idea/artifacts/web_login_war.xml
create mode 100644 web_login/.idea/artifacts/web_login_war_exploded.xml
create mode 100644 web_login/.idea/compiler.xml
create mode 100644 web_login/.idea/misc.xml
create mode 100644 web_login/.idea/modules.xml
create mode 100644 web_login/.idea/workspace.xml
create mode 100644 web_login/build/adduser
create mode 100644 web_login/build/local/log4j.properties
create mode 100644 web_login/build/local/taurus-core.xml
create mode 100644 web_login/build/pro/log4j.properties
create mode 100644 web_login/build/pro/taurus-core.xml
create mode 100644 web_login/build/test/log4j.properties
create mode 100644 web_login/build/test/taurus-core.xml
create mode 100644 web_login/config/log4j.properties
create mode 100644 web_login/config/taurus-core.xml
create mode 100644 web_login/god
create mode 100644 web_login/pom.xml
create mode 100644 web_login/src/main/java/com/mjlogin/MainServer.java
create mode 100644 web_login/src/main/java/com/mjlogin/Protocol.java
create mode 100644 web_login/src/main/java/com/mjlogin/WebInterceptor.java
create mode 100644 web_login/src/main/java/com/mjlogin/service/AccountService.java
create mode 100644 web_login/src/main/java/com/mjlogin/service/IndexService.java
create mode 100644 web_login/src/main/java/com/mjlogin/service/MilitaryService.java
create mode 100644 web_login/src/main/java/com/mjlogin/service/RoomService.java
create mode 100644 web_login/src/main/java/com/mjlogin/util/sms/RedisKey.java
create mode 100644 web_login/src/main/java/com/mjlogin/util/sms/SMSThread.java
create mode 100644 web_login/src/main/java/com/mjlogin/util/sms/SMSVerification.java
create mode 100644 web_login/src/main/webapp/WEB-INF/web.xml
create mode 100644 web_login/src/main/webapp/config/log4j.properties
create mode 100644 web_login/src/main/webapp/config/taurus-core.xml
create mode 100644 web_login/src/test/java/web_login/MainWebLogin.java
diff --git a/data_cache/config/log4j.properties b/data_cache/config/log4j.properties
new file mode 100644
index 0000000..60b65bc
--- /dev/null
+++ b/data_cache/config/log4j.properties
@@ -0,0 +1,20 @@
+
+log4j.rootLogger = INFO,consoleAppender,fileAppender
+
+# ConsoleAppender
+log4j.appender.consoleAppender=org.apache.log4j.ConsoleAppender
+log4j.appender.consoleAppender.layout=org.apache.log4j.PatternLayout
+log4j.appender.consoleAppender.layout.ConversionPattern=%d{HH:mm:ss,SSS} %-5p [%t] %c{2} %3x - %m%n
+
+
+# Regular FileAppender
+log4j.appender.fileAppender=org.apache.log4j.DailyRollingFileAppender
+log4j.appender.fileAppender.layout=org.apache.log4j.PatternLayout
+log4j.appender.fileAppender.File=${WORKDIR}/logs/evt_mgr.log
+log4j.appender.fileAppender.layout.ConversionPattern=%d{dd MMM yyyy | HH:mm:ss,SSS} | %-5p | %t | %c{3} | %3x | %m%n
+log4j.appender.fileAppender.Encoding=UTF-8
+log4j.appender.fileAppender.DatePattern='.'yyyy-MM-dd
+log4j.appender.dailyFile.Append=true
+
+# The file is rolled over very day
+log4j.appender.fileAppender.DatePattern ='.'yyyy-MM-dd
\ No newline at end of file
diff --git a/data_cache/config/mpnet-tools.xml b/data_cache/config/mpnet-tools.xml
new file mode 100644
index 0000000..0fc606d
--- /dev/null
+++ b/data_cache/config/mpnet-tools.xml
@@ -0,0 +1,93 @@
+
+
+
+
+
+ 80
+
+ 2
+
+ 10
+
+ -1
+
+ true
+
+ true
+
+ true
+
+ select 1
+
+ 180000
+
+ 60000
+
+ 30000
+
+ false
+
+ 300000
+
+ false
+
+ -1
+
+
+
+
+ db1
+ com.mysql.jdbc.Driver
+ jdbc:mysql://127.0.0.1:8060/wb_game
+ root
+ root
+
+
+
+
+
+
+
+ 80
+
+ 8
+
+ 2
+
+ -1
+
+ true
+
+ true
+
+ true
+
+ 100
+
+ 60000
+
+ 30000
+
+ 1800000
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/data_cache/pom.xml b/data_cache/pom.xml
new file mode 100644
index 0000000..33adc3c
--- /dev/null
+++ b/data_cache/pom.xml
@@ -0,0 +1,63 @@
+
+ 4.0.0
+
+ com.data
+ data_cache
+ 1.0.1
+ jar
+
+
+ UTF-8
+ 1.8
+ 1.8
+
+
+
+
+ junit
+ junit
+ 3.8.1
+ test
+
+
+
+
+ com.taurus
+ taurus-core
+ 1.0.1
+
+
+
+
+ redis.clients
+ jedis
+ 2.9.0
+
+
+
+
+ log4j
+ log4j
+ 1.2.17
+
+
+
+
+ data_cache
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.6.1
+
+ 1.8
+ 1.8
+ UTF-8
+
+
+
+
+
+
diff --git a/data_cache/src/main/java/com/data/bean/AccountBean.java b/data_cache/src/main/java/com/data/bean/AccountBean.java
new file mode 100644
index 0000000..5976064
--- /dev/null
+++ b/data_cache/src/main/java/com/data/bean/AccountBean.java
@@ -0,0 +1,37 @@
+package com.data.bean;
+
+import java.util.Map;
+
+import com.taurus.core.util.StringUtil;
+
+
+/**
+ * account bean class
+ *
+ */
+public class AccountBean extends BaseBean{
+
+ public String nick;
+ public String portrait;
+ public int type;
+ public int mng;
+ public int sex;
+ public String ip;
+
+ public void fillData(Map redis_map) {
+ String _id = redis_map.get("id");
+ if(StringUtil.isEmpty(_id)) {
+ this.del = true;
+ return;
+ }
+ this.id =Integer.parseInt(_id);
+ this.nick = redis_map.get("nick");
+ this.portrait = redis_map.get("portrait");
+ this.ip = redis_map.get("ip");
+ this.type = Integer.parseInt(redis_map.get("type"));
+ this.sex = Integer.parseInt(redis_map.get("sex"));
+ if(this.sex == 0)this.sex = 1;
+ }
+
+
+}
diff --git a/data_cache/src/main/java/com/data/bean/BaseBean.java b/data_cache/src/main/java/com/data/bean/BaseBean.java
new file mode 100644
index 0000000..f36ec34
--- /dev/null
+++ b/data_cache/src/main/java/com/data/bean/BaseBean.java
@@ -0,0 +1,34 @@
+package com.data.bean;
+
+import java.util.Map;
+
+/**
+ * base bean class.
+ */
+public class BaseBean {
+ /**
+ * id
+ */
+ public int id;
+ /**
+ * redis key
+ */
+ public String redis_key;
+ /**
+ * cache version.
+ */
+ public volatile long cache_ver;
+
+ /**
+ * cache last time.
+ */
+ public volatile long cache_time;
+ /**
+ * 标记是否删除
+ */
+ public volatile boolean del;
+
+ public void fillData(Map map) {
+
+ }
+}
diff --git a/data_cache/src/main/java/com/data/bean/GameBean.java b/data_cache/src/main/java/com/data/bean/GameBean.java
new file mode 100644
index 0000000..cef648f
--- /dev/null
+++ b/data_cache/src/main/java/com/data/bean/GameBean.java
@@ -0,0 +1,105 @@
+package com.data.bean;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import com.taurus.core.entity.ITObject;
+import com.taurus.core.entity.TObject;
+import com.taurus.core.plugin.redis.Redis;
+
+
+
+/**
+ * game bean class.
+ *
+ */
+public class GameBean extends BaseBean{
+
+ /**
+ * name
+ */
+ public String name;
+ /**
+ * 最大人数
+ */
+ public int maxPlayers;
+ /**
+ * 体力值类型
+ */
+ public int hpType;
+ /**
+ * 包名
+ */
+ public String bundle;
+ /**
+ * 局数设置
+ */
+ public Map opt;
+ /**
+ * 版本
+ */
+ public String version;
+
+ public int gameType;
+
+ /**
+ * 服务器列表
+ */
+ public Set svr_list;
+ /**
+ * 支付设置
+ */
+ public Map pay;
+ /**不可负分*/
+ public int isNonnegative ;
+
+
+
+ public void fillData(Map redis_map) {
+// Map redis_map = jedis.hgetAll(redis_key);
+ if(redis_map.isEmpty()) {
+ this.del = true;
+ return;
+ }
+ this.id = Integer.parseInt(redis_map.get("id"));
+ this.name = redis_map.get("name");
+ this.bundle = redis_map.get("bundle");
+ this.maxPlayers =Integer.parseInt(redis_map.get("maxPlayers"));
+ this.hpType =Integer.parseInt(redis_map.get("hpType"));
+ this.opt = new HashMap<>();
+ for(int i=1;i<=5;++i) {
+ String key = "opt"+i;
+ this.opt.put(i, Integer.parseInt(redis_map.get(key)));
+ }
+ this.version = redis_map.get("version");
+ this.gameType =Integer.parseInt( redis_map.get("gameType"));
+ this.isNonnegative = Integer.parseInt(redis_map.get("isNonnegative"));
+ this.svr_list = Redis.use("group1_db1").smembers("game_svr:" + id);
+
+ this.pay = new HashMap<>();
+ for (Entry entry : redis_map.entrySet()) {
+ String key = entry.getKey();
+ if(key.startsWith("pay")) {
+ this.pay.put(key, Integer.parseInt(entry.getValue()));
+ }
+ }
+ }
+
+ public ITObject getTObject() {
+ ITObject obj = TObject.newInstance();
+ obj.putInt("game_id", id);
+ obj.putString("name", name);
+ obj.putString("bundle", bundle);
+ obj.putInt("hpType", hpType);
+ obj.putString("version", version);
+ obj.putInt("gameType", gameType);
+ obj.putInt("isNonnegative", isNonnegative);
+ return obj;
+ }
+
+ public static String genKey(int gid) {
+ return "game:" + gid;
+ }
+}
diff --git a/data_cache/src/main/java/com/data/bean/GroupBean.java b/data_cache/src/main/java/com/data/bean/GroupBean.java
new file mode 100644
index 0000000..3918807
--- /dev/null
+++ b/data_cache/src/main/java/com/data/bean/GroupBean.java
@@ -0,0 +1,113 @@
+package com.data.bean;
+
+import java.util.Map;
+
+import com.data.cache.GroupMemberCache;
+import com.data.cache.GroupPlayCache;
+import com.taurus.core.util.Logger;
+
+public class GroupBean extends BaseBean {
+
+ private final static Logger log;
+
+ static {
+ log = Logger.getLogger(GroupBean.class);
+ }
+ /**
+ * name
+ */
+ public String name;
+ public int owner;
+ public int type;
+ public int create_time;
+ public int ban;
+ public int gms;
+ public int pay_type;
+ public int stop;
+ public int ban_apply;
+ public int dissolve_opt;
+ public int kick_opt;
+ public boolean ban_chat1;
+ public boolean ban_chat2;
+ public int exit_opt;
+ public int option;
+ public int show_num;
+ public GroupMemberCache memberCache;
+
+ public GroupPlayCache playCache;
+ public int isShow;
+ public int isOpenChatRoom;
+ public int isShowBeginRoom = 0;
+
+ // 微信号
+ public String wechatId;
+
+ public int isWatch;
+
+ public void fillData(Map map) {
+ if (map.isEmpty()) {
+ this.del = true;
+ return;
+ }
+ int opt = Integer.parseInt(map.get("opt"));
+ if (opt != 1) {
+ this.del = true;
+ return;
+ }
+ this.id = Integer.parseInt(map.get("id"));
+ this.name = map.get("name");
+ this.type = Integer.parseInt(map.get("type"));
+ this.create_time = Integer.parseInt(map.get("create_time"));
+ this.ban = Integer.parseInt(map.get("ban"));
+ this.gms = Integer.parseInt(map.get("gms"));
+ this.owner = Integer.parseInt(map.get("owner"));
+ this.pay_type = Integer.parseInt(map.get("pay_type"));
+ this.wechatId = map.get("wechatId");
+// this.messageCount =map.get("messageCount");
+ if (map.containsKey("wechatId")) {
+ this.wechatId = map.get("wechatId");
+ }
+
+ if (map.containsKey("isOpenChatRoom")) {
+ this.isOpenChatRoom = Integer.parseInt(map.get("isOpenChatRoom"));
+ }
+ if (map.containsKey("isShowBeginRoom")) {
+ this.isShowBeginRoom = Integer.parseInt(map.get("isShowBeginRoom"));
+ }
+
+ if (map.containsKey("isWatch")) {
+ this.isWatch = Integer.parseInt(map.get("isWatch"));
+ }
+
+ if (map.containsKey("isShow")) {
+ this.isShow = Integer.parseInt(map.get("isShow"));
+ }
+
+ if (map.containsKey("stop")) {
+ this.stop = Integer.parseInt(map.get("stop"));
+ }
+ if (map.containsKey("ban_apply")) {
+ this.ban_apply = Integer.parseInt(map.get("ban_apply"));
+ }
+ kick_opt = Integer.parseInt(map.get("kick_opt"));
+ dissolve_opt = Integer.parseInt(map.get("dissolve_opt"));
+ if (map.containsKey("ban_chat1")) {
+ this.ban_chat1 = Boolean.parseBoolean(map.get("ban_chat1"));
+ }
+ if (map.containsKey("ban_chat2")) {
+ this.ban_chat2 = Boolean.parseBoolean(map.get("ban_chat2"));
+ }
+ if (map.containsKey("exit_opt")) {
+ this.exit_opt = Integer.parseInt(map.get("exit_opt"));
+ }
+
+ if (map.containsKey("option")) {
+ this.option = Integer.parseInt(map.get("option"));
+ }
+
+ if (map.containsKey("show_num")) {
+ this.show_num = Integer.parseInt(map.get("show_num"));
+ }
+
+ }
+}
diff --git a/data_cache/src/main/java/com/data/bean/GroupMemberBean.java b/data_cache/src/main/java/com/data/bean/GroupMemberBean.java
new file mode 100644
index 0000000..5755a5a
--- /dev/null
+++ b/data_cache/src/main/java/com/data/bean/GroupMemberBean.java
@@ -0,0 +1,50 @@
+package com.data.bean;
+
+import java.util.Map;
+
+public class GroupMemberBean extends BaseBean{
+ public int groupId;
+ public int parentId;
+ public int partnerLev;
+ public int lev;
+ public int ban;
+ public int top_time;
+ public int join_time;
+ public int last_time;
+ public int permission;
+ public int score;
+ public int mj_score;
+ public int pk_score;
+ public GroupMemberBean(int gid) {
+ this.groupId = gid;
+ }
+
+ public void fillData(Map map) {
+ if(map.isEmpty()) {
+ this.del = true;
+ return;
+ }
+ int opt = Integer.parseInt(map.get("opt"));
+ if(opt!=1) {
+ this.del = true;
+ return;
+ }
+ this.id = Integer.parseInt(map.get("uid"));
+ this.parentId = Integer.parseInt(map.get("parentId"));
+ this.partnerLev = Integer.parseInt(map.get("partnerLev"));
+ this.lev = Integer.parseInt(map.get("lev"));
+ this.ban = Integer.parseInt(map.get("ban"));
+ this.top_time = Integer.parseInt(map.get("top_time"));
+ this.join_time = Integer.parseInt(map.get("join_time"));
+ if(map.containsKey("last_time")) {
+ this.last_time = Integer.parseInt(map.get("last_time"));
+ }
+ if(map.containsKey("permission")) {
+ this.permission = Integer.parseInt(map.get("permission"));
+ }
+ if(map.containsKey("score")) {
+ this.score = Integer.parseInt(map.get("score"));
+ }
+
+ }
+}
diff --git a/data_cache/src/main/java/com/data/bean/GroupPlayBean.java b/data_cache/src/main/java/com/data/bean/GroupPlayBean.java
new file mode 100644
index 0000000..c7a5d9e
--- /dev/null
+++ b/data_cache/src/main/java/com/data/bean/GroupPlayBean.java
@@ -0,0 +1,141 @@
+package com.data.bean;
+
+import java.util.Map;
+
+import com.data.cache.GameCache;
+import com.taurus.core.entity.ITObject;
+import com.taurus.core.entity.TObject;
+
+public class GroupPlayBean extends BaseBean {
+ public ITObject data = null;
+ public ITObject simp_data = null;
+ public int pay_type;
+ public int gameType;
+ public int gameId;
+ public int maxPlayers;
+ public String config;
+ public String hpConfig;
+ public int hp_times;
+ public int hpOnOff;
+ public int ban;
+ public boolean mark;
+ public String name;
+ public int deskId;
+ public int reward;
+ public int xipai_reward;
+ public int rewardType;
+ public int rewardValueType;
+ public int xipai_rewardType;
+ public int xipai_rewardValueType;
+ public int robot_room;
+ public ITObject configData;
+
+ public int BanChat;
+ public int BanMissile;
+
+
+
+
+
+ public void fillData(Map map) {
+ if(!map.get("opt").equals("1")) {
+ this.del = true;
+ return;
+ }
+ ITObject obj = data;
+ if(obj==null) {
+ obj = TObject.newInstance();
+ this.data = obj;
+ }
+ this.id = Integer.parseInt(map.get("id"));
+ this.name = map.get("name");
+ this.gameId = Integer.parseInt(map.get("gameId"));
+ this.config = map.get("config");
+ this.hpConfig = map.get("hpData");
+ this.hpOnOff = Integer.parseInt(map.get("hpOnOff"));
+ this.hp_times = Integer.parseInt(map.get("hp_times"));
+ this.ban = map.containsKey("ban") ? Integer.parseInt(map.get("ban")) : 0;
+
+
+
+ int iMark = map.containsKey("mark") ? Integer.parseInt(map.get("mark")) : 0;
+ this.mark = iMark==1 ? true : false;
+
+ this.reward = Integer.parseInt(map.get("reward"));
+ this.xipai_reward = 100000000;
+ if(map.get("xipai_reward") != null) {
+ this.xipai_reward = Integer.parseInt(map.get("xipai_reward"));
+ }
+ this.rewardType = Integer.parseInt(map.get("rewardType"));
+ this.rewardValueType = 1;
+ if(map.get("rewardValueType") != null) {
+ this.rewardValueType = Integer.parseInt(map.get("rewardValueType"));
+ }
+
+ this.xipai_rewardType = 1;
+ if(map.get("xipai_rewardType") != null) {
+ this.xipai_rewardType = Integer.parseInt(map.get("xipai_rewardType"));
+ }
+
+ this.xipai_rewardValueType = 1;
+ if(map.get("xipai_rewardValueType") != null) {
+ this.xipai_rewardValueType = Integer.parseInt(map.get("xipai_rewardValueType"));
+ }
+
+ this.robot_room = 0;
+ if(map.get("robot_room") != null) {
+ this.robot_room = Integer.parseInt(map.get("robot_room"));
+ }
+ if(map.get("deskId") != null) {
+ this.deskId = Integer.parseInt(map.get("deskId"));
+ }
+
+ if (map.get("BanMissile") != null){
+ this.BanMissile = Integer.parseInt(map.get("BanMissile"));
+ }
+
+ if (map.get("BanChat") != null){
+ this.BanChat = Integer.parseInt(map.get("BanChat"));
+ }
+
+ obj.putInt("id", this.id);
+ obj.putString("name", this.name);
+ obj.putInt("gameId", gameId);
+ obj.putInt("deskId", this.deskId);
+ obj.putString("config", config);
+ obj.putString("hpData", hpConfig);
+ obj.putInt("hp_times", hp_times);
+ obj.putInt("hpOnOff", hpOnOff);
+ obj.putInt("reward", reward);
+ obj.putInt("xipai_reward", xipai_reward);
+ obj.putInt("rewardType", rewardType);
+ obj.putInt("rewardValueType", rewardValueType);
+ obj.putInt("xipai_rewardType", xipai_rewardType);
+ obj.putInt("xipai_rewardValueType", xipai_rewardValueType);
+ obj.putInt("ban", ban);
+ obj.putBoolean("mark", mark);
+
+ GameBean gb = GameCache.getGame(gameId);
+ obj.putString("game_name", gb.name);
+
+
+
+ configData = TObject.newFromJsonData(map.get("config"));
+ maxPlayers = gb.maxPlayers;
+ if(configData.containsKey("maxPlayers")) {
+ maxPlayers = configData.getInt("maxPlayers");
+ }
+ obj.putInt("maxPlayers", maxPlayers);
+
+ if(simp_data==null) {
+ simp_data = TObject.newInstance();
+ }
+
+ simp_data.putInt("gameId", gameId);
+ simp_data.putInt("id", this.id);
+ simp_data.putInt("hpOnOff", obj.getInt("hpOnOff"));
+ simp_data.putInt("maxPlayers", maxPlayers);
+ simp_data.putString("name", obj.getString("name"));
+ simp_data.putInt("deskId", this.deskId);
+ }
+}
diff --git a/data_cache/src/main/java/com/data/cache/AccountCache.java b/data_cache/src/main/java/com/data/cache/AccountCache.java
new file mode 100644
index 0000000..d6b7ca0
--- /dev/null
+++ b/data_cache/src/main/java/com/data/cache/AccountCache.java
@@ -0,0 +1,43 @@
+package com.data.cache;
+
+import com.data.bean.AccountBean;
+import com.data.bean.BaseBean;
+
+/**
+ * account cache class.
+ */
+public class AccountCache extends BaseCache{
+
+ protected AccountCache() {
+ super("{user}:","group1_db0");
+ }
+
+
+ static AccountCache inst;
+
+
+ public static AccountBean getAccount(int id) {
+ if(inst==null)inst = new AccountCache();
+ return inst.getBean(id);
+ }
+
+ public static AccountBean getAccount(String session) {
+ if(inst==null)inst = new AccountCache();
+ return inst.getBean(session);
+ }
+
+
+ @Override
+ protected BaseBean newBean() {
+ return new AccountBean();
+ }
+
+ public static void clearData() {
+ if(inst==null)inst = new AccountCache();
+ inst.clearExpireData();
+ }
+
+ public static String genKey(int gid) {
+ return "{user}:" + gid;
+ }
+}
diff --git a/data_cache/src/main/java/com/data/cache/BaseCache.java b/data_cache/src/main/java/com/data/cache/BaseCache.java
new file mode 100644
index 0000000..0cb1ffc
--- /dev/null
+++ b/data_cache/src/main/java/com/data/cache/BaseCache.java
@@ -0,0 +1,229 @@
+package com.data.cache;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+import com.data.bean.BaseBean;
+import com.data.bean.GroupBean;
+import com.taurus.core.plugin.redis.Redis;
+import com.taurus.core.util.Logger;
+import com.taurus.core.util.StringUtil;
+
+import redis.clients.jedis.Jedis;
+
+/**
+ * base cache class.
+ *
+ */
+public abstract class BaseCache {
+ private final static Logger log;
+
+ static {
+ log = Logger.getLogger(BaseCache.class);
+ }
+ private static final String VER_KEY= "cache_ver";
+ private static final String MAIN_KEY= "id";
+ protected ConcurrentMap mapByKey = new ConcurrentHashMap<>();
+ protected ConcurrentMap mapById = new ConcurrentHashMap<>();
+ protected String key;
+ protected String cacheKey;
+ protected int fillSize;
+ /**默认1秒*/
+ protected int readTime = 1000;
+
+ protected BaseCache(String key,String cacheKey) {
+ this.key = key;
+ this.cacheKey = cacheKey;
+ }
+
+ private long readVersion(String str_ver) {
+ if(StringUtil.isEmpty(str_ver)) {
+ return -1;
+ }
+ int cache_ver = Integer.parseInt(str_ver);
+ return cache_ver;
+ }
+
+ /**
+ * 版本KEY更新
+ * @param jedis
+ * @param key
+ */
+ public static void updateCacheVer(Jedis jedis,String key) {
+ jedis.hincrBy(key, VER_KEY, 1);
+ }
+
+ /**
+ * new bean class
+ * @return
+ */
+ protected abstract BaseBean newBean();
+
+ /**
+ * 主键KEY
+ * @return
+ */
+ protected String mainKey() {
+ return MAIN_KEY;
+ }
+
+ protected BaseBean fillBean(BaseBean bean){
+ Jedis jedis = Redis.use(cacheKey).getJedis();
+ try {
+ String str_ver = null;
+ long cache_ver = -1;
+ if(System.currentTimeMillis() - bean.cache_time >= readTime) {
+ List list = jedis.hmget(bean.redis_key, mainKey(),VER_KEY);
+ if(StringUtil.isEmpty(list.get(0))) {
+ bean.del = true;
+ }else {
+ str_ver = list.get(1);
+ cache_ver = readVersion(str_ver);
+ if(bean.cache_ver > 0 && cache_ver==-1) {
+ cache_ver = bean.cache_ver;
+ }
+
+ bean.cache_time = System.currentTimeMillis();
+ }
+ }else {
+ cache_ver = bean.cache_ver;
+ }
+
+ if(!bean.del && (cache_ver == -1 || bean.cache_ver < cache_ver)) {
+ Map map = jedis.hgetAll(bean.redis_key);
+ try {
+ if(map==null || map.size() == 0){
+ bean.del = true;
+ }else {
+ bean.fillData(map);
+ }
+ }catch (Exception e) {
+ throw new RuntimeException(bean.redis_key, e);
+ }
+
+ if(!bean.del) {
+ mapById.put(bean.id, bean);
+ mapByKey.put(bean.redis_key, bean);
+ bean.del = false;
+ str_ver = map.get(VER_KEY);
+ cache_ver = readVersion(str_ver);
+ bean.cache_ver = bean.cache_ver > cache_ver ? bean.cache_ver : cache_ver;
+ }
+ }
+
+ if(bean.del) {
+ mapById.remove(bean.id);
+ mapByKey.remove(bean.redis_key);
+ return null;
+ }
+
+ }finally {
+ jedis.close();
+ }
+ return bean;
+ }
+
+ private String genKey(int id) {
+ String s_id = fillSize>0?(String.format("%0"+fillSize+"d", id)):(id+StringUtil.Empty);
+ String key = this.key + s_id;
+ return key;
+ }
+
+ /**
+ * get bean by id
+ * @param id
+ * @return
+ */
+ @SuppressWarnings("unchecked")
+ public T getBean(int id){
+ String key = genKey(id);
+ synchronized (key) {
+ BaseBean bean = mapById.get(id);
+ if(bean==null) {
+ bean = newBean();
+ bean.id = id;
+ bean.redis_key = key;
+ }else {
+ if(bean.del) {
+ return null;
+ }
+ }
+ return (T) fillBean(bean);
+ }
+ }
+
+ /**
+ * get bean by key
+ * @param key
+ * @return
+ */
+ @SuppressWarnings("unchecked")
+ public T getBean(String key){
+ synchronized (key) {
+ BaseBean bean = mapByKey.get(key);
+ if(bean==null) {
+ bean = newBean();
+ bean.redis_key = key;
+ }else {
+ if(bean.del) {
+ return null;
+ }
+ }
+ return (T) fillBean(bean);
+ }
+ }
+
+ /**
+ * delete bean by id
+ * @param id
+ * @return
+ */
+ public boolean delBean(int id) {
+ BaseBean bean = mapById.get(id);
+ if(bean!=null) {
+ bean.del = true;
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * delete bean by key
+ * @param key
+ * @return
+ */
+ public boolean delBean(String key) {
+ BaseBean bean = mapByKey.get(key);
+ if(bean!=null) {
+ bean.del = true;
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * clear expire data
+ */
+ public synchronized void clearExpireData() {
+ List list = new ArrayList<>(mapById.values());
+ for(BaseBean bean : list) {
+ if(bean.del || System.currentTimeMillis() - bean.cache_time > 180000) {
+ bean.del = true;
+ mapById.remove(bean.id);
+ mapByKey.remove(bean.redis_key);
+ }
+ }
+ }
+
+ /**
+ * clear all
+ */
+ public synchronized void clear() {
+ this.mapById.clear();
+ this.mapByKey.clear();
+ }
+
+}
diff --git a/data_cache/src/main/java/com/data/cache/GameCache.java b/data_cache/src/main/java/com/data/cache/GameCache.java
new file mode 100644
index 0000000..ba49b37
--- /dev/null
+++ b/data_cache/src/main/java/com/data/cache/GameCache.java
@@ -0,0 +1,44 @@
+package com.data.cache;
+
+import com.data.bean.BaseBean;
+import com.data.bean.GameBean;
+
+/**
+ * game cache class.
+ */
+public class GameCache extends BaseCache{
+
+ protected GameCache() {
+ super("game:","group1_db1");
+ }
+
+ static GameCache inst;
+
+ public static GameBean getGame(int id) {
+ if(inst==null) {
+ inst = new GameCache();
+ }
+ return inst.getBean(id);
+ }
+
+ public static GameBean getGame(String key) {
+ if(inst==null) {
+ inst = new GameCache();
+ }
+ return inst.getBean(key);
+ }
+
+ @Override
+ protected BaseBean newBean() {
+ return new GameBean();
+ }
+
+ public static void clearData() {
+ if(inst==null)inst = new GameCache();
+ inst.clearExpireData();
+ }
+
+ public static String genKey(int gid) {
+ return "game_" + gid;
+ }
+}
diff --git a/data_cache/src/main/java/com/data/cache/GroupCache.java b/data_cache/src/main/java/com/data/cache/GroupCache.java
new file mode 100644
index 0000000..af8527b
--- /dev/null
+++ b/data_cache/src/main/java/com/data/cache/GroupCache.java
@@ -0,0 +1,125 @@
+package com.data.cache;
+
+import com.data.bean.BaseBean;
+import com.data.bean.GroupBean;
+import com.data.bean.GroupMemberBean;
+import com.data.bean.GroupPlayBean;
+
+public class GroupCache extends BaseCache{
+ static GroupCache inst;
+
+ protected GroupCache() {
+ super("group:", "group1_db11");
+ this.readTime = 0;
+ }
+
+ @Override
+ protected BaseBean newBean() {
+ return new GroupBean();
+ }
+
+ private static GroupCache me() {
+ if (inst == null) {
+ inst = new GroupCache();
+ }
+ return inst;
+ }
+
+ public static void clearData() {
+ me().clearExpireData();
+ }
+
+ public static GroupBean getGroup(int id) {
+ return me().getBean(id);
+ }
+
+ public static GroupBean getGroup(String key) {
+ return me().getBean(key);
+ }
+
+ public static GroupMemberBean getMember(int gid, int uid) {
+ GroupBean gb = getGroup(gid);
+ if (gb != null) {
+ synchronized (gb) {
+ if (gb.memberCache == null) {
+ gb.memberCache = new GroupMemberCache(gid);
+ }
+ }
+ return gb.memberCache.getBean(uid);
+ }
+ return null;
+ }
+
+ public static GroupPlayBean getPlay(int gid, int pid) {
+ GroupBean gb = getGroup(gid);
+ if (gb != null) {
+ synchronized (gb) {
+ if (gb.playCache == null) {
+ gb.playCache = new GroupPlayCache(gid,gb.pay_type);
+ }
+ }
+ return gb.playCache.getBean(pid);
+ }
+ return null;
+ }
+
+ public static String genGroupsKey(int uid) {
+ return "groups:" + uid;
+ }
+
+ public static String genKey(int gid) {
+ return "group:" + gid;
+ }
+
+ public static String genRewardKey(int gid,int pid) {
+ return "g{" + gid+"}:reward:"+pid;
+ }
+
+ public static String genXiPaiRewardKey(int gid,int pid) {
+ return "g{" + gid+"}:xipai_reward:"+pid;
+ }
+
+ public static String genRoomsKey(int gid) {
+ return "g{" + gid+"}:rooms";
+ }
+
+ public static String genPidsKey(int gid) {
+ return "g{" + gid + "}:pids";
+ }
+
+ public static String genPlayKey(int gid,int pid) {
+ return "g{" + gid + "}:play:" + pid;
+ }
+
+ public static String genBanKey(int gid,int uid) {
+ return "g{" + gid+"}:ban:"+uid;
+ }
+
+ public static String genMemberListKey(int gid,int uid) {
+ return "g{"+gid+"}:member_list:"+uid;
+ }
+
+ public static String genParListKey(int gid,int uid) {
+ return "g{"+gid+"}:par_list:"+uid;
+ }
+
+ public static String genJoinsKey(int gid) {
+ return "gmjs_"+gid;
+ }
+
+ public static String genRemarkKey(int gid) {
+ return "g{"+gid+"}:gremark";
+ }
+
+ public static String genReadStatusKey(int gid) {
+ return "g{"+gid+"}:greadStatus";
+ }
+
+ public static String genMailKey(int gid,int uid) {
+ return "g{"+gid+"}:mail:"+uid;
+ }
+
+ public static String genMailTipKey(int gid) {
+ return "g{"+gid+"}:mail_tip";
+ }
+}
diff --git a/data_cache/src/main/java/com/data/cache/GroupMemberCache.java b/data_cache/src/main/java/com/data/cache/GroupMemberCache.java
new file mode 100644
index 0000000..3a42942
--- /dev/null
+++ b/data_cache/src/main/java/com/data/cache/GroupMemberCache.java
@@ -0,0 +1,32 @@
+package com.data.cache;
+
+import com.data.bean.BaseBean;
+import com.data.bean.GroupMemberBean;
+
+public class GroupMemberCache extends BaseCache{
+ private static final String MAIN_KEY= "join_time";
+ private int groupId;
+
+ public GroupMemberCache(int gid) {
+ super("g{"+gid+"}:m", "group1_db10");
+ this.groupId = gid;
+ this.readTime = 0;
+ }
+
+ @Override
+ protected BaseBean newBean() {
+ return new GroupMemberBean(groupId);
+ }
+
+ /**
+ * 主键KEY
+ * @return
+ */
+ protected String mainKey() {
+ return MAIN_KEY;
+ }
+
+ public static String genKey(int gid, int uid) {
+ return String.format("g{%s}:m%s", gid, uid);
+ }
+}
diff --git a/data_cache/src/main/java/com/data/cache/GroupPlayCache.java b/data_cache/src/main/java/com/data/cache/GroupPlayCache.java
new file mode 100644
index 0000000..4c4d54e
--- /dev/null
+++ b/data_cache/src/main/java/com/data/cache/GroupPlayCache.java
@@ -0,0 +1,106 @@
+package com.data.cache;
+
+import java.util.Map.Entry;
+import java.util.Set;
+
+import com.data.bean.BaseBean;
+import com.data.bean.GroupPlayBean;
+import com.taurus.core.entity.ITArray;
+import com.taurus.core.entity.TArray;
+import com.taurus.core.plugin.redis.Redis;
+
+import redis.clients.jedis.Jedis;
+
+public class GroupPlayCache extends BaseCache{
+ private ITArray playList;
+ private ITArray simpPlayList;
+ private int groupId;
+ private long last_time;
+ private int pay_type;
+ private int gameType;
+
+ public GroupPlayCache(int groupId,int pay_type) {
+ super("g{"+groupId+"}:play:","group1_db11");
+ this.groupId = groupId;
+ this.pay_type = pay_type;
+ playList = TArray.newInstance();
+ simpPlayList = TArray.newInstance();
+ }
+
+ @Override
+ protected BaseBean newBean() {
+ GroupPlayBean p = new GroupPlayBean();
+ p.pay_type = pay_type;
+ return p;
+ }
+
+ /**
+ * update play data.
+ * @param play_data
+ */
+ public void updatePlay() {
+ playList.clear();
+ simpPlayList.clear();
+ Set> set = this.mapById.entrySet();
+ for(Entry entry : set) {
+ GroupPlayBean gp =(GroupPlayBean)entry.getValue();
+ if(!gp.del) {
+ playList.addTObject(gp.data);
+ simpPlayList.addTObject(gp.simp_data);
+ }else {
+ this.mapById.remove(gp.id);
+ this.mapByKey.remove(gp.redis_key);
+ }
+ }
+
+ }
+
+ /**
+ * 获取玩法列表
+ * @return
+ */
+ public final ITArray getPlayList(int lev){
+ /*if(System.currentTimeMillis() - last_time < 180000) {
+ if(lev < 3) {
+ return playList;
+ }else {
+ return simpPlayList;
+ }
+ }*/
+
+ last_time = System.currentTimeMillis();
+ playList.clear();
+ simpPlayList.clear();
+ Jedis jedis11 = Redis.use("group1_db11").getJedis();
+ Jedis jedis1 = Redis.use("group1_db1").getJedis();
+ try {
+ String gpids_key = GroupCache.genPidsKey(groupId);
+ Set pids = jedis11.zrangeByScore(gpids_key, 10, 11);
+ String key = "g{"+this.groupId + "}:play:";
+ for(String tem : pids) {
+ String gp_key = key+tem;
+ GroupPlayBean gp = this.getBean(gp_key);
+ if(gp!=null) {
+ String gkey = "game:"+gp.gameId ;
+ int gameType = Integer.parseInt(jedis1.hget(gkey,"gameType"));
+ //gp.gameType = gameType;
+ gp.data.putInt("gameType",gameType);
+ playList.addTObject(gp.data);
+ simpPlayList.addTObject(gp.simp_data);
+ }
+ }
+ }finally {
+ jedis11.close();
+ jedis1.close();
+ }
+
+
+// if(lev < 3) {
+// return playList;
+// }else {
+// return simpPlayList;
+// }
+
+ return playList;
+ }
+}
diff --git a/data_cache/src/main/java/com/data/util/ConsumeCode.java b/data_cache/src/main/java/com/data/util/ConsumeCode.java
new file mode 100644
index 0000000..a466b81
--- /dev/null
+++ b/data_cache/src/main/java/com/data/util/ConsumeCode.java
@@ -0,0 +1,51 @@
+package com.data.util;
+
+public class ConsumeCode {
+
+ /** 普通创建房间 **/
+ public final static int DIAMO_CREAT_ROOM = 1;
+ /** AA加入房 **/
+ public final static int DIAMO_JOIN_ROOM = 4;
+ /** 反还**/
+ public final static int DIAMO_REFUND = 5;
+ /** 代开房 **/
+ public final static int DIAMO_AGENT_ROOM = 2;
+ /** 结算 **/
+ public final static int HP_CLEARING = 6;
+ /** 抽水 **/
+ public final static int HP_PUMP = 7;
+ /** 管理员上分 **/
+ public final static int HP_MGR_UPPER = 8;
+ /** 管理员下分 **/
+ public final static int HP_MGR_SUB = 9;
+ /** 合伙人上分 **/
+ public final static int HP_PARTNER_UPPER = 10;
+ /** 合伙人下分 **/
+ public final static int HP_PARTNER_SUB = 11;
+ /** 合伙人奖励 **/
+ public final static int HP_PARTNER_REWARD = 12;
+ /** 转账 **/
+ public final static int HP_TRADE = 13;
+ /** 体力值提取 **/
+ public final static int HP_TAKE_REWARD = 14;
+ /**大局游戏hp的变化总值*/
+ public final static int HP_PUMP_TOTAL = 15;
+ /***/
+ public final static int HP_TAKE_BANK = 16;
+
+ public final static int HP_SAVE_BANK = 17;
+
+ /** 洗牌 **/
+ public final static int HP_XIPAI_PUMP = 20;
+ /** 合伙人洗牌奖励 **/
+ public final static int HP_PARTNER_XIPAI_REWARD = 21;
+
+ /** 邮件 **/
+ public final static int DIAMO_MAIL = 50;
+ /** 转盘**/
+ public final static int DIAMO_WHEEL = 51;
+ /** 分享**/
+ public final static int DIAMO_SH = 52;
+ /** 后台充值**/
+ public final static int DIAMO_ADD = 99;
+}
diff --git a/data_cache/src/main/java/com/data/util/CountUtil.java b/data_cache/src/main/java/com/data/util/CountUtil.java
new file mode 100644
index 0000000..ea3cb60
--- /dev/null
+++ b/data_cache/src/main/java/com/data/util/CountUtil.java
@@ -0,0 +1,262 @@
+package com.data.util;
+
+
+
+import com.taurus.core.util.DateUtils;
+import com.taurus.core.util.StringUtil;
+
+import redis.clients.jedis.Jedis;
+import redis.clients.jedis.Pipeline;
+
+public class CountUtil {
+
+ public static final int LOG_FOREVER = 0;
+ public static final int LOG_DAY = 1;
+ public static final int LOG_LASTDAY = 2;
+ public static final int LOG_WEEK = 3;
+ public static final int LOG_LASTWEEK = 4;
+ public static final int LOG_MONTH = 5;
+ public static final int LOG_LASTMONTH = 6;
+
+ private static final int DAY2 = 172800;
+ private static final int DAY3 = 259200;
+ private static final int DAY10 = 864000;
+ private static final int MONTH = 2592000;
+// private static final int WEEK2 = 1209600;
+ private static final int MONTH2 = 2678400;
+
+ public static int getCountLog(String key,int type,Jedis jedis) {
+ String value = jedis.get(key);
+ if(StringUtil.isNotEmpty(value)) {
+ return Integer.parseInt(value);
+ }
+ return 0;
+ }
+
+
+
+
+ /**
+ * 获取天数据
+ * @param key
+ * @param jedis
+ * @return
+ */
+ public static int getCountLogByDay(String key,Jedis jedis) {
+ String day_key = key + ":d"+DateUtils.getBeginDay();
+ String value = jedis.get(day_key);
+ if(StringUtil.isEmpty(value))return 0;
+ return Integer.parseInt(value);
+ }
+
+
+
+
+ /**
+ * 统计
+ * @param key
+ * @param num
+ * @param jedis
+ */
+ public static void countLog(String key,int num,Jedis jedis) {
+ countLog(key,num,jedis,false);
+ }
+
+ public static void countLog(String key,int num,Pipeline pipeline) {
+ countLog(key,num,pipeline,false);
+ }
+
+ /**
+ * 统计
+ * @param key
+ * @param num
+ * @param jedis
+ * @param day_expire_month 天数据保存一个月
+ */
+ public static void countLog(String key,int num,Jedis jedis,boolean day_expire_month) {
+
+ String day_key = key + ":d"+DateUtils.getBeginDay();
+// String week_key = key + ":w"+DateUtils.getBeginWeek();
+// String month_key = key + ":m"+DateUtils.getBeginMonth();
+ jedis.incrBy(day_key,num);
+ jedis.expire(day_key, day_expire_month?MONTH2:DAY10);
+// jedis.incrBy(week_key,num);
+// jedis.expire(week_key, WEEK2);
+// jedis.incrBy(month_key,num);
+// jedis.expire(month_key, MONTH2);
+ }
+
+ /**
+ * 统计
+ * @param key
+ * @param num
+ * @param jedis
+ * @param day_expire_month 天数据保存一个月
+ */
+ public static void countLog(String key,int num,Pipeline pipeline,boolean day_expire_month) {
+
+ String day_key = key + ":d"+DateUtils.getBeginDay();
+// String week_key = key + ":w"+DateUtils.getBeginWeek();
+// String month_key = key + ":m"+DateUtils.getBeginMonth();
+ pipeline.incrBy(day_key,num);
+ pipeline.expire(day_key, day_expire_month?MONTH2:DAY10);
+// pipeline.incrBy(week_key,num);
+// pipeline.expire(week_key, WEEK2);
+// pipeline.incrBy(month_key,num);
+// pipeline.expire(month_key, MONTH2);
+ }
+
+ public static void countLog(String key,int num,Jedis jedis,boolean day_expire_month,boolean total) {
+
+ if(total) {
+ jedis.incrBy(key,num);
+ }
+ countLog(key,num,jedis,day_expire_month);
+ }
+
+ public static void countLog(String key,int num,Pipeline pipeline,boolean day_expire_month,boolean total) {
+
+ if(total) {
+ pipeline.incrBy(key,num);
+ }
+ countLog(key,num,pipeline,day_expire_month);
+ }
+
+ /**
+ * 统计天数据(存10天)
+ * @param key
+ * @param num
+ * @param jedis
+ */
+ public static long countLogByDay(String key,int num,Jedis jedis) {
+ return countLogByDay(key,num,jedis,DAY10);
+ }
+
+
+ /**
+ * 统计天数据(存10天)
+ * @param key
+ * @param num
+ * @param jedis
+ */
+ public static void countLogByDay(String key,int num,Pipeline pipeline) {
+ countLogByDay(key,num,pipeline,DAY10);
+ }
+
+ /**
+ * 统计天数据(存10天)
+ * @param key
+ * @param num
+ * @param jedis
+ */
+ public static void countLogByDay30(String key,int num,Pipeline pipeline) {
+
+ countLogByDay(key,num,pipeline,MONTH);
+
+ String month_key = key + ":m"+DateUtils.getBeginMonth();
+ pipeline.incrBy(month_key,num);
+ pipeline.expire(month_key, MONTH2);
+ }
+
+ /**
+ * 统计天数据(存10天)
+ * @param key
+ * @param num
+ * @param jedis
+ */
+ public static void countLogByDay(String key,int num,Pipeline pipeline,boolean total) {
+
+ if(total) {
+ pipeline.incrBy(key,num);
+ }
+
+ countLogByDay(key,num,pipeline,DAY10);
+ }
+
+ /**
+ * 统计天数据(存30天)
+ * @param key
+ * @param num
+ * @param jedis
+ */
+ public static void countLogByDay30(String key,int num,Pipeline pipeline,boolean total) {
+
+ if(total) {
+ pipeline.incrBy(key,num);
+ }
+
+ countLogByDay(key,num,pipeline,MONTH);
+
+ String month_key = key + ":m"+DateUtils.getBeginMonth();
+ pipeline.incrBy(month_key,num);
+ pipeline.expire(month_key, MONTH2);
+ }
+
+ /**
+ * 统计天数据(存10天)
+ * @param key
+ * @param num
+ * @param jedis
+ */
+ public static long countLogByDay(String key,int num,Jedis jedis,boolean total) {
+
+ if(total) {
+ jedis.incrBy(key,num);
+ }
+
+ return countLogByDay(key,num,jedis,DAY10);
+ }
+
+ /**
+ * 统计天数据
+ * @param key
+ * @param num
+ * @param jedis
+ */
+ public static long countLogByDay(String key,int num,Jedis jedis,int time) {
+ String day_key = key + ":d"+DateUtils.getBeginDay();
+
+ long value = jedis.incrBy(day_key,num);
+ jedis.expire(day_key, time);
+ return value;
+ }
+
+ /**
+ * 统计天数据
+ * @param key
+ * @param num
+ * @param jedis
+ */
+ public static void countLogByDay(String key,int num,Pipeline pipeline,int time) {
+ String day_key = key + ":d"+DateUtils.getBeginDay();
+
+ pipeline.incrBy(day_key,num);
+ pipeline.expire(day_key, time);
+ }
+
+ /**
+ * 统计天数据(存2天)
+ * @param key
+ * @param num
+ * @param jedis
+ */
+ public static long countLogByDay2(String key,int num,Jedis jedis) {
+ String day_key = key + ":d"+DateUtils.getBeginDay();
+ long value = jedis.incrBy(day_key,num);
+ jedis.expire(day_key, DAY2);
+ return value;
+ }
+
+ /**
+ * 统计天数据(存2天)
+ * @param key
+ * @param num
+ * @param jedis
+ */
+ public static long countLogByDay3(String key,int num,Jedis jedis) {
+ String day_key = key + ":d"+DateUtils.getBeginDay();
+ long value = jedis.incrBy(day_key,num);
+ jedis.expire(day_key, DAY3);
+ return value;
+ }
+}
diff --git a/data_cache/src/main/java/com/data/util/ErrorCode.java b/data_cache/src/main/java/com/data/util/ErrorCode.java
new file mode 100644
index 0000000..e8fc526
--- /dev/null
+++ b/data_cache/src/main/java/com/data/util/ErrorCode.java
@@ -0,0 +1,172 @@
+package com.data.util;
+
+public class ErrorCode {
+ // 成功
+ public final static int _SUCC = 0;
+ // 失败
+ public final static int _FAILED = 1;
+ /** session 不存在 */
+ public final static int _NO_SESSION = 2;
+ // 已经在房间可重连(创建房间协议)
+ public final static int BE_IN_ROOM = 3;
+ // 已创建房间可进入(创建房间协议)
+ public final static int CREATED_ROOM = 4;
+ // 不可选游�?
+ public final static int NO_GAME = 5;
+ // 无游戏服�?
+ public final static int NO_SERVICE = 6;
+ // 缺钻�?
+ public final static int NO_DIAMO = 7;
+ // 房间不可进入
+ public final static int ROOM_CLOSE = 10;
+ // 房间号错�?
+ public final static int NO_ROOM_NUM = 11;
+ // 邮件不存�?
+ public final static int NO_MAIL = 12;
+ // 邮件已领�?
+ public final static int RECEIVED_MAIL = 13;
+ // 任务不存�?
+ public final static int NO_TASK = 14;
+ // 任务已领�?
+ public final static int TASK_COMPLETE = 16;
+ // 缺奖�?
+ public final static int NO_RAFFLE = 17;
+ // 没有战绩
+ public final static int NO_MILITARY = 19;
+ // 没有回放
+ public final static int NO_REC = 25;
+ //多次登录失败,禁止登录, 半个小时后再试
+ public final static int BAN_LOGIN = 28;
+
+ /** 无效的手机号码 **/
+ public final static int INVALID_PHONE = 58;
+ /** 无效的验证码 **/
+ public final static int INVALID_CODE = 59;
+ /** 手机号码已发短信手机不一致 **/
+ public final static int ATYPISM_PHONE = 60;
+ /** 手机号码已绑定玩家 **/
+ public final static int BINDED_PHONE = 61;
+ /** 该手机号码未绑定游戏 **/
+ public final static int NO_BINDED_PHONE = 62;
+ /** ACC已存在 **/
+ public final static int EXIST_ACC = 63;
+
+
+ /** 房间已删除 */
+ public final static int ROOM_DEL = 80;
+ /** 是圈子房间 */
+ public final static int ROOM_IS_GROUP = 81;
+ /** 玩家申请解散已达上限次数 **/
+ public final static int ROOM_DIS_UPPER_LIMIT = 82;
+ /** 坐下体力值不足*/
+ public final static int ROOM_NOT_HP = 83;
+ /** 是否禁止解散房间*/
+ public final static int ROOM_DIS_NOT_ALLOWED = 84;
+
+
+
+ /** 是否已申请加入 */
+ public final static int GROUP_JOIN_EXIST = 1000;
+ /** 成员已存在 */
+ public final static int GROUP_MEMBER_EXIST = 1001;
+ /** 成员不存在 */
+ public final static int GROUP_NOT_MEMBER = 1002;
+ /** 成员存在上级合伙人 */
+ public final static int GROUP_MEMBER_EXIST_PARTENER = 1003;
+ /** 玩法已满 */
+ public final static int GROUP_PLAY_FULL = 1004;
+ /** 房间被删除 */
+ public final static int GROUP_ROOM_DEL = 1005;
+ /** 玩法不存在 */
+ public final static int GROUP_PLAY_EXIST = 1007;
+ /** 不是管理员 */
+ public final static int GROUP_MGR_EXIST = 1008;
+ /** 合伙人有成员 */
+ public final static int GROUP_PARTNER_MEMBERS = 1009;
+ /** 目标是管理员 */
+ public final static int GROUP_TAG_ISMGR = 1010;
+ /** 目标是合伙人 */
+ public final static int GROUP_TAG_ISPARTENER = 1011;
+ /** 目标体力值不够 */
+ public final static int GROUP_TAG_NO_HP = 1012;
+ /** 操作人体力值不够 */
+ public final static int GROUP_TAG_MGR_HP = 1013;
+ /** 没有权限 */
+ public final static int GROUP_NOT_PERMISSION = 1014;
+ /** 体力值不为0 */
+ public final static int GROUP_HP_NOT_0 = 1015;
+ /** 成员在房间内 */
+ public final static int GROUP_MEMBER_ROOM_EXIST = 1016;
+ /** 成员体力值事件正在执行 */
+ public final static int GROUP_MEMBER_HPEVT_RUNING = 1017;
+ /** 圈子不存在 */
+ public final static int GROUP_NO_EXIST = 1018;
+ /** 圈子已满 */
+ public final static int GROUP_FULL = 1019;
+ /** 圈子还有房间 */
+ public final static int GROUP_EXIST_ROOMS = 1020;
+ /** 圈子禁止娱乐 */
+ public final static int GROUP_BAN = 1021;
+ /** 不是圈主 */
+ public final static int GROUP_NOT_OWNER = 1022;
+ /** 目標玩家是合伙人 */
+ public final static int GROUP_ALREADY_PARTNER = 1023;
+ /** 目標玩家不是合伙人 */
+ public final static int GROUP_NOT_PARTNER = 1024;
+ /** 圈子成员禁止娱乐 */
+ public final static int GROUP_MEMBER_BAN = 1025;
+ /** 进入房间体力值不足 */
+ public final static int GROUP_LIMIT_NO_HP = 1026;
+ /** 大联盟只能创建一个 */
+ /** 大联盟只能创建5个 */
+ public final static int GROUP_TYPE2_ONLY_1 = 1027;
+ /** 大联盟必须开启体力值 */
+ public final static int GROUP_TYPE2_MUST_HP = 1028;
+ /** 改玩法还存在房间 */
+ public final static int GROUP_PLAY_EXIST_ROOM = 1029;
+ /** 不在此圈子房间中 */
+ public final static int GROUP_NOT_CURGROUP_ROOM = 1030;
+ /** 玩家关闭被邀请 */
+ public final static int GROUP_CLOSE_INVITATION = 1031;
+ /** 圈子已满 */
+ public final static int GROUP_IS_FULL = 1032;
+ /** 圈子成员已满 */
+ public final static int GROUP_MEMBER_IS_FULL = 1033;
+ /** 玩家正在游戏 不能上下分 **/
+ public final static int GROUP_DONOT_SUB_HP = 1034;
+ /** 奖励池体力值不足 **/
+ public final static int GROUP_REWARD_NO_HP = 1035;
+ /** 奖励池没提取 **/
+ public final static int GROUP_REWARD_NO_TAKE = 1036;
+ /** 禁止同桌 **/
+ public final static int GROUP_BAN_DESK = 1037;
+ /** 玩法禁止娱乐 **/
+ public final static int GROUP_BAN_PLAY = 1038;
+ /** 禁止申请加入圈子 **/
+ public final static int GROUP_BAN_APPLY = 1039;
+ /** 圈子停止服务 **/
+ public final static int GROUP_STOP_SERVICE = 1040;
+ /** 大联盟不能退出 **/
+ public final static int GROUP_TYPE2_NOT_EXIT = 1041;
+ /** 玩法存在推广奖励 **/
+ public final static int GROUP_PAY_TYPE3_EXIST = 1042;
+ /** 全民推广已开启,不能转移 **/
+ public final static int GROUP_PROMOTION_ACTIVE = 1043;
+ /** 全民推广为开启 **/
+ public final static int GROUP_PROMOTION_NOT_ACTIVE = 1044;
+ /** 有下级合伙人给其合伙人的分成高于此比例 **/
+ public final static int GROUP_HAS_MEMBER_OVERFLOW = 1045;
+ /** 合伙人体力值不足 **/
+ public final static int GROUP_PARTNER_HP_NOT_ENOUGH = 1046;
+ /** 体力值超越上线, 请保存到保险箱里 **/
+ public final static int GROUP_PARTNER_HP_THAN_LIMIET = 1047;
+ /** 玩家体力值超越上线, 请提醒他保存到上线 **/
+ public final static int GROUP_PARTNER_OTHER_HP_THAN_LIMIET = 1048;
+
+ //禁止表情
+ public final static int GROUP_BAN_EMOJI = 1049;
+
+
+ //禁止聊天
+ public final static int GROUP_BAN_CHAT = 1050;
+}
diff --git a/data_cache/src/main/java/com/data/util/EventType.java b/data_cache/src/main/java/com/data/util/EventType.java
new file mode 100644
index 0000000..21dc418
--- /dev/null
+++ b/data_cache/src/main/java/com/data/util/EventType.java
@@ -0,0 +1,60 @@
+package com.data.util;
+
+public class EventType {
+ /**
+ * 扣房卡事件
+ */
+ public static final int REDIS_EVENT_PAY = 1;
+ /**
+ * 反还房卡事件
+ */
+ public static final int REDIS_EVENT_BACK_PAY = 4;
+ /**
+ * 赢事件
+ */
+ public static final int REDIS_EVENT_WIN = 2;
+ /**
+ * 输事件
+ */
+ public static final int REDIS_EVENT_LOSE = 3;
+ /**
+ * 游戏结束事件
+ */
+ public static final int REDIS_EVENT_OVER = 5;
+ /**
+ * 牌友圈局数事件
+ */
+ public static final int REDIS_EVENT_GROUP_ROUND = 6;
+ /**
+ * 牌友圈成员局数事件
+ */
+ public static final int REDIS_EVENT_GROUP_MEMBER_ROUND = 7;
+ /**
+ * 牌友圈体力值事件
+ */
+ public static final int REDIS_EVENT_GROUP_HP = 8;
+ /**
+ *
+ */
+ public static final int REDIS_EVENT_GROUP_HP_DB = 90;
+ /**
+ * 邮件
+ */
+ public static final int REDIS_EVENT_MAIL = 95;
+ /**
+ * 转盘
+ */
+ public static final int REDIS_EVENT_WHEEL = 96;
+ /**
+ * 圈子创房
+ */
+ public static final int REDIS_EVENT_GROUP_ROOM = 97;
+ /**
+ * 普通创房
+ */
+ public static final int REDIS_EVENT_CREATE_ROOM = 98;
+ /**
+ * 后台充钻石
+ */
+ public static final int REDIS_EVENT_ADDPAY = 99;
+}
diff --git a/data_cache/src/main/java/com/data/util/Utility.java b/data_cache/src/main/java/com/data/util/Utility.java
new file mode 100644
index 0000000..3159f44
--- /dev/null
+++ b/data_cache/src/main/java/com/data/util/Utility.java
@@ -0,0 +1,399 @@
+
+package com.data.util;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import com.data.bean.GameBean;
+import com.data.bean.GroupMemberBean;
+import com.data.cache.GameCache;
+import com.data.cache.GroupCache;
+import com.taurus.core.entity.ITArray;
+import com.taurus.core.entity.ITObject;
+import com.taurus.core.entity.TArray;
+import com.taurus.core.entity.TObject;
+import com.taurus.core.plugin.redis.Redis;
+import com.taurus.core.util.StringUtil;
+
+import jdk.nashorn.internal.objects.Global;
+import redis.clients.jedis.Jedis;
+
+public class Utility {
+ /**
+ * API 版本
+ */
+ public static int API_VER = 2;
+
+ /**
+ * 获取战绩数据
+ *
+ * @param jedis5
+ * @param key
+ * @param platform
+ * @return
+ */
+ public final static ITObject getMilitaryList(Jedis jedis5, String key, String platform) {
+ Map military = jedis5.hgetAll(key);
+ if (military == null || military.isEmpty()) {
+ return null;
+ }
+ ITObject obj = TObject.newInstance();
+ obj.putString("military_id", key);
+ String strData = military.get("game_id");
+ if (strData == null) {
+ return null;
+ }
+ obj.putString("game_id", strData);
+ obj.putString("room_id", military.get("room_id"));
+ obj.putString("round", military.get("round"));
+ obj.putString("agreeDismisUserId", military.get("agreeDismisUserId"));
+ obj.putString("applyDismisUserId", military.get("applyDismisUserId"));
+ obj.putInt("dismisType", military.get("dismisType") == null ? 0 : Integer.parseInt(military.get("dismisType")));
+
+// obj.putString("is_read", military.get("is_read"));
+ String totalScore = military.get("totalScore");
+ ITArray players = TArray.newFromJsonData(totalScore);
+ for (int j = 0; j < players.size(); j++) {
+ ITObject player = players.getTObject(j);
+ int playerId = player.getInt("accId");
+ obj.putString("is_read_" + playerId, military.get("is_read_" + playerId));
+
+ }
+
+ int hp_times = 10;
+ if (military.containsKey("hp_times")) {
+ hp_times = Integer.parseInt(military.get("hp_times"));
+ }
+ int groupPid = 0;
+ String pname = "";
+ if (military.containsKey("groupPid")) {
+ groupPid = Integer.parseInt(military.get("groupPid"));
+ pname = military.get("groupPname");
+ }
+ obj.putString("pname", pname);
+
+ obj.putDouble("valid_diamo",
+ military.get("valid_diamo") == null ? 0 : Double.parseDouble(military.get("valid_diamo")));
+
+ obj.putInt("hp_times", hp_times);
+ obj.putInt("groupPid", groupPid);
+ GameBean gb = GameCache.getGame(Integer.parseInt(strData));
+ ITObject gameObj = gb.getTObject();
+ obj.putTObject("game_info", gameObj);
+ obj.putString("create_time", military.get("create_time"));
+ strData = military.get("totalScore");
+ String strDatas = military.get("hpData");
+ obj.putString("hpData", strDatas);
+ if (strData != null) {
+ obj.putString("totalScore", strData);
+ }
+ String hpOnOff = military.get("hpOnOff");
+ if (StringUtil.isNotEmpty(hpOnOff)) {
+ obj.putInt("hpOnOff", Integer.parseInt(hpOnOff));
+ } else {
+ obj.putInt("hpOnOff", 0);
+ }
+
+ strData = military.get("groupId");
+ if (strData == null) {
+ strData = "0";
+ }
+ obj.putString("groupId", strData);
+ for (int i = 1; i <= Integer.parseInt(military.get("round")); i++) {
+ String roundKey = "round_" + i;
+ try {
+ obj.putString(roundKey, military.get(roundKey));
+ } catch (Exception e) {
+ }
+ }
+ return obj;
+ }
+
+ /**
+ * 获取成员上级列表
+ *
+ * @param groupId
+ * @param uid
+ * @return
+ */
+ public static List getMemberParents(int groupId, int uid) {
+ Jedis jedis10 = Redis.use("group1_db10").getJedis();
+ try {
+ return getMemberParents(jedis10, groupId, uid, false);
+ } finally {
+ jedis10.close();
+ }
+ }
+
+ /**
+ * 获取成员上级列表
+ *
+ * @param groupId
+ * @param uid
+ * @return
+ */
+ public static List getMemberParents(Jedis jedis10, int groupId, int uid, boolean self) {
+ return getMemberParents(jedis10, groupId, uid, self, 1);
+ }
+
+ public static int getParentsinfo(int groupId, int uid) {
+ // Jedis jedis10 = Redis.use("group1_db10").getJedis();
+ GroupMemberBean gmb = GroupCache.getMember(groupId, uid);
+ if (gmb == null) {
+ return 0;
+ }
+ int parentId = 0;
+ parentId = gmb.parentId;
+ return parentId;
+ }
+
+ /**
+ * 获取成员上级列表
+ *
+ * @param groupId
+ * @param uid
+ * @return
+ */
+ public static List getMemberParents(Jedis jedis10, int groupId, int uid, boolean self, int start_par_lev) {
+ GroupMemberBean gmb = GroupCache.getMember(groupId, uid);
+ if (gmb == null) {
+ return null;
+ }
+
+ int partnerLev = 0;
+ int parentId = 0;
+ if (self) {
+ partnerLev = gmb.partnerLev;
+ if (partnerLev > 0) {
+ parentId = uid;
+ } else {
+ parentId = gmb.parentId;
+ }
+ } else {
+ parentId = gmb.parentId;
+ }
+
+ if (parentId > 0) {
+ if (parentId != uid) {
+ gmb = GroupCache.getMember(groupId, parentId);
+ partnerLev = gmb.partnerLev;
+ }
+ if (partnerLev == 0)
+ return null;
+ List list = new ArrayList(partnerLev);
+ for (int i = start_par_lev - 1; i < partnerLev; ++i) {
+ list.add(parentId);
+ parentId = gmb.parentId;
+ gmb = GroupCache.getMember(groupId, parentId);
+ }
+ return list;
+ }
+ return null;
+ }
+
+ /**
+ * 获取子合伙人Sql
+ *
+ * @param groupId
+ * @param uid
+ * @return
+ */
+ public static String getChildParentSql(int groupId, int uid, boolean self) {
+ String pl_key = String.format("g{%s}:par_list:%s", groupId, uid);
+ Set child_list = Redis.use("group1_db10").smembers(pl_key);
+ String p = self ? uid + "" : StringUtil.Empty;
+ for (String str : child_list) {
+ p += "," + str;
+ }
+ return p;
+ }
+
+ /**
+ * 获取子合伙人Sql
+ *
+ * @param groupId
+ * @param uid
+ * @return
+ */
+ public static List getChildParentList(int groupId, int uid, boolean self) {
+ String pl_key = String.format("g{%s}:par_list:%s", groupId, uid);
+ Set child_list = Redis.use("group1_db10").smembers(pl_key);
+ List list = new ArrayList<>();
+ if (self) {
+ list.add(uid);
+ }
+ for (String str : child_list) {
+ list.add(Integer.parseInt(str));
+ }
+ return list;
+ }
+
+ /**
+ *
+ * @param type 1 update 2 call
+ * @param sql
+ */
+ public static void evtdb(int gid, int type, String sql) {
+ if (StringUtil.isEmpty(sql))
+ return;
+ String str = type + sql;
+ Redis.use(CHACHE_KEY).lpush("evt_db_" + (gid % 10), str);
+ }
+
+ /**
+ *
+ * @param type 1 update 2 call 插入不是很重要的LOG, 可以走随机线程
+ * @param sql
+ */
+ public static void evtdbLog(int gid, int type, String sql) {
+ if (StringUtil.isEmpty(sql))
+ return;
+ String str = type + sql;
+ int id = (int) (gid * Math.random() * 100);
+ id = id % 10;
+ Redis.use(CHACHE_KEY).lpush("evt_db_" + (id), str);
+ }
+
+ private final static String EVT_TYPE = "E";
+ private final static String EVT_UID = "uid";
+ private final static String CHACHE_KEY = "group1_db8";
+
+ /**
+ * 支付钻石事件
+ *
+ * @param type
+ * @param uid
+ * @param game
+ * @param pay
+ * @param gid
+ * @param pid
+ */
+ public static void payDiamo(int type, int uid, int game, int pay, int gid, int pid) {
+ ITObject data = TObject.newInstance();
+ data.putInt("pay", pay);
+ data.putInt("game", game);
+ data.putInt("group", gid);
+ if (pid > 0) {
+ data.putInt("pid", pid);
+ }
+ data.putInt(EVT_UID, uid);
+ data.putInt(EVT_TYPE, type);
+ Redis.use(CHACHE_KEY).lpush("event_" + (uid % 10), data.toJson());
+ }
+
+ /**
+ * 支付钻石事件
+ *
+ * @param type
+ * @param uid
+ * @param game
+ * @param pay
+ * @param cur_diamo
+ * @param gid
+ * @param pid
+ */
+ public static void payDiamo(int type, int uid, int game, int pay, int cur_diamo, int gid, int pid) {
+ ITObject data = TObject.newInstance();
+ data.putInt("pay", pay);
+ data.putInt("game", game);
+ data.putInt("diamo", cur_diamo);
+ data.putInt("group", gid);
+ if (pid > 0) {
+ data.putInt("pid", pid);
+ }
+ data.putInt(EVT_UID, uid);
+ data.putInt(EVT_TYPE, type);
+ Redis.use(CHACHE_KEY).lpush("event_" + (uid % 10), data.toJson());
+ }
+
+ final static String pay_lua = "local diamo = tonumber(redis.call('hget', KEYS[1],'diamo'))\n"
+ + "local pay = tonumber(ARGV[1]) \n" + "if pay > diamo then \n" + "return {2,0}\n" + "end\n"
+ + "diamo = redis.call('hincrBy',KEYS[1],'diamo',-pay)\n" + "return {0,diamo}";
+
+ @SuppressWarnings("unchecked")
+ public static ArrayList payDiamo(Jedis jedis0, String session, int pay) {
+ Object obj = jedis0.eval(pay_lua, Arrays.asList(session), Arrays.asList(pay + ""));
+ if (obj == null)
+ return null;
+ return (ArrayList) obj;
+ }
+
+ /**
+ * 检测房间钻石
+ *
+ * @param jedis0
+ * @param session
+ * @param pay
+ * @param opt
+ * @param AA
+ * @param maxPlayers
+ * @return
+ * @throws Exception
+ */
+ public static int checkRoomDiamo(Jedis jedis0, String session, int pay) throws Exception {
+ if (pay <= 0) {
+ return 0;
+ }
+ int p_diamo = Integer.parseInt(jedis0.hget(session, "diamo"));
+ if (p_diamo < pay) {
+ return ErrorCode.NO_DIAMO;
+ }
+ return 0;
+ }
+
+ /**
+ * 获取session 已在房间
+ *
+ * @param jedis0
+ * @param groupId
+ * @param session
+ * @param uid
+ * @return
+ */
+ public static final String getOldRoomV2(Jedis jedis0, int groupId, String session, int uid) {
+ String oldRoom = jedis0.hget(session, "room");
+ boolean enter_old = false;
+ if (StringUtil.isNotEmpty(oldRoom)) {
+ enter_old = true;
+ }
+ if (enter_old) {
+ List _list = jedis0.hmget(oldRoom, "status", "score_" + uid);
+ String status = _list.get(0);
+ if (StringUtil.isEmpty(status) || status.equals("2") || status.equals("3")) {
+ jedis0.hdel(session, "room");
+ return null;
+ }
+ String s_uid = _list.get(1);
+ if (StringUtil.isNotEmpty(s_uid)) {
+ return oldRoom;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * 删除session房间
+ *
+ * @param jedis0
+ * @param session_key
+ * @param room_key
+ * @return
+ */
+ public static final boolean delRoomBySession(Jedis jedis0, String session_key, String room_key) {
+ String cur_room = jedis0.hget(session_key, "room");
+ if (StringUtil.isNotEmpty(cur_room)) {
+ if (cur_room.equals(room_key)) {
+ if (API_VER == 1) {
+ jedis0.hdel(session_key, "room", "seat");
+ } else {
+ jedis0.hdel(session_key, "room");
+ }
+ return true;
+ }
+ }
+ return false;
+ }
+}
diff --git a/event_mgr/build/local/taurus-core.xml b/event_mgr/build/local/taurus-core.xml
new file mode 100644
index 0000000..0c9036a
--- /dev/null
+++ b/event_mgr/build/local/taurus-core.xml
@@ -0,0 +1,96 @@
+
+
+ log4j.properties
+
+
+ database
+ com.taurus.core.plugin.database.DataBasePlugin
+
+
+
+ 100
+
+ 10
+
+ 180000
+
+ select 1
+
+ 10000
+
+ 60000
+
+
+
+ false
+ true
+ utf-8
+
+ UTC
+
+ true
+
+ 250
+
+ 2048
+
+
+
+
+
+ db1
+ com.mysql.cj.jdbc.Driver
+ jdbc:mysql://123.207.203.115:8060/wb_game
+ wb_game
+ 363b76546c
+
+
+
+
+
+ redis
+ com.taurus.core.plugin.redis.RedisPlugin
+
+
+
+ 80
+
+ 20
+
+ 5
+
+ -1
+
+ true
+
+ true
+
+ true
+
+ 100
+
+ 60000
+
+ 30000
+
+ 1800000
+
+ true
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/event_mgr/build/pro/log4j.properties b/event_mgr/build/pro/log4j.properties
new file mode 100644
index 0000000..6786dba
--- /dev/null
+++ b/event_mgr/build/pro/log4j.properties
@@ -0,0 +1,20 @@
+
+log4j.rootLogger = INFO,consoleAppender,fileAppender
+
+# ConsoleAppender
+log4j.appender.consoleAppender=org.apache.log4j.ConsoleAppender
+log4j.appender.consoleAppender.layout=org.apache.log4j.PatternLayout
+log4j.appender.consoleAppender.layout.ConversionPattern=%d{HH:mm:ss,SSS} %-5p [%t] %c{2} %3x - %m%n
+
+
+# Regular FileAppender
+log4j.appender.fileAppender=org.apache.log4j.DailyRollingFileAppender
+log4j.appender.fileAppender.layout=org.apache.log4j.PatternLayout
+log4j.appender.fileAppender.File=${WORKDIR}/logs/web_main.log
+log4j.appender.fileAppender.layout.ConversionPattern=%d{dd MMM yyyy | HH:mm:ss,SSS} | %-5p | %t | %c{3} | %3x | %m%n
+log4j.appender.fileAppender.Encoding=UTF-8
+log4j.appender.fileAppender.DatePattern='.'yyyy-MM-dd
+log4j.appender.dailyFile.Append=true
+
+# The file is rolled over very day
+log4j.appender.fileAppender.DatePattern ='.'yyyy-MM-dd
\ No newline at end of file
diff --git a/event_mgr/build/pro/taurus-core.xml b/event_mgr/build/pro/taurus-core.xml
new file mode 100644
index 0000000..0c9036a
--- /dev/null
+++ b/event_mgr/build/pro/taurus-core.xml
@@ -0,0 +1,96 @@
+
+
+ log4j.properties
+
+
+ database
+ com.taurus.core.plugin.database.DataBasePlugin
+
+
+
+ 100
+
+ 10
+
+ 180000
+
+ select 1
+
+ 10000
+
+ 60000
+
+
+
+ false
+ true
+ utf-8
+
+ UTC
+
+ true
+
+ 250
+
+ 2048
+
+
+
+
+
+ db1
+ com.mysql.cj.jdbc.Driver
+ jdbc:mysql://123.207.203.115:8060/wb_game
+ wb_game
+ 363b76546c
+
+
+
+
+
+ redis
+ com.taurus.core.plugin.redis.RedisPlugin
+
+
+
+ 80
+
+ 20
+
+ 5
+
+ -1
+
+ true
+
+ true
+
+ true
+
+ 100
+
+ 60000
+
+ 30000
+
+ 1800000
+
+ true
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/event_mgr/build/test/log4j.properties b/event_mgr/build/test/log4j.properties
new file mode 100644
index 0000000..6786dba
--- /dev/null
+++ b/event_mgr/build/test/log4j.properties
@@ -0,0 +1,20 @@
+
+log4j.rootLogger = INFO,consoleAppender,fileAppender
+
+# ConsoleAppender
+log4j.appender.consoleAppender=org.apache.log4j.ConsoleAppender
+log4j.appender.consoleAppender.layout=org.apache.log4j.PatternLayout
+log4j.appender.consoleAppender.layout.ConversionPattern=%d{HH:mm:ss,SSS} %-5p [%t] %c{2} %3x - %m%n
+
+
+# Regular FileAppender
+log4j.appender.fileAppender=org.apache.log4j.DailyRollingFileAppender
+log4j.appender.fileAppender.layout=org.apache.log4j.PatternLayout
+log4j.appender.fileAppender.File=${WORKDIR}/logs/web_main.log
+log4j.appender.fileAppender.layout.ConversionPattern=%d{dd MMM yyyy | HH:mm:ss,SSS} | %-5p | %t | %c{3} | %3x | %m%n
+log4j.appender.fileAppender.Encoding=UTF-8
+log4j.appender.fileAppender.DatePattern='.'yyyy-MM-dd
+log4j.appender.dailyFile.Append=true
+
+# The file is rolled over very day
+log4j.appender.fileAppender.DatePattern ='.'yyyy-MM-dd
\ No newline at end of file
diff --git a/event_mgr/build/test/taurus-core.xml b/event_mgr/build/test/taurus-core.xml
new file mode 100644
index 0000000..0c9036a
--- /dev/null
+++ b/event_mgr/build/test/taurus-core.xml
@@ -0,0 +1,96 @@
+
+
+ log4j.properties
+
+
+ database
+ com.taurus.core.plugin.database.DataBasePlugin
+
+
+
+ 100
+
+ 10
+
+ 180000
+
+ select 1
+
+ 10000
+
+ 60000
+
+
+
+ false
+ true
+ utf-8
+
+ UTC
+
+ true
+
+ 250
+
+ 2048
+
+
+
+
+
+ db1
+ com.mysql.cj.jdbc.Driver
+ jdbc:mysql://123.207.203.115:8060/wb_game
+ wb_game
+ 363b76546c
+
+
+
+
+
+ redis
+ com.taurus.core.plugin.redis.RedisPlugin
+
+
+
+ 80
+
+ 20
+
+ 5
+
+ -1
+
+ true
+
+ true
+
+ true
+
+ 100
+
+ 60000
+
+ 30000
+
+ 1800000
+
+ true
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/event_mgr/pom.xml b/event_mgr/pom.xml
new file mode 100644
index 0000000..86389d3
--- /dev/null
+++ b/event_mgr/pom.xml
@@ -0,0 +1,117 @@
+
+ 4.0.0
+ com.evt
+ event_mgr
+ war
+ 1.0.0
+
+ UTF-8
+ 1.8
+ 1.8
+ pro
+
+
+
+
+ junit
+ junit
+ 3.8.1
+ test
+
+
+
+
+ com.data
+ data_cache
+ 1.0.1
+
+
+
+
+ com.taurus
+ taurus-core
+ 1.0.1
+
+
+
+
+ com.taurus
+ taurus-web
+ 1.0.1
+
+
+
+
+ redis.clients
+ jedis
+ 2.9.0
+
+
+
+
+ com.zaxxer
+ HikariCP
+ 3.3.1
+
+
+
+
+ mysql
+ mysql-connector-java
+ 8.0.16
+
+
+
+
+ jdom
+ jdom
+ 1.0
+
+
+
+
+ log4j
+ log4j
+ 1.2.17
+
+
+
+ org.quartz-scheduler
+ quartz
+ 2.2.3
+
+
+
+
+ org.eclipse.jetty
+ jetty-webapp
+ 8.2.0.v20160908
+ provided
+
+
+
+
+ ROOT
+
+
+ org.apache.maven.plugins
+ maven-war-plugin
+
+ 1.8
+ 1.8
+ UTF-8
+ logs/**,config/**
+
+
+ config/
+ ${project.basedir}/build/${build.type}/
+
+
+
+
+
+
+
+
diff --git a/event_mgr/src/main/java/com/evt/mgr/EventController.java b/event_mgr/src/main/java/com/evt/mgr/EventController.java
new file mode 100644
index 0000000..07c7f2c
--- /dev/null
+++ b/event_mgr/src/main/java/com/evt/mgr/EventController.java
@@ -0,0 +1,149 @@
+package com.evt.mgr;
+
+import java.sql.SQLException;
+
+import com.data.util.CountUtil;
+import com.taurus.core.entity.ITArray;
+import com.taurus.core.entity.ITObject;
+import com.taurus.core.entity.TArray;
+import com.taurus.core.entity.TObject;
+import com.taurus.core.plugin.database.DataBase;
+import com.taurus.core.plugin.redis.Redis;
+import com.taurus.core.util.StringUtil;
+
+import redis.clients.jedis.Jedis;
+
+public class EventController {
+ private static final String EVENT_TYPE = "E";
+ private static final String EVENT_GID = "gid";
+ private static final String EVENT_UID = "uid";
+
+ public static final int execEvt(String key,boolean isGroupEvt) {
+ int count = 0;
+ do {
+ String jsonStr = Redis.use(EventReceiver.CHACHE_KEY).rpop(key);
+ if(StringUtil.isEmpty(jsonStr))
+ {
+ break;
+ }
+
+ long startTime = System.currentTimeMillis();
+ ITObject data = null;
+ try {
+ data = TObject.newFromJsonData(jsonStr);
+ } catch (Exception e) {
+ EventServer.log.error(jsonStr + ":event json error!", e);
+ }
+ int type = 0;
+ int uid = 0;
+ int groupId =0;
+ int reulst = 0;
+ try {
+ type = data.getInt(EVENT_TYPE);
+
+ if(isGroupEvt) {
+ groupId = data.getInt(EVENT_GID);
+ }else {
+ uid = data.getInt(EVENT_UID);
+ }
+
+ IHandler handler = EventServer.eventReceiver.getHandler(type);
+ if(handler!=null) {
+ if(isGroupEvt) {
+ reulst = handler.processGroup(groupId, data);
+ EventServer.log.info(jsonStr + " use time:" + (System.currentTimeMillis() - startTime) + " ms");
+ }else {
+ reulst = handler.process(uid, data);
+ EventServer.log.info(jsonStr + " use time:" + (System.currentTimeMillis() - startTime) + " ms");
+ }
+ if(reulst!=0) {
+ if(reulst == -1) {
+ jsonStr = data.toJson();
+ }
+ Redis.use(EventReceiver.CHACHE_KEY).lpush(key, jsonStr);
+ }
+ }
+ }catch (Exception e) {
+ e.printStackTrace();
+ Redis.use("group1_db15").lpush(key, jsonStr);
+ break;
+ }
+
+ if(reulst == 0) {
+ count++;
+ }
+ } while(true);
+
+ return count;
+ }
+
+ /**
+ *
+ * @param uid
+ * @param pay
+ * @param cur_diamo
+ * @param reason
+ * @param gameId
+ * @param groupId
+ * @param pid
+ * @throws SQLException
+ */
+ public static final void payDiamo(int uid,int pay,int cur_diamo,int reason,int gameId,int groupId,int pid) throws SQLException{
+ ITArray data = TArray.newInstance();
+ data.addInt(uid);
+ data.addInt(pay);
+ data.addInt(reason);
+ data.addInt(gameId);
+ data.addInt(groupId);
+ data.addInt(cur_diamo);
+ DataBase.use().prepareCallNonResult("sp_transfer_diamo", data);
+ if(groupId>0) {
+ Jedis jedis9 = Redis.use("group1_db9").getJedis();
+ try {
+ CountUtil.countLog(String.format("g%s:diamo_cost",groupId), pay, jedis9);
+ if(pid > 0) {
+ CountUtil.countLog(String.format("g%s:diamo_cost:p%s",groupId,pid), pay, jedis9,false,true);
+ }
+ }finally {
+ jedis9.close();
+ }
+ }
+ }
+
+ public static final int execSql(String key) {
+ int count = 0;
+ do {
+ String str = Redis.use(EventReceiver.CHACHE_KEY).rpop(key);
+// EventServer.log.info( " execsql:"+str);
+ if(StringUtil.isEmpty(str))
+ {
+ break;
+ }
+
+ int reulst = 0;
+ long startTime = System.currentTimeMillis();
+ try {
+ int type = Integer.parseInt(str.substring(0,1));
+ String sql = str.substring(1);
+ if(type==1) {
+ DataBase.use().executeUpdate(sql);
+ EventServer.log.info(sql + " use time:" + (System.currentTimeMillis() - startTime) + " ms");
+ }else {
+ DataBase.use().executeCall(sql, false);
+ EventServer.log.info(sql + " use time:" + (System.currentTimeMillis() - startTime) + " ms");
+ }
+
+ }catch (Exception e) {
+ e.printStackTrace();
+ Redis.use("group1_db15").lpush(key, str);
+ break;
+ }
+
+ if(reulst == 0) {
+ count++;
+ }
+ } while(true);
+
+ return count;
+ }
+}
diff --git a/event_mgr/src/main/java/com/evt/mgr/EventReceiver.java b/event_mgr/src/main/java/com/evt/mgr/EventReceiver.java
new file mode 100644
index 0000000..cd5f251
--- /dev/null
+++ b/event_mgr/src/main/java/com/evt/mgr/EventReceiver.java
@@ -0,0 +1,101 @@
+package com.evt.mgr;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import com.taurus.core.util.Logger;
+
+public class EventReceiver {
+ private final static String GROUP_EVT_KEY = "evt_group_";
+ private final static String EVT_KEY = "event_";
+ private final static String EVT_DB_KEY = "evt_db_";
+ public final static String CHACHE_KEY = "group1_db8";
+
+ Map handlerMap;
+ volatile boolean run;
+
+ public EventReceiver() {
+ handlerMap = new HashMap<>();
+ }
+
+ void start() {
+ run = true;
+ for (int i = 0; i < 10; ++i) {
+ new GroupRunnable(i, this, 1);
+ }
+
+ for (int i = 0; i < 10; ++i) {
+ new GroupRunnable(i, this, 2);
+ }
+
+ for (int i = 0; i < 10; ++i) {
+ new GroupRunnable(i, this, 3);
+ }
+ }
+
+ void destroy() {
+ run = false;
+ }
+
+ IHandler getHandler(int type) {
+ IHandler handler = handlerMap.get(type);
+ return handler;
+ }
+
+ private static final class GroupRunnable implements Runnable {
+ private Logger log = Logger.getLogger(GroupRunnable.class);
+ EventReceiver receiver;
+ int type;
+ int id;
+ Thread thread;
+
+ public GroupRunnable(int id, EventReceiver receiver, int type) {
+ this.receiver = receiver;
+ this.type = type;
+ this.id = id;
+ this.thread = new Thread(this, id + "");
+ this.thread.start();
+ }
+
+ @Override
+ public void run() {
+ while (receiver.run) {
+ int count=0;
+ long startTime = System.currentTimeMillis();
+ try {
+ switch (type) {
+ case 1:
+ count = EventController.execEvt(GROUP_EVT_KEY + this.id, true);
+ break;
+ case 2:
+ count = EventController.execEvt(EVT_KEY + id, false);
+ break;
+ case 3:
+ count = EventController.execSql(EVT_DB_KEY+id);
+ break;
+ }
+
+ long useTime = (System.currentTimeMillis() - startTime);
+ if (count > 0)
+ {
+ EventServer.log.info("handle event:" + count + " use time:" + useTime + " ms");
+ }
+ if (useTime >= 30 || count >= 30)
+ {
+ Thread.sleep(1);
+ }
+ else if (count > 0){
+ Thread.sleep(5);
+ }
+ else {
+ Thread.sleep(20);
+ }
+ } catch (Exception e) {
+ log.error(e);
+ }
+ }
+ }
+
+ }
+
+}
diff --git a/event_mgr/src/main/java/com/evt/mgr/EventServer.java b/event_mgr/src/main/java/com/evt/mgr/EventServer.java
new file mode 100644
index 0000000..115535a
--- /dev/null
+++ b/event_mgr/src/main/java/com/evt/mgr/EventServer.java
@@ -0,0 +1,105 @@
+package com.evt.mgr;
+
+import static org.quartz.CronScheduleBuilder.cronSchedule;
+import static org.quartz.JobBuilder.newJob;
+import static org.quartz.TriggerBuilder.newTrigger;
+
+import com.evt.mgr.job.CleanGroupLogJob;
+import org.quartz.CronTrigger;
+import org.quartz.JobDetail;
+import org.quartz.Scheduler;
+import org.quartz.SchedulerFactory;
+import org.quartz.impl.StdSchedulerFactory;
+
+import com.data.util.ConsumeCode;
+import com.data.util.EventType;
+import com.evt.mgr.handler.HandlerGroupMemberRound;
+import com.evt.mgr.handler.HandlerGroupRound;
+import com.evt.mgr.handler.HandlerHpConsume;
+import com.evt.mgr.handler.HandlerLose;
+import com.evt.mgr.handler.HandlerOver;
+import com.evt.mgr.handler.HandlerPay;
+import com.evt.mgr.handler.HandlerWin;
+import com.evt.mgr.job.CleanTimeOutRoomJob;
+import com.taurus.core.routes.Extension;
+import com.taurus.core.routes.Routes;
+import com.taurus.core.util.Logger;
+
+public class EventServer extends Extension{
+ static EventReceiver eventReceiver;
+ public static Logger log;
+
+ @Override
+ public void onStart() {
+ log = Logger.getLogger(EventServer.class);
+ eventReceiver = new EventReceiver();
+ initHandler();
+
+ initJob();
+
+ eventReceiver.start();
+ }
+
+ @Override
+ public void configRoute(Routes me) {
+ }
+
+ public void initJob() {
+
+ try {
+ log.info("clean invalid room, no diamond");
+
+ SchedulerFactory sf = new StdSchedulerFactory();
+ Scheduler sched = sf.getScheduler();
+
+ JobDetail job = newJob(CleanTimeOutRoomJob.class).withIdentity("clean_group_room", "group").build();
+ CronTrigger trigger= newTrigger().withIdentity("clean_group_room_trigger", "group").withSchedule(cronSchedule("0 0 5 * * ? ")).build();
+ sched.scheduleJob(job, trigger);
+
+ job = newJob(CleanTimeOutRoomJob.class).withIdentity("clean_invalid_room", "group").build();
+ trigger= newTrigger().withIdentity("clean_invalid_room_trigger", "group").withSchedule(cronSchedule("0 30 5 * * ? ")).build();
+ sched.scheduleJob(job, trigger);
+
+ JobDetail log_job = newJob(CleanGroupLogJob.class).withIdentity("clean_group_member_log", "group").build();
+ CronTrigger log_trigger= newTrigger().withIdentity("clean_group_member_log_trigger", "group").withSchedule(cronSchedule("0 0 0/1 * * ? ")).build();
+ sched.scheduleJob(log_job, log_trigger);
+
+ log_job = newJob(CleanGroupLogJob.class).withIdentity("clean_group_hp_log", "group").build();
+ log_trigger= newTrigger().withIdentity("clean_group_hp_log_trigger", "group").withSchedule(cronSchedule("0 0 0/1 * * ? ")).build();
+ sched.scheduleJob(log_job, log_trigger);
+
+ log_job = newJob(CleanGroupLogJob.class).withIdentity("clean_rec_room_log", "group").build();
+ log_trigger= newTrigger().withIdentity("clean_rec_room_log_trigger", "group").withSchedule(cronSchedule("0 0 0/1 * * ? ")).build();
+ sched.scheduleJob(log_job, log_trigger);
+
+ sched.start();
+ }
+ catch(Exception e) {
+
+ }
+ }
+
+
+ private void initHandler() {
+ eventReceiver.handlerMap.put(EventType.REDIS_EVENT_OVER, new HandlerOver());
+ eventReceiver.handlerMap.put(EventType.REDIS_EVENT_LOSE, new HandlerLose());
+ eventReceiver.handlerMap.put(EventType.REDIS_EVENT_WIN, new HandlerWin());
+ eventReceiver.handlerMap.put(EventType.REDIS_EVENT_PAY, new HandlerPay(ConsumeCode.DIAMO_JOIN_ROOM,true));
+ eventReceiver.handlerMap.put(EventType.REDIS_EVENT_BACK_PAY, new HandlerPay(ConsumeCode.DIAMO_REFUND,false));
+ eventReceiver.handlerMap.put(EventType.REDIS_EVENT_GROUP_ROOM, new HandlerPay(ConsumeCode.DIAMO_AGENT_ROOM,true));
+ eventReceiver.handlerMap.put(EventType.REDIS_EVENT_CREATE_ROOM, new HandlerPay(ConsumeCode.DIAMO_CREAT_ROOM,true));
+ eventReceiver.handlerMap.put(EventType.REDIS_EVENT_MAIL, new HandlerPay(ConsumeCode.DIAMO_MAIL,false));
+ eventReceiver.handlerMap.put(EventType.REDIS_EVENT_WHEEL, new HandlerPay(ConsumeCode.DIAMO_WHEEL,false));
+ eventReceiver.handlerMap.put(EventType.REDIS_EVENT_GROUP_ROUND, new HandlerGroupRound());
+ eventReceiver.handlerMap.put(EventType.REDIS_EVENT_GROUP_MEMBER_ROUND, new HandlerGroupMemberRound());
+ eventReceiver.handlerMap.put(EventType.REDIS_EVENT_GROUP_HP, new HandlerHpConsume());
+ eventReceiver.handlerMap.put(EventType.REDIS_EVENT_ADDPAY, new HandlerPay(ConsumeCode.DIAMO_ADD,false));
+ }
+
+ @Override
+ public void onStop() {
+ eventReceiver.destroy();
+ }
+
+
+}
diff --git a/event_mgr/src/main/java/com/evt/mgr/GroupPublisherService.java b/event_mgr/src/main/java/com/evt/mgr/GroupPublisherService.java
new file mode 100644
index 0000000..73c6ebc
--- /dev/null
+++ b/event_mgr/src/main/java/com/evt/mgr/GroupPublisherService.java
@@ -0,0 +1,75 @@
+package com.evt.mgr;
+
+import com.data.util.EventType;
+import com.taurus.core.entity.ITObject;
+import com.taurus.core.entity.TObject;
+import com.taurus.core.plugin.redis.Redis;
+
+import redis.clients.jedis.Jedis;
+
+public class GroupPublisherService {
+ public static final String CHANNEL_NAME = "mgr_group";
+
+ private static final String CMD_UPDATE_MEMBER = "update_member";
+
+ private static final String CMD_DEL_ROOM = "del_room";
+
+ private final static String EVT_TYPE = "E";
+ private final static String EVT_UID = "uid";
+
+ private final static String EVT_KEY = "event_";
+
+ /**
+ * 1 hp 2 等级 3 合伙人等级
+ *
+ * @param groupId
+ * @param uid
+ * @param type
+ * @param value
+ */
+ public static void updateMemberEvt(int groupId, int uid, int type, int value) {
+ ITObject data = TObject.newInstance();
+ data.putInt("gid", groupId);
+ data.putInt("uid", uid);
+ data.putInt("type", type);
+ data.putInt("value", value);
+ data.putString("cmd", CMD_UPDATE_MEMBER);
+ Jedis jedis11 =Redis.use("group1_db11").getJedis();
+ jedis11.publish(CHANNEL_NAME, data.toJson());
+ jedis11.close();
+ }
+
+ public static void delRoomEvt(int groupId, String roomid) {
+ ITObject data = TObject.newInstance();
+ data.putInt("gid", groupId);
+ data.putString("roomid", roomid);
+ data.putString("cmd", CMD_DEL_ROOM);
+ Jedis jedis11 =Redis.use("group1_db11").getJedis();
+ jedis11.publish(CHANNEL_NAME, data.toJson());
+ jedis11.close();
+ }
+
+ /**
+ * 返还钻石
+ *
+ * @param uid
+ * @param pay
+ * @param groupId
+ */
+ public static void refundDiamo(int uid, int pay, int groupId, int gameId) {
+ ITObject data = TObject.newInstance();
+ data.putInt("pay", -pay);
+ data.putInt("game", gameId);
+ if (groupId > 0) {
+ data.putInt("group", groupId);
+ }
+ //sendEvt(EventType.REDIS_EVENT_BACK_PAY, uid, data);
+ }
+
+ private static void sendEvt(int type, int uid, ITObject data) {
+ int id = uid % 10;
+ data.putInt(EVT_UID, uid);
+ data.putInt(EVT_TYPE, type);
+ Redis.use(EventReceiver.CHACHE_KEY).lpush(EVT_KEY + id, data.toJson());
+ }
+}
diff --git a/event_mgr/src/main/java/com/evt/mgr/IHandler.java b/event_mgr/src/main/java/com/evt/mgr/IHandler.java
new file mode 100644
index 0000000..3c47eff
--- /dev/null
+++ b/event_mgr/src/main/java/com/evt/mgr/IHandler.java
@@ -0,0 +1,10 @@
+package com.evt.mgr;
+
+import com.taurus.core.entity.ITObject;
+
+public interface IHandler {
+
+ public int process(int uid,ITObject param) throws Exception;
+
+ public int processGroup(int groupId,ITObject param) throws Exception;
+}
diff --git a/event_mgr/src/main/java/com/evt/mgr/Utils.java b/event_mgr/src/main/java/com/evt/mgr/Utils.java
new file mode 100644
index 0000000..cc877a7
--- /dev/null
+++ b/event_mgr/src/main/java/com/evt/mgr/Utils.java
@@ -0,0 +1,221 @@
+package com.evt.mgr;
+
+import java.util.List;
+
+import org.eclipse.jetty.util.log.Log;
+
+import com.data.cache.GroupCache;
+import com.data.util.CountUtil;
+import com.data.util.Utility;
+import com.evt.mgr.handler.HandlerHpConsume;
+import com.taurus.core.entity.ITArray;
+import com.taurus.core.plugin.redis.Redis;
+import com.taurus.core.util.DateUtils;
+import com.taurus.core.util.Logger;
+
+import redis.clients.jedis.Jedis;
+import redis.clients.jedis.Pipeline;
+
+public class Utils {
+ static Logger log = Logger.getLogger(Utils.class);
+
+ public static final void countValidAndTotal(Jedis jedis10, Pipeline pipeline9, int uid, int groupId, int pid,
+ int valid_count, int valid_diamo, int all_count) {
+
+ if (valid_count > 0) {
+ String gmv = String.format("g{%s}:m%s:valid_round", groupId, uid);
+ CountUtil.countLogByDay30(gmv, valid_count, pipeline9);
+ CountUtil.countLogByDay30(gmv + "_self", valid_count, pipeline9);
+ }
+
+ if (valid_diamo > 0) {
+ String gmv = String.format("g{%s}:m%s:valid_diamo", groupId, uid);
+ CountUtil.countLogByDay30(gmv, valid_diamo, pipeline9);
+ CountUtil.countLogByDay30(gmv + "_self", valid_diamo, pipeline9);
+
+// CountUtil.countLogByDay30(groupDiamo + "_self", valid_diamo, pipeline9);
+
+ }
+
+ String gmr = String.format("g{%s}:m%s:round_log", groupId, uid);
+ CountUtil.countLogByDay30(gmr, 1, pipeline9, true);
+ CountUtil.countLogByDay30(gmr + "_self", 1, pipeline9, true);
+
+ List temp = Utility.getMemberParents(jedis10, groupId, uid, true);
+ if (temp != null && temp.size() > 0) {
+
+ if (valid_count > 0) {
+
+ for (int i = 0; i < temp.size(); ++i) {
+
+ int par = temp.get(i);
+ if (par != uid) {
+ String gmv = String.format("g{%s}:m%s:valid_round", groupId, par);
+ CountUtil.countLogByDay30(gmv, valid_count, pipeline9);
+ }
+
+ String gmvp = String.format("g{%s}:m%s:valid_round:p%s", groupId, par, pid);
+ CountUtil.countLogByDay30(gmvp, valid_count, pipeline9);
+
+ String gmvp2 = String.format("g{%s}:m%s:valid_round2:p%s", groupId, par, pid);
+ CountUtil.countLogByDay30(gmvp2, valid_count, pipeline9);
+
+ boolean add_uid = (uid == par || i == 0);
+ if (add_uid == true) {
+ String gmv = String.format("g{%s}:m%s:d_valid_round", groupId, par);
+ CountUtil.countLogByDay30(gmv, valid_count, pipeline9);
+ }
+ }
+ }
+
+ for (int i = 0; i < temp.size(); ++i) {
+ int par = temp.get(i);
+ if (par != uid) {
+ gmr = String.format("g{%s}:m%s:round_log", groupId, par);
+ CountUtil.countLogByDay30(gmr, 1, pipeline9, true);
+ }
+
+ gmr = String.format("g{%s}:m%s:valid_diamo:p%s", groupId, par, pid);
+ CountUtil.countLogByDay30(gmr, valid_diamo, pipeline9);
+
+ gmr = String.format("g{%s}:m%s:all_count:p%s", groupId, par, pid);
+ CountUtil.countLogByDay30(gmr, all_count, pipeline9, true);
+
+ boolean add_uid = (uid == par || i == 0);
+ if (add_uid == true) {
+ gmr = String.format("g{%s}:m%s:d_round_log", groupId, par);
+ CountUtil.countLogByDay30(gmr, 1, pipeline9, true);
+ }
+ }
+ }
+ }
+
+ public static final void countValidAndTotal(Pipeline pipeline9, ITArray playerList, int groupId, int pid,
+ int valid_count, int valid_diamo, int all_count) {
+
+ Jedis jedis10 = Redis.use("group1_db10").getJedis();
+ try {
+
+ for (int i = 0; i < playerList.size(); i++) {
+
+ int uid = playerList.getInt(i);
+ countValidAndTotal(jedis10, pipeline9, uid, groupId, pid, valid_count, valid_diamo, all_count);
+ }
+ log.info("消耗房卡:"+valid_diamo);
+ //保存消耗房卡
+ String groupDiamo = String.format("g{%s}:valid_diamo", groupId);
+ CountUtil.countLogByDay30(groupDiamo, valid_diamo, pipeline9);
+
+ } finally {
+ jedis10.close();
+ }
+ }
+
+ /**
+ * 统计合伙人局数和赢
+ *
+ * @param jedis9
+ * @param groupId
+ * @param uid
+ * @param win
+ */
+ public static final void countRoundWin(Pipeline pipeline9, int groupId, int pid, int uid, boolean win, int score) {
+ List par_list = null;
+ Jedis jedis10 = Redis.use("group1_db10").getJedis();
+ try {
+ par_list = Utility.getMemberParents(jedis10, groupId, uid, true);
+
+ Pipeline pipeline10 = jedis10.pipelined();
+
+ if (par_list == null)
+ return;
+
+ String key = String.format("g{%s}:m%s:total_win", groupId, uid);
+ CountUtil.countLogByDay30(key, score, pipeline9);
+ CountUtil.countLogByDay30(key + "_self", score, pipeline9);
+
+ for (int i = 0; i < par_list.size(); ++i) {
+
+ int par = par_list.get(i);
+
+ boolean add_uid = (uid == par || i == 0);
+ if (add_uid == true) {
+
+ key = String.format("g{%s}:m%s:d_total_win", groupId, par);
+ CountUtil.countLogByDay30(key, score, pipeline9);
+ }
+
+ String mlk = GroupCache.genMemberListKey(groupId, par);
+ pipeline10.sadd(mlk, uid + "");
+
+ if (par != uid) {
+ key = String.format("g{%s}:m%s:total_win", groupId, par);
+ CountUtil.countLogByDay30(key, score, pipeline9);
+ }
+ }
+
+ pipeline10.sync();
+
+ } finally {
+ jedis10.close();
+ }
+ }
+
+ /**
+ * 统计合伙人体力值消耗,输赢统计
+ *
+ * @param jedis9
+ * @param groupId
+ * @param uid
+ * @param pump
+ * @param hp
+ */
+ public static final void countHpconsume(Pipeline pipeline9, int groupId, int uid, int pump, int hp) {
+ List par_list = null;
+ Jedis jedis10 = Redis.use("group1_db10").getJedis();
+ try {
+ par_list = Utility.getMemberParents(jedis10, groupId, uid, true);
+ } finally {
+ jedis10.close();
+ }
+ if (par_list == null)
+ return;
+ String key;
+
+ key = String.format("g{%s}:m%s:hp_consume_log", groupId, uid);
+ CountUtil.countLogByDay(key, hp, pipeline9);
+
+ int day = DateUtils.getBeginDay();
+ boolean self = par_list.get(0) == uid;
+ for (int i = 0; i < par_list.size(); ++i) {
+
+ int par = par_list.get(i);
+ boolean add_uid = i == 0 || (i <= 1 && self);
+
+ if (pump > 0) {
+
+ key = String.format("g%s:hp_cost:par%s_%s", groupId, par, day);
+ pipeline9.hincrBy(key, "total", pump);
+ if (add_uid) {
+ pipeline9.hincrBy(key, uid + "", pump);
+ }
+
+ pipeline9.expire(key, 3600 * 24 * 2);
+ }
+
+ if (uid != par) {
+ key = String.format("g{%s}:m%s:hp_consume_log", groupId, par);
+ CountUtil.countLogByDay(key, hp, pipeline9);
+ }
+
+ key = String.format("g%s:hp_consume:par%s_%s", groupId, par, day);
+ pipeline9.hincrBy(key, "total", hp);
+ if (add_uid) {
+ pipeline9.hincrBy(key, uid + "", hp);
+ }
+
+ pipeline9.expire(key, 3600 * 24 * 2);
+ }
+
+ }
+}
diff --git a/event_mgr/src/main/java/com/evt/mgr/handler/HandlerGroupMemberRound.java b/event_mgr/src/main/java/com/evt/mgr/handler/HandlerGroupMemberRound.java
new file mode 100644
index 0000000..820e817
--- /dev/null
+++ b/event_mgr/src/main/java/com/evt/mgr/handler/HandlerGroupMemberRound.java
@@ -0,0 +1,104 @@
+package com.evt.mgr.handler;
+
+import com.data.util.ConsumeCode;
+import com.data.util.CountUtil;
+import com.data.util.Utility;
+import com.evt.mgr.IHandler;
+import com.evt.mgr.Utils;
+import com.taurus.core.entity.ITArray;
+import com.taurus.core.entity.ITObject;
+import com.taurus.core.entity.TArray;
+import com.taurus.core.plugin.database.DataBase;
+import com.taurus.core.plugin.redis.Redis;
+import com.taurus.core.util.DateUtils;
+import com.taurus.core.util.StringUtil;
+
+import redis.clients.jedis.Jedis;
+import redis.clients.jedis.Pipeline;
+
+import java.sql.SQLException;
+
+public class HandlerGroupMemberRound implements IHandler{
+
+ @Override
+ public int process(int uid, ITObject param) throws Exception {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ private static boolean addMemberLog(int gid, int pid,int uid, int score, int win, int time, int perfectRound,int valid_count) throws SQLException {
+ String sql = String.format("{call sp_add_member_log(%s,%s,%s,%s,%s,%s,%s,%s)}",
+ gid,pid,uid,score,win,time,perfectRound,valid_count);
+ Utility.evtdbLog(gid, 2, sql);
+ return false;
+ }
+
+ @Override
+ public int processGroup(int groupId, ITObject param) throws Exception {
+
+ int pid = param.getInt("pid");
+ int score = param.getInt("score");
+ int uid = param.getInt("uid");
+ int win = param.getInt("win");
+ int time = DateUtils.getBeginDay();
+ int perfectRound = param.getInt("perfect_round");
+ int valid_count = param.getInt("valid_count");
+ int pump = param.getInt("pump");
+ int cur_hp = param.getInt("cur_hp");
+ int xipai_total = param.getInt("xi_pai_total");
+ String roomid = param.getString("room");
+ int cur_time = (int)(System.currentTimeMillis() / 1000);
+ if (param.containsKey("time"))
+ {
+ cur_time = param.getInt("time");
+ }
+
+ //ITArray param1 = TArray.newInstance();
+ //param1.addInt(groupId);
+ //param1.addInt(pid);
+ //param1.addInt(uid);
+ //param1.addInt(score - pump - xipai_total);
+ //param1.addInt(win);
+ //param1.addInt(time);
+ //param1.addInt(perfectRound);
+ //param1.addInt(valid_count);
+ //DataBase.use().prepareCallNonResult("sp_add_member_log", param1);
+// addMemberLog(groupId, pid, uid, score - pump - xipai_total, win, time, perfectRound, valid_count);
+ addMemberLog(groupId, pid, uid, score, win, time, perfectRound, valid_count);
+
+ Jedis jedis11 = Redis.use("group1_db11").getJedis();
+ int gameid = 0;
+ try {
+ String gameIdstr = jedis11.hget("g{" + groupId + "}:play:" + pid, "gameId");
+ gameid = StringUtil.isEmpty(gameIdstr)?0:Integer.parseInt(gameIdstr);
+ }finally {
+ jedis11.close();
+ }
+
+ String sql = String.format("INSERT INTO group_hp_log(gid,uid,reason,hp,cur_hp,pid,gameid,roomid,time) "
+ + "VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s)",
+ groupId,uid,ConsumeCode.HP_PUMP_TOTAL,score - pump - xipai_total,
+ cur_hp,pid,gameid,roomid,(int) (cur_time));
+ Utility.evtdb(groupId, 1, sql);
+ //DataBase.use().executeUpdate(sql);
+
+ String gmrp_key = String.format("g%s:m%s:round:p%s",groupId,uid,pid);
+ String gmr_key = String.format("g%s:m%s:round",groupId,uid);
+
+ Jedis jedis9 = Redis.use("group1_db9").getJedis();
+
+ try {
+ CountUtil.countLog(gmrp_key, 1, jedis9);
+ CountUtil.countLog(gmr_key, 1, jedis9);
+
+ Pipeline pipeline9 = jedis9.pipelined();
+ Utils.countRoundWin(pipeline9, groupId, pid, uid, win==1,score - pump);
+ pipeline9.sync();
+
+ }finally {
+ jedis9.close();
+ }
+ return 0;
+ }
+
+}
diff --git a/event_mgr/src/main/java/com/evt/mgr/handler/HandlerGroupRound.java b/event_mgr/src/main/java/com/evt/mgr/handler/HandlerGroupRound.java
new file mode 100644
index 0000000..8f99d59
--- /dev/null
+++ b/event_mgr/src/main/java/com/evt/mgr/handler/HandlerGroupRound.java
@@ -0,0 +1,72 @@
+package com.evt.mgr.handler;
+
+import com.data.util.CountUtil;
+import com.evt.mgr.IHandler;
+import com.evt.mgr.Utils;
+import com.taurus.core.entity.ITArray;
+import com.taurus.core.entity.ITObject;
+import com.taurus.core.plugin.redis.Redis;
+
+import redis.clients.jedis.Jedis;
+import redis.clients.jedis.Pipeline;
+
+public class HandlerGroupRound implements IHandler{
+
+ @Override
+ public int process(int uid, ITObject param) throws Exception {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int processGroup(int groupId, ITObject param) throws Exception {
+ int pid = param.getInt("pid");
+ int valid = param.getInt("valid");
+ ITArray playerList = param.getTArray("player_list");
+ int valid_count = param.getInt("valid_count");
+ int valid_diamo = 0;
+ int all_count = 0;
+ if (param.containsKey("valid_diamo"))
+ {
+ valid_diamo = param.getInt("valid_diamo");
+ }
+
+ if (param.containsKey("all_count"))
+ {
+ all_count = param.getInt("all_count");
+ }
+
+ String rp_key = String.format("g%s:round:p%s",groupId,pid);
+ String round_key = String.format("g%s:round",groupId);
+
+ Jedis jedis9 = Redis.use("group1_db9").getJedis();
+ try {
+ Pipeline pipeline9 = jedis9.pipelined();
+
+ CountUtil.countLog(rp_key, 1, pipeline9,false,true);
+ CountUtil.countLog(round_key, 1, pipeline9,true);
+
+ if(valid == 1) {
+
+ String valid_key = String.format("g%s:valid_room",groupId);
+ String p_valid_key = String.format("g%s:valid_room:p%s",groupId,pid);
+ CountUtil.countLogByDay(p_valid_key, 1, pipeline9,true);
+ CountUtil.countLog(valid_key, 1, pipeline9);
+ }else {
+
+ String no_valid_key = String.format("g%s:no_valid_room",groupId);
+ String p_no_valid_key = String.format("g%s:no_valid_room:p%s",groupId,pid);
+ CountUtil.countLogByDay(p_no_valid_key, 1, pipeline9,true);
+ CountUtil.countLog(no_valid_key, 1, pipeline9);
+ }
+ Utils.countValidAndTotal(pipeline9, playerList, groupId, pid, valid_count, valid_diamo, all_count);
+
+ pipeline9.sync();
+
+ }finally {
+ jedis9.close();
+ }
+ return 0;
+ }
+
+}
diff --git a/event_mgr/src/main/java/com/evt/mgr/handler/HandlerHpConsume.java b/event_mgr/src/main/java/com/evt/mgr/handler/HandlerHpConsume.java
new file mode 100644
index 0000000..3f0077a
--- /dev/null
+++ b/event_mgr/src/main/java/com/evt/mgr/handler/HandlerHpConsume.java
@@ -0,0 +1,551 @@
+package com.evt.mgr.handler;
+
+import java.sql.SQLException;
+
+import com.data.bean.GroupBean;
+import com.data.cache.GroupCache;
+import com.data.cache.GroupMemberCache;
+import com.data.util.ConsumeCode;
+import com.data.util.CountUtil;
+import com.data.util.Utility;
+import com.evt.mgr.IHandler;
+import com.taurus.core.entity.ITArray;
+import com.taurus.core.entity.ITObject;
+import com.taurus.core.entity.TArray;
+import com.taurus.core.plugin.database.DataBase;
+import com.taurus.core.plugin.redis.Redis;
+import com.taurus.core.util.Logger;
+import com.taurus.core.util.StringUtil;
+
+import redis.clients.jedis.Jedis;
+import redis.clients.jedis.Pipeline;
+
+public class HandlerHpConsume implements IHandler{
+ static Logger log = Logger.getLogger(HandlerHpConsume.class);
+ final static String DB = "group1_db10";
+
+ private static boolean hpConsume(int gid, int uid,int pid, int hp,int cur_hp,int reason, String roomid, int time,String desc) throws SQLException {
+ String sql = String.format("{call sp_update_hp(%s,%s,%s,%s,%s,%s,'%s',%s,'%s')}",
+ gid,uid,hp,cur_hp,reason,pid,roomid,time,desc);
+ Utility.evtdb(gid, 2, sql);
+ return false;
+ }
+
+ @Override
+ public int process(int uid, ITObject param) throws Exception {
+ return 0;
+ }
+
+ private void to_reward(Pipeline pipeline, int uid, String prs,int rewardType, int valueType, int real_pump, int pump,int groupId,int pid,String roomid,int time,int max_player) throws Exception {
+
+ int useValue = 0;
+ if(StringUtil.isNotEmpty(prs)) {
+
+ int round = 100 / max_player;
+ ITArray list = TArray.newFromJsonData(prs);
+
+ for(int i=list.size()-1;i>=0;--i) {
+
+ ITObject obj1 = list.getTObject(i);
+ int parentId = obj1.getInt("p");
+ int rewardPercent = 0;
+ if (obj1.containsKey("r"))
+ {
+ rewardPercent = obj1.getInt("r");
+ }
+ int rv = 0;
+ if(i > 0) {
+ ITObject obj2 = list.getTObject(i - 1);
+ if (!obj2.containsKey("r"))
+ {
+ rv =rewardPercent - 0;
+ }
+ else {
+ rv =rewardPercent -obj2.getInt("r");
+ }
+ }else {
+
+ rv=rewardPercent;
+ }
+ int reward_value = rv;
+ if(valueType == 1) {
+ reward_value = Math.round(pump * (rv / 100f));
+ }
+ else {
+ if(rewardType == 2) {
+ reward_value = reward_value / max_player;
+ }
+ }
+
+ if (reward_value < 0)
+ {
+ continue;
+ }
+
+ String key = String.format("g{%s}:m%s:reward_hp", groupId,parentId);
+ Redis.use(DB).incrBy(key, reward_value);
+ String rewardsql = String.format("update group_member set reward_hp = %s where uid = %s AND groupId = %s", Redis.use(DB).get(key), parentId,groupId);
+ Utility.evtdb(groupId, 1, rewardsql);
+ //String all_key = String.format("g{%s}:m%s:all_reward_hp", groupId,parentId);
+ //Redis.use(DB).incrBy(all_key, reward_value);
+ useValue += reward_value;
+
+ Jedis jedis9 = Redis.use("group1_db9").getJedis();
+ try {
+ String desc = "" + uid;
+ long cur_hp = CountUtil.countLogByDay3(String.format("g%s:hp_reward:m%s",groupId,parentId), reward_value, jedis9);
+
+ Jedis jedis11 = Redis.use("group1_db11").getJedis();
+ int gameid = 0;
+ try {
+ String gameIdstr = jedis11.hget("g{" + groupId + "}:play:" + pid, "gameId");
+ gameid = StringUtil.isEmpty(gameIdstr)?0:Integer.parseInt(gameIdstr);
+ }finally {
+ jedis11.close();
+ }
+
+ String sql = String.format("INSERT INTO group_hp_log(gid,uid,reason,hp,cur_hp,pid,gameid,roomid,time,round, info) "
+ + "VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)", groupId,parentId,ConsumeCode.HP_PARTNER_REWARD,reward_value,cur_hp,pid,gameid,roomid,time,round, desc);
+ DataBase.use().executeUpdate(sql);
+ }finally {
+ jedis9.close();
+ }
+
+ // 记录代理每天的推广奖励
+ CountUtil.countLogByDay30(key, reward_value, pipeline);
+
+ key = String.format("g{%s}:m%s:reward_log", groupId,parentId);
+ CountUtil.countLogByDay30(key, reward_value, pipeline);
+
+ key = String.format("g{%s}:m%s:p%s:reward_log", groupId,parentId,pid);
+ CountUtil.countLogByDay30(key, reward_value, pipeline);
+
+ // 记录每个人对上级的推广奖励是多少
+ key = String.format("g{%s}:m%s:reward_log_to:par%s", groupId,uid, parentId);
+ CountUtil.countLogByDay30(key, reward_value, pipeline);
+
+ boolean add_uid = (uid == parentId || i == 0);
+ if(add_uid == true) {
+ key = String.format("g{%s}:m%s:d_reward", groupId,parentId);
+ CountUtil.countLogByDay30(key, reward_value, pipeline);
+ }
+
+ if(i>0) {
+
+ for(int j = i - 1; j >= 0; j--) {
+
+ ITObject obj2 = list.getTObject(j);
+ int temp = obj2.getInt("p");
+ if(temp != uid) {
+ key = String.format("g{%s}:m%s:reward_log_to:par%s", groupId,temp, parentId);
+ CountUtil.countLogByDay30(key, reward_value, pipeline);
+ }
+ }
+ }
+
+
+ //某个玩法的抽水总值
+ CountUtil.countLogByDay30(String.format("g%s:hp_cost:m%s:p%s",groupId,parentId,pid),pump,pipeline);
+
+ CountUtil.countLogByDay30(String.format("g%s:hp_reward",groupId), reward_value, pipeline);
+ }
+ }
+
+ GroupBean gb = GroupCache.getGroup(groupId);
+ if (gb != null) {
+ int round = 100 / max_player;
+ int leftValue = real_pump - useValue;
+ String key = String.format("g{%s}:m%s:reward_hp", groupId,gb.owner);
+ Redis.use(DB).incrBy(key, leftValue);
+ String rewardsql = String.format("update group_member set reward_hp = %s where uid = %s AND groupId = %s", Redis.use(DB).get(key), gb.owner,groupId);
+ Utility.evtdb(groupId, 1, rewardsql);
+ //String all_key = String.format("g{%s}:m%s:all_reward_hp", groupId,gb.owner);
+ //Redis.use(DB).incrBy(all_key, leftValue);
+ // 记录代理每天的推广奖励
+ CountUtil.countLogByDay30(key, leftValue, pipeline);
+
+ key = String.format("g{%s}:m%s:reward_log", groupId,gb.owner);
+ CountUtil.countLogByDay30(key, leftValue, pipeline);
+
+ key = String.format("g{%s}:m%s:p%s:reward_log", groupId,gb.owner,pid);
+ CountUtil.countLogByDay30(key, leftValue, pipeline);
+
+ // 记录每个人对上级的推广奖励是多少
+ key = String.format("g{%s}:m%s:reward_log_to:par%s", groupId,uid, gb.owner);
+ CountUtil.countLogByDay30(key, leftValue, pipeline);
+
+ boolean add_uid = (uid == gb.owner);
+ if(add_uid == true) {
+ key = String.format("g{%s}:m%s:d_reward", groupId,gb.owner);
+ CountUtil.countLogByDay30(key, leftValue, pipeline);
+ }
+ Jedis jedis9 = Redis.use("group1_db9").getJedis();
+ try {
+ String desc = "" + uid;
+ long cur_hp = CountUtil.countLogByDay3(String.format("g%s:hp_reward:m%s",groupId,gb.owner), leftValue, jedis9);
+ Jedis jedis11 = Redis.use("group1_db11").getJedis();
+ int gameid = 0;
+ try {
+ String gameIdstr = jedis11.hget("g{" + groupId + "}:play:" + pid, "gameId");
+ gameid = StringUtil.isEmpty(gameIdstr)?0:Integer.parseInt(gameIdstr);
+ }finally {
+ jedis11.close();
+ }
+
+ String sql = String.format("INSERT INTO group_hp_log(gid,uid,reason,hp,cur_hp,pid,gameid,roomid,time,round,info) "
+ + "VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)", groupId,gb.owner,ConsumeCode.HP_PARTNER_REWARD,leftValue,cur_hp,pid,gameid,roomid,time,round,desc);
+ DataBase.use().executeUpdate(sql);
+ }finally {
+ jedis9.close();
+ }
+ }
+ }
+
+ private void xipai_to_reward(Pipeline pipeline, int uid, String prs,int rewardType, int valueType, int real_pump, int pump,int groupId,int pid,String roomid,int time,int max_player) throws Exception {
+
+ int useValue = 0;
+ if(StringUtil.isNotEmpty(prs)) {
+
+ int round = 100 / max_player;
+ ITArray list = TArray.newFromJsonData(prs);
+
+ for(int i=list.size()-1;i>=0;--i) {
+
+ ITObject obj1 = list.getTObject(i);
+ int parentId = obj1.getInt("p");
+ int rewardPercent = 0;
+ if (obj1.containsKey("x"))
+ {
+ rewardPercent = obj1.getInt("x");
+ }
+ int rv = 0;
+ if(i > 0) {
+ ITObject obj2 = list.getTObject(i - 1);
+ if (!obj2.containsKey("x"))
+ {
+ rv = rewardPercent - 0;
+ }
+ else {
+ rv = rewardPercent -obj2.getInt("x");
+ }
+ }else {
+
+ rv=rewardPercent;
+ }
+ int reward_value = rv;
+ if(valueType == 1) {
+ reward_value = Math.round(pump * (rv / 100f));
+ }
+
+ if (reward_value < 0)
+ {
+ continue;
+ }
+
+ String key = String.format("g{%s}:m%s:reward_hp", groupId,parentId);
+ Redis.use(DB).incrBy(key, reward_value);
+ String rewardsql = String.format("update group_member set reward_hp = %s where uid = %s AND groupId = %s", Redis.use(DB).get(key), parentId,groupId);
+ Utility.evtdb(groupId, 1, rewardsql);
+ //String all_key = String.format("g{%s}:m%s:all_reward_hp", groupId,parentId);
+ //Redis.use(DB).incrBy(all_key, reward_value);
+ useValue += reward_value;
+
+ Jedis jedis9 = Redis.use("group1_db9").getJedis();
+ try {
+ String desc = "" + uid;
+ long cur_hp = CountUtil.countLogByDay3(String.format("g%s:hp_reward:m%s",groupId,parentId), reward_value, jedis9);
+ Jedis jedis11 = Redis.use("group1_db11").getJedis();
+ int gameid = 0;
+ try {
+ String gameIdstr = jedis11.hget("g{" + groupId + "}:play:" + pid, "gameId");
+ gameid = StringUtil.isEmpty(gameIdstr)?0:Integer.parseInt(gameIdstr);
+ }finally {
+ jedis11.close();
+ }
+ String sql = String.format("INSERT INTO group_hp_log(gid,uid,reason,hp,cur_hp,pid,gameid,roomid,time,round,info) "
+ + "VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)", groupId,parentId,ConsumeCode.HP_PARTNER_XIPAI_REWARD,reward_value,cur_hp,pid,gameid,roomid,time,round,desc);
+ DataBase.use().executeUpdate(sql);
+ }finally {
+ jedis9.close();
+ }
+
+ // 记录代理每天的推广奖励
+ CountUtil.countLogByDay30(key, reward_value, pipeline);
+
+ key = String.format("g{%s}:m%s:xipai_reward_log", groupId,parentId);
+ CountUtil.countLogByDay30(key, reward_value, pipeline);
+
+ key = String.format("g{%s}:m%s:p%s:xipai_reward_log", groupId,parentId,pid);
+ CountUtil.countLogByDay30(key, reward_value, pipeline);
+
+ // 记录每个人对上级的推广奖励是多少
+ key = String.format("g{%s}:m%s:xipai_reward_log_to:par%s", groupId,uid, parentId);
+ CountUtil.countLogByDay30(key, reward_value, pipeline);
+
+ boolean add_uid = (uid == parentId || i == 0);
+ if(add_uid == true) {
+ key = String.format("g{%s}:m%s:d_xipai_reward", groupId,parentId);
+ CountUtil.countLogByDay30(key, reward_value, pipeline);
+ }
+
+ if(i>0) {
+
+ for(int j = i - 1; j >= 0; j--) {
+
+ ITObject obj2 = list.getTObject(j);
+ int temp = obj2.getInt("p");
+ if(temp != uid) {
+ key = String.format("g{%s}:m%s:xipai_reward_log_to:par%s", groupId,temp, parentId);
+ CountUtil.countLogByDay30(key, reward_value, pipeline);
+ }
+ }
+ }
+
+ //某个玩法的抽水总值
+ CountUtil.countLogByDay30(String.format("g%s:xipai_hp_cost:m%s:p%s",groupId,parentId,pid),pump,pipeline);
+
+ CountUtil.countLogByDay30(String.format("g%s:xipai_hp_reward",groupId), reward_value, pipeline);
+ }
+ }
+ GroupBean gb = GroupCache.getGroup(groupId);
+ if (gb != null) {
+ int round = 100 / max_player;
+ int leftValue = real_pump - useValue;
+ String key = String.format("g{%s}:m%s:reward_hp", groupId,gb.owner);
+ Redis.use(DB).incrBy(key, leftValue);
+ String rewardsql = String.format("update group_member set reward_hp = %s where uid = %s AND groupId = %s", Redis.use(DB).get(key), gb.owner,groupId);
+ Utility.evtdb(groupId, 1, rewardsql);
+ //String all_key = String.format("g{%s}:m%s:all_reward_hp", groupId,gb.owner);
+ //Redis.use(DB).incrBy(all_key, leftValue);
+ // 记录代理每天的推广奖励
+ CountUtil.countLogByDay30(key, leftValue, pipeline);
+
+ key = String.format("g{%s}:m%s:xipai_reward_log", groupId,gb.owner);
+ CountUtil.countLogByDay30(key, leftValue, pipeline);
+
+ key = String.format("g{%s}:m%s:p%s:xipai_reward_log", groupId,gb.owner,pid);
+ CountUtil.countLogByDay30(key, leftValue, pipeline);
+
+ // 记录每个人对上级的推广奖励是多少
+ key = String.format("g{%s}:m%s:xipai_reward_log_to:par%s", groupId,uid, gb.owner);
+ CountUtil.countLogByDay30(key, leftValue, pipeline);
+
+ boolean add_uid = (uid == gb.owner);
+ if(add_uid == true) {
+ key = String.format("g{%s}:m%s:d_xipai_reward", groupId,gb.owner);
+ CountUtil.countLogByDay30(key, leftValue, pipeline);
+ }
+ Jedis jedis9 = Redis.use("group1_db9").getJedis();
+ try {
+ String desc = "" + uid;
+ long cur_hp = CountUtil.countLogByDay3(String.format("g%s:hp_reward:m%s",groupId,gb.owner), leftValue, jedis9);
+ Jedis jedis11 = Redis.use("group1_db11").getJedis();
+ int gameid = 0;
+ try {
+ String gameIdstr = jedis11.hget("g{" + groupId + "}:play:" + pid, "gameId");
+ gameid = StringUtil.isEmpty(gameIdstr)?0:Integer.parseInt(gameIdstr);
+ }finally {
+ jedis11.close();
+ }
+ String sql = String.format("INSERT INTO group_hp_log(gid,uid,reason,hp,cur_hp,pid,gameid,roomid,time,round,info) "
+ + "VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)", groupId,gb.owner,ConsumeCode.HP_PARTNER_XIPAI_REWARD,leftValue,cur_hp,pid,gameid,roomid,time,round,desc);
+ DataBase.use().executeUpdate(sql);
+ }finally {
+ jedis9.close();
+ }
+ }
+ }
+
+ private void to_mengzhu_reward(Pipeline pipeline, int uid, String prs,int rewardType, int valueType, int real_pump, int pump,int groupId,int pid,String roomid,int time,int max_player) throws Exception {
+ GroupBean gb = GroupCache.getGroup(groupId);
+ if (gb != null) {
+ int round = 100 / max_player;
+ int leftValue = real_pump;
+ String key = String.format("g{%s}:m%s:reward_hp", groupId,gb.owner);
+ Redis.use(DB).incrBy(key, leftValue);
+ String rewardsql = String.format("update group_member set reward_hp = %s where uid = %s AND groupId = %s", Redis.use(DB).get(key), gb.owner,groupId);
+ Utility.evtdb(groupId, 1, rewardsql);
+ //String all_key = String.format("g{%s}:m%s:all_reward_hp", groupId,gb.owner);
+ //Redis.use(DB).incrBy(all_key, leftValue);
+ // 记录代理每天的推广奖励
+ CountUtil.countLogByDay30(key, leftValue, pipeline);
+
+ key = String.format("g{%s}:m%s:reward_log", groupId,gb.owner);
+ CountUtil.countLogByDay30(key, leftValue, pipeline);
+
+ key = String.format("g{%s}:m%s:p%s:reward_log", groupId,gb.owner,pid);
+ CountUtil.countLogByDay30(key, leftValue, pipeline);
+
+ // 记录每个人对上级的推广奖励是多少
+ key = String.format("g{%s}:m%s:reward_log_to:par%s", groupId,uid, gb.owner);
+ CountUtil.countLogByDay30(key, leftValue, pipeline);
+
+ boolean add_uid = (uid == gb.owner);
+ if(add_uid == true) {
+ key = String.format("g{%s}:m%s:d_reward", groupId,gb.owner);
+ CountUtil.countLogByDay30(key, leftValue, pipeline);
+ }
+
+ Jedis jedis9 = Redis.use("group1_db9").getJedis();
+ try {
+ String desc = "" + uid;
+ long cur_hp = CountUtil.countLogByDay3(String.format("g%s:hp_reward:m%s",groupId,gb.owner), leftValue, jedis9);
+ Jedis jedis11 = Redis.use("group1_db11").getJedis();
+ int gameid = 0;
+ try {
+ String gameIdstr = jedis11.hget("g{" + groupId + "}:play:" + pid, "gameId");
+ gameid = StringUtil.isEmpty(gameIdstr)?0:Integer.parseInt(gameIdstr);
+ }finally {
+ jedis11.close();
+ }
+ String sql = String.format("INSERT INTO group_hp_log(gid,uid,reason,hp,cur_hp,pid,gameid,roomid,time,round,info) "
+ + "VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)", groupId,gb.owner,ConsumeCode.HP_PARTNER_REWARD,leftValue,cur_hp,pid,gameid,roomid,time,round,desc);
+ DataBase.use().executeUpdate(sql);
+ }finally {
+ jedis9.close();
+ }
+ }
+ }
+
+ @Override
+ public int processGroup(int groupId, ITObject param) throws Exception {
+ int uid = param.getInt("uid");
+ try {
+ int hp = param.getInt("hp");
+ int cur_hp = param.getInt("cur_hp");
+ boolean is_pump = param.containsKey("pump");
+ int pump = 0;
+ String roomid = param.getString("room");
+ int pid = param.getInt("pid");
+ int time = param.getInt("time");
+ int reward_value = 0;
+ int xipai_reward_value = 0;
+ int max_player = 0;
+ int rewardValueType = 0;
+ int xipai_rewardValueType = 0;
+ int rewardType = 1;
+ int xipai_rewardType = 1;
+
+ boolean is_xipai = param.containsKey("xipai");
+ int xipai = 0;
+
+ String prs =null;
+ if(is_pump) {
+ pump = param.getInt("pump");
+ max_player = param.getInt("max_player");
+ if(param.containsKey("reward_value")) {
+ reward_value = param.getInt("reward_value");
+ prs = param.getString("prs");
+ }
+ if(param.containsKey("reward_type")) {
+ rewardType = param.getInt("reward_type");
+ }
+ if(param.containsKey("rewardValueType")) {
+ rewardValueType = param.getInt("rewardValueType");
+ }
+ }
+
+ if (is_xipai)
+ {
+ xipai = param.getInt("xipai");
+ max_player = param.getInt("max_player");
+ if(param.containsKey("xipai_reward_value")) {
+ xipai_reward_value = param.getInt("xipai_reward_value");
+ prs = param.getString("prs");
+ }
+ if(param.containsKey("xipai_reward_type")) {
+ xipai_rewardType = param.getInt("xipai_reward_type");
+ }
+ if(param.containsKey("xipai_rewardValueType")) {
+ xipai_rewardValueType = param.getInt("xipai_rewardValueType");
+ }
+ }
+
+ if (param.containsKey("hp_than_max_value"))
+ {
+ int more_hp = param.getInt("hp_than_max_value");
+ String gm_key = GroupMemberCache.genKey(groupId, uid);
+ String bank_hp = Redis.use("group1_db10").hget(gm_key, "bank_hp");
+ String sql = String.format("{call sp_bank_hp(%s,%s,%s,%s)}", groupId, uid, more_hp, cur_hp);
+ Utility.evtdb(groupId, 2, sql);
+ String sql2 = String.format("update group_member set bank_hp = %s where uid = %s AND groupId = %s", bank_hp, uid, groupId);
+ Utility.evtdb(groupId, 1, sql2);
+ }
+
+ String desc = param.getString("desc");
+ desc = StringUtil.isNotEmpty(desc) ? desc : StringUtil.Empty;
+ if(hp!=0) {
+ hpConsume(groupId, uid,pid, hp,cur_hp + pump,ConsumeCode.HP_CLEARING, roomid,time, desc);
+ }
+
+ Jedis jedis9 = Redis.use("group1_db9").getJedis();
+ try {
+
+ String key = String.format("g%s:m%s:consume_hp", groupId,uid);
+ if(hp!=0) {
+ CountUtil.countLogByDay(key, hp, jedis9, 691200);
+ }
+
+ if(pump>0) {
+
+ CountUtil.countLogByDay(key, -pump, jedis9, 691200);
+ time += 1;
+ hpConsume(groupId, uid,pid, -pump,cur_hp, ConsumeCode.HP_PUMP, roomid,time, desc);
+
+ CountUtil.countLog(String.format("g%s:hp_cost",groupId), pump, jedis9);
+ CountUtil.countLogByDay(String.format("g%s:hp_cost:p%s",groupId,pid),pump,jedis9);
+ CountUtil.countLogByDay(String.format("g%s:hp_cost:m%s",groupId,uid),pump,jedis9);
+ }
+
+ if (xipai > 0)
+ {
+ CountUtil.countLogByDay(key, -xipai, jedis9, 691200);
+ time += 1;
+ hpConsume(groupId, uid,pid, -xipai,cur_hp, ConsumeCode.HP_XIPAI_PUMP, roomid,time, desc);
+
+ CountUtil.countLog(String.format("g%s:hp_cost",groupId), xipai, jedis9);
+ CountUtil.countLogByDay(String.format("g%s:hp_cost:p%s",groupId,pid),xipai,jedis9);
+ CountUtil.countLogByDay(String.format("g%s:hp_cost:m%s",groupId,uid),xipai,jedis9);
+ }
+
+ Pipeline pipeline = jedis9.pipelined();
+ if(reward_value > 0 || (rewardValueType == 2 && is_pump)) {
+
+ time += 1;
+ to_reward(pipeline,uid,prs,rewardType,rewardValueType, pump, reward_value ,groupId,pid,roomid,time,max_player);
+ }
+ /*
+ else {
+ if (is_pump && pump > 0)
+ {
+ log.error("pump to_mengzhu_reward:"+pump+" uid:" + uid + " groupId:" + groupId);
+ to_mengzhu_reward(pipeline,uid,prs,rewardType,rewardValueType, pump, reward_value ,groupId,pid,roomid,time,max_player);
+ }
+ }
+ */
+ if(xipai_reward_value > 0 || (xipai_rewardValueType == 2 && is_xipai)) {
+
+ time += 1;
+ xipai_to_reward(pipeline,uid,prs,xipai_rewardType,xipai_rewardValueType, xipai, xipai_reward_value ,groupId,pid,roomid,time,max_player);
+ }
+ /*
+ else {
+ if (is_xipai && xipai > 0)
+ {
+ log.error("xipai to_mengzhu_reward:"+pump+" uid:" + uid + " groupId:" + groupId);
+ to_mengzhu_reward(pipeline,uid,prs,xipai_rewardType,xipai_rewardValueType, xipai, xipai_reward_value ,groupId,pid,roomid,time,max_player);
+ }
+ }
+ */
+ pipeline.sync();
+
+ }finally {
+ jedis9.close();
+ }
+ }catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ return 0;
+ }
+}
diff --git a/event_mgr/src/main/java/com/evt/mgr/handler/HandlerLose.java b/event_mgr/src/main/java/com/evt/mgr/handler/HandlerLose.java
new file mode 100644
index 0000000..6cf37c8
--- /dev/null
+++ b/event_mgr/src/main/java/com/evt/mgr/handler/HandlerLose.java
@@ -0,0 +1,18 @@
+package com.evt.mgr.handler;
+
+import com.evt.mgr.IHandler;
+import com.taurus.core.entity.ITObject;
+
+public class HandlerLose implements IHandler{
+
+ @Override
+ public int process(int uid, ITObject param) throws Exception {
+ return 0;
+ }
+
+ @Override
+ public int processGroup(int groupId, ITObject param) throws Exception {
+ return 0;
+ }
+
+}
diff --git a/event_mgr/src/main/java/com/evt/mgr/handler/HandlerOver.java b/event_mgr/src/main/java/com/evt/mgr/handler/HandlerOver.java
new file mode 100644
index 0000000..138772e
--- /dev/null
+++ b/event_mgr/src/main/java/com/evt/mgr/handler/HandlerOver.java
@@ -0,0 +1,90 @@
+package com.evt.mgr.handler;
+
+import java.awt.Event;
+
+import com.data.cache.GroupMemberCache;
+import com.evt.mgr.EventServer;
+import com.evt.mgr.IHandler;
+import com.taurus.core.entity.ITArray;
+import com.taurus.core.entity.ITObject;
+import com.taurus.core.plugin.database.DataBase;
+import com.taurus.core.plugin.redis.Redis;
+import com.taurus.core.util.StringUtil;
+import redis.clients.jedis.Jedis;
+
+public class HandlerOver implements IHandler {
+
+ public static final int _SHARE_NUM = 20;
+
+ private static void share(String id) throws Exception {
+ if (!Redis.use("group1_db1").sismember("shares", id)) {
+ return;
+ }
+ String sql = "SELECT succ,playtimes FROM shares WHERE uid = " + id;
+ ITArray resultArray = DataBase.use().executeQueryByTArray(sql);
+ if (resultArray.size() == 0) {
+ return;
+ }
+ ITObject dbData = resultArray.getTObject(0);
+ if (dbData.getInt("succ") != 0) {
+ Redis.use("group1_db1").srem("shares", id);
+ return;
+ }
+ int playTimes = dbData.getInt("playtimes") + 1;
+ dbData.putInt("playtimes", playTimes);
+ if (playTimes >= _SHARE_NUM) {
+ dbData.putInt("succ", 1);
+ Redis.use("group1_db1").srem("shares", id);
+ }
+ DataBase.use().update("shares", dbData, "uid=" + id);
+
+ }
+
+ @Override
+ public int process(int uid, ITObject param) throws Exception {
+ int is_rec = param.getInt("is_rec");
+ if (is_rec == 1) {
+ String roomid = param.getString("roomid");
+ String rec_key = param.getString("rec_key");
+ int gid = param.containsKey("gid") ? param.getInt("gid") : 0;
+ int time = param.getInt("time");
+ int par = 0;
+ if (gid > 0) {
+ String gm_key = GroupMemberCache.genKey(gid, uid);
+ String parentId = Redis.use("group1_db10").hget(gm_key, "parentId");
+ par = StringUtil.isEmpty(parentId) ? 0 : Integer.parseInt(parentId);
+ }
+
+
+ String sql = String.format(
+ "insert into room_rec_log(roomid,gid,uid,rec_key,time,parentId) values('%s',%s,%s,'%s',%s,%s)",
+ roomid, gid, uid, rec_key, time, par);
+ DataBase.use().executeUpdate(sql);
+ ITArray array = param.getTArray("tagIds");
+ EventServer.log.info("param:" + param);
+ EventServer.log.info("array:" + array);
+
+ String sqls = "";
+ for (int i = 0; i < array.size(); i++) {
+ EventServer.log.info("array.getInt(i):" + array.getInt(i));
+
+ sqls = String.format(
+ "insert into room_rec_log_new(roomid,gid,uid,rec_key,time,parentId,tagId) values('%s',%s,%s,'%s',%s,%s,%s)",
+ roomid, gid, uid, rec_key, time, par, array.getInt(i));
+ EventServer.log.info("sqls:" + sqls);
+
+ DataBase.use().executeUpdate(sqls);
+ }
+
+ }
+
+ share(uid + "");
+ return 0;
+ }
+
+ @Override
+ public int processGroup(int groupId, ITObject param) throws Exception {
+ return 0;
+ }
+
+}
diff --git a/event_mgr/src/main/java/com/evt/mgr/handler/HandlerPay.java b/event_mgr/src/main/java/com/evt/mgr/handler/HandlerPay.java
new file mode 100644
index 0000000..5a8f32a
--- /dev/null
+++ b/event_mgr/src/main/java/com/evt/mgr/handler/HandlerPay.java
@@ -0,0 +1,84 @@
+package com.evt.mgr.handler;
+
+import java.util.ArrayList;
+
+import com.data.cache.AccountCache;
+import com.data.util.ConsumeCode;
+import com.data.util.Utility;
+import com.evt.mgr.EventController;
+import com.evt.mgr.IHandler;
+import com.taurus.core.entity.ITObject;
+import com.taurus.core.plugin.redis.Redis;
+import com.taurus.core.util.Logger;
+
+import redis.clients.jedis.Jedis;
+
+public class HandlerPay implements IHandler{
+
+ int reason;
+ boolean isPay;
+ public HandlerPay(int reason,boolean isPay) {
+ this.reason = reason;
+ this.isPay = isPay;
+ }
+ private static final Logger log = Logger.getLogger(HandlerPay.class);
+
+ @Override
+ public int process(int uid, ITObject param) throws Exception {
+ int pay = param.getInt("pay");
+ if(pay==0) {
+ return 0;
+ }
+ int result = 1;
+ int gameId =param.getInt("game");
+ int groupId = 0;
+ int pid = 0;
+ if(param.containsKey("group")) {
+ groupId = param.getInt("group");
+ }
+ if(param.containsKey("pid")) {
+ pid = param.getInt("pid");
+ }
+
+ if(reason == ConsumeCode.DIAMO_JOIN_ROOM) {
+ pay = Math.abs(pay);
+ }
+ if(reason == ConsumeCode.DIAMO_REFUND) {
+ pay = -Math.abs(pay);
+ }
+ if(reason == ConsumeCode.DIAMO_ADD) {
+ pay = -pay;
+ }
+
+ if(isPay) {
+ int cur_diamo = param.getInt("diamo");
+ EventController.payDiamo(uid, pay, cur_diamo, reason, gameId, groupId, pid);
+ result = 0;
+ }else {
+ String session = AccountCache.genKey(uid);
+ Jedis jedis0 = Redis.use("group1_db0").getJedis();
+ try {
+ ArrayList result_list = Utility.payDiamo(jedis0, session,pay);
+ if(result_list!=null) {
+ result = result_list.get(0).intValue();
+ if(result ==0) {
+ long cur_diamo = result_list.get(1);
+ EventController.payDiamo(uid, pay, (int)cur_diamo, reason, gameId, groupId, pid);
+ }
+ result = 0;
+ }
+ }finally {
+ jedis0.close();
+ }
+ }
+
+ return result;
+ }
+
+ @Override
+ public int processGroup(int groupId, ITObject param) throws Exception {
+
+ return 0;
+ }
+
+}
diff --git a/event_mgr/src/main/java/com/evt/mgr/handler/HandlerWin.java b/event_mgr/src/main/java/com/evt/mgr/handler/HandlerWin.java
new file mode 100644
index 0000000..dffc80f
--- /dev/null
+++ b/event_mgr/src/main/java/com/evt/mgr/handler/HandlerWin.java
@@ -0,0 +1,18 @@
+package com.evt.mgr.handler;
+
+import com.evt.mgr.IHandler;
+import com.taurus.core.entity.ITObject;
+
+public class HandlerWin implements IHandler{
+
+ @Override
+ public int process(int uid, ITObject param) throws Exception {
+ return 0;
+ }
+
+ @Override
+ public int processGroup(int groupId, ITObject param) throws Exception {
+ return 0;
+ }
+
+}
diff --git a/event_mgr/src/main/java/com/evt/mgr/job/CleanGroupLogJob.java b/event_mgr/src/main/java/com/evt/mgr/job/CleanGroupLogJob.java
new file mode 100644
index 0000000..a0ed0d9
--- /dev/null
+++ b/event_mgr/src/main/java/com/evt/mgr/job/CleanGroupLogJob.java
@@ -0,0 +1,94 @@
+package com.evt.mgr.job;
+
+import java.util.List;
+import java.util.Set;
+
+import com.taurus.core.plugin.database.DataBase;
+import com.taurus.core.util.DateUtils;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobKey;
+
+import com.data.util.EventType;
+import com.data.util.Utility;
+import com.evt.mgr.GroupPublisherService;
+import com.taurus.core.entity.ITArray;
+import com.taurus.core.entity.TArray;
+import com.taurus.core.plugin.redis.Redis;
+import com.taurus.core.plugin.redis.RedisLock;
+import com.taurus.core.util.Logger;
+import com.taurus.core.util.StringUtil;
+
+import redis.clients.jedis.Jedis;
+import redis.clients.jedis.ScanParams;
+import redis.clients.jedis.ScanResult;
+
+public class CleanGroupLogJob implements Job {
+ private Logger logger = Logger.getLogger(CleanGroupLogJob.class);
+
+ public CleanGroupLogJob() {
+
+ }
+
+ /**
+ * 清除亲友圈中无效的房间
+ */
+ private void cleanGroupMemberLog() {
+ int time = DateUtils.getBeginDay() - 5 * 24 * 3600;
+ String deleteSql = String.format("delete from group_member_log where time < %s", time);
+ try {
+ long startTime = System.currentTimeMillis();
+ DataBase.use().executeUpdate(deleteSql);
+// logger.info("cleanGroupMemberLog use time:"+(System.currentTimeMillis()-startTime)+ " " + deleteSql);
+ }
+ catch (Exception e)
+ {
+ logger.error(e);
+ }
+ }
+
+ private void CleanGroupHpLog() {
+ int time = DateUtils.getBeginDay() - 20 * 24 * 3600;
+ String deleteSql3 = String.format("delete from group_hp_log where time < %s limit 1000000", time);
+ try {
+ long startTime = System.currentTimeMillis();
+ DataBase.use().executeUpdate(deleteSql3);
+// logger.info("CleanGroupHpLog use time:"+(System.currentTimeMillis()-startTime)+ " " + deleteSql3);
+ }
+ catch (Exception e)
+ {
+ logger.error(e);
+ }
+ }
+
+ private void CleanRecRoomLog() {
+ int time = DateUtils.getBeginDay() - 5 * 24 * 3600;
+ String deleteSql2 = String.format("delete from room_rec_log where time < %s limit 1000000", time);
+ try {
+ long startTime = System.currentTimeMillis();
+ DataBase.use().executeUpdate(deleteSql2);
+// logger.info("CleanRecRoomLog use time:"+(System.currentTimeMillis()-startTime) + " " + deleteSql2);
+ }
+ catch (Exception e)
+ {
+ logger.error(e);
+ }
+ }
+
+ @Override
+ public void execute(JobExecutionContext context) {
+ JobKey jobKey = context.getJobDetail().getKey();
+ if(jobKey.getName().equals("clean_group_member_log")) {
+ logger.info("执行成功" + jobKey.getName());
+ cleanGroupMemberLog();
+ }
+ if(jobKey.getName().equals("clean_group_hp_log")) {
+ logger.info("执行成功" + jobKey.getName());
+ CleanGroupHpLog();
+ }
+ if(jobKey.getName().equals("clean_rec_room_log")) {
+ logger.info("执行成功" + jobKey.getName());
+ CleanRecRoomLog();
+ }
+ }
+}
diff --git a/event_mgr/src/main/java/com/evt/mgr/job/CleanTimeOutRoomJob.java b/event_mgr/src/main/java/com/evt/mgr/job/CleanTimeOutRoomJob.java
new file mode 100644
index 0000000..e500016
--- /dev/null
+++ b/event_mgr/src/main/java/com/evt/mgr/job/CleanTimeOutRoomJob.java
@@ -0,0 +1,323 @@
+package com.evt.mgr.job;
+
+import java.util.List;
+import java.util.Set;
+
+import com.taurus.core.util.DateUtils;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobKey;
+
+import com.data.util.EventType;
+import com.data.util.Utility;
+import com.evt.mgr.GroupPublisherService;
+import com.taurus.core.entity.ITArray;
+import com.taurus.core.entity.TArray;
+import com.taurus.core.plugin.redis.Redis;
+import com.taurus.core.plugin.redis.RedisLock;
+import com.taurus.core.util.Logger;
+import com.taurus.core.util.StringUtil;
+
+import redis.clients.jedis.Jedis;
+import redis.clients.jedis.ScanParams;
+import redis.clients.jedis.ScanResult;
+
+public class CleanTimeOutRoomJob implements Job{
+
+ private Logger logger = Logger.getLogger(CleanTimeOutRoomJob.class);
+
+ public CleanTimeOutRoomJob() {
+
+ }
+
+ private void deleteRoomFromRedis(String tag_key,Jedis jedis0) {
+
+ RedisLock room_lock = new RedisLock(tag_key, jedis0);
+ try {
+ // 0 1 2 3 4 5 6 7 8 9
+ List paramList = jedis0.hmget(tag_key, "AA", "payer", "pay", "group","game","delete_status","status","create_time","id","players");
+
+ if(StringUtil.isEmpty(paramList.get(4))) {
+ Redis.use().expire(tag_key, 20);
+ return;
+ }
+
+ String delete_status = paramList.get(5);
+ if(StringUtil.isEmpty(delete_status)) {
+
+ String status = paramList.get(6);
+ int _status = Integer.parseInt(status);
+ if(_status == 2 || _status == 3) {
+// logger.info(tag_key + "房间的状态不对,此时房间的状态["+status + "]");
+ Redis.use().expire(tag_key, 20);
+ return;
+ }
+
+ // 如果房间的存活时间小于4个小时,考虑到游戏服务器也在删除 所以延时10分钟
+ String create_time = paramList.get(7);
+ String roomid = paramList.get(8);
+ long now = System.currentTimeMillis() / 1000;
+ if((now - Long.parseLong(create_time)) > 14400 + 600) {
+
+ deleteRoomFromServer(tag_key,jedis0,false);
+ }
+
+ return;
+ }
+
+ boolean pay_AA = Integer.parseInt(paramList.get(0)) == 1;
+ int payer = Integer.parseInt(paramList.get(1));
+ int pay = Integer.parseInt(paramList.get(2));
+ int gameId = Integer.parseInt(paramList.get(4));
+ String group = paramList.get(3);
+ int _gid = 0;
+ if(StringUtil.isNotEmpty(group)) {
+ _gid = Integer.parseInt(group);
+ }
+ int _delete_status = Integer.parseInt(delete_status);
+ if(_delete_status == 0) {
+
+ // 如果需要支付钻石
+ if(pay > 0) {
+
+ if (pay_AA) {
+
+ String players_json = paramList.get(9);
+ if(StringUtil.isEmpty(players_json) == false) {
+ ITArray players = TArray.newFromJsonData(players_json);
+ for (int i = 0; i < players.size(); i++) {
+ //GroupPublisherService.refundDiamo(players.getInt(i), pay, _gid, gameId);
+ }
+ }
+ }else{
+
+ if(_gid == 0) {
+ //GroupPublisherService.refundDiamo(payer, pay, _gid, gameId);
+ }
+ }
+ }
+ }
+
+ Redis.use().hset(tag_key, "status", 3 + "");
+ Redis.use().hincrBy(tag_key, "cache_ver", 1);
+ Redis.use().expire(tag_key, 20);
+ }
+ catch(Exception e) {
+ logger.info(tag_key + "删除房间发生异常["+e.getMessage() + "]");
+ }
+ finally {
+ room_lock.unlock(false);
+ }
+ }
+
+ private boolean deleteRoomFromServer(String roomid,Jedis jedis0,boolean lock) {
+
+ String tag_key = roomid;
+ RedisLock room_lock = null;
+
+ if(lock) {
+ room_lock = new RedisLock(tag_key, jedis0);
+ }
+
+ try {
+
+ if( jedis0.exists(tag_key) == false) {
+ return false;
+ }
+ // 0 1 2 3 4 5 6 7
+ List paramList = jedis0.hmget(tag_key, "AA", "payer", "pay", "group","game","status","create_time","id");
+
+ String status = paramList.get(5);
+ int _status = Integer.parseInt(status);
+ if(_status == 2 || _status == 3) {
+ logger.info("删除房间" + roomid + "失败,原因状态不对,此时的状态是[" + _status +"]");
+ return true;
+ }
+
+ String group = paramList.get(3);
+ int _gid = 0;
+ if(StringUtil.isNotEmpty(group)) {
+ _gid = Integer.parseInt(group);
+ }
+
+ // 如果房间的存活时间小于4个小时,考虑到游戏服务器也在删除 所以延时10分钟
+ String create_time = paramList.get(6);
+ long now = System.currentTimeMillis() / 1000;
+ if((now - Long.parseLong(create_time)) < 14400 + 600) {
+ logger.info("删除房间" + roomid + "失败,房间距离创建没有超过4个小时");
+ return true;
+ }
+
+ if(_gid != 0) {
+
+ // 如果游戏没有开始_status = 0
+ // 不是aa支付,则退出回创建者创建钻石的费用
+ // aa支付,设置status=2之后,则交给游戏服务器去做(如果游戏服务器挂了呢,或者房间在游戏服务器中根本就不存在呢),
+ // 如果游戏已经开始_status = 1,则不用考虑钻石回退的问题,下一次执行的时候,如果redis还存在房间的信息,则直接从redis删除就可以了
+ if(_status==0) {
+
+ int gameId = Integer.parseInt(paramList.get(4));
+ boolean pay_AA = Integer.parseInt(paramList.get(0)) == 1;
+ if (!pay_AA) {
+ int payer = Integer.parseInt(paramList.get(1));
+ int pay = Integer.parseInt(paramList.get(2));
+ //Utility.payDiamo(EventType.REDIS_EVENT_BACK_PAY, payer, gameId, pay, _gid,0);
+ }
+ }
+ String strRoomID = "";
+ if(StringUtil.isNotEmpty(paramList.get(7))) {
+ strRoomID =paramList.get(7);
+ }
+ GroupPublisherService.delRoomEvt(_gid, strRoomID);
+ }
+
+ jedis0.hset(tag_key, "status", "2");
+ jedis0.hset(tag_key, "delete_status", "" + status);
+ jedis0.hincrBy(tag_key, "cache_ver", 1);
+
+ logger.info("删除房间" + roomid + "成功");
+ }
+ catch(Exception e){
+
+ }
+ finally {
+
+ if(room_lock != null) {
+ room_lock.unlock(false);
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * 清除无效的房间
+ */
+ private void cleanInvalidRoom() {
+ try {
+
+ Jedis jedis0 = Redis.use("group1_db0").getJedis();
+ try {
+
+ String cursor = ScanParams.SCAN_POINTER_START;
+ String key = "room:*";
+ ScanParams scanParams = new ScanParams();
+ scanParams.match(key);
+ scanParams.count(1000);
+
+ // 处理所有redis的房间
+ while (true){
+
+ ScanResult scanResult = jedis0.scan(cursor, scanParams);
+ cursor = scanResult.getStringCursor();
+ List list = scanResult.getResult();
+
+ for(int m = 0; m < list.size(); m++){
+
+ String mapentry = list.get(m);
+ logger.info("正在检查房间 " + mapentry);
+ deleteRoomFromRedis(mapentry,jedis0);
+ }
+
+ if ("0".equals(cursor)){
+ break;
+ }
+ }
+ }
+ finally {
+ jedis0.close();
+ }
+ }
+ catch(Exception e) {
+
+ }
+ }
+
+ /**
+ * 清除亲友圈中无效的房间
+ */
+ private void cleanGroupRoom() {
+
+ try {
+
+ Jedis jedis11 = Redis.use("group1_db11").getJedis();
+ Jedis jedis0 = Redis.use("group1_db0").getJedis();
+
+ RedisLock lock = new RedisLock("room_clean", jedis11);
+ try {
+
+ String cursor = ScanParams.SCAN_POINTER_START;
+ String key = "*:rooms*";
+ ScanParams scanParams = new ScanParams();
+ scanParams.match(key);
+ scanParams.count(1000);
+
+ // 处理亲友圈的房间
+ while (true){
+
+ ScanResult scanResult = jedis11.scan(cursor, scanParams);
+ cursor = scanResult.getStringCursor();
+ List list = scanResult.getResult();
+
+ for(int m = 0; m < list.size(); m++){
+
+
+ String mapentry = list.get(m);
+ logger.info("正在查询群" +mapentry + "的无效房间");
+ Set rooms = jedis11.zrangeByScore(mapentry, 100000, 1000000);
+
+ for (String roomId : rooms) {
+ logger.info("正在查询群" +mapentry + "的无效房间" + roomId);
+ boolean existed = deleteRoomFromServer(roomId,jedis0,true);
+ if(!existed) {
+ jedis11.zrem(mapentry, roomId);
+ logger.info("删除群" +mapentry + "的无效房间" + roomId + "因为房间不存在");
+ }
+ }
+ }
+
+ if ("0".equals(cursor)){
+ break;
+ }
+ }
+ }
+ finally {
+ lock.unlock();
+ jedis0.close();
+ jedis11.close();
+ }
+ }
+ catch(Exception e) {
+
+ }
+ }
+
+ /**
+ * 清除亲友圈中无效的房间
+ */
+ private void cleanGroupMemberLog() {
+ int time = DateUtils.getBeginDay() - 5 * 24 * 3600;
+ String deleteSql = String.format("delete from group_member_log where time < %s", time);
+ Utility.evtdbLog(1, 1, deleteSql);
+ String deleteSql2 = String.format("delete from room_rec_log where time < %s and time > %s", time, time - 24 * 3600);
+ Utility.evtdbLog(1, 1, deleteSql2);
+ String deleteSql3 = String.format("delete from group_hp_log where time < %s and time > %s", time, time - 24 * 3600);
+ Utility.evtdbLog(1, 1, deleteSql3);
+ }
+
+ @Override
+ public void execute(JobExecutionContext context) {
+
+ JobKey jobKey = context.getJobDetail().getKey();
+ if(jobKey.getName().equals("clean_group_room") || jobKey.getName().equals("clean_group_room1")) {
+ logger.info("执行成功" + jobKey.getName());
+ cleanGroupRoom();
+ logger.info("执行成功cleanGroupMemberLog");
+ cleanGroupMemberLog();
+ }
+ else if(jobKey.getName().equals("clean_invalid_room")|| jobKey.getName().equals("clean_invalid_room1")) {
+ logger.info("执行成功" + jobKey.getName());
+ cleanInvalidRoom();
+ }
+ }
+}
diff --git a/event_mgr/src/main/webapp/WEB-INF/web.xml b/event_mgr/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..7b0149b
--- /dev/null
+++ b/event_mgr/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,19 @@
+
+
+
+
+ taurus-web
+ com.taurus.web.WebFilter
+
+ main
+ com.evt.mgr.EventServer
+
+
+
+
+ taurus-web
+ /*
+
+
diff --git a/event_mgr/src/main/webapp/config/log4j.properties b/event_mgr/src/main/webapp/config/log4j.properties
new file mode 100644
index 0000000..6786dba
--- /dev/null
+++ b/event_mgr/src/main/webapp/config/log4j.properties
@@ -0,0 +1,20 @@
+
+log4j.rootLogger = INFO,consoleAppender,fileAppender
+
+# ConsoleAppender
+log4j.appender.consoleAppender=org.apache.log4j.ConsoleAppender
+log4j.appender.consoleAppender.layout=org.apache.log4j.PatternLayout
+log4j.appender.consoleAppender.layout.ConversionPattern=%d{HH:mm:ss,SSS} %-5p [%t] %c{2} %3x - %m%n
+
+
+# Regular FileAppender
+log4j.appender.fileAppender=org.apache.log4j.DailyRollingFileAppender
+log4j.appender.fileAppender.layout=org.apache.log4j.PatternLayout
+log4j.appender.fileAppender.File=${WORKDIR}/logs/web_main.log
+log4j.appender.fileAppender.layout.ConversionPattern=%d{dd MMM yyyy | HH:mm:ss,SSS} | %-5p | %t | %c{3} | %3x | %m%n
+log4j.appender.fileAppender.Encoding=UTF-8
+log4j.appender.fileAppender.DatePattern='.'yyyy-MM-dd
+log4j.appender.dailyFile.Append=true
+
+# The file is rolled over very day
+log4j.appender.fileAppender.DatePattern ='.'yyyy-MM-dd
\ No newline at end of file
diff --git a/event_mgr/src/main/webapp/config/taurus-core.xml b/event_mgr/src/main/webapp/config/taurus-core.xml
new file mode 100644
index 0000000..6d5a892
--- /dev/null
+++ b/event_mgr/src/main/webapp/config/taurus-core.xml
@@ -0,0 +1,98 @@
+
+
+ log4j.properties
+
+
+ database
+ com.taurus.core.plugin.database.DataBasePlugin
+
+
+
+ 100
+
+ 10
+
+ 180000
+
+ select 1
+
+ 10000
+
+ 60000
+
+
+
+ false
+ true
+ utf-8
+
+ UTC
+
+ true
+
+ 250
+
+ 2048
+
+
+
+
+
+ db1
+ com.mysql.cj.jdbc.Driver
+ jdbc:mysql://123.207.203.115:8060/wb_game
+ wb_game
+ 363b76546c
+
+
+
+
+
+ redis
+ com.taurus.core.plugin.redis.RedisPlugin
+
+
+
+ 80
+
+ 20
+
+ 5
+
+ -1
+
+ true
+
+ true
+
+ true
+
+ 100
+
+ 60000
+
+ 30000
+
+ 1800000
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/event_mgr/src/test/java/MainEventMgr.java b/event_mgr/src/test/java/MainEventMgr.java
new file mode 100644
index 0000000..ccdf5ee
--- /dev/null
+++ b/event_mgr/src/test/java/MainEventMgr.java
@@ -0,0 +1,12 @@
+
+
+import com.taurus.web.JettyServer;
+
+public class MainEventMgr {
+
+ public static void main(String[] args) {
+ new JettyServer("src/main/webapp",8083,"/").start();
+
+ }
+
+}
diff --git a/game_common/.idea/compiler.xml b/game_common/.idea/compiler.xml
new file mode 100644
index 0000000..7fa5e4b
--- /dev/null
+++ b/game_common/.idea/compiler.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/game_common/.idea/encodings.xml b/game_common/.idea/encodings.xml
new file mode 100644
index 0000000..aa00ffa
--- /dev/null
+++ b/game_common/.idea/encodings.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/game_common/.idea/jarRepositories.xml b/game_common/.idea/jarRepositories.xml
new file mode 100644
index 0000000..712ab9d
--- /dev/null
+++ b/game_common/.idea/jarRepositories.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/game_common/.idea/misc.xml b/game_common/.idea/misc.xml
new file mode 100644
index 0000000..d5cd614
--- /dev/null
+++ b/game_common/.idea/misc.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/game_common/.idea/vcs.xml b/game_common/.idea/vcs.xml
new file mode 100644
index 0000000..6c0b863
--- /dev/null
+++ b/game_common/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/game_common/pom.xml b/game_common/pom.xml
new file mode 100644
index 0000000..d4bb088
--- /dev/null
+++ b/game_common/pom.xml
@@ -0,0 +1,85 @@
+
+ 4.0.0
+
+ com.game
+ game_common
+ 1.0.0
+ jar
+ game_common
+
+
+ UTF-8
+ 1.8
+ 1.8
+
+
+
+
+ junit
+ junit
+ 3.8.1
+ test
+
+
+
+ com.data
+ data_cache
+ 1.0.1
+
+
+
+
+ com.taurus
+ taurus-core
+ 1.0.1
+
+
+
+
+ com.taurus
+ taurus-permanent
+ 1.0.1
+
+
+
+
+ redis.clients
+ jedis
+ 2.9.0
+
+
+
+
+ jdom
+ jdom
+ 1.0
+
+
+
+
+ log4j
+ log4j
+ 1.2.17
+
+
+
+
+ game_common-${version}
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.6.1
+
+
+ 1.8
+ 1.8
+ UTF-8
+
+
+
+
+
+
diff --git a/game_common/src/main/java/com/game/ActionEvent.java b/game_common/src/main/java/com/game/ActionEvent.java
new file mode 100644
index 0000000..19bd769
--- /dev/null
+++ b/game_common/src/main/java/com/game/ActionEvent.java
@@ -0,0 +1,51 @@
+package com.game;
+
+/**
+ * 服务器内部事件常量表
+ *
+ */
+public class ActionEvent {
+
+ /**
+ * 准备
+ */
+ public static final String EVENT_READY = "ready";
+
+ /**
+ * 准备洗牌
+ */
+ public static final String EVENT_READY_AND_XIPAI = "ready_and_xipai";
+
+ /**
+ * 开始游戏
+ */
+ public static final String EVENT_START_GAME = "start_game";
+
+ /**
+ * 退出房间
+ */
+ public static final String EVENT_EXIT_ROOM = "exit_room";
+
+ /**
+ * 自动
+ */
+ public static final String EVENT_TIMER_AUTO = "timer_auto";
+ /**
+ * 托管
+ */
+ public static final String EVENT_ENTRUST = "entrust";
+ /**
+ * 离线
+ */
+ public static final String EVENT_OFFLINE = "offline";
+
+ /**
+ * 洗牌
+ */
+ public static final String EVENT_XIPAI = "xi_pai";
+
+ /**
+ * 观战
+ */
+ public static final String EVENT_SPECTATOR = "spectator";
+}
diff --git a/game_common/src/main/java/com/game/Constant.java b/game_common/src/main/java/com/game/Constant.java
new file mode 100644
index 0000000..41be2a2
--- /dev/null
+++ b/game_common/src/main/java/com/game/Constant.java
@@ -0,0 +1,62 @@
+package com.game;
+
+public interface Constant {
+ /**
+ * 当局大结算
+ */
+ int ENTRUST_CURREN_RESULT = 1;
+ /**
+ * 满2局大结算
+ */
+ int ENTRUST_TWO_RESULT = 2;
+ /**
+ * 满3局大结算
+ */
+ int ENTRUST_THREE_RESULT = 3;
+ /**
+ * 满局大结算
+ */
+ int ENTRUST_TOTAL_RESULT1 = 4;
+
+ /**
+ * 未开始
+ */
+ int ROOM_STATUS_NOBEGIN = 0;
+ /**
+ * 游戏中
+ */
+ int ROOM_STATUS_PLAYING = 1;
+ /**
+ * 正准备删除
+ */
+ int ROOM_STATUS_DEL_FALG = 2;
+ /**
+ * 已删除
+ */
+ int ROOM_STATUS_DEL = 3;
+ /**
+ * 正常大结算
+ */
+ int END_TYPE_NORMAL = 1;
+ /**
+ * 托管当局大结算
+ */
+ int END_TYPE_ENTRUST = 2;
+ /**
+ * 体力值不足大结算
+ */
+ int END_TYPE_HP = 3;
+ /**
+ * 申请解散大结算
+ */
+ int END_TYPE_DISSMISS = 4;
+
+ /**
+ * 管理员解散大结算
+ */
+ int END_TYPE_ADMIN = 5;
+ /**
+ * 体力值不足
+ */
+ int HP_NOT_ENOUGH = -1;
+}
diff --git a/game_common/src/main/java/com/game/EventController.java b/game_common/src/main/java/com/game/EventController.java
new file mode 100644
index 0000000..ace150e
--- /dev/null
+++ b/game_common/src/main/java/com/game/EventController.java
@@ -0,0 +1,376 @@
+package com.game;
+
+import java.sql.SQLException;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+
+import com.data.bean.GameBean;
+import com.data.bean.GroupPlayBean;
+import com.data.cache.GameCache;
+import com.data.cache.GroupCache;
+import com.data.cache.GroupMemberCache;
+import com.data.util.EventType;
+import com.game.data.Player;
+import com.game.data.Room;
+import com.taurus.core.entity.ITArray;
+import com.taurus.core.entity.ITObject;
+import com.taurus.core.entity.TArray;
+import com.taurus.core.entity.TObject;
+import com.taurus.core.plugin.database.DataBase;
+import com.taurus.core.plugin.redis.Redis;
+import com.taurus.core.util.StringUtil;
+
+import redis.clients.jedis.Jedis;
+
+/**
+ * redis 事件控制器
+ */
+public class EventController {
+ private final static String GROUP_EVT_KEY = "evt_group_";
+ private final static String EVT_KEY = "event_";
+ private final static String CHACHE_KEY = "group1_db8";
+
+ private final static String EVT_TYPE = "E";
+ private final static String EVT_GID = "gid";
+ private final static String EVT_UID = "uid";
+
+ private static void sendGroupEvt(int type, int gid, ITObject data) {
+ int id = gid % 10;
+ data.putInt(EVT_GID, gid);
+ data.putInt(EVT_TYPE, type);
+ Redis.use(CHACHE_KEY).lpush(GROUP_EVT_KEY + id, data.toJson());
+ }
+
+ private static void sendEvt(int type, int uid, ITObject data) {
+ int id = uid % 10;
+ data.putInt(EVT_UID, uid);
+ data.putInt(EVT_TYPE, type);
+ Redis.use(CHACHE_KEY).lpush(EVT_KEY + id, data.toJson());
+ }
+
+ /**
+ * 注册redis事件
+ *
+ * @param uid
+ * @param type
+ * @param num
+ */
+ public void redisEvent(int uid, int type, int num) {
+ ITObject data = TObject.newInstance();
+ data.putInt("N", num);
+ sendEvt(type, uid, data);
+ }
+
+ /**
+ * 圈子一局结束事件
+ *
+ * @param gid
+ * @param pid
+ * @param valid
+ */
+ public void redisGroupRound(Room room, int gid, int pid, int valid) {
+ ITObject data = TObject.newInstance();
+ data.putInt("pid", pid);
+ data.putInt("valid", valid);
+ data.putTArray("player_list", room.getValidPlayerList());
+ data.putInt("perfect_round", room.endType == Constant.END_TYPE_NORMAL ? 1 : 0);
+ int maxPlayer = room.getValidPlayer();
+ if (valid == 1 && maxPlayer > 0) {
+ data.putInt("valid_count", 100 / maxPlayer);
+ } else {
+ data.putInt("valid_count", 0);
+ }
+
+ if (maxPlayer > 0) {
+ data.putInt("all_count", 100 / maxPlayer);
+ }
+
+ try {
+ GroupPlayBean gpb = GroupCache.getPlay(gid, pid);
+ if (gpb != null) {
+ int maxPlayers = gpb.maxPlayers;
+ ITObject configData = TObject.newFromJsonData(gpb.config);
+ int opt = configData.getInt("opt");
+ int gameId = gpb.gameId;
+ GameBean gb = GameCache.getGame(gameId);
+ if (gb != null) {
+
+ int score = 0;
+ for (Entry entry : room.playerMapById.entrySet()) {
+ Player player = entry.getValue();
+
+ if (player.score.total_score > score) {
+ score += Math.abs(player.score.total_score);
+ }
+ }
+ Jedis jedis10 = Redis.use("group1_db10").getJedis();
+ int diamo = Integer.parseInt(jedis10.hget("g{" + gid + "}:diamo", "diamo"));
+ if (room.round <= 1 && score == 0) {
+ data.putInt("valid_diamo", 0);
+ Integer pay = gb.pay.get("pay" + opt + "_" + maxPlayers);
+ jedis10.hset("g{" + gid + "}:diamo", "diamo", (diamo + pay) + "");
+ // 保存预扣房卡消息
+ Global.logger.info("返回全部房卡-----------------------");
+
+ String messagesql = String.format(
+ "insert into diamo_message(group_id,diamo_type,diamo_cur,diamo_num,m_time,m_state,uid,group_name,user_nick)"
+ + " values(%s,%s,%s,%s,%s,%s,%s,'%s','%s')",
+ gid, 1, diamo + pay, pay, System.currentTimeMillis(),0, 0,gb.name,"");
+ if (DataBase.use() != null) {
+ DataBase.use().executeUpdate(messagesql);
+ }
+
+ } else {
+ Integer pay = gb.pay.get("pay" + opt + "_" + maxPlayers);
+ if (pay != null && pay > 0 && maxPlayer > 0) {
+ int maxRound = room.hpData.getInt("maxRound");
+
+ if (maxRound > room.round) {
+ double payDiamo = Math.ceil((double) pay / room.hpData.getInt("maxRound") * room.round);
+ data.putInt("valid_diamo", (int) payDiamo * 100);
+ int backDiamo = (pay - (int) payDiamo);
+ jedis10.hset("g{" + gid + "}:diamo", "diamo", (diamo + backDiamo) + "");
+ // 保存预扣房卡消息
+ Global.logger.info("返回部分房卡-----------------------");
+
+ String messagesql = String.format(
+ "insert into diamo_message(group_id,diamo_type,diamo_cur,diamo_num,m_time,m_state,uid,group_name,user_nick)"
+ + " values(%s,%s,%s,%s,%s,%s,%s,'%s','%s')",
+ gid, 1, diamo+backDiamo, backDiamo, System.currentTimeMillis(),0, 0,gb.name,"");
+
+ DataBase.use().executeUpdate(messagesql);
+ } else {
+ data.putInt("valid_diamo", pay * 100);
+ }
+
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ Global.logger.error(e);
+ }
+
+ sendGroupEvt(EventType.REDIS_EVENT_GROUP_ROUND, gid, data);
+ }
+
+ /**
+ * 圈子玩家一局结束事件
+ *
+ * @param owner
+ * @param pid
+ * @param win
+ */
+ public void redisGroupMemberRound(Player owner, int pid, boolean win, boolean hpPump, int cur_hp) {
+
+ Room room = owner.room;
+ ITObject data = TObject.newInstance();
+ data.putInt("pid", pid);
+ data.putInt("uid", owner.playerid);
+// if (owner.hp != null) {
+// data.putInt("score", owner.hp.total_hp);
+// } else {
+// data.putInt("score", owner.score.total_score);
+// }
+ data.putInt("score", owner.score.total_score);
+ data.putInt("time", (int) (System.currentTimeMillis() / 1000));
+ data.putInt("pump", owner.practicalHpPump);
+ data.putInt("xi_pai_total", owner.xi_pai_total);
+ data.putInt("win", win ? 1 : 0);
+ data.putInt("perfect_round", owner.room.endType == Constant.END_TYPE_NORMAL ? 1 : 0);
+ data.putInt("cur_hp", cur_hp);
+ data.putUtfString("room", room.roomid);
+ int maxPlayer = owner.room.getValidPlayer();
+ if (hpPump && maxPlayer > 0) {
+ data.putInt("valid_count", 100 / maxPlayer);
+ } else {
+ data.putInt("valid_count", 0);
+ }
+
+ sendGroupEvt(EventType.REDIS_EVENT_GROUP_MEMBER_ROUND, owner.room.groupId, data);
+ }
+
+ /**
+ * 注册redis体力值事件 reward以前没有用到,现在表示抽水值只给盟主,不给合伙人参与分成
+ */
+ public long redisFag(Player owner, int hp, boolean hpPump, boolean mengzhu_reward, int xipai_score, boolean xipai,
+ String desc) {
+ Jedis jedis10 = Redis.use("group1_db10").getJedis();
+ try {
+ Room room = owner.room;
+ String gm_key = GroupMemberCache.genKey(room.groupId, owner.playerid);
+
+ long cur_hp = 0;
+ if (hpPump) {
+ String strCurHp = Redis.use("group1_db10").hget(gm_key, "hp");
+ if (StringUtil.isNotEmpty(strCurHp)) {
+ cur_hp = Long.parseLong(strCurHp);
+ if (cur_hp < owner.practicalHpPump) {
+ owner.practicalHpPump = (int) cur_hp;
+ if (owner.practicalHpPump < 0) {
+ owner.practicalHpPump = 0;
+ }
+ }
+ }
+ cur_hp = Redis.use("group1_db10").hincrBy(gm_key, "hp", -owner.practicalHpPump);
+ } else if (xipai) {
+ String strCurHp = Redis.use("group1_db10").hget(gm_key, "hp");
+ if (StringUtil.isNotEmpty(strCurHp)) {
+ cur_hp = Long.parseLong(strCurHp);
+ if (cur_hp < xipai_score) {
+ xipai_score = (int) cur_hp;
+ if (xipai_score < 0) {
+ xipai_score = 0;
+ }
+ }
+ }
+ cur_hp = Redis.use("group1_db10").hincrBy(gm_key, "hp", -xipai_score);
+ } else {
+ cur_hp = Redis.use("group1_db10").hincrBy(gm_key, "hp", hp);
+ }
+
+ ITObject data = TObject.newInstance();
+ if (cur_hp > Integer.MAX_VALUE) {
+ long del_value = cur_hp - (long) Integer.MAX_VALUE;
+ cur_hp = Redis.use("group1_db10").hincrBy(gm_key, "hp", -del_value);
+ Redis.use("group1_db10").hincrBy(gm_key, "bank_hp", del_value);
+ data.putInt("hp_than_max_value", (int) del_value);
+ }
+ data.putInt("hp", hp);
+ data.putInt("cur_hp", (int) cur_hp);
+ data.putInt("pid", room.groupPid);
+ data.putInt("uid", owner.playerid);
+ data.putInt("time", (int) (System.currentTimeMillis() / 1000));
+ data.putUtfString("room", room.roomid);
+ // 临时处理
+ data.putUtfString("desc", StringUtil.isNotEmpty(desc) ? desc : Global.gameName + " " + room.roomid);
+ data.putInt("rewardType", room.rewardType);
+ data.putInt("rewardValueType", room.rewardValueType);
+ data.putInt("xipai_rewardType", room.xipai_rewardType);
+ data.putInt("xipai_rewardValueType", room.xipai_rewardValueType);
+ if (xipai) {
+ data.putInt("xipai", xipai_score);
+ int xipai_reward_value = 0;
+ if (room.xipai_rewardValueType == 1) {
+ xipai_reward_value = xipai_score;
+ }
+
+ data.putInt("max_player", room.maxPlayers);
+ data.putInt("xipai_reward_type", room.xipai_rewardType);
+ data.putInt("xipai_reward_value", xipai_reward_value);
+ if (StringUtil.isNotEmpty(owner.prs) && !mengzhu_reward) {
+ data.putUtfString("prs", owner.prs);
+ }
+ }
+ if (hpPump) {
+ data.putInt("pump", owner.practicalHpPump);
+ int reward_value = 0;
+ int max_player = room.getValidPlayer();
+ if (room.rewardValueType == 1) {
+
+ if (room.rewardType == 1) {
+ if (room.totalPump + room.basePump != 0) {
+ reward_value = owner.practicalHpPump
+ - room.basePump * owner.practicalHpPump / (room.totalPump + room.basePump);
+ } else {
+ reward_value = owner.practicalHpPump;
+ }
+ } else {
+ reward_value = room.totalPump / max_player;
+ if (room.basePump > 0) {
+ if (reward_value + (room.basePump / max_player) > owner.practicalHpPump) {
+ reward_value = owner.practicalHpPump - (room.basePump / max_player);
+ if (reward_value < 0) {
+ reward_value = 0;
+ }
+ }
+ } else {
+ if (reward_value > owner.practicalHpPump) {
+ reward_value = owner.practicalHpPump;
+ }
+ }
+ }
+ }
+
+ data.putInt("max_player", room.getValidPlayer());
+ data.putInt("reward_type", room.rewardType);
+ data.putInt("reward_value", reward_value);
+ if (StringUtil.isNotEmpty(owner.prs) && !mengzhu_reward) {
+ data.putUtfString("prs", owner.prs);
+ }
+ }
+ sendGroupEvt(EventType.REDIS_EVENT_GROUP_HP, room.groupId, data);
+ return cur_hp;
+
+ } finally {
+ jedis10.close();
+ }
+
+ }
+
+ /**
+ * 返还钻石
+ *
+ * @param uid
+ * @param pay
+ * @param groupId
+ */
+ public void refundDiamo(int uid, int pay, int groupId, int pid) {
+ ITObject data = TObject.newInstance();
+ data.putInt("pay", -pay);
+ data.putInt("game", Global.gameId);
+ if (groupId > 0) {
+ data.putInt("group", groupId);
+ data.putInt("pid", pid);
+ }
+// Jedis jedis0 = Redis.use("group1_db0").getJedis();
+// try {
+// int diamo = Integer.parseInt(jedis0.hget("{user}:" + uid, "diamo"));
+// String sql = String.format("insert into diamo_message(group_id,diamo_type,diamo_cur,diamo_num,m_time,m_state,uid)"
+// + " values(%s,%s,%s,%s,%s,%s,%s)", 0, 1, diamo, pay, System.currentTimeMillis(), 0,uid);
+// DataBase.use().executeUpdate(sql);
+//
+// } catch (SQLException e) {
+// // TODO Auto-generated catch block
+// e.printStackTrace();
+// }finally {
+// jedis0.close();
+// }
+
+// sendEvt(EventType.REDIS_EVENT_BACK_PAY, uid, data);
+ }
+
+ /**
+ * 大局结束事件
+ *
+ * @param
+ * @param
+ * @param
+ */
+ public void redisOver(Player owner, int time, String rec_key) {
+ Room room = owner.room;
+ ITObject data = TObject.newInstance();
+ if (StringUtil.isNotEmpty(rec_key)) {
+ data.putInt("is_rec", 1);
+ data.putUtfString("roomid", room.roomid);
+ data.putInt("gid", room.groupId);
+ data.putUtfString("rec_key", rec_key);
+ data.putInt("time", time);
+ } else {
+ data.putInt("is_rec", 0);
+ }
+ // 保存聊天室在线人员
+ String groupIdKey = "g{" + room.groupId + "}:onlines";
+ Map onlines = Redis.use("group1_db10").hgetAll(groupIdKey);
+ ITArray array = TArray.newInstance();
+ Set keys = onlines.keySet();
+ for (String key : keys) {
+ int uid = Integer.parseInt(key);
+ array.addInt(uid);
+ }
+ data.putTArray("tagIds", array);
+
+ sendEvt(EventType.REDIS_EVENT_OVER, owner.playerid, data);
+ }
+}
diff --git a/game_common/src/main/java/com/game/GPSUtil.java b/game_common/src/main/java/com/game/GPSUtil.java
new file mode 100644
index 0000000..36637fd
--- /dev/null
+++ b/game_common/src/main/java/com/game/GPSUtil.java
@@ -0,0 +1,63 @@
+package com.game;
+
+import com.taurus.core.util.StringUtil;
+
+/**
+ * @author dong.teng
+ */
+public class GPSUtil {
+ // 地球半径
+ private static final double EARTH_RADIUS = 6378137;
+
+ private static double radian(double lngLat) {
+ return lngLat * Math.PI / 180.0;
+ }
+
+ /**
+ * 根据两点间经纬度坐标,计算直线距离 单位 :米
+ */
+ public static double getDistance(String gps1, String gps2) {
+ double distance = 0;
+ if (isOpenGPS(gps1) && isOpenGPS(gps2)) {
+ String[] gps1Arr = gps1.split(",");
+ String[] gps2Arr = gps2.split(",");
+ Double lat1 = Double.parseDouble(gps1Arr[1]);
+ Double lng1 = Double.parseDouble(gps1Arr[0]);
+ Double lat2 = Double.parseDouble(gps2Arr[1]);
+ Double lng2 = Double.parseDouble(gps2Arr[0]);
+ double radLat1 = radian(lat1);
+ double radLat2 = radian(lat2);
+ double a = radLat1 - radLat2;
+ double b = radian(lng1) - radian(lng2);
+ distance = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
+ distance *= EARTH_RADIUS;
+ distance = Math.round(distance * 10000) / 10000;
+ }
+ return distance;
+ }
+
+ /**
+ * 两位置是否过近
+ *
+ * @param gps1
+ * @param gps2
+ * @param measure
+ * 衡量过近米
+ * @return
+ */
+ public static boolean isDistanceNear(String gps1, String gps2, int measure) {
+ return getDistance(gps1, gps2) <= measure;
+ }
+
+ /**
+ * 是否打开gps
+ */
+ public static boolean isOpenGPS(String gps) {
+ return StringUtil.isNotEmpty(gps) && gps.contains(",");
+ }
+
+ public static void main(String[] args) {
+ System.out.println(isDistanceNear("109.19300079346,27.710248947144", "100.23030090332,25.59494972229",50));
+ }
+
+}
diff --git a/game_common/src/main/java/com/game/GameController.java b/game_common/src/main/java/com/game/GameController.java
new file mode 100644
index 0000000..fc33379
--- /dev/null
+++ b/game_common/src/main/java/com/game/GameController.java
@@ -0,0 +1,1022 @@
+package com.game;
+
+import java.net.URLEncoder;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+
+import com.data.bean.AccountBean;
+import com.data.bean.GameBean;
+import com.data.bean.GroupPlayBean;
+import com.data.cache.AccountCache;
+import com.data.cache.GameCache;
+import com.data.cache.GroupCache;
+import com.data.cache.GroupMemberCache;
+import com.data.util.ErrorCode;
+import com.data.util.EventType;
+import com.data.util.Utility;
+import com.game.data.JoinRoomData;
+import com.game.data.Player;
+import com.game.data.Room;
+import com.game.player.state.PlayerInitState;
+import com.game.player.state.PlayerReadyState;
+import com.game.player.state.PlayerSpectatorState;
+import com.game.room.state.RoomDestoryGameState;
+import com.mysql.cj.xdevapi.JsonParser;
+import com.taurus.core.entity.ITArray;
+import com.taurus.core.entity.ITObject;
+import com.taurus.core.entity.TArray;
+import com.taurus.core.entity.TObject;
+import com.taurus.core.plugin.database.DataBase;
+import com.taurus.core.plugin.redis.Redis;
+import com.taurus.core.plugin.redis.RedisLock;
+import com.taurus.core.routes.ActionKey;
+import com.taurus.core.routes.IController;
+import com.taurus.core.util.StringUtil;
+import com.taurus.permanent.TPServer;
+import com.taurus.permanent.data.Session;
+
+import redis.clients.jedis.Jedis;
+
+/**
+ * 基本游戏控制器
+ *
+ */
+public class GameController implements IController {
+
+ /**
+ * 聊天
+ */
+ @ActionKey(Router.GAME_INTERACTION)
+ public void routerChat(Session sender, ITObject params, int gid, Player owner) {
+ int canMissile = owner.room.hpData.getInt("BanMissile");
+ int canChat = owner.room.hpData.getInt("BanChat");
+ int type = params.getInt("type");
+ TObject data = new TObject();
+ data.putInt("canMissile", canMissile);
+
+ // 禁止表情
+ if (canMissile == 1 && type == 7) {
+ MainServer.instance.sendResponse(gid, ErrorCode.GROUP_BAN_EMOJI, data, sender);
+ } else if (canMissile == 0 && type == 7) {
+ owner.room.broadCastToClient(0, Router.GAME_EVT_INTERACTION, params);
+ owner.room.broadCastToClientOfSpectator(Router.GAME_EVT_INTERACTION, params);
+
+ }
+
+ // 禁止聊天
+ if (canChat == 1 && type == 2) {
+ MainServer.instance.sendResponse(gid, ErrorCode.GROUP_BAN_CHAT, data, sender);
+ } else if (canChat == 0 && (type == 2 || type == 4 || type == 3)) {
+ owner.room.broadCastToClient(0, Router.GAME_EVT_INTERACTION, params);
+ owner.room.broadCastToClientOfSpectator(Router.GAME_EVT_INTERACTION, params);
+
+ }
+
+ // 禁止聊天
+ if (canChat == 1 && type == 1) {
+ MainServer.instance.sendResponse(gid, ErrorCode.GROUP_BAN_CHAT, data, sender);
+ } else if (canChat == 0 && (type == 2 || type == 4 || type == 3 || type == 1)) {
+ owner.room.broadCastToClient(0, Router.GAME_EVT_INTERACTION, params);
+ owner.room.broadCastToClientOfSpectator(Router.GAME_EVT_INTERACTION, params);
+
+ }
+
+ // 禁止表情
+ if (canMissile == 1 && type == 7) {
+ MainServer.instance.sendResponse(gid, ErrorCode.GROUP_BAN_EMOJI, data, sender);
+ } else if (canMissile == 0 && type == 7) {
+
+ owner.room.broadCastToClientOfSpectator(Router.GAME_EVT_INTERACTION, params);
+
+ }
+
+ // 禁止聊天
+ if (canChat == 1 && type == 2) {
+ MainServer.instance.sendResponse(gid, ErrorCode.GROUP_BAN_CHAT, data, sender);
+ } else if (canChat == 0 && (type == 2 || type == 4 || type == 3)) {
+
+ owner.room.broadCastToClientOfSpectator(Router.GAME_EVT_INTERACTION, params);
+
+ }
+
+ // 禁止聊天
+ if (canChat == 1 && type == 1) {
+ MainServer.instance.sendResponse(gid, ErrorCode.GROUP_BAN_CHAT, data, sender);
+ } else if (canChat == 0 && (type == 2 || type == 4 || type == 3 || type == 1)) {
+
+ owner.room.broadCastToClientOfSpectator(Router.GAME_EVT_INTERACTION, params);
+
+ }
+ }
+
+ /**
+ * 请求准备
+ *
+ */
+ @ActionKey(Router.GAME_READY)
+ public void routerReady(Session sender, ITObject params, int gid, Player owner) {
+ System.out.println("---------------参数session为null,参数params:" + params);
+
+ owner.stateMachine.execute(ActionEvent.EVENT_READY, gid, params);
+ }
+
+ /**
+ * 请求准备
+ *
+ */
+ @ActionKey(Router.GAME_READY_AND_XIPAI)
+ public void routerReadyAndXiPai(Session sender, ITObject params, int gid, Player owner) {
+ owner.stateMachine.execute(ActionEvent.EVENT_READY_AND_XIPAI, gid, params);
+ }
+
+ /**
+ * 请求开始游戏
+ */
+ @ActionKey(Router.GAME_START)
+ public void routerStartGame(Session sender, ITObject params, int gid, Player owner) {
+ owner.room.stateMachine.execute(ActionEvent.EVENT_START_GAME, gid, params);
+ }
+
+ @ActionKey(Router.GAME_XIPAI)
+ public void RouterXiPai(Session sender, ITObject params, int gid, Player owner) {
+ owner.stateMachine.execute(ActionEvent.EVENT_XIPAI, 0, params);
+ owner.room.stateMachine.execute(ActionEvent.EVENT_XIPAI, 0, params);
+ }
+
+ /**
+ * 托管
+ *
+ */
+ @ActionKey(Router.GAME_ENTRUST)
+ @SuppressWarnings("unchecked")
+ public void routerEntrust(Session sender, ITObject params, int gid, Player owner) {
+ if (owner.room.status == Constant.ROOM_STATUS_PLAYING && owner.room.isEntrust()) {
+ owner.entrust = params.getBoolean("ok");
+ Global.gameCtr.updatePlayerEntrust(owner);
+ Global.logger.info(owner + " manual " + (owner.entrust ? "entrust" : "quitEntrust"));
+ if (owner.entrust) {
+ owner.setEntrustData(params);
+ owner.stateMachine.curState.execute(owner, ActionEvent.EVENT_ENTRUST, gid, params);
+ } else {
+ owner.exitEntrust();
+ }
+ }
+ }
+
+ /**
+ * 请求进入房间
+ */
+ @ActionKey(value = Router.GAME_JOIN_ROOM, validate = GameInterceptor.NOT_PLAYER)
+ public void routerJoinRoom(Session sender, ITObject params, int gid) {
+ String session_id = params.getUtfString("session");
+ String[] sourceStrArrays = session_id.split(",");
+ String uid = sourceStrArrays[0];
+ Jedis jedis0 = Redis.use("group1_db0").getJedis();
+ Jedis jedis11 = Redis.use("group1_db11").getJedis();
+ try {
+ jedis0.hset(uid, "online", "startPlaying");
+ String userOnline = jedis0.hget(uid, "online");
+ TObject param = new TObject();
+ param.putString("online", userOnline);
+ String[] split = uid.split(":");
+ String uids = split[1];
+ param.putString("uid", uids);
+ String key = GroupCache.genGroupsKey(Integer.parseInt(uids));
+ Set groups = jedis11.zrevrange(key, 0, -1);
+ for (String tem : groups) {
+ GroupPublisherService.playerGameState(Integer.parseInt(tem), param);
+ }
+ } catch (Exception e) {
+ Global.logger.error("setGroupHeartbeat error-------", e);
+ } finally {
+ jedis0.close();
+ jedis11.close();
+ }
+
+// Jedis jedis0 = Redis.use("group1_db0").getJedis();
+// try {
+// Global.logger.info("进入房间---------------");
+// jedis0.hset("{user}:" + acc.id, "online", "startPlaying");
+// } catch (Exception e) {
+// Global.logger.error("setGroupHeartbeat error", e);
+// }finally {
+// jedis0.close();
+// }
+
+ // String sessionToken = Utils.getUniqueSessionToken(sender);
+ String token = null;
+ if (StringUtil.isEmpty(session_id)) {
+ session_id = "";
+ } else {
+ String[] sourceStrArray = session_id.split(",");
+ if (sourceStrArray.length == 2) {
+ session_id = sourceStrArray[0];
+ token = sourceStrArray[1];
+ }
+
+ if (StringUtil.isNotEmpty(token) && StringUtil.isNotEmpty(session_id)) {
+ String token_session = Redis.use("group1_db0").hget(token, "user");
+ if (StringUtil.isEmpty(token_session)) {
+ MainServer.instance.sendResponse(gid, ErrorCode._NO_SESSION, null, sender);
+ return;
+ } else {
+ if (!token_session.equals(session_id)) {
+ MainServer.instance.sendResponse(gid, ErrorCode._NO_SESSION, null, sender);
+ return;
+ }
+ }
+ } else {
+ MainServer.instance.sendResponse(gid, ErrorCode._NO_SESSION, null, sender);
+ return;
+ }
+ }
+ sender.setHashId(session_id);
+ String pos = params.getUtfString("pos");
+// if (!pos.equals("")){
+ Global.roomMgr.joinRoom(sender, session_id, gid, pos);
+// }
+
+ }
+
+ /**
+ * 请求进入房间
+ */
+ @ActionKey(value = Router.GAME_JOIN_SPECTATOR, validate = GameInterceptor.NOT_PLAYER)
+ public void routerJoinRoom1(Session sender, ITObject params, int gid) {
+ String session_id = params.getUtfString("session");
+ String token = null;
+ if (StringUtil.isEmpty(session_id)) {
+ session_id = "";
+ } else {
+ String[] sourceStrArray = session_id.split(",");
+ if (sourceStrArray.length == 2) {
+ session_id = sourceStrArray[0];
+ token = sourceStrArray[1];
+ }
+
+ if (StringUtil.isNotEmpty(token) && StringUtil.isNotEmpty(session_id)) {
+ String token_session = Redis.use("group1_db0").hget(token, "user");
+ if (StringUtil.isEmpty(token_session)) {
+ MainServer.instance.sendResponse(gid, ErrorCode._NO_SESSION, null, sender);
+ return;
+ } else {
+ if (!token_session.equals(session_id)) {
+ MainServer.instance.sendResponse(gid, ErrorCode._NO_SESSION, null, sender);
+ return;
+ }
+ }
+ } else {
+ MainServer.instance.sendResponse(gid, ErrorCode._NO_SESSION, null, sender);
+ return;
+ }
+ }
+ sender.setHashId(session_id);
+ String pos = params.getUtfString("pos");
+ Global.roomMgr.joinRoomOfSpectator(sender, session_id, gid, pos);
+ }
+
+ /**
+ * 自动出牌
+ */
+ @ActionKey(Router.GAME_AUTO_CARD)
+ public void routerAutoCard(Session sender, ITObject params, int gid, Player owner) {
+ owner.manualAutoCard = params.getBoolean("autoCard");
+
+ if (owner.manualAutoCard) {
+ if (!owner.room.openEntrust) {
+ owner.manualAutoCard = false;
+ return;
+ }
+ }
+
+ owner.entrust = owner.manualAutoCard;
+
+ Global.gameCtr.updatePlayerEntrust(owner);
+ Global.logger.info(owner + " manualAutoCard " + (owner.entrust ? "entrust" : "quitEntrust"));
+
+ if (owner.manualAutoCard) {
+ owner.stateMachine.curState.execute(owner, ActionEvent.EVENT_ENTRUST, gid, params);
+ } else {
+ owner.exitEntrust();
+ }
+ }
+
+ /**
+ * 请求删除解散房间(外部)
+ *
+ */
+ @ActionKey(value = Router.GAME_REMOVE_ROOM, validate = GameInterceptor.NOT_PLAYER)
+ public void routerRemoveRoom(Session sender, ITObject params, int gid) {
+ try {
+ String roomid = params.getUtfString("room");
+ MainServer.instance.sendResponse(gid, 0, null, sender);
+ } catch (Exception e) {
+ Global.logger.error(e);
+ MainServer.instance.sendResponse(gid, 1, null, sender);
+ }
+ }
+
+ /**
+ * 请求退出房间
+ */
+ @ActionKey(Router.GAME_EXIT_ROOM)
+ public void routerExitRoom(Session sender, ITObject params, int gid, Player owner) {
+ owner.stateMachine.execute(ActionEvent.EVENT_EXIT_ROOM, gid, params);
+
+ }
+
+ /**
+ * 请求解散房间
+ */
+ @ActionKey(Router.GAME_ASK_DISMISS_ROOM)
+ public void routerAskDismiss(Session sender, ITObject params, int gid, Player owner) {
+ owner.room.dismissRunable.askDismiss(owner, gid);
+ }
+
+ /**
+ * 房间解散投票请求
+ */
+ @ActionKey(Router.GAME_DISMISS_ROOM_VOTE)
+ public void routerDismissRoomVote(Session sender, ITObject params, int gid, Player owner) {
+ boolean agree = params.getBoolean("result");
+// if (agree){
+ owner.room.agreeDismisUserId.add(owner.nick);
+// }else {
+// owner.room.applyDismisUserId ="";
+// owner.room.agreeDismisUserId.clear();
+// }
+ owner.room.dismissRunable.responseDismiss(owner, agree);
+ }
+
+ /**
+ * 请求更新GPS位置
+ *
+ */
+ @ActionKey(Router.GAME_UPDATE_POS)
+ public void routerUpdatePos(Session sender, ITObject params, int gid, Player owner) {
+ owner.gps_pos = params.getUtfString("pos");
+ updatePlayerPos(owner);
+ }
+
+ /**
+ * 入座
+ */
+ @ActionKey(Router.GAME_JOIN_SEAT)
+ public void routerJoinSeat(Session sender, ITObject params, int gid, Player owner) {
+ Global.gameCtr.joinSeat(owner, gid);
+ }
+
+// /**
+// * 观战
+// */
+// @ActionKey(Router.GAME_JOIN_SPECTATOR)
+// public void routerJoinSpectator(Session sender, ITObject params, int gid) {
+//
+//// player.seat = 0;
+// System.out.println("---------------参数session为null,参数params:"+params);
+// Global.logger.info("---------------参数session为null,参数params:{}", params);
+//// //进入房间
+//// player.room.addPlayer(player, true, false);
+//// ITObject data = new TObject();
+//// data.putInt("player", player.playerid);
+//// player.room.loadRedisPlayer();
+//// player.room.broadCastToClient(0, Router.GAME_EVT_JOIN_SPECTATOR, data);
+//// Global.roomMgr.joinRoom(sender, session_id, gid, pos);
+//// Global.gameCtr.joinSpectator(owner, gid);
+// String session_id = params.getUtfString("session");
+// // String sessionToken = Utils.getUniqueSessionToken(sender);
+// String token = null;
+// if (StringUtil.isEmpty(session_id)) {
+// Global.logger.info("---------------参数session为null,参数params:{}", params);
+// session_id = "";
+// } else {
+// String[] sourceStrArray = session_id.split(",");
+// if (sourceStrArray.length == 2) {
+// session_id = sourceStrArray[0];
+// token = sourceStrArray[1];
+// }
+//
+// if (StringUtil.isNotEmpty(token) && StringUtil.isNotEmpty(session_id)) {
+// String token_session = Redis.use("group1_db0").hget(token, "user");
+// if (StringUtil.isEmpty(token_session)) {
+// MainServer.instance.sendResponse(gid, ErrorCode._NO_SESSION, null, sender);
+// return;
+// } else {
+// if (!token_session.equals(session_id)) {
+// MainServer.instance.sendResponse(gid, ErrorCode._NO_SESSION, null, sender);
+// return;
+// }
+// }
+// } else {
+// MainServer.instance.sendResponse(gid, ErrorCode._NO_SESSION, null, sender);
+// return;
+// }
+// }
+// sender.setHashId(session_id);
+// String pos = params.getUtfString("pos");
+// Global.roomMgr.joinRoomOfSpectator(sender, session_id, gid, pos);
+// }
+
+ /**
+ * 退出观战
+ */
+ @ActionKey(value = Router.GAME_OUT_SPECTATOR)
+ public void routerOutSpectator(Session sender, ITObject params, int gid, Player owner) {
+
+ String session_id = "{user}:" + owner.playerid;
+ Global.roomMgr.outRoomOfSpectator(sender, session_id, gid, owner.playerid);
+
+ }
+
+ /**
+ * 进入房间
+ *
+ * @param parm
+ * @param gid
+ * @return
+ */
+ @SuppressWarnings("unchecked")
+ public int joinRoom(JoinRoomData parm, int gid) {
+ Room owner = parm.room;
+ String session_key = parm.session_key;
+ Session sender = parm.sender;
+ String gps_pos = parm.gps_pos;
+ AccountBean acc = AccountCache.getAccount(session_key);
+ int playerid = acc.id;
+
+ boolean full = owner.playerMapBySeat.size() >= owner.maxPlayers;
+ boolean reload = owner.status == Constant.ROOM_STATUS_PLAYING;
+
+ String ip = acc.ip;
+ if (StringUtil.isEmpty(ip)) {
+ ip = sender.getAddress();
+ }
+
+ Player player = null;
+ boolean new_player = false;
+ if (owner.playerMapById.containsKey(playerid)) {
+ player = owner.playerMapById.get(playerid);
+ if (player.isReload) {
+ player.isReload = false;
+ player.stateMachine.changeState(Global.getState(PlayerInitState.class));
+ }
+ player.setSender(sender);
+ Global.gameCtr.playerNetState(player);
+ Global.gameCtr.updatePlayerPos(player);
+ } else {
+ if (full) {
+ sender.setHashId(null);
+ delRoomSeat(session_key, owner.room_key);
+ return ErrorCode.ROOM_CLOSE;
+ }
+ // 检测是否打开GPS 、IP检测
+ boolean openGps = owner.isOpenGPSCheck(), openIP = owner.isOpenIPCheck();
+ if (openGps || openIP) {
+ int errResult = 0;
+ if (openGps) {
+ Global.warn("room:{},playid:{},gps:{}", owner.room_key, playerid, gps_pos);
+ // 开了检测GPS 但是未获取到位置、或未打开
+ if (!GPSUtil.isOpenGPS(gps_pos)) {
+ errResult = 55;
+ }
+ // 距离过近
+ if (errResult == 0 && owner.checkGps(gps_pos)) {
+ errResult = 54;
+ }
+ }
+ if (openIP) {
+ // 相同IP
+
+ if (errResult == 0 && owner.checkIp(ip)) {
+ errResult = 53;
+ }
+ }
+ if (errResult != 0) {
+ delRoomSeat(session_key, owner.room_key);
+ return errResult;
+ }
+ }
+ boolean onseat = true;
+ long cur_hp = 0;
+ if (onseat && owner.hpData != null) {
+ cur_hp = Util.readRedisHp(owner.groupId, playerid);
+ if (!checkHplimitInRoom(owner, cur_hp)) {
+ return ErrorCode.GROUP_LIMIT_NO_HP;
+ }
+ }
+
+ player = MainServer.instance.newPlayer(playerid, owner, session_key);
+ player.hp.cur_hp = cur_hp;
+
+ owner.addPlayer(player, false, onseat);
+ player.setSender(sender);
+ player.stateMachine.changeState(Global.getState(PlayerInitState.class));
+ new_player = true;
+ }
+
+ player.nick = acc.nick;
+ player.portrait = acc.portrait;
+ player.sex = acc.sex;
+ player.ip = ip;
+ if (StringUtil.isNotEmpty(gps_pos))
+ player.gps_pos = gps_pos;
+
+ ITObject data = new TObject();
+ if (reload) {
+ data.putTObject("reloadInfo", owner.getReloadInfo(player));
+ }
+ data.putBoolean("reload", reload);
+ data.putInt("owner", owner.owner_id);
+ data.putInt("agent", owner.agent ? 1 : 0);
+ data.putInt("createTime", Integer.parseInt(owner.redis_room_map.get("create_time")));
+// data.putInt("jing", owner.);
+ data.putTObject("tableInfo", owner.getRoomInfo());
+ data.putString("userIp", ip);
+ player.response(data, gid, 0);
+
+ if (new_player && player.seat != 0) {
+ owner.broadCastToClient(player.playerid, Router.GAME_EVT_PLAYER_JOIN, player.getInfo());
+ owner.broadCastToClientOfSpectator(Router.GAME_EVT_PLAYER_JOIN, player.getInfo());
+
+ }
+
+ if (reload) {
+ owner.join_player = player;
+ owner.dismissRunable.reload(player);
+ owner.stateMachine.curState.reload(owner);
+ player.stateMachine.curState.reload(player);
+ owner.join_player = null;
+ }
+ return 0;
+
+ }
+
+ /**
+ * 进入房间(观战)
+ *
+ * @param parm
+ * @param gid
+ * @return
+ */
+ @SuppressWarnings("unchecked")
+ public int joinRoomOfSpectator(JoinRoomData parm, int gid) {
+ Room owner = parm.room;
+ String session_key = parm.session_key;
+ Session sender = parm.sender;
+ String gps_pos = parm.gps_pos;
+ AccountBean acc = AccountCache.getAccount(session_key);
+ int playerid = acc.id;
+
+ boolean reload = owner.status == Constant.ROOM_STATUS_PLAYING;
+
+ String ip = acc.ip;
+ if (StringUtil.isEmpty(ip)) {
+ ip = sender.getAddress();
+ }
+
+ Player player = MainServer.instance.newPlayer(playerid, owner, session_key);
+ player.setSender(sender);
+
+ player.nick = acc.nick;
+ player.portrait = acc.portrait;
+ player.sex = acc.sex;
+ player.ip = ip;
+// if (StringUtil.isNotEmpty(gps_pos))
+// player.gps_pos = gps_pos;
+ owner.addPlayer(player, false, false);
+ ITObject data = new TObject();
+ data.putBoolean("reload", reload);
+ data.putInt("owner", owner.owner_id);
+ data.putInt("agent", owner.agent ? 1 : 0);
+ data.putInt("createTime", Integer.parseInt(owner.redis_room_map.get("create_time")));
+ data.putTObject("tableInfo", owner.getRoomInfo());
+ player.responseSpectator(data, gid, 0);
+
+ player.room.broadCastToClient(0, Router.GAME_EVT_JOIN_SPECTATOR, data);
+ player.room.broadCastToClientOfSpectator(Router.GAME_EVT_JOIN_SPECTATOR, data);
+
+ return 0;
+
+ }
+
+ /**
+ * 进入房间
+ *
+ * @param
+ * @param gid
+ * @return
+ */
+ @SuppressWarnings("unchecked")
+ public int spectator(Player owner, int gid) {
+ owner.stateMachine.changeState(Global.getState(PlayerSpectatorState.class));
+ return 0;
+
+ }
+
+ /**
+ * 玩家不能进入房间,删除redis 玩家身上room、seat
+ *
+ * @param session_key
+ * @param owner
+ */
+ public void delRoomSeat(String session_key, String room_key) {
+ Jedis jedis0 = Redis.use("group1_db0").getJedis();
+ RedisLock lock = new RedisLock(session_key, jedis0);
+ try {
+ lock.lock();
+ String cur_room = jedis0.hget(session_key, "room");
+ if (StringUtil.isNotEmpty(cur_room)) {
+ if (cur_room.equals(room_key)) {
+ jedis0.hdel(session_key, "room", "seat");
+ }
+ }
+ } finally {
+ lock.unlock();
+ }
+ }
+
+ /**
+ * 检测加人房间限制
+ *
+ * @param owner
+ * @return
+ */
+ public boolean checkHplimitInRoom(Room room, long cur_hp) {
+// if (room.hpData != null) {
+// int limitInRoom = room.hpData.getInt("limitInRoom");
+// if (cur_hp < (long) limitInRoom) {
+// return false;
+// }
+// }
+ return true;
+ }
+
+ /**
+ * 检测加人房间限制
+ *
+ * @param owner
+ * @return
+ */
+ public boolean checkHplimitPlay(Room room, int cur_hp) {
+// if (room.hpData != null) {
+// int limitInRoom = room.hpData.getInt("limitInRoom");
+// if (cur_hp < limitInRoom) {
+// return false;
+// }
+// }
+ return true;
+ }
+
+ /**
+ * 坐下
+ *
+ * @param owner
+ * @param gid
+ */
+ public void joinSeat(Player owner, int gid) {
+
+ }
+
+ /**
+ * 聊天转发
+ *
+ * @param owner
+ * @param params
+ */
+ public void chat(Player owner, ITObject params) {
+ owner.room.broadCastToClient(0, Router.GAME_EVT_INTERACTION, params);
+ }
+
+ /**
+ * 托管事件
+ *
+ * @param owner
+ */
+ public void entrust(Player owner, int time) {
+ ITObject broadParam = new TObject();
+ broadParam.putInt("aid", owner.playerid);
+ broadParam.putInt("time", time);
+ owner.room.broadCastToClient(0, Router.GAME_EVT_READY_ENTRUST, broadParam);
+ owner.room.broadCastToClientOfSpectator(Router.GAME_EVT_READY_ENTRUST, broadParam);
+ Global.info("{} Ready Entrust, left time:{}", owner.playerid, time);
+ }
+
+ /**
+ * 取消托管事件
+ *
+ * @param owner
+ */
+ public void cancelEntrust(Player owner) {
+ ITObject broadParam = new TObject();
+ broadParam.putInt("aid", owner.playerid);
+ owner.room.broadCastToClient(0, Router.GAME_EVT_CANCEL_READY_ENTRUST, broadParam);
+ // Global.info("{} Cancel Ready Entrust", owner.playerid);
+ }
+
+ /**
+ * 准备事件
+ *
+ * @param owner
+ */
+ public void ready(Player owner) {
+ ITObject broadParam = new TObject();
+ broadParam.putInt("aid", owner.playerid);
+ long cur_hp = Util.readRedisHp(owner.room.groupId, owner.playerid);
+ if (cur_hp < owner.hp.cur_hp) {
+ Global.logger.error("cur hp:" + cur_hp + " < hp.cur_hp:" + owner.hp.cur_hp + " playerId:" + owner.playerid);
+ if (owner.room.round == 0 && (!checkHplimitInRoom(owner.room, cur_hp) || cur_hp == 0)) {
+ owner.room.saveMilitaryTotal(true);
+ owner.room.stateMachine.changeState(Global.getState(RoomDestoryGameState.class));
+ String gm_key = GroupMemberCache.genKey(owner.room.groupId, owner.playerid);
+ Redis.use("group1_db10").hset(gm_key, "ban", "1");
+ Redis.use("group1_db10").hset(gm_key, "group_ban", "1");
+ return;
+ }
+ }
+ owner.hp.cur_hp = cur_hp;
+
+ boolean flag = true;
+ if (owner.room.maxPlayers == owner.room.playerMapBySeat.size()) {
+ for (Map.Entry entry : owner.room.playerMapBySeat.entrySet()) {
+ if (entry.getValue().playerid != owner.playerid
+ && !(entry.getValue().stateMachine.curState instanceof PlayerReadyState)) {
+ flag = false;
+ break;
+ }
+ }
+ } else {
+ flag = false;
+ }
+
+ if (flag) {
+ broadParam.putInt("start", 1);
+ } else {
+ broadParam.putInt("start", 0);
+ }
+ owner.room.broadCastToClient(0, Router.GAME_EVT_READY, broadParam);
+ owner.stateMachine.changeState(Global.getState(PlayerReadyState.class));
+ }
+
+ /**
+ * 准备和洗牌事件
+ *
+ * @param owner
+ */
+ public void readyAndXipai(Player owner) {
+ if (owner.xi_pai == false) {
+ owner.xi_pai = true;
+ owner.room.redisUpdateXiPaiPlayer(owner);
+ }
+ long cur_hp = Util.readRedisHp(owner.room.groupId, owner.playerid);
+ if (cur_hp < owner.hp.cur_hp || cur_hp == 0) {
+ Global.logger.error("cur hp:" + cur_hp + " < hp.cur_hp:" + owner.hp.cur_hp + " playerId:" + owner.playerid);
+ if (owner.room.round == 0 && (!checkHplimitInRoom(owner.room, cur_hp) || cur_hp == 0)) {
+ owner.room.saveMilitaryTotal(true);
+ owner.room.stateMachine.changeState(Global.getState(RoomDestoryGameState.class));
+ String gm_key = GroupMemberCache.genKey(owner.room.groupId, owner.playerid);
+ Redis.use("group1_db10").hset(gm_key, "ban", "1");
+ Redis.use("group1_db10").hset(gm_key, "group_ban", "1");
+ return;
+ }
+ }
+ owner.hp.cur_hp = cur_hp;
+ ITObject broadParam = new TObject();
+ broadParam.putInt("aid", owner.playerid);
+
+ boolean flag = true;
+ if (owner.room.maxPlayers == owner.room.playerMapById.size()) {
+ for (Map.Entry entry : owner.room.playerMapById.entrySet()) {
+ if (entry.getValue().playerid != owner.playerid
+ && !(entry.getValue().stateMachine.curState instanceof PlayerReadyState)) {
+ flag = false;
+ break;
+ }
+ }
+ } else {
+ flag = false;
+ }
+
+ if (flag) {
+ broadParam.putInt("start", 1);
+ } else {
+ broadParam.putInt("start", 0);
+ }
+ owner.room.broadCastToClient(0, Router.GAME_EVT_READY_AND_XIPAI, broadParam);
+ owner.stateMachine.changeState(Global.getState(PlayerReadyState.class));
+ }
+
+ /**
+ * 解散房间通知
+ *
+ * @param askPlayer
+ * @param sender
+ * @param time
+ */
+ public void dismissRoom(Player askPlayer, Player sender, List playerList, int time) {
+ ITObject parm = TObject.newInstance();
+ parm.putInt("req_aid", askPlayer.playerid);
+ parm.putInt("time", time);
+ ITArray list = TArray.newInstance();
+ parm.putTArray("list", list);
+ askPlayer.room.applyDismisUserId = askPlayer.nick;
+ askPlayer.room.dismisType = 1;
+ for (Player player : playerList) {
+ ITObject tem = TObject.newInstance();
+ tem.putInt("aid", player.playerid);
+ tem.putInt("result", player.dismissState);
+ list.addTObject(tem);
+ }
+ if (sender != null) {
+ sender.sendEvent(Router.GAME_EVT_DISMISS_ROOM, parm);
+ } else {
+ askPlayer.room.broadCastToClient(0, Router.GAME_EVT_DISMISS_ROOM, parm);
+ }
+
+// if (askPlayer.already_round == 1) {
+// int groupId = askPlayer.room.groupId;
+// int pid = askPlayer.room.groupPid;
+//
+// GroupPlayBean gpb = GroupCache.getPlay(groupId, pid);
+// int gameId = gpb.gameId;
+//
+// GameBean gb = GameCache.getGame(gameId);
+// int maxPlayers = gpb.maxPlayers;
+// Jedis jedis10 = Redis.use("group1_db10").getJedis();
+// int groupDiamo = Integer
+// .parseInt(jedis10.hget("g{" + askPlayer.room.groupId + "}:diamo", "diamo") == null ? "0"
+// : jedis10.hget("g{" + askPlayer.room.groupId + "}:diamo", "diamo"));
+//
+// ITObject configData = TObject.newFromJsonData(gpb.config);
+// int opt = configData.getInt("opt");
+// Integer pay = gb.pay.get("pay" + opt + "_" + maxPlayers);
+//
+// jedis10.hset("g{" + askPlayer.room.groupId + "}:diamo", "diamo", (groupDiamo + pay) + "");
+//
+// }
+// Utility.payDiamo(EventType.REDIS_EVENT_GROUP_ROOM, group.owner, gameId, pay, (int) cur_diamo, groupId, pid);
+
+ }
+
+// /**
+// * 观众席
+// *
+// * @param owner
+// */
+// public void joinSpectator(Player player, int gid) {
+//// if (Global.loggerDebug) {
+//// Global.logger.info(player + " exit seat!");
+//// }
+// player.seat = 0;
+// player.room.addPlayer(player, true, false);
+//
+//// player.room.broadCastToClient(0, Router.GAME_EVT_JOIN_SPECTATOR, data);
+//// player.room.stateMachine.execute(ActionEvent.EVENT_READY, 0, null);
+// }
+
+ /**
+ * 解散失败
+ *
+ * @param owner
+ */
+ public void dismisRoomFail(Room owner, List playerList, Player askPlayer, int time) {
+ ITObject parm = TObject.newInstance();
+ parm.putInt("req_aid", askPlayer.playerid);
+ ITArray list = TArray.newInstance();
+ parm.putTArray("list", list);
+
+ for (Player player : playerList) {
+ ITObject tem = TObject.newInstance();
+ tem.putInt("aid", player.playerid);
+ tem.putInt("result", player.dismissState);
+ list.addTObject(tem);
+ }
+
+ owner.broadCastToClient(0, Router.GAME_EVT_DISMISS_ROOM_FAIL, parm);
+ }
+
+ /**
+ * 退出房间
+ *
+ * @param owner
+ * @param gid
+ */
+ public void exitRoom(Player owner, int gid, boolean kick) {
+ if (kick) {
+ owner.sendEvent(Router.GAME_EVT_KICK_PLAYER, null);
+ } else {
+ owner.response(null, gid, 0);
+ }
+ if (owner.room.status == Constant.ROOM_STATUS_NOBEGIN || owner.spectator) {
+
+ owner.room.dismisType = 1;
+ owner.room.applyDismisUserId = owner.nick;
+ int owner_id = owner.room.owner_id;
+ if (!owner.room.agent && owner.playerid == owner_id) {
+ owner.room.stateMachine.changeState(Global.getState(RoomDestoryGameState.class));
+ } else {
+ // 在座位上
+ if (owner.room.playerMapBySeat.containsKey(owner.seat)) {
+ ITObject data = new TObject();
+ data.putInt("aid", owner.playerid);
+ owner.room.broadCastToClient(owner.playerid, Router.GAME_EVT_PLAYER_EXIT, data);
+ owner.destroy(true);
+ }
+
+ }
+ // 观战
+ for (Entry entry : owner.room.playerMapBySpectator.entrySet()) {
+ ITObject data = new TObject();
+ data.putInt("aid", owner.playerid);
+ owner.room.broadCastToClientOfSpectator(Router.GAME_EVT_PLAYER_EXIT, data);
+ owner.destroy(true);
+ }
+
+ Jedis jedis0 = Redis.use("group1_db0").getJedis();
+ Jedis jedis11 = Redis.use("group1_db11").getJedis();
+ try {
+ jedis0.hset("{user}:" + owner.playerid, "online", "stopPlaying");
+
+ String userOnline = jedis0.hget("{user}:" + owner.playerid, "online");
+
+ ITObject params = new TObject();
+ params.putString("online", userOnline);
+ params.putString("uid", String.valueOf(owner.playerid));
+ String key = GroupCache.genGroupsKey(owner.playerid);
+ Set groups = jedis11.zrevrange(key, 0, -1);
+ for (String tem : groups) {
+ GroupPublisherService.playerGameState(Integer.parseInt(tem), params);
+ }
+ } catch (Exception e) {
+ Global.logger.error("setGroupHeartbeat error", e);
+ } finally {
+ jedis0.close();
+ jedis11.close();
+ }
+
+ }
+ }
+
+ /**
+ * 玩家网络状态通知
+ *
+ * @param owner
+ */
+ public void playerNetState(Player owner) {
+ ITObject param = new TObject();
+ param.putInt("aid", owner.playerid);
+ param.putInt("online", owner.isConnect ? 1 : 0);
+ owner.room.updatePlayerOffline(owner);
+ owner.room.broadCastToClient(owner.playerid, Router.GAME_EVT_PLAYER_NET_STATE, param);
+ owner.room.broadCastToClientOfSpectator(Router.GAME_EVT_PLAYER_NET_STATE, param);
+
+ }
+
+ /**
+ * 更新玩家GPS位置
+ *
+ * @param owner
+ */
+ public void updatePlayerPos(Player owner) {
+ ITObject param = new TObject();
+ param.putInt("seat", owner.seat);
+ param.putUtfString("pos", owner.gps_pos);
+ owner.room.broadCastToClient(owner.playerid, Router.GAME_EVT_UPDATE_POS, param);
+ }
+
+ /**
+ * 更新玩家托管
+ *
+ * @param owner
+ */
+ public void updatePlayerEntrust(Player owner) {
+ ITObject param = new TObject();
+ param.putInt("aid", owner.playerid);
+ param.putInt("type", 5);
+ param.putBoolean("entrust", owner.entrust);
+ owner.room.broadCastToClient(0, Router.GAME_EVT_UPDATE_PLAYERINFO, param);
+ owner.room.broadCastToClientOfSpectator(Router.GAME_EVT_UPDATE_PLAYERINFO, param);
+ }
+
+// @ActionKey(Router.SET_HOME_MEMBER_COUNT)
+// public void setHomeMemberCount(Session sender, ITObject params, int gid, Player owner) {
+// Global.logger.info("setHomeMemberCount----------------------进来了");
+// int uids = params.getInt("uid");
+// String gameStatus = params.getString("gameStatus");
+//
+// Jedis jedis0 = Redis.use("group1_db0").getJedis();
+//
+// try {
+// jedis0.hset("{user}:" + uids, "setHome", gameStatus);
+// jedis0.hset("{user}:" + uids+ "_online", "online", "0");
+// String setHome = jedis0.hget("{user}:" + uids, "setHome");
+// params.putString("setHome", setHome);
+// owner.room.broadCastToClient(0, Router.GAME_PUSH_HOME_MEMBER_COUNT, params);
+// }catch (Exception e){
+// Global.logger.error("setGroupHeartbeat error", e);
+// }finally {
+// jedis0.close();
+// }
+// }
+}
diff --git a/game_common/src/main/java/com/game/GameInterceptor.java b/game_common/src/main/java/com/game/GameInterceptor.java
new file mode 100644
index 0000000..32dee42
--- /dev/null
+++ b/game_common/src/main/java/com/game/GameInterceptor.java
@@ -0,0 +1,55 @@
+package com.game;
+
+import java.lang.reflect.Method;
+
+import com.game.data.Player;
+import com.game.data.Room;
+import com.taurus.core.entity.TObject;
+import com.taurus.core.routes.Action;
+import com.taurus.core.routes.IController;
+import com.taurus.core.routes.Interceptor;
+import com.taurus.permanent.data.Session;
+
+public class GameInterceptor implements Interceptor{
+ public final static int NOT_PLAYER = 1;
+
+ @Override
+ public void intercept(Action action, IController controller,Object... args) throws Exception{
+ int validate = action.getActionKeyObj().validate();
+ Session sender = (Session)args[0];
+ TObject params = (TObject)args[1];
+ int gid = (int)args[2];
+ Method method = action.getMethod();
+ if((validate&NOT_PLAYER)!=0) {
+ method.invoke(controller,sender,params,gid);
+ }else {
+ Player player = Global.sessionMgr.getPlayer(sender);
+ if (player != null) {
+ Room room = player.room;
+ if (room == null)return;
+ if (room.isDestroy)return;
+ room.enqueueRunnable(new Runnable() {
+ @Override
+ public void run() {
+ if(player.isDestroy)return;
+ if(player.room.playerMapById.containsKey(player.playerid)) {
+ try {
+ method.invoke(controller, sender,params,gid,player);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ if(player.room.playerMapBySpectator.containsKey(player.playerid)) {
+ try {
+ method.invoke(controller, sender,params,gid,player);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+ });
+ }
+ }
+ }
+
+}
diff --git a/game_common/src/main/java/com/game/Global.java b/game_common/src/main/java/com/game/Global.java
new file mode 100644
index 0000000..86b80a0
--- /dev/null
+++ b/game_common/src/main/java/com/game/Global.java
@@ -0,0 +1,104 @@
+package com.game;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import com.game.manager.RoomManager;
+import com.game.manager.SessionManager;
+import com.game.player.state.PlayerEndState;
+import com.game.player.state.PlayerInitState;
+import com.game.player.state.PlayerPauseState;
+import com.game.player.state.PlayerPopupState;
+import com.game.player.state.PlayerReadyState;
+import com.game.player.state.PlayerReloadState;
+import com.game.player.state.PlayerSpectatorState;
+import com.game.player.state.PlayerWaitState;
+import com.game.room.state.RoomDestoryGameState;
+import com.game.room.state.RoomEndState;
+import com.game.room.state.RoomInitState;
+import com.game.room.state.RoomReloadState;
+import com.game.room.state.RoomStartGameState;
+import com.game.room.state.RoomWaitState;
+import com.game.state.StateBase;
+import com.taurus.core.util.Logger;
+
+public class Global {
+ /**
+ * debug模式
+ */
+ public static boolean loggerDebug = false;
+ // 日志
+ public static Logger logger;
+ // session管理器
+ public static SessionManager sessionMgr;
+ // 桌子管理器
+ public static RoomManager roomMgr;
+
+ public static GameController gameCtr;
+
+ public static EventController eventCtr;
+ /**
+ * 游戏ID
+ */
+ public static int gameId = 1;
+ /**
+ * 游戏名字
+ */
+ public static String gameName = "";
+
+
+
+ public static void init() {
+
+ Global.sessionMgr = new SessionManager();
+ Global.roomMgr = new RoomManager();
+ Global.eventCtr = new EventController();
+
+ registerState(RoomInitState.class, new RoomInitState());
+ registerState(RoomEndState.class, new RoomEndState());
+ registerState(RoomDestoryGameState.class, new RoomDestoryGameState());
+ registerState(RoomWaitState.class, new RoomWaitState());
+ registerState(RoomReloadState.class, new RoomReloadState());
+ registerState(RoomStartGameState.class, new RoomStartGameState());
+
+ registerState(PlayerInitState.class, new PlayerInitState());
+ registerState(PlayerPauseState.class, new PlayerPauseState());
+ registerState(PlayerReadyState.class, new PlayerReadyState());
+ registerState(PlayerReloadState.class, new PlayerReloadState());
+ registerState(PlayerWaitState.class, new PlayerWaitState());
+ registerState(PlayerSpectatorState.class, new PlayerSpectatorState());
+ registerState(PlayerPopupState.class, new PlayerPopupState());
+ registerState(PlayerEndState.class, new PlayerEndState());
+ }
+
+ private static Map, StateBase>> state_map = new HashMap<>();
+
+ public static void registerState(Class> cls, StateBase> state) {
+ state_map.put(cls, state);
+ }
+
+ public static StateBase> getState(Class> cls) {
+ StateBase> state = state_map.get(cls);
+ return state;
+ }
+
+
+
+ public static void info(String msg, Object... params) {
+ if (loggerDebug) {
+ logger.info(Util.stringFormat(msg, params));
+ }
+ }
+
+ public static void warn(String msg, Object... params) {
+ if (loggerDebug) {
+ logger.warn(Util.stringFormat(msg, params));
+ }
+ }
+
+ public static void error(String msg, Object... params) {
+ if (loggerDebug) {
+ logger.error(Util.stringFormat(msg, params));
+ }
+ }
+}
diff --git a/game_common/src/main/java/com/game/GroupPublisherService.java b/game_common/src/main/java/com/game/GroupPublisherService.java
new file mode 100644
index 0000000..7270de0
--- /dev/null
+++ b/game_common/src/main/java/com/game/GroupPublisherService.java
@@ -0,0 +1,95 @@
+package com.game;
+
+import com.data.util.Utility;
+import com.taurus.core.entity.ITArray;
+import com.taurus.core.entity.ITObject;
+import com.taurus.core.entity.TArray;
+import com.taurus.core.entity.TObject;
+import com.taurus.core.plugin.database.DataBase;
+import com.taurus.core.plugin.redis.Redis;
+import com.taurus.permanent.TPServer;
+import redis.clients.jedis.Jedis;
+
+import java.sql.SQLException;
+
+/**
+ * 圈子订阅服务
+ */
+public class GroupPublisherService {
+ public static final String CHANNEL_NAME = "mgr_group";
+
+ private static final String CMD_DEL_ROOM = "del_room";
+ private static final String CMD_UPDATE_ROOM = "update_room";
+ // 实时推送数据
+ public static final String CMD_PUSH_CHAT_ROOM = "push_chat_room";
+
+// 玩家游戏状态推送
+ public static final String CMD_PLAYER_GAME_STATE = "player_game_state";
+
+ /**
+ * 删除房间事件
+ *
+ * @param groupId
+ * @param roomid
+ */
+ public static void delRoomEvt(int groupId, String roomid) {
+ if (groupId == 0)
+ return;
+ ITObject data = TObject.newInstance();
+ data.putInt("gid", groupId);
+ data.putUtfString("roomid", roomid);
+ data.putUtfString("cmd", CMD_DEL_ROOM);
+ Jedis jedis11 = Redis.use("group1_db11").getJedis();
+ jedis11.publish(CHANNEL_NAME, data.toJson());
+ jedis11.close();
+ }
+
+ /**
+ * 更新房间事件
+ *
+ * @param groupId
+ * @param roomid
+ */
+ public static void updateRoomEvt(int groupId, String roomid) {
+ if (groupId == 0)
+ return;
+ ITObject data = TObject.newInstance();
+ data.putInt("gid", groupId);
+ data.putUtfString("roomid", roomid);
+ data.putUtfString("cmd", CMD_UPDATE_ROOM);
+ Jedis jedis11 = Redis.use("group1_db11").getJedis();
+
+ jedis11.publish(CHANNEL_NAME, data.toJson());
+ jedis11.close();
+ }
+
+ public static void pushChatRoom(int groupId, ITObject data, String messageCount) {
+ if (groupId == 0)
+ return;
+ ITObject datas = TObject.newInstance();
+ datas.putInt("gid", groupId);
+ datas.putUtfString("messageCount", messageCount);
+// datas.putInt("uid",);
+ datas.putTObject("datas", data);
+ datas.putUtfString("cmd", CMD_PUSH_CHAT_ROOM);
+ Jedis jedis11 = Redis.use("group1_db11").getJedis();
+
+ jedis11.publish(CHANNEL_NAME, datas.toJson());
+ jedis11.close();
+ }
+
+ // 游戏中状态推送
+ public static void playerGameState(int groupId, ITObject data) {
+ if (groupId == 0)
+ return;
+ ITObject datas = TObject.newInstance();
+ datas.putString("uid", data.getString("uid"));
+ datas.putInt("gid", groupId);
+ datas.putString("playing", data.getString("online"));
+ datas.putUtfString("cmd", CMD_PLAYER_GAME_STATE);
+ Jedis jedis11 = Redis.use("group1_db11").getJedis();
+ jedis11.publish(CHANNEL_NAME, datas.toJson());
+ jedis11.close();
+ }
+
+}
diff --git a/game_common/src/main/java/com/game/MainServer.java b/game_common/src/main/java/com/game/MainServer.java
new file mode 100644
index 0000000..1b02d41
--- /dev/null
+++ b/game_common/src/main/java/com/game/MainServer.java
@@ -0,0 +1,172 @@
+package com.game;
+
+import java.io.FileInputStream;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.input.SAXBuilder;
+
+import com.game.data.Player;
+import com.game.data.Room;
+import com.taurus.core.entity.ITObject;
+import com.taurus.core.events.Event;
+import com.taurus.core.events.IEventListener;
+import com.taurus.core.plugin.redis.Redis;
+import com.taurus.core.routes.Extension;
+import com.taurus.core.routes.Routes;
+import com.taurus.core.util.Logger;
+import com.taurus.permanent.TPServer;
+import com.taurus.permanent.core.TPEvents;
+import com.taurus.permanent.data.Session;
+
+/**
+ *
+ *
+ */
+public abstract class MainServer extends Extension implements IEventListener{
+
+ public static MainServer instance;
+
+ private static final String GMAE_CONFIG = "config/game-config.xml";
+ public GameSetting gameSetting;
+
+ @Override
+ public void onStart() {
+ instance = this;
+
+ Global.logger = Logger.getLogger(getClass());
+ try {
+ loadConfig();
+ } catch (Exception e) {
+ Global.logger.error(e);
+ }
+
+ Global.init();
+
+ TPServer.me().getEventManager().addEventListener(TPEvents.EVENT_SESSION_DISCONNECT, this);
+
+ Map svr_info = new HashMap<>();
+ svr_info.put("ip", gameSetting.host);
+ svr_info.put("port", gameSetting.port + "");
+ svr_info.put("intranet", gameSetting.intranet);
+ svr_info.put("conns", "0");
+ String svr_key = "svr" +gameSetting.serverId;
+ Global.gameId = gameSetting.gameId;
+ Global.gameName = Redis.use("group1_db1").hget("game:" + Global.gameId, "name");
+ Global.loggerDebug = gameSetting.loggerDebug;
+ Redis.use().hmset(svr_key, svr_info);
+ Redis.use().expire(svr_key, 60);
+ TPServer.me().getTimerPool().scheduleAtFixedRate(new Runnable() {
+
+ @Override
+ public void run() {
+ try {
+ svr_info.put("conns", Global.sessionMgr.size() + "");
+ Redis.use().hmset(svr_key, svr_info);
+ Redis.use().expire(svr_key, 60);
+ } catch (Exception e) {
+ Global.logger.error(e);
+ }
+ }
+ }, 30, 30, TimeUnit.SECONDS);
+
+ Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
+
+ @Override
+ public void run() {
+ List list = Global.sessionMgr.getPlayerList();
+ for (Player p : list) {
+ Global.sessionMgr.deleteSession(p.sender);
+ }
+ }
+ }));
+ }
+
+ public abstract Room newRoom(String roomid, Map redis_room_map);
+
+ public abstract Player newPlayer(int playerid, Room room, String session_id);
+
+ /**
+ * 创建游戏控制器
+ * @return
+ */
+ protected abstract GameController newController();
+
+
+ /**
+ * 发送事件给单一客户端
+ * @param cmdName 事件协议号
+ * @param params 数据参数
+ * @param recipient 客户端session
+ */
+ public void sendEvent(String cmdName, ITObject params, Session recipient) {
+ TPServer.me().getController().sendEvent(cmdName, params, recipient);
+ }
+
+ /**
+ * 发送事件给客户端
+ * @param cmdName 事件协议号
+ * @param params 数据参数
+ * @param recipients 客户端session列表
+ */
+ public void sendEvent(String cmdName, ITObject params, List recipients) {
+ TPServer.me().getController().sendEvent(cmdName, params, recipients);
+ }
+
+ /**
+ * 动态响应客户端请示
+ * @param gid 响应标识ID
+ * @param result 响应结果 0成功
+ * @param params 数据参数
+ * @param recipient 客户端session
+ */
+ public void sendResponse(int gid, int result, ITObject params, Session recipient) {
+ TPServer.me().getController().sendResponse(gid, result, params, recipient);
+ }
+
+ protected void loadConfig() throws Exception {
+ FileInputStream is = new FileInputStream(GMAE_CONFIG);
+ SAXBuilder builder = new SAXBuilder();
+ Document document = builder.build(is);
+ Element root = document.getRootElement();
+ GameSetting config = new GameSetting();
+ config.host = root.getChildTextTrim("host");
+ config.port = Integer.parseInt(root.getChildTextTrim("port"));
+ config.serverId = Integer.parseInt(root.getChildTextTrim("serverId"));
+ config.gameId = Integer.parseInt(root.getChildTextTrim("gameId"));
+ config.loggerDebug =Boolean.parseBoolean(root.getChildTextTrim("loggerDebug"));
+ config.intranet = root.getChildTextTrim("intranet");
+ this.gameSetting = config;
+ }
+
+ @Override
+ public void handleEvent(Event event) {
+ if (event.getName() == TPEvents.EVENT_SESSION_DISCONNECT) {
+ Session session = (Session) event.getParameter(TPEvents.PARAM_SESSION);
+ Global.sessionMgr.disconnect(session);
+ }
+ }
+
+
+
+
+ @Override
+ public void configRoute(Routes me) {
+ me.setInterceptor(new GameInterceptor());
+ Global.gameCtr = newController();
+ me.add("",Global.gameCtr);
+ }
+
+ public static final class GameSetting {
+ public String host = "127.0.0.1";
+ public String intranet = "127.0.0.1";
+ public int port = 6379;
+ public int serverId = 1;
+ public int gameId = 1;
+ public boolean loggerDebug = true;
+ }
+}
diff --git a/game_common/src/main/java/com/game/Router.java b/game_common/src/main/java/com/game/Router.java
new file mode 100644
index 0000000..3180b25
--- /dev/null
+++ b/game_common/src/main/java/com/game/Router.java
@@ -0,0 +1,183 @@
+package com.game;
+
+import com.game.data.Player;
+import com.taurus.core.entity.ITObject;
+import com.taurus.permanent.data.Session;
+
+/**
+ * 网络路由处理
+ *
+ */
+public abstract class Router {
+ /**
+ * 删除房间
+ */
+ public static final String GAME_REMOVE_ROOM = "1000";
+ /**
+ * 更新GPS位置
+ */
+ public static final String GAME_UPDATE_POS = "1001";
+ /**
+ * 更新GPS位置事件
+ */
+ public static final String GAME_EVT_UPDATE_POS = "2000";
+ /**
+ * 进入房
+ */
+ public static final String GAME_JOIN_ROOM = "1002";
+ /**
+ * 玩家进入房间
+ */
+ public static final String GAME_EVT_PLAYER_JOIN = "2001";
+ /**
+ * 玩家退出
+ */
+ public static final String GAME_EVT_PLAYER_EXIT = "2002";
+ /**
+ * 玩家网络状态
+ */
+ public static final String GAME_EVT_PLAYER_NET_STATE = "2003";
+ /**
+ * 发送聊天
+ */
+ public static final String GAME_INTERACTION = "1006";
+ /**
+ * 聊天事件
+ */
+ public static final String GAME_EVT_INTERACTION = "2017";
+ /**
+ * 退出房间
+ */
+ public static final String GAME_EXIT_ROOM = "1005";
+ /**
+ * 房主退出房间解散
+ */
+ public static final String GAME_EVT_EXIT_ROOM_DISMISS = "2008";
+
+ /**
+ * 发送准备
+ */
+ public static final String GAME_READY = "1003";
+
+ /**
+ * 发送准备加洗牌
+ */
+ public static final String GAME_READY_AND_XIPAI = "201004";
+
+ /**
+ * 准备加洗牌 返回
+ */
+ public static final String GAME_EVT_READY_AND_XIPAI = "202009";
+
+ /**
+ * 准备事件
+ */
+ public static final String GAME_EVT_READY = "2009";
+
+
+
+
+ /**
+ * 通知托管倒计时
+ */
+ public static final String GAME_EVT_READY_ENTRUST = "22010";
+ public static final String GAME_EVT_CANCEL_READY_ENTRUST = "22011";
+
+
+ public static final String GAME_XIPAI = "20836";
+
+ public static final String GAME_EVENT_XIPAI = "20837";
+
+ public static final String GAME_EVENT_NOTIFY_XIPAI = "20838";
+
+ /**
+ * 请求开始游戏
+ */
+ public static final String GAME_START = "1004";
+ /**
+ * 请求解散房间
+ */
+ public static final String GAME_ASK_DISMISS_ROOM = "1007";
+ /**
+ * 解散房间
+ */
+ public static final String GAME_EVT_DISMISS_ROOM = "2005";
+ /**
+ * 请求解散房间投票
+ */
+ public static final String GAME_DISMISS_ROOM_VOTE = "1008";
+ /**
+ * 解散房间投票事件
+ */
+ public static final String GAME_EVT_DISMISS_ROOM_VOTE = "2006";
+ /**
+ * 解散房间失败
+ */
+ public static final String GAME_EVT_DISMISS_ROOM_FAIL= "2027";
+ /**
+ *
+ */
+ public static final String GAME_EVT_SEND_REDPACKET= "3000";
+ /**
+ * 玩家被退出
+ */
+ public static final String GAME_EVT_KICK_PLAYER= "3001";
+
+ /**
+ * 玩家缺体力值弹起
+ */
+ public static final String GAME_EVT_STAND_UP= "3004";
+
+ /**
+ * 托管
+ */
+ public static final String GAME_ENTRUST= "1301";
+ /**
+ * 入座
+ */
+ public static final String GAME_JOIN_SEAT= "1302";
+ /**
+ * 自动
+ */
+ public static final String GAME_AUTO_CARD = "1303";
+
+ /**
+ * 玩家进入观众席
+ */
+ public static final String GAME_EVT_JOIN_SPECTATOR= "3012";
+
+ /**
+ * 玩家退出观众席
+ */
+ public static final String GAME_EVT_OUT_SPECTATOR= "3022";
+ /**
+ * 玩家进入观众席
+ */
+ public static final String GAME_JOIN_SPECTATOR= "3013";
+ /**
+ * 玩家退出观众席
+ */
+ public static final String GAME_OUT_SPECTATOR= "3023";
+// public static final String SET_HOME_MEMBER_COUNT= "3009";
+ //推送
+// public static final String GAME_PUSH_HOME_MEMBER_COUNT= "3010";
+ /**
+ * 更新玩家信息
+ */
+ public static final String GAME_EVT_UPDATE_PLAYERINFO= "3003";
+ /**
+ * 客户端数据出错,需要重连服务器,更新关键数据
+ */
+ public static final String GAME_EVT__UPDATE_RECONECT = "3005";
+
+
+
+
+
+
+ public void handel(Session sender, ITObject params, int gid){
+
+ }
+
+ public abstract void handelRoom(Player owner, ITObject params, int gid);
+}
diff --git a/game_common/src/main/java/com/game/Util.java b/game_common/src/main/java/com/game/Util.java
new file mode 100644
index 0000000..ef8ffcb
--- /dev/null
+++ b/game_common/src/main/java/com/game/Util.java
@@ -0,0 +1,302 @@
+package com.game;
+
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+
+import com.data.cache.GroupMemberCache;
+import com.taurus.core.entity.ITArray;
+import com.taurus.core.entity.TArray;
+import com.taurus.core.plugin.redis.Redis;
+import com.taurus.core.util.DateUtils;
+import com.taurus.core.util.StringUtil;
+
+import redis.clients.jedis.Jedis;
+
+public class Util {
+ public final static Random random = new Random();
+ static {
+ random.setSeed(System.currentTimeMillis());
+ }
+
+ /**
+ * list to TArray
+ * @param list
+ * @return
+ */
+ public static final ITArray toTArray(List list) {
+ ITArray result = new TArray();
+ for (Integer card : list) {
+ result.addInt(card);
+ }
+ return result;
+ }
+
+ /**
+ * call checkCard
+ * @param eventCard
+ * @param cardList
+ * @return
+ */
+ @Deprecated
+ public static boolean cardInList(int eventCard, List cardList) {
+ return checkCard(eventCard, cardList);
+ }
+
+ @Deprecated
+ public static final ITArray toMPGroup(List list) {
+ ITArray result = new TArray();
+ for (int[] card : list) {
+ result.addInt(card[0]);
+ }
+ return result;
+ }
+
+ /**
+ * list to mod 100 list
+ * @param list
+ * @return
+ */
+ public static final List toModList(List list){
+ List tem = new ArrayList();
+ for(Integer card : list) {
+ tem.add(card % 100);
+ }
+ return tem;
+ }
+
+ /**
+ * TArray to mod 100 list
+ * @param list
+ * @return
+ */
+ public static final List toModList(ITArray list){
+ List tem = new ArrayList<>();
+ for(int i=0;i cardList) {
+ int result = 0;
+ for (Integer card : cardList) {
+ if (card == eventCard) {
+ result += 1;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * 检测牌是否存在
+ * @param eventCard
+ * @param cardList
+ * @return
+ */
+ public static final boolean checkCard(int eventCard, List cardList) {
+ for (Integer card : cardList) {
+ if (card == eventCard) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * 检测牌数量
+ * @param eventCard
+ * @param cardList
+ * @param num
+ * @return
+ */
+ public static final boolean checkCard(int eventCard, List cardList, int num) {
+ int result = 0;
+ for (Integer card : cardList) {
+ if (card == eventCard) {
+ result++;
+ if (result == num)
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * 检测牌数量并将满足条件的删除
+ * @param eventCard
+ * @param cardList
+ * @param num
+ * @return
+ */
+ public static final boolean checkCardAndRomve(int eventCard, List cardList, int num) {
+ if (checkCard(eventCard, cardList, num)) {
+ removeCard(cardList, eventCard, num);
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * 获取每张牌的数量MAP
+ * @param cardList
+ * @return
+ */
+ public static final Map getCardNumMap(List cardList) {
+ Map result = new HashMap();
+ for (Integer card : cardList) {
+ if (!result.containsKey(card)) {
+ result.put(card, 1);
+ } else {
+ int num = result.get(card);
+ result.put(card, (num + 1));
+ }
+ }
+ return result;
+ }
+
+ /**
+ * 检测牌数量
+ * @param map
+ * @param card
+ * @param num
+ * @return
+ */
+ public static boolean cardNum(Map map, int card, int num) {
+ Integer _num = map.get(card);
+ if (_num != null && _num >= num) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * 移除指定数量的牌
+ * @param cardList
+ * @param card
+ * @param count
+ */
+ public static final void removeCard(List cardList, int card, int count) {
+ int curCount = 0;
+ for (int i = 0; i < cardList.size(); i++) {
+ if (cardList.get(i) == card) {
+ cardList.remove(i);
+ i--;
+ curCount++;
+ }
+
+ if (count == curCount) {
+ return;
+ }
+ }
+ }
+
+ static final public void addCard(ITArray opcard, int card, int num) {
+ for (int i = 0; i < num; ++i) {
+ opcard.addInt(card);
+ }
+ }
+
+ static final public void addCard(List cardList, int card, int num) {
+ for (int i = 0; i < num; ++i) {
+ cardList.add(card);
+ }
+ }
+
+ /**
+ * 获取今天凌晨0点时间戳
+ * @return
+ */
+ public static int todayTimeSec() {
+ Calendar cal = Calendar.getInstance();
+ cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
+ int timeSec = (int) (cal.getTimeInMillis() / 1000);
+ return timeSec;
+ }
+
+ /**
+ * 根据时间戳获取指定当天凌晨10位时间戳
+ * @param timeSec
+ * @return
+ */
+ public static int todayTimeSec(Long timeSec) {
+ Calendar cal = Calendar.getInstance();
+ // 指定日期
+ cal.setTime(new Date(timeSec));
+ cal.set(Calendar.HOUR_OF_DAY, 0);
+ cal.set(Calendar.MINUTE, 0);
+ cal.set(Calendar.SECOND, 0);
+ cal.set(Calendar.MILLISECOND, 0);
+ return (int) (cal.getTimeInMillis() / 1000);
+ }
+
+ /**
+ * msg ps : param:{},param:{}
+ * ==> param: abc,param:abced
+ * @param msg
+ * @param params
+ * @return
+ */
+ public static String stringFormat(String msg, Object... params) {
+ try {
+ if (StringUtil.isNotEmpty(msg)) {
+ msg = msg.replaceAll("\\{}", "\\%s");
+ return String.format(msg, params);
+ }
+ } catch (Exception e) {
+ return "";
+ }
+ return "";
+ }
+
+// public static void countLog(String key,int num,Jedis jedis) {
+// String day_key = key + ":d"+DateUtils.getBeginDay();
+// String week_key = key + ":w"+DateUtils.getBeginWeek();
+// String month_key = key + ":m"+DateUtils.getBeginMonth();
+// jedis.incrBy(day_key,num);
+// jedis.expire(day_key, 11*3600*24);
+// jedis.incrBy(week_key,num);
+// jedis.expire(week_key, 15*3600*24);
+// jedis.incrBy(month_key,num);
+// jedis.expire(month_key, 63*3600*24);
+// }
+
+ /**
+ * 获取玩家体力值
+ * @param gid
+ * @param uid
+ * @return
+ */
+ public static long readRedisHp(int gid,int uid) {
+ String key = GroupMemberCache.genKey(gid, uid);
+ String hp = Redis.use("group1_db10").hget(key, "hp");
+ long cur_hp = StringUtil.isNotEmpty(hp) ? Long.parseLong(hp) : 0;
+ return cur_hp;
+ }
+}
diff --git a/game_common/src/main/java/com/game/data/BasePlayBack.java b/game_common/src/main/java/com/game/data/BasePlayBack.java
new file mode 100644
index 0000000..c721e31
--- /dev/null
+++ b/game_common/src/main/java/com/game/data/BasePlayBack.java
@@ -0,0 +1,108 @@
+package com.game.data;
+
+import java.util.Map.Entry;
+
+import com.game.Global;
+import com.taurus.core.entity.ITArray;
+import com.taurus.core.entity.ITObject;
+import com.taurus.core.entity.TArray;
+import com.taurus.core.entity.TObject;
+import com.taurus.core.util.Utils;
+
+/**
+ * 回放数据记录
+ *
+ */
+public abstract class BasePlayBack {
+ /**
+ * 房间信息
+ */
+ protected ITObject info;
+ /**
+ * 指令列表
+ */
+ protected ITArray cmdList;
+
+ protected BasePlayBack(Room room) {
+ info = TObject.newInstance();
+ cmdList = TArray.newInstance();
+ info.putUtfString("roomid", room.roomid);
+ info.putInt("round", room.round);
+ info.putTObject("config", room.config);
+ info.putInt("banker_seat", room.bankerSeat);
+ info.putInt("active_seat", room.activeSeat);
+ info.putInt("game_id", Global.gameId);
+
+ ITArray infoList = new TArray();
+ for (Entry entry : room.playerMapByPlaying.entrySet()) {
+ Player player = entry.getValue();
+ if(player.already_round==0)continue;
+ ITObject obj = getPlayerInfo(player);
+ infoList.addTObject(obj);
+ }
+ info.putTArray("playerData", infoList);
+ }
+
+ protected ITObject getPlayerInfo(Player player) {
+ ITObject obj = TObject.newInstance();
+ obj.putInt("aid", player.playerid);
+ obj.putUtfString("nick", player.nick);
+ obj.putInt("sex", player.sex);
+ obj.putUtfString("portrait", player.portrait);
+ obj.putInt("seat", player.seat);
+ player.hp_info(obj);
+ return obj;
+ }
+
+ protected void addCommand(String cmd, int seat, ITObject data) {
+ ITObject cmdObj = TObject.newInstance();
+ cmdObj.putUtfString("cmd", cmd);
+ cmdObj.putInt("seat", seat);
+ cmdObj.putTObject("data", data);
+ cmdList.addTObject(cmdObj);
+ }
+
+ /**
+ * 获取战绩回放数据,保存到redisd
+ *
+ * @return
+ */
+ public ITObject getData() {
+ ITObject data = TObject.newInstance();
+ data.putTObject("info", info);
+ data.putTArray("cmdList", cmdList);
+ return data;
+ }
+ /**
+ * 给客户端的提示按钮
+ * @param seat
+ * @param cmdData
+ */
+ public void addTipCommand(int seat, ITObject cmdData) {
+ addCommand("Tip", seat, cmdData);
+ }
+
+ /**
+ * 玩家操作点击的提示
+ * @param seat
+ * @param type
+ * @param weight
+ */
+ public void addClickTipCommand(int seat, int type, int weight) {
+ ITObject cmdData = TObject.newInstance();
+ cmdData.putInt("weight", weight);
+ cmdData.putInt("type", type);
+ addCommand("ClickTip", seat, cmdData);
+ }
+
+ /**
+ * 小结算数据
+ */
+ public void addResult(ITObject resultData) {
+ ITObject data = TObject.newInstance();
+ Utils.objectCopyDeep(resultData, data);
+ data.putInt("type", 0);
+ addCommand("Result", 0, data);
+ }
+
+}
diff --git a/game_common/src/main/java/com/game/data/Hp.java b/game_common/src/main/java/com/game/data/Hp.java
new file mode 100644
index 0000000..14fda27
--- /dev/null
+++ b/game_common/src/main/java/com/game/data/Hp.java
@@ -0,0 +1,24 @@
+package com.game.data;
+
+public class Hp {
+ /**
+ * 当前体力值,每局更新,用于判断当局能输赢多少
+ */
+ public long cur_hp = 0;
+ /**
+ * 牌局开始到结束,总输赢体力值,不包括奖励体力值。因命名之前没有奖励一说
+ */
+ public int total_hp = 0;
+ /**
+ * 当局实际输赢体力值
+ */
+ public int round_actual_hp = 0;
+ /**
+ * 当局本应输赢体力值
+ */
+ public int round_answer_hp = 0;
+ /**
+ * 输赢是否已达上限
+ */
+ public boolean upper_limit = false;
+}
diff --git a/game_common/src/main/java/com/game/data/JoinRoomData.java b/game_common/src/main/java/com/game/data/JoinRoomData.java
new file mode 100644
index 0000000..9e9fbea
--- /dev/null
+++ b/game_common/src/main/java/com/game/data/JoinRoomData.java
@@ -0,0 +1,12 @@
+package com.game.data;
+
+import com.taurus.permanent.data.Session;
+
+public class JoinRoomData {
+ public Room room;
+ public String session_key;
+ public Session sender;
+ public String gps_pos;
+ public boolean test_user;
+
+}
diff --git a/game_common/src/main/java/com/game/data/Player.java b/game_common/src/main/java/com/game/data/Player.java
new file mode 100644
index 0000000..82e4653
--- /dev/null
+++ b/game_common/src/main/java/com/game/data/Player.java
@@ -0,0 +1,614 @@
+package com.game.data;
+
+import com.game.ActionEvent;
+import com.game.Global;
+import com.game.MainServer;
+import com.game.player.state.PlayerPopupState;
+import com.game.player.state.PlayerReloadState;
+import com.game.state.StateMachine;
+import com.taurus.core.entity.ITObject;
+import com.taurus.core.entity.TObject;
+import com.taurus.core.util.StringUtil;
+import com.taurus.permanent.TPServer;
+import com.taurus.permanent.data.Session;
+
+/**
+ * 基本玩家对象
+ *
+ *
+ */
+public class Player {
+ /**
+ * 所在房间对象
+ */
+ public Room room = null;
+ /**
+ * 用户id
+ */
+ public int playerid = 0;
+
+ public String ip = null;
+ /**
+ * redis session id
+ */
+ public String session_id = StringUtil.Empty;
+ public String score_key = StringUtil.Empty;
+ public String net_key = StringUtil.Empty;
+ /**
+ * 玩家状态机
+ */
+ public StateMachine stateMachine = null;
+
+ /**
+ * mpnet session
+ */
+ public volatile Session sender = null;
+ /**
+ * 是否正在链接
+ */
+ public volatile boolean isConnect = false;
+ /**
+ * 是否是重连
+ */
+ public boolean isReload = false;
+ /**
+ * 是否被摧毁
+ */
+ public volatile boolean isDestroy = false;
+
+ /**
+ * 当前座位号
+ */
+ public int seat = 0;
+ public int nextSeat = 0;
+ public int lastSeat = 0;
+
+ /**
+ * 昵称
+ */
+ public String nick = StringUtil.Empty;
+ /**
+ * 性别
+ */
+ public int sex = 1;
+ /**
+ * 头像
+ */
+ public String portrait = StringUtil.Empty;
+ /**
+ * GPS位置
+ */
+ public String gps_pos = StringUtil.Empty;
+
+ /**
+ * 0 无 1 胡 2 输
+ */
+ public int winer = 0;
+
+ /**
+ * 胡牌统计
+ */
+ public int winCount = 0;
+ /**
+ * 准备状态
+ */
+ public boolean ready = false;
+
+ public boolean is_white = false;
+
+ public int black_white_status = 0;
+
+ public double black_white_rate = 10;
+
+ /**
+ * 解散房间状态
+ */
+ public int dismissState = 0;
+ /**
+ * 申请解散次数
+ */
+ public int dismissCount = 0;
+ /**
+ * 计分统计
+ */
+ public Score score;
+ /**
+ * action计时器
+ */
+ public Timer actionTimer;
+ /**
+ * 计时器
+ */
+ public Timer timer;
+ public volatile long offlineTime;
+ /**
+ * 抽水值
+ */
+ public int practicalHpPump = 0;
+ /**
+ * 奖励数据
+ */
+ public String prs = StringUtil.Empty;
+ /**
+ * 托管
+ */
+ public volatile boolean entrust = false;
+ /**
+ * 自动出牌
+ */
+ public volatile boolean manualAutoCard = false;
+ /**
+ * 是否正在观看
+ */
+ public volatile boolean spectator = false;
+ /**
+ * 已玩局数
+ */
+ public int already_round = 0;
+ /**
+ * 体力值
+ */
+ public Hp hp;
+ /**
+ * 托管局数
+ */
+ public int entrust_round = 0;
+ /**
+ * 是否检测退出限制
+ */
+ public boolean check_exit_limit = true;
+
+ public boolean xi_pai = false;
+ /**
+ * 抽水值total
+ */
+ public int xi_pai_total = 0;
+
+ public Player(int playerid, Room table, String session_id) {
+ this.room = table;
+ this.playerid = playerid;
+ this.session_id = session_id;
+ this.score_key = "score_" + playerid;
+ this.net_key = "net_" + playerid;
+ this.score = newScore();
+ this.stateMachine = new StateMachine(this);
+ this.isReload = false;
+ this.hp = new Hp();
+ this.xi_pai = false;
+ }
+
+ protected Score newScore() {
+ return new Score(this);
+ }
+
+ /**
+ * 设置玩家session
+ *
+ * @param sender
+ */
+ public void setSender(Session sender) {
+ // 服务器从崩溃中重启
+ if (sender == null) {
+ this.isReload = true;
+ this.isConnect = false;
+ this.stateMachine.changeState(Global.getState(PlayerReloadState.class));
+ return;
+ }
+ if (this.isConnect && this.sender != null && this.sender != sender) {
+ Global.sessionMgr.deleteSession(this.sender);
+ TPServer.me().getController().disconnect(this.sender);
+ }
+ // 已经连接
+ this.sender = sender;
+ Global.sessionMgr.putPlayer(sender, this);
+ this.isConnect = true;
+ // if (this.stateMachine.curState == null || this.isReload) {
+ // this.stateMachine.changeState(Global.getState(PlayerInitState.class));
+ this.isReload = false;
+ // }
+ }
+
+ /**
+ * 计时器,Ps 到某状态自动执行某操作
+ *
+ * @param time 时间 ms
+ * @param cmd 计时完执行事件
+ * @param param 执行事件参数
+ */
+ public void startTimer(int time, String cmd, Object param) {
+ stopTimer();
+ this.timer = new Timer(time, new Timer.ITaskHandler() {
+ @SuppressWarnings("unchecked")
+ @Override
+ public void doTask(Timer timer) {
+ Global.info("{} [{}] Timer Excute ActionEvent [{}] param :{}", Player.this.toString(),
+ stateMachine.curState.getClass().getSimpleName(), cmd,
+ param == null ? "null" : param.toString());
+ stateMachine.curState.execute(Player.this, cmd, 0, param);
+ }
+ });
+ room.addTimer(this.timer);
+ }
+
+ /**
+ * 指定时间计时, cmd :timer_auto
+ *
+ * @param time
+ */
+ public void startTimer(int time) {
+ startTimer(time, ActionEvent.EVENT_TIMER_AUTO, null);
+ }
+
+ /**
+ * 默认配置计时器 time : 1000ms cmd : timer_auto
+ */
+ public void startTimer() {
+ startTimer(room.def_actionTimer_time, ActionEvent.EVENT_TIMER_AUTO, null);
+ }
+
+ public void stopTimer() {
+ if (this.timer != null) {
+ this.timer.stop();
+ this.timer = null;
+ }
+ }
+
+ /**
+ * 停止所有计时器,如玩家退出某状态时
+ */
+ public void stopAllTimer() {
+ stopTimer();
+ stopActionTimer();
+ }
+
+ /**
+ * 托管计时器
+ *
+ * @param time 单位毫秒
+ */
+ public void startActionTimer(int time, Object param) {
+ stopActionTimer();
+ this.actionTimer = new Timer(time, new Timer.ITaskHandler() {
+ @SuppressWarnings("unchecked")
+ @Override
+ public void doTask(Timer timer) {
+ String type = "";
+ if (param != null) {
+ ITObject netParam = (ITObject) param;
+ if (netParam.containsKey("type")) {
+ type = netParam.getUtfString("type");
+ }
+ }
+ if (ActionEvent.EVENT_ENTRUST.equals(type) && !entrust) {
+ entrust = true;
+ Global.gameCtr.updatePlayerEntrust(Player.this);
+ }
+ Global.info("{} [{}] Entrust Auto Execute ActionEvent", Player.this.toString(),
+ stateMachine.curState.getClass().getSimpleName());
+ stateMachine.curState.execute(Player.this, ActionEvent.EVENT_TIMER_AUTO, 0, param);
+ }
+ });
+ String type = "";
+ int broad = 0;
+ if (param != null) {
+ ITObject netParam = (ITObject) param;
+ if (netParam.containsKey("type")) {
+ type = netParam.getUtfString("type");
+ }
+ if (netParam.containsKey("broad")) {
+ broad = netParam.getInt("broad");
+ }
+ }
+ if (ActionEvent.EVENT_ENTRUST.equals(type) && broad == 1) {
+ this.actionTimer.parameters.put("param", param);
+ }
+ room.addTimer(this.actionTimer);
+ }
+
+ /**
+ *
+ * @param time 单位毫秒
+ */
+ public void startActionTimer(int time) {
+ startActionTimer(time, null);
+ }
+
+ public boolean isEntrust() {
+ return this.room.isEntrust() && this.entrust;
+ }
+
+ /**
+ * 托管.
+ */
+ public void startActionTimer() {
+ stopActionTimer();
+ if (room.isEntrust()) {
+ ITObject param = TObject.newInstance();
+ param.putUtfString("type", ActionEvent.EVENT_ENTRUST);
+ if (isEntrust()) {
+ param.putInt("broad", 0);
+ startActionTimer(this.room.default_entrust_time, param);
+ } else {
+ param.putInt("broad", 1);
+ startActionTimer(this.room.entrustTime, param);
+ Global.gameCtr.entrust(Player.this, this.room.entrustTime / 1000);
+ }
+ }
+ }
+
+ public void stopActionTimer() {
+ if (this.actionTimer != null) {
+ if (this.actionTimer.parameters.containsKey("param")) {
+ ITObject param = (ITObject) this.actionTimer.parameters.get("param");
+ String type = "";
+ if (param != null) {
+ ITObject netParam = (ITObject) param;
+ if (netParam.containsKey("type")) {
+ type = netParam.getUtfString("type");
+ }
+ }
+ if (ActionEvent.EVENT_ENTRUST.equals(type)) {
+ Global.gameCtr.cancelEntrust(Player.this);
+ }
+ }
+ this.actionTimer.stop();
+ this.actionTimer = null;
+ }
+ }
+
+ public int getActionLeftTime() {
+ if (this.actionTimer != null) {
+ return Math.abs(this.actionTimer.getCountdownTime() / 1000);
+ }
+ return 0;
+ }
+
+ public int getEntrustActionLeftTime() {
+ if (this.actionTimer != null) {
+ if (this.actionTimer.parameters.containsKey("param")) {
+ ITObject param = (ITObject) this.actionTimer.parameters.get("param");
+ String type = "";
+ if (param != null) {
+ ITObject netParam = (ITObject) param;
+ if (netParam.containsKey("type")) {
+ type = netParam.getUtfString("type");
+ }
+ }
+ if (ActionEvent.EVENT_ENTRUST.equals(type)) {
+ return Math.abs(this.actionTimer.getCountdownTime() / 1000);
+ }
+ }
+ }
+ return 0;
+ }
+
+ /**
+ * 返回结果
+ *
+ * @param params
+ * @param gid
+ * @param error
+ */
+ public void response(ITObject params, int gid, int error) {
+ if (!this.isConnect)
+ return;
+ if (error == 0) {
+ MainServer.instance.sendResponse(gid, error, params, this.sender);
+ } else {
+ MainServer.instance.sendResponse(gid, error, null, this.sender);
+ }
+ }
+
+ /**
+ * 返回结果
+ *
+ * @param params
+ * @param gid
+ * @param error
+ */
+ public void responseSpectator(ITObject params, int gid, int error) {
+ if (error == 0) {
+ MainServer.instance.sendResponse(gid, error, params, this.sender);
+ } else {
+ MainServer.instance.sendResponse(gid, error, null, this.sender);
+ }
+ }
+
+ /**
+ * 发送事件给客户端
+ *
+ * @param cmd
+ * @param param
+ */
+ public void sendEvent(String cmd, ITObject param) {
+ if (!this.isConnect)
+ return;
+ MainServer.instance.sendEvent(cmd, param, this.sender);
+ }
+
+ /**
+ * 获取玩家信息
+ *
+ * @return
+ */
+ public ITObject getInfo() {
+ ITObject playerData = new TObject();
+ playerData.putInt("aid", this.playerid);
+ playerData.putUtfString("nick", this.nick);
+ playerData.putInt("sex", this.sex);
+ playerData.putUtfString("portrait", this.portrait);
+ if (StringUtil.isNotEmpty(gps_pos)) {
+ playerData.putUtfString("pos", gps_pos);
+ }
+ String ip = this.ip;
+ if (this.ip == null && this.sender != null) {
+ ip = sender.getAddress();
+ }
+ playerData.putInt("ready", this.ready ? 1 : 0);
+ playerData.putUtfString("ip", ip);
+ playerData.putInt("seat", this.seat);
+ playerData.putInt("online", this.isConnect ? 1 : 0);
+ playerData.putBoolean("spectator", spectator);
+ if (this.room.openEntrust) {
+ playerData.putBoolean("entrust", this.entrust);
+ playerData.putInt("entrust_time", getEntrustActionLeftTime());
+ }
+ hp_info(playerData);
+ // if (Redis.use().hexists(this.session_id, "offLineTime")) {
+ // int offLineTime = Integer.parseInt(Redis.use().hget(this.session_id,
+ // "offLineTime"));
+ // playerData.putInt("offLineTime", Utils.differSecond(offLineTime));
+ // }
+ return playerData;
+ }
+
+ public ITObject getReloadInfo() {
+ ITObject playerData = new TObject();
+ playerData.putInt("playerid", playerid);
+ if (this.room.openEntrust && this.room.isEntrust) {
+ playerData.putBoolean("entrust", this.entrust);
+ playerData.putInt("entrust_time", getEntrustActionLeftTime());
+
+// Global.logger.info("entrust_time getEntrustActionLeftTime() : " + getEntrustActionLeftTime());
+ }
+ playerData.putBoolean("popup", this.stateMachine.curState instanceof PlayerPopupState);
+ hp_info(playerData);
+ return playerData;
+ }
+
+ /**
+ * 玩家销毁时调用
+ *
+ * @param sysredis
+ */
+ public void destroy(boolean sysredis) {
+ if (isDestroy)
+ return;
+ isDestroy = true;
+ stopActionTimer();
+ this.room.removePlayer(this, sysredis);
+ if (this.sender != null) {
+ Global.sessionMgr.deleteSession(sender);
+ }
+ }
+
+ private int __checkSeat(int seat, int count, boolean add) {
+ if (seat > this.room.maxPlayers) {
+ seat = 1;
+ } else if (seat <= 0) {
+ seat = this.room.maxPlayers;
+ }
+ if (count == this.room.maxPlayers)
+ return seat;
+ Player player = this.room.playerMapBySeat.get(seat);
+ if (player == null || player.spectator) {
+ if (add)
+ seat = seat + 1;
+ else
+ seat = seat - 1;
+ count++;
+ return __checkSeat(seat, count, add);
+ }
+ return seat;
+ }
+
+ /**
+ * 初始化座位信息
+ */
+ public void initSeat() {
+ this.nextSeat = __checkSeat(this.seat + 1, 1, true);
+ this.lastSeat = __checkSeat(this.seat - 1, 1, false);
+ }
+
+ /**
+ * 清理玩家数据
+ */
+ public void clear() {
+ this.winer = 0;
+ this.check_exit_limit = true;
+ this.is_white = false;
+ this.manualAutoCard = false;
+
+ stopActionTimer();
+ }
+
+ /**
+ * 注册redis事件,总服处理
+ *
+ * @param type
+ * @param num
+ */
+ public void redisEvent(int type, int num) {
+ Global.eventCtr.redisEvent(playerid, type, num);
+ }
+
+ public String toString() {
+ return session_id;
+ }
+
+ public void hp_info(ITObject param) {
+ ITObject hp_info = TObject.newInstance();
+ // 下局体力值
+ hp_info.putLong("cur_hp", hp.cur_hp);
+ // 本局实际输赢体力值
+ hp_info.putInt("round_actual_hp", hp.round_actual_hp);
+ // 输赢是否已达上限
+ hp_info.putBoolean("upper_limit", hp.upper_limit);
+ // 总输赢体力值
+ hp_info.putInt("total_hp", hp.total_hp);
+ param.putTObject("hp_info", hp_info);
+
+ }
+
+ /**
+ * 获取当前体力值
+ */
+ public Long getHp() {
+ return this.hp.cur_hp + (long) this.hp.round_actual_hp;
+ }
+
+// public void updateHp() {
+// this.hp.cur_hp = this.hp.cur_hp + this.hp.round_actual_hp;
+// }
+
+ public void clearHp() {
+ this.hp.round_actual_hp = 0;
+ this.hp.round_answer_hp = 0;
+ this.hp.upper_limit = false;
+ }
+
+ /**
+ * 设置托管数据
+ *
+ * @param data
+ */
+ public void setEntrustData(ITObject data) {
+
+ }
+
+ public void exitEntrust() {
+ if (this.room.isEntrust()) {
+ this.entrust_round = 0;
+ stopActionTimer();
+ this.entrust = false;
+ if (room.activeSeat == this.seat) {
+ startActionTimer();
+ }
+ }
+ }
+
+ /**
+ * 牌局结束输赢总体力值,包括奖励体力值
+ */
+ public int totalHp() {
+ return hp.total_hp;
+ }
+
+ /**
+ * 需要抽水的具体体力值,不可负分 - 实际赢体力值,可负分 - 实际赢积分 换算成赢总体力值
+ */
+ public int hpPumpValue() {
+ return hp.total_hp;
+ }
+
+}
diff --git a/game_common/src/main/java/com/game/data/Room.java b/game_common/src/main/java/com/game/data/Room.java
new file mode 100644
index 0000000..c5e9e47
--- /dev/null
+++ b/game_common/src/main/java/com/game/data/Room.java
@@ -0,0 +1,2202 @@
+package com.game.data;
+
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
+
+import com.data.bean.AccountBean;
+import com.data.bean.GameBean;
+import com.data.bean.GroupPlayBean;
+import com.data.cache.AccountCache;
+import com.data.cache.GameCache;
+import com.data.cache.GroupCache;
+import com.data.cache.GroupMemberCache;
+import com.game.Constant;
+import com.game.GPSUtil;
+import com.game.Global;
+import com.game.GroupPublisherService;
+import com.game.MainServer;
+import com.game.Router;
+import com.game.Util;
+import com.game.player.state.PlayerPopupState;
+import com.game.room.state.RoomDestoryGameState;
+import com.game.room.state.RoomEndState;
+import com.game.room.state.RoomInitState;
+import com.game.state.StateMachine;
+import com.taurus.core.entity.ITArray;
+import com.taurus.core.entity.ITObject;
+import com.taurus.core.entity.TArray;
+import com.taurus.core.entity.TObject;
+import com.taurus.core.plugin.database.DataBase;
+import com.taurus.core.plugin.redis.Redis;
+import com.taurus.core.util.StringUtil;
+import com.taurus.permanent.data.Session;
+
+import redis.clients.jedis.Jedis;
+
+/**
+ * 基本房间对象
+ *
+ *
+ */
+public class Room implements Runnable {
+ /**
+ * 房间ID
+ */
+ public String roomid = "";
+ /**
+ * 房间redis_key
+ */
+ public String room_key = "";
+ /**
+ * 房间状态机
+ */
+ public StateMachine stateMachine;
+ /**
+ * 玩家列表ID映射
+ */
+ public final Map playerMapById = new HashMap();
+ /**
+ * 玩家列表Seat映射
+ */
+ public final Map playerMapBySeat = new HashMap();
+ /**
+ * 游戏中玩家列表
+ */
+ public final Map playerMapByPlaying = new HashMap();
+ /**
+ * 观看列表
+ */
+ public final Map playerMapBySpectator = new HashMap();
+ /**
+ * 房间配置数据
+ */
+ public ITObject config;
+ /**
+ * 房间最大人数
+ */
+ public int maxPlayers;
+ /**
+ * 开始游戏数量 0 首位开始 >
+ */
+ public int startGameNum;
+
+ private Thread roomUpdateThread;
+ /**
+ * 房间是否被激活
+ */
+ private volatile boolean isActive = false;
+ /**
+ * 房间是否被销毁
+ */
+ public volatile boolean isDestroy = false;
+ final BlockingQueue updateHandleList = new LinkedBlockingQueue();
+ final List timerList = new ArrayList<>();
+ /**
+ * 当前激活的座位号
+ */
+ public int activeSeat = 0;
+ /**
+ * 庄家座位号
+ */
+ public int bankerSeat = 0;
+ /**
+ * 房主ID
+ */
+ public int owner_id = 0;
+ /**
+ * 局數
+ */
+ public Integer round = 0;
+ /**
+ * 最大回合数
+ */
+ public int maxRound = 0;
+ /**
+ * 服务器重连
+ */
+ public boolean serverRload = false;
+ /**
+ * 是否开始
+ */
+ public boolean isplaying = false;
+
+ /**
+ * 是否禁止解散
+ */
+ public boolean isBanDismiss = false;
+
+ /**
+ * 房间解散处理对象
+ */
+ public RoomDismiss dismissRunable;
+ /**
+ * 当前房间对象逻辑锁
+ */
+ public Object lock = new Object();
+ /**
+ * 房间数据redis映射
+ */
+ public Map redis_room_map;
+ /**
+ * 战绩回放redis key
+ */
+ public String military_key;
+ /**
+ * 退还
+ */
+ public int pay = 0;
+ /**
+ * 支付人玩家ID
+ */
+ public int pay_playerid = 0;
+ /**
+ * 是否AA支付
+ */
+ public boolean pay_AA = false;
+ /**
+ * 是否是代理房间
+ */
+ public boolean agent = false;
+ /**
+ * 0 未开始 1开始 2删除标记 3已删除
+ */
+ public int status = 0;
+ /**
+ * 圈子ID
+ */
+ public int groupId = 0;
+ /**
+ * 圈子玩法ID
+ */
+ public int groupPid = 0;
+
+ /**
+ * 圈子玩法名称
+ */
+ public String groupPname = "";
+ /**
+ * 奖励类型
+ */
+ public int rewardType = 1;
+ public int rewardValueType = 1;
+ public int basePump = 0;
+ public int totalPump = 0;
+
+ public int xipai_rewardType = 1;
+ public int xipai_rewardValueType = 1;
+
+ /**
+ * 人头制时,是否需要奖励
+ */
+ public boolean aHeadReward = true;
+
+ /**
+ * 精牌
+ */
+ public boolean jingCard = true;
+
+ /**
+ * 限制进入房间 limitInRoom 限制抢庄 limitloot 退出游戏体力值限制 limitPlay 抽水设置 limitPump (0
+ * --大赢家抽水 ; 1 --全部赢家抽水) 抽水比例 pumpProportion 单人单局抽水上限 UpperLimit 抽水类型 type
+ * 1.固定抽水 : 2.浮动抽水(百分比) 倍数 times
+ */
+ public ITObject hpData;
+ /**
+ * 是否打开托管
+ */
+ public boolean openEntrust;
+ /**
+ * 托管时间
+ */
+ public int entrustTime = 60000;
+ /**
+ * 1 单局结束 大结算 2 局满结算 3 局结算
+ */
+ public int entrusResultType = 1;
+ /**
+ * 默认托管时间 500ms
+ */
+ public int default_entrust_time = 2000;
+ /**
+ * 计时器默认时间
+ */
+ public int def_actionTimer_time = 1000;
+ /**
+ * 踢出时间
+ */
+ public int kickTime = 0;
+ /**
+ * 回放数据
+ */
+ public BasePlayBack playBackData;
+ /**
+ * 是否托管玩法。
+ */
+ public boolean isEntrust = false;
+ /**
+ * 游戏结束类型 1-正常结束 2-托管当局大结算 3-体力值不足 4-中途申请解散 5-管理员解散
+ */
+ public int endType = Constant.END_TYPE_NORMAL;
+
+ public List win, loss;
+ /**
+ * 当前局战绩是否已存储
+ */
+ public boolean roundSave = false;
+
+ /**
+ * 申请解散用户
+ */
+ public String applyDismisUserId;
+
+ /**
+ * 解散类型 0:正常结束 1:中途解散 2:管理员解散
+ */
+ public int dismisType = 0;
+
+ /**
+ * 同意解散用户集合
+ */
+ public List agreeDismisUserId = new ArrayList<>();
+
+ /**
+ * 进入玩家
+ */
+ public Player join_player;
+
+ public boolean while_list = false;
+
+ public double white_value = 20;
+
+ public int xi_pai_score = 0;
+
+ public Room(String roomid, Map redis_room_map) {
+ this.roomid = roomid;
+ this.room_key = "room:" + roomid;
+ if (owner_id == 0) {
+ String owner_key = redis_room_map.get("owner");
+ String ownerid = Redis.use().hget(owner_key, "id");
+ owner_id = Integer.parseInt(ownerid);
+ military_key = "military_" + roomid + redis_room_map.get("create_time");
+ }
+
+ this.stateMachine = new StateMachine(this);
+ this.stateMachine.changeState(Global.getState(RoomInitState.class));
+ redis_room_map.remove("cache_ver");
+ this.redis_room_map = redis_room_map;
+ this.win = new ArrayList<>();
+ this.loss = new ArrayList<>();
+ this.config = TObject.newFromJsonData(redis_room_map.get("options"));
+ this.maxPlayers = Integer.parseInt(redis_room_map.get("maxPlayers"));
+ this.maxRound = Integer.parseInt(redis_room_map.get("times"));
+ this.config.putInt("maxPlayers", this.maxPlayers);
+ this.config.putInt("times", this.maxRound);
+ this.pay = Integer.parseInt(redis_room_map.get("pay"));
+ this.pay_playerid = Integer.parseInt(redis_room_map.get("payer"));
+ this.pay_AA = Integer.parseInt(redis_room_map.get("AA")) == 1;
+ this.config.putInt("AA", this.pay_AA ? 1 : 0);
+ this.agent = Integer.parseInt(redis_room_map.get("agent")) > 0;
+ this.status = Integer.parseInt(redis_room_map.get("status"));
+ if (this.config.containsKey("start_num")) {
+ this.startGameNum = this.config.getInt("start_num");
+ } else {
+ this.startGameNum = this.maxPlayers;
+ }
+
+ Integer str = config.getInt("isBanDismiss");// 0 / 1
+ if (str != null && str == 1) {
+ this.isBanDismiss = true;
+ } else {
+ this.isBanDismiss = false;
+ }
+
+ this.dismissRunable = new RoomDismiss(this);
+ this.xi_pai_score = 0;
+ if (redis_room_map.containsKey("group")) {
+ groupId = Integer.parseInt(redis_room_map.get("group"));
+ if (groupId > 0) {
+ if (redis_room_map.containsKey("dismiss_time")) {
+ this.dismissRunable.maxTime = Integer.parseInt(redis_room_map.get("dismiss_time"));
+ }
+ if (redis_room_map.containsKey("kick_time")) {
+ this.kickTime = Integer.parseInt(redis_room_map.get("kick_time"));
+ }
+ groupPid = Integer.parseInt(redis_room_map.get("gpid"));
+
+ groupPname = redis_room_map.get("gpname");
+
+ rewardType = Integer.parseInt(redis_room_map.get("rewardType"));
+ if (redis_room_map.get("rewardValueType") != null) {
+ rewardValueType = Integer.parseInt(redis_room_map.get("rewardValueType"));
+ }
+
+ if (redis_room_map.get("xipai_rewardType") != null) {
+ xipai_rewardType = Integer.parseInt(redis_room_map.get("xipai_rewardType"));
+ }
+
+ if (redis_room_map.get("xipai_rewardValueType") != null) {
+ xipai_rewardValueType = Integer.parseInt(redis_room_map.get("xipai_rewardValueType"));
+ }
+
+ if (this.config.containsKey("hpData")) {
+ hpData = this.config.getTObject("hpData");
+
+ if (hpData.containsKey("basePump")) {
+ basePump = hpData.getInt("basePump");
+ }
+ }
+ if (this.config.containsKey("tuoguan_active_time")) {
+
+ this.entrustTime = this.config.getInt("tuoguan_active_time") * 1000;
+ this.openEntrust = this.entrustTime > 0;
+ this.entrusResultType = this.config.getInt("tuoguan_result_type");
+ }
+
+ }
+ } else {
+
+ if (this.config.containsKey("tuoguan_active_time")) {
+ this.entrustTime = this.config.getInt("tuoguan_active_time") * 1000;
+ this.openEntrust = this.entrustTime > 0;
+ this.entrusResultType = this.config.getInt("tuoguan_result_type");
+ }
+// Global.logger.info("普通用户创建房间的信息config:" + this.config);
+
+ hpData = this.config.getTObject("hpData");
+// Global.logger.info("普通用户创建房间的信息hpData:" + hpData);
+ }
+ }
+
+ /**
+ * 决定总结算方式
+ *
+ * @return true : 总结算
+ */
+ protected boolean totalType() {
+ boolean result = false;
+ int jieNum = 0;
+
+ for (Entry entry : this.playerMapBySeat.entrySet()) {
+ Player player = entry.getValue();
+
+ // 托管
+ Integer jieShan = 0;
+ if (player.room.hpData != null) {
+ jieShan = player.room.hpData.getInt("JieShan");
+
+ }
+
+ if (jieShan == 1) {
+ jieNum = 0;
+ }
+
+ if (jieShan == 2) {
+ jieNum = 1;
+ }
+ if (jieShan == 3) {
+ jieNum = 2;
+ }
+ if (jieShan == 4) {
+ jieNum = 3;
+ }
+ if (player.entrust == true) {
+ this.endType = Constant.END_TYPE_ENTRUST;
+ }
+
+ if (this.endType == Constant.END_TYPE_ENTRUST) {
+ result = player.entrust_round == jieNum;
+ }
+
+ if (this.endType == Constant.END_TYPE_NORMAL) {
+ result = this.round >= this.maxRound;
+
+ }
+ if (this.endType == Constant.END_TYPE_ADMIN) {
+ result = this.round >= this.maxRound;
+ this.dismisType = 2;
+
+ }
+ if (this.round >= this.maxRound) {
+ return true;
+ }
+ }
+ return result;
+ }
+
+ public void start() {
+ if (isActive)
+ return;
+ last_read_status_time = 0;
+ roomUpdateThread = new Thread(this, room_key + "_" + round);
+ roomUpdateThread.start();
+ isActive = true;
+ }
+
+ private void handleTimer(int index) {
+ if (isDestroy) {
+ return;
+ }
+ if (timerList.size() > index) {
+ Timer timer = timerList.get(index);
+ if (timer.isRuning()) {
+ timer.executeTask();
+ handleTimer(index + 1);
+ } else {
+ synchronized (timerList) {
+ timerList.remove(index);
+ }
+ handleTimer(index);
+ }
+ }
+ }
+
+ private void handleTask() {
+ if (isDestroy) {
+ return;
+ }
+ if (updateHandleList.size() > 0) {
+ Runnable tem = null;
+ synchronized (updateHandleList) {
+ tem = updateHandleList.poll();
+ }
+ if (tem == null)
+ return;
+ tem.run();
+ handleTask();
+ }
+ }
+
+ private long last_read_status_time = 0;
+
+ public void run() {
+
+ while (isActive && !isDestroy) {
+ try {
+ synchronized (lock) {
+ if (System.currentTimeMillis() - last_read_status_time > 1000) {
+ last_read_status_time = System.currentTimeMillis();
+ String status = Redis.use().hget(room_key, "status");
+ if (StringUtil.isNotEmpty(status)) {
+ int tem = Integer.parseInt(status);
+
+ if (tem == Constant.ROOM_STATUS_DEL_FALG || tem == Constant.ROOM_STATUS_DEL_FALG) {
+ this.endType = Constant.END_TYPE_ADMIN;
+ this.dismisType = 2;
+ this.saveMilitaryTotal(true);
+ this.stateMachine.changeState(Global.getState(RoomDestoryGameState.class));
+
+ Global.roomMgr.dismissRoom(roomid, false);
+ continue;
+ }
+ } else {
+ this.dismisType = 2;
+ this.endType = Constant.END_TYPE_ADMIN;
+ this.saveMilitaryTotal(true);
+ this.stateMachine.changeState(Global.getState(RoomDestoryGameState.class));
+
+ Global.roomMgr.dismissRoom(roomid, false);
+ continue;
+ }
+ }
+ handleTimer(0);
+ if (isDestroy)
+ continue;
+ handleTask();
+ if (isDestroy)
+ continue;
+ }
+ Thread.sleep(5);
+ } catch (InterruptedException e) {
+ isActive = false;
+ Global.logger.error("[" + room_key + "] room thread interrupted!");
+ } catch (Throwable t) {
+ Global.logger.error("[" + room_key + "] exception!", t);
+ }
+ }
+ }
+
+ /**
+ * add queue runnable
+ *
+ * @param runnable
+ */
+ public void enqueueRunnable(Runnable runnable) {
+ if (!isActive)
+ return;
+ if (runnable == null)
+ return;
+ synchronized (updateHandleList) {
+ updateHandleList.add(runnable);
+ }
+ }
+
+ /**
+ * 单线程计时器
+ *
+ * @param timer
+ */
+ public void addTimer(Timer timer) {
+ if (!isActive)
+ return;
+ if (timer == null)
+ return;
+ synchronized (timerList) {
+ timerList.add(timer);
+ timer.start();
+ }
+ }
+
+ /**
+ * 开始游戏改变状态
+ */
+ public void startGame() {
+ this.isActive = true;
+ this.isDestroy = false;
+ while_list = false;
+ for (Entry entry : this.playerMapBySeat.entrySet()) {
+ Player player = entry.getValue();
+ player.clear();
+ if (player.stateMachine.curState instanceof PlayerPopupState) {
+ continue;
+ }
+ // 已玩局数++
+ player.already_round++;
+ player.ready = false;
+ player.is_white = false;
+ player.black_white_status = 0;
+ String gm_key = GroupMemberCache.genKey(this.groupId, player.playerid);
+ String black_key = Redis.use("group1_db10").hget(gm_key, "group_black_key");
+ if (StringUtil.isEmpty(black_key)) {
+ black_key = gm_key;
+ }
+
+ String black = Redis.use("group1_db10").hget(black_key, "black");
+ String black_rate = Redis.use("group1_db10").hget(black_key, "group_black_rate");
+
+ if (StringUtil.isNotEmpty(black) && black.equals("0")) {
+ player.black_white_status = 0;
+ player.black_white_rate = 0;
+ } else if (StringUtil.isNotEmpty(black) && black.equals("1")) {
+ player.black_white_status = 1;
+ if (StringUtil.isNotEmpty(black_rate)) {
+ try {
+ player.black_white_rate = Integer.parseInt(black_rate);
+ } catch (NumberFormatException e) {
+ player.black_white_rate = 10;
+ }
+ }
+ } else if (StringUtil.isNotEmpty(black) && black.equals("2")) {
+ player.black_white_status = 2;
+ if (StringUtil.isNotEmpty(black_rate)) {
+ try {
+ player.black_white_rate = Integer.parseInt(black_rate);
+ } catch (NumberFormatException e) {
+ player.black_white_rate = 10;
+ }
+ }
+ } else {
+ player.black_white_status = 0;
+ player.black_white_rate = 0;
+ }
+
+ player.initSeat();
+ this.playerMapByPlaying.put(player.playerid, player);
+
+// Jedis jedis10 = Redis.use("group1_db10").getJedis();
+// String playingGroupIdKey ="g{"+this.groupId+"}:playings";
+// try {
+// jedis10.hset(playingGroupIdKey, player.playerid+"","playing");
+// }catch (Exception e){
+// Global.logger.info("数据没存上", e);
+// }finally {
+// jedis10.close();
+// }
+
+ }
+ if (this.round == 0 && this.status == Constant.ROOM_STATUS_NOBEGIN) {
+ this.status = Constant.ROOM_STATUS_PLAYING;
+ this.redis_room_map.put("status", this.status + "");
+ Redis.use().hset(this.room_key, "status", this.status + "");
+ this.redis_room_map.put("open", "0");
+ Redis.use().hset(this.room_key, "open", "0");
+
+ }
+
+ this.round++;
+ this.isplaying = true;
+ this.roundSave = false;
+ this.updateRound();
+ this.clearHp();
+ }
+
+ /**
+ * 房间小结算
+ */
+ protected void roomResult() {
+
+ }
+
+ public void CountXiPai() {
+ for (Entry entry : this.playerMapBySeat.entrySet()) {
+ Player player = entry.getValue();
+
+ if (player.xi_pai) {
+ player.xi_pai = false;
+ }
+
+ // redisUpdateXiPaiPlayer(player);
+ }
+ }
+
+ /**
+ * 游戏结束
+ */
+ public void endGame() {
+ boolean total = totalType();
+ if (!total)
+// total = entrustTotal();
+ CountXiPai();
+ CheckModifyHp();
+// boolean settlement = redisUpdateHp();
+ // total = total || settlement;
+ this.saveRecRound(this);
+
+ if (total) {
+ this.saveMilitaryTotal(false);
+ } else {
+ roomResult();
+ }
+
+ // 游戏结束时重置玩家的自动出牌状态和托管状态
+ for (Entry entry : this.playerMapById.entrySet()) {
+ Player player = entry.getValue();
+ Global.logger.info("重置玩家自动出牌及托管状态--------" + player);
+ Global.logger.info("player.manualAutoCard--------" + player.manualAutoCard);
+ player.entrust = false;
+ Global.gameCtr.updatePlayerEntrust(player);
+
+// if (player.manualAutoCard) {
+// player.manualAutoCard = false;
+// // 如果房间开启了托管功能,则取消该玩家的托管状态
+// if (player.room.isEntrust()) {
+// player.entrust = false;
+// Global.gameCtr.updatePlayerEntrust(player);
+// }
+// }
+ }
+
+ if (total) {
+ this.stateMachine.changeState(Global.getState(RoomDestoryGameState.class));
+ } else {
+ this.stateMachine.changeState(Global.getState(RoomEndState.class));
+ this.playerMapByPlaying.clear();
+ this.clear();
+ }
+
+ }
+
+ /**
+ * 保存积分
+ */
+ public void saveSocre() {
+ for (Entry entry : this.playerMapBySeat.entrySet()) {
+ Player player = entry.getValue();
+ redis_room_map.put(player.score_key, player.score.total_score + "");
+ }
+ Redis.use().hmset(this.room_key, redis_room_map);
+ }
+
+ /**
+ * 加载或重新加载玩家信息 此方法用于在游戏过程中加载或重新加载指定玩家的信息,包括从缓存中获取账户信息, 初始化玩家对象,并更新玩家的分数、状态等
+ *
+ * @param player_id 玩家ID,用于唯一标识玩家
+ * @param seat 玩家的座位号,表示玩家在游戏中座位位置
+ * @return 返回初始化或更新后的玩家对象
+ */
+ protected Player loadReloadPlayer(int player_id, int seat) {
+ // 从账户缓存中获取玩家账户信息
+ AccountBean acc = AccountCache.getAccount(player_id);
+
+ // 创建或更新玩家对象
+ Player player = MainServer.instance.newPlayer(player_id, this, acc.redis_key);
+ player.seat = seat;
+ player.nick = acc.nick;
+ player.sex = acc.sex;
+ player.portrait = acc.portrait;
+
+ // 从Redis中获取玩家分数字符串,并解析为整数
+ String score_str = this.redis_room_map.get(player.score_key);
+ int num = StringUtil.isNotEmpty(score_str) ? Integer.parseInt(score_str) : 0;
+ player.score.total_score = num;
+
+ // 设置玩家的发送器为null,并记录玩家的离线时间
+ player.setSender(null);
+ player.offlineTime = System.currentTimeMillis();
+ this.redis_room_map.put(player.net_key, player.offlineTime + "");
+
+ // 更新玩家的当前轮次和生命值
+ player.already_round = this.round;
+ player.hp.cur_hp = Util.readRedisHp(this.groupId, player.playerid);
+
+ // 如果组ID大于0,获取玩家的权限信息
+ if (groupId > 0) {
+ player.prs = redis_room_map.get("prs_" + player.playerid);
+ }
+
+ // 将玩家添加到游戏中
+ addPlayer(player, true, true);
+ return player;
+ }
+
+ /**
+ * 服务器重连恢复玩家数据
+ */
+ public void loadRedisPlayer() {
+ if (this.redis_room_map != null && this.redis_room_map.containsKey("players")) {
+ this.serverRload = true;
+ this.status = Integer.parseInt(this.redis_room_map.get("status"));
+ if (this.redis_room_map.containsKey("round")) {
+ this.round = Math.max(Integer.parseInt(this.redis_room_map.get("round")) - 1, 0);
+ }
+ ITArray players = TArray.newFromJsonData(this.redis_room_map.get("players"));
+ ITArray seats = TArray.newFromJsonData(this.redis_room_map.get("seats"));
+ for (int i = 0; i < players.size(); i++) {
+ int player_id = players.getInt(i);
+ this.loadReloadPlayer(player_id, seats.getInt(i));
+ }
+ }
+
+ }
+
+ /**
+ * 添加玩家,加入房间
+ *
+ * @param player
+ * @param reload
+ */
+ public void addPlayer(Player player, boolean reload, boolean onseat) {
+ if (!reload) {
+ if (onseat) {
+ player.seat = this.getSeat();
+ }
+ Redis.use().hset(player.session_id, "seat", player.seat + "");
+ if (groupId > 0) {
+ player.prs = Redis.use().hget(this.room_key, "prs_" + player.playerid);
+ }
+ this.redis_room_map.remove(player.net_key);
+ this.redis_room_map.put(player.score_key, "0");
+ // 不是支付人,不是代理房间的AA至,由游戏服发送扣钱事件
+ // if (this.pay_AA && this.pay > 0) {
+ // if ((player.playerid != this.pay_playerid && !this.agent) || this.agent) {
+ // Global.eventCtr.payDiamo(player, pay, groupId);
+ // }
+ // }
+ }
+ if (onseat) {
+ this.playerMapBySeat.put(player.seat, player);
+ this.playerMapById.put(player.playerid, player);
+ } else {
+ this.playerMapBySpectator.put(player.playerid, player);
+ }
+
+ if (!reload && onseat) {
+ updateRedisMap();
+ }
+ }
+
+ /**
+ * 观众席入座
+ *
+ * @param owner
+ */
+ public boolean joinSeat(Player owner) {
+ if (owner.spectator) {
+ int seat = this.getSeat();
+ if (seat == 0)
+ return false;
+ if (!this.playerMapBySeat.containsKey(seat)) {
+ owner.ready = true;
+ owner.seat = seat;
+ this.playerMapBySeat.put(owner.seat, owner);
+ this.playerMapBySpectator.remove(owner.playerid);
+ updateRedisMap();
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * 离开座位到观众席
+ *
+ * @param player
+ */
+ public boolean exitSeat(Player player) {
+ if (this.playerMapBySeat.containsKey(player.seat)) {
+ if (!this.isplaying && player.seat == this.bankerSeat) {
+ if (this.playerMapBySeat.size() > 1) {
+ for (Player tem : this.playerMapBySeat.values()) {
+ tem.initSeat();
+ }
+ this.bankerSeat = player.nextSeat;
+ } else {
+ this.bankerSeat = 0;
+ }
+ }
+ this.playerMapBySeat.remove(player.seat);
+ this.playerMapBySpectator.put(player.playerid, player);
+ updateRedisMap();
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * 刪除玩家,退出房间
+ *
+ * @param player
+ */
+ public void removePlayer(Player player, boolean sysredis) {
+ this.playerMapBySeat.remove(player.seat);
+ this.playerMapById.remove(player.playerid);
+ this.playerMapByPlaying.remove(player.playerid);
+ this.playerMapBySpectator.remove(player.playerid);
+ if (this.status == 0 && this.pay > 0) {
+ if (this.pay_AA) {
+ Global.eventCtr.refundDiamo(player.playerid, pay, groupId, groupPid);
+ } else if (this.pay_playerid == player.playerid && !this.agent) {
+ Global.eventCtr.refundDiamo(player.playerid, pay, groupId, groupPid);
+ }
+ }
+ Global.gameCtr.delRoomSeat(player.session_id, this.room_key);
+ if (sysredis) {
+ redis_room_map.remove(player.score_key);
+ updateRedisMap();
+ }
+ }
+
+ /**
+ * 更新房间redis数据
+ */
+ public void updateRedisMap() {
+ Iterator> it = playerMapBySeat.entrySet().iterator();
+ List seat_list = new ArrayList<>();
+ List player_list = new ArrayList<>();
+ while (it.hasNext()) {
+ Entry entry = (Entry) it.next();
+ seat_list.add(entry.getKey());
+ player_list.add(entry.getValue().playerid);
+ }
+ redis_room_map.put("players", Util.toTArray(player_list).toJson());
+ redis_room_map.put("seats", Util.toTArray(seat_list).toJson());
+ Redis.use().hmset(this.room_key, redis_room_map);
+ roomUpdateEvent();
+ }
+
+ /**
+ * 获取房间信息
+ *
+ * @return
+ */
+ public ITObject getRoomInfo() {
+ ITObject data = new TObject();
+ data.putTObject("config", this.config);
+ data.putInt("round", this.round);
+ data.putString("roomid", this.roomid);
+ TArray playerData = new TArray();
+ for (Entry entry : this.playerMapBySeat.entrySet()) {
+ Player player = entry.getValue();
+ playerData.addTObject(player.getInfo());
+ }
+ data.putTArray("playerData", playerData);
+ TArray playerSpectatorData = new TArray();
+ for (Entry entry : this.playerMapBySpectator.entrySet()) {
+ Player player = entry.getValue();
+ playerSpectatorData.addTObject(player.getInfo());
+ }
+ data.putTArray("playerSpectatorData", playerSpectatorData);
+ data.putInt("xipai_score", this.xi_pai_score);
+ return data;
+
+ }
+
+ /**
+ * 获取重连数据
+ *
+ * @return
+ */
+ public ITObject getReloadInfo(Player player) {
+ ITObject data = new TObject();
+ data.putInt("active_seat", this.activeSeat);
+ data.putInt("banker_seat", this.bankerSeat);
+ data.putBoolean("playing", this.isplaying);
+ ITArray info_list = TArray.newInstance();
+ for (Entry entry : this.playerMapBySeat.entrySet()) {
+ info_list.addTObject(entry.getValue().getReloadInfo());
+ }
+ data.putTArray("info_list", info_list);
+ return data;
+ }
+
+ /**
+ * 广播消息到客户端
+ *
+ * @param withOutPlayerid 排除的玩家ID0+ 0
+ * @param cmd 协议指令
+ * @param param 协议数据
+ */
+ public void broadCastToClient(int withOutPlayerid, String cmd, ITObject param) {
+ if (!isActive)
+ return;
+ List list = new ArrayList();
+ for (Entry entry : this.playerMapBySeat.entrySet()) {
+ Player player = entry.getValue();
+ if (player.playerid == withOutPlayerid) {
+ continue;
+ }
+ if (!player.isConnect)
+ continue;
+ list.add(player.sender);
+ }
+
+ MainServer.instance.sendEvent(cmd, param, list);
+ }
+
+ // 广播亲友圈所以用户
+
+// public void broadCastToClientOfClub(int withOutPlayerid, String cmd, ITObject param)throws Exception {
+// Global.logger.info("广播亲友圈所有用户"+groupId+"------"+param);
+// if (!isActive)
+// return;
+// List list = new ArrayList();
+// String sql = String.format("SELECT uid FROM group_member WHERE groupId=%s", groupId);
+// ITArray arr = DataBase.use().executeQueryByTArray(sql);
+// for (int i = 0; i < arr.size(); ++i) {
+// ITObject obj = arr.getTObject(i);
+// int uid = obj.getInt("uid");
+// Player player = this.playerMapById.get(uid);
+// if (player.playerid == withOutPlayerid) {
+// continue;
+// }
+// if (!player.isConnect)
+// continue;
+// list.add(player.sender);
+// }
+// Global.logger.info("广播-------");
+//// for (Entry entry : this.playerMapById.entrySet()) {
+//// Player player = entry.getValue();
+//// if (player.playerid == withOutPlayerid) {
+//// continue;
+//// }
+//// if (!player.isConnect)
+//// continue;
+//// list.add(player.sender);
+//// }
+// MainServer.instance.sendEvent(cmd, param, list);
+// }
+
+ /**
+ * 广播消息到客户端(观战)
+ *
+ * @param + 0
+ * @param cmd 协议指令
+ * @param param 协议数据
+ */
+ public void broadCastToClientOfSpectator(String cmd, ITObject param) {
+ if (!isActive)
+ return;
+ List list = new ArrayList();
+ for (Entry entry : this.playerMapBySpectator.entrySet()) {
+ Player player = entry.getValue();
+ if (!player.isConnect)
+ continue;
+ list.add(player.sender);
+ Global.info("通知到用户:" + player.playerid);
+ }
+ Global.info("list:" + list);
+
+ MainServer.instance.sendEvent(cmd, param, list);
+ }
+
+ /**
+ * 广播服务器事件
+ *
+ * @param withOutPlayerid 排除的玩家ID
+ * @param cmd
+ * @param param
+ */
+ public void broadCastToServer(int withOutPlayerid, String cmd, Object param) {
+ if (!isActive)
+ return;
+ for (Entry entry : this.playerMapByPlaying.entrySet()) {
+ Player player = entry.getValue();
+ if (player.playerid == withOutPlayerid)
+ continue;
+ player.stateMachine.execute(cmd, 0, param);
+ }
+
+ }
+
+ /**
+ * 获取当前房间空闲座位号
+ *
+ * @return
+ */
+ public int getSeat() {
+ if (!isActive)
+ return 1;
+ for (int seat = 1; seat <= this.maxPlayers; seat++) {
+ if (!this.playerMapBySeat.containsKey(seat)) {
+ return seat;
+ }
+ }
+ return 1;
+ }
+
+ /**
+ * 更新redis回合
+ */
+ private void updateRound() {
+ redis_room_map.put("round", this.round.toString());
+ this.roomUpdateThread.setName(room_key + "_" + round);
+ Redis.use().hset(this.room_key, "round", this.round.toString());
+ roomUpdateEvent();
+ }
+
+ /**
+ * 更新redis玩家离线
+ *
+ * @param player
+ */
+ public void updatePlayerOffline(Player player) {
+ if (player.seat == 0)
+ return;
+ if (player.isConnect) {
+ redis_room_map.remove(player.net_key);
+ Redis.use().hdel(this.room_key, player.net_key);
+ } else {
+ player.offlineTime = System.currentTimeMillis();
+ redis_room_map.put(player.net_key, player.offlineTime + "");
+ Redis.use().hset(this.room_key, player.net_key, redis_room_map.get(player.net_key));
+ }
+ roomUpdateEvent();
+ }
+
+ /**
+ * 每局的战绩
+ *
+ */
+ public void saveRecRound(Room room) {
+// if (this.playBackData == null || roundSave)
+// return;
+ ITArray plist = TArray.newInstance();
+ Jedis jedis5 = Redis.use("group1_db5").getJedis();
+ Jedis jedis11 = Redis.use("group1_db11").getJedis();
+ Jedis jedis1 = Redis.use("group1_db1").getJedis();
+
+ try {
+// if (!jedis5.exists(military_key)) {
+ Map militart_map = new HashMap<>();
+ militart_map.put("game_id", Global.gameId + "");
+ militart_map.put("room_id", roomid);
+ militart_map.put("groupId", this.groupId + "");
+ militart_map.put("create_time", redis_room_map.get("create_time"));
+ int hp_times = this.hpData != null ? this.hpData.getInt("times") : 0;
+ militart_map.put("hp_times", hp_times + "");
+ militart_map.put("groupPid", this.groupPid + "");
+ militart_map.put("groupPname", this.groupPname + "");
+
+ for (Entry entry : this.playerMapById.entrySet()) {
+ Player player = entry.getValue();
+ militart_map.put("is_read_" + player.playerid, "0");
+ }
+ militart_map.put("groupPid", this.groupPid + "");
+ double result = pay;
+ if (maxRound > room.round && this.groupId > 0) {
+ result = Math.ceil((double) pay / room.hpData.getInt("maxRound") * room.round);
+
+ }
+ jedis5.hset(military_key, "applyDismisUserId", this.applyDismisUserId + "");
+ jedis5.hset(military_key, "agreeDismisUserId", this.agreeDismisUserId + "");
+ jedis5.hset(military_key, "dismisType", this.dismisType + "");
+ militart_map.put("valid_diamo", ((int) (result * 100)) + "");
+ jedis5.hmset(military_key, militart_map);
+// }
+ jedis5.hset(military_key, "round", this.round.toString());
+
+ for (Entry entry : room.playerMapById.entrySet()) {
+ Player player = entry.getValue();
+ ITObject pdata = TObject.newInstance();
+ pdata.putUtfString("nick", player.nick);
+ pdata.putInt("score", player.score.round_score);
+
+ if (room.round == 1) {
+ pdata.putInt("score", player.score.total_score);
+
+ }
+
+ if (player.hp != null) {
+ pdata.putInt("hp", player.hp.round_actual_hp);
+ }
+
+ plist.addTObject(pdata);
+
+ }
+ if (this.playBackData != null) {
+ jedis5.hset(military_key, "round_" + this.round, plist.toJson());
+ String json = this.playBackData.getData().toJson();
+ jedis5.hset(military_key, "rec_" + this.round, json);
+ }
+
+// Global.logger.info("json: " + json);
+
+ roundSave = true;
+ } catch (Exception e) {
+ Global.logger.error(e);
+ } finally {
+ jedis5.close();
+ jedis11.close();
+ jedis1.close();
+ }
+ }
+
+ public void saveMilitaryTotalOfSelf(boolean dissmiss) {
+ Jedis jedis0 = Redis.use("group1_db0").getJedis();
+
+ Global.logger.info("保存个人录像------------");
+// String countKey = "g{"+groupId+"}:m"+join_player;
+ // 广播1
+ // this.broadCastToClient(0, Router.GAME_EVT_EXIT_ROOM_DISMISS, null);
+ TObject data = TObject.newInstance();
+ if (dissmiss) {
+// this.dismisType = 1;
+ saveRecRound(this);
+ }
+ this.endType = dissmiss ? Constant.END_TYPE_DISSMISS : this.endType;
+ int scoreWin = 0;
+
+ Jedis jedis5 = Redis.use("group1_db5").getJedis();
+ boolean hpPump = false;
+
+ int count = 0;
+ int totalPumpHp = 0;
+ int roomMoney = 0;
+ try {
+ AccountBean acc = AccountCache.getAccount(this.owner_id);
+ ITArray plist = TArray.newInstance();
+ boolean isMilitary = jedis5.exists(military_key);
+ int time = (int) (System.currentTimeMillis() / 1000);
+
+ totalPumpHp = roomPlayerHpPump();
+// ITArray info_list = TArray.newInstance();
+ for (Entry entry : this.playerMapById.entrySet()) {
+ Player player = entry.getValue();
+ if (this.agent && this.groupId > 0) {
+ if (player.score.total_score > scoreWin) {
+ scoreWin = player.score.total_score;
+ }
+
+ if (player.practicalHpPump > 0) {
+ hpPump = true;
+ }
+ }
+
+ }
+ Global.logger.info("个人房间owner_id:" + this.owner_id);
+ // 第一局且没有输赢则全额退还房卡
+// int MaxRound = this.hpData.getInt("maxRound");
+ Global.logger.info("当前进行轮数-----------------------" + maxRound);
+
+ if (scoreWin == 0 && this.round <= 1) {
+
+ int diamo = Integer.parseInt(jedis0.hget("{user}:" + this.owner_id, "diamo"));
+ jedis0.hset("{user}:" + this.owner_id, "diamo", (diamo + pay) + "");
+ // 保存预扣房卡消息
+
+ String messagesql = String.format(
+ "insert into diamo_message(group_id,diamo_type,diamo_cur,diamo_num,m_time,m_state,uid,group_name,user_nick)"
+ + " values(%s,%s,%s,%s,%s,%s,%s,'%s','%s')",
+ 0, 1, diamo + pay, pay, System.currentTimeMillis(), 0, this.owner_id, "", acc.nick);
+ if (DataBase.use() != null) {
+ DataBase.use().executeUpdate(messagesql);
+ }
+
+ } else if (this.round < maxRound) {
+ double payDiamo = Math.ceil((double) pay / this.hpData.getInt("maxRound") * round);
+ int backDiamo = (pay - (int) payDiamo);
+ Global.logger.info("返回部分房卡-----------------------");
+
+ int diamo = Integer.parseInt(jedis0.hget("{user}:" + this.owner_id, "diamo"));
+ // 记录日志
+ jedis0.hset("{user}:" + this.owner_id, "diamo", (diamo + backDiamo) + "");
+
+ String messagesql = String.format(
+ "insert into diamo_message(group_id,diamo_type,diamo_cur,diamo_num,m_time,m_state,uid,group_name,user_nick)"
+ + " values(%s,%s,%s,%s,%s,%s,%s,'%s','%s')",
+ 0, 1, diamo + backDiamo, backDiamo, System.currentTimeMillis(), 0, this.owner_id, "", acc.nick);
+
+ DataBase.use().executeUpdate(messagesql);
+
+ }
+
+ for (Entry entry : this.playerMapById.entrySet()) {
+ Player player = entry.getValue();
+ if (player.already_round == 0)
+ continue;
+
+ Global.eventCtr.redisOver(player, time, isMilitary ? military_key : null);
+
+ ITObject pdata = TObject.newInstance();
+ pdata = TObject.newInstance();
+ pdata.putUtfString("nick", player.nick);
+ pdata.putUtfString("portrait", player.portrait);
+ pdata.putInt("score", player.score.total_score);
+ if (player.hp != null) {
+ pdata.putInt("hp", player.hp.total_hp - player.practicalHpPump);
+ }
+
+ pdata.putInt("accId", player.playerid);
+ plist.addTObject(pdata);
+
+ }
+ data.putTArray("datas", plist);
+ data.putInt("time", time);
+ data.putInt("pid", groupPid);
+ data.putInt("maxRound", maxRound);
+ data.putInt("round", round);
+ data.putInt("roomid", Integer.parseInt(roomid));
+ Map map = new HashMap<>();
+ map.put("totalScore", plist.toJson());
+ if (hpData != null) {
+ map.put("hpData", hpData.toJson());
+ }
+ map.put("create_time", time + "");
+
+ // 增加判断条件,需要分数大于0的才计入统计
+ if (isMilitary) {
+ jedis5.hmset(military_key, map);
+ jedis5.expire(military_key, 3600 * 24 * 3);
+
+ }
+
+ } catch (Exception e) {
+ Global.logger.error("error", e);
+ } finally {
+ jedis5.close();
+ jedis0.close();
+ }
+
+ if (totalPumpHp > 0) {
+ if (totalPumpHp >= basePump) {
+ this.totalPump = totalPumpHp - basePump;
+ } else {
+ this.totalPump = 0;
+ }
+ }
+
+ // 增加判断条件,需要分数大于0的才计入统计
+ if (this.agent && (scoreWin > 0 || this.round > 1)) {
+
+ Global.eventCtr.redisGroupRound(this, groupId, groupPid, hpPump ? 1 : 0);
+
+ for (Entry entry : this.playerMapBySeat.entrySet()) {
+ Player player = entry.getValue();
+ if (player.already_round == 0)
+ continue;
+ if (aHeadReward == false && roomMoney > 0) {
+ player.practicalHpPump += roomMoney;
+ this.totalPump += roomMoney;
+ }
+ }
+ for (Entry entry : this.playerMapBySeat.entrySet()) {
+ Player player = entry.getValue();
+ if (player.already_round == 0)
+ continue;
+
+ long curHp = 0;
+ if (aHeadReward == false && roomMoney > 0) {
+ curHp = Global.eventCtr.redisFag(player, 0, hpPump || player.practicalHpPump > 0, true, 0, false,
+ null);
+ } else {
+ curHp = Global.eventCtr.redisFag(player, 0, hpPump || player.practicalHpPump > 0, false, 0, false,
+ null);
+ }
+
+ Global.eventCtr.redisGroupMemberRound(player, 0,
+ (scoreWin > 0 || this.round > 1) && player.score.total_score == scoreWin, hpPump, (int) curHp);
+ }
+
+ }
+
+ if (round > 1) {
+ Jedis jedis10 = Redis.use("group1_db10").getJedis();
+
+ try {
+ GroupPublisherService.pushChatRoom(groupId, data, String.valueOf(count));
+
+ } catch (Exception e) {
+ Global.logger.error("推送圈子数据失败:{}", e);
+ } finally {
+ jedis10.close();
+ }
+ }
+
+ }
+
+ /**
+ * 总战绩
+ */
+ public void saveMilitaryTotal(boolean dissmiss) {
+ Jedis jedis10 = Redis.use("group1_db10").getJedis();
+ Jedis jedis5 = Redis.use("group1_db5").getJedis();
+ Jedis jedis0 = Redis.use("group1_db0").getJedis();
+ Jedis jedis11 = Redis.use("group1_db11").getJedis();
+ try {
+ if (this.groupId == 0) {
+ saveMilitaryTotalOfSelf(dissmiss);
+ return;
+ }
+ TObject data = TObject.newInstance();
+ if (dissmiss) {
+ saveRecRound(this);
+ }
+ this.endType = dissmiss ? Constant.END_TYPE_DISSMISS : this.endType;
+ int scoreWin = 0;
+
+ boolean hpPump = false;
+
+ int count = 0;
+ int totalPumpHp = 0;
+ int roomMoney = 0;
+ ITArray plist = TArray.newInstance();
+ boolean isMilitary = jedis5.exists(military_key);
+ int time = (int) (System.currentTimeMillis() / 1000);
+
+ totalPumpHp = roomPlayerHpPump();
+// ITArray info_list = TArray.newInstance();
+ for (Entry entry : this.playerMapById.entrySet()) {
+ Player player = entry.getValue();
+ if (this.agent && this.groupId > 0) {
+ if (player.score.total_score > scoreWin) {
+ scoreWin = player.score.total_score;
+ }
+
+ if (player.practicalHpPump > 0) {
+ hpPump = true;
+ }
+ }
+
+ }
+ // 第一局且没有输赢则全额退还房卡
+ if (scoreWin == 0 && this.round <= 1) {
+
+ GroupPlayBean gpb = GroupCache.getPlay(groupId, groupPid);
+ int gameId = gpb.gameId;
+ ITObject configData = TObject.newFromJsonData(gpb.config);
+ int opt = configData.getInt("opt");
+
+ GameBean gb = GameCache.getGame(gameId);
+ int diamo = Integer.parseInt(jedis10.hget("g{" + groupId + "}:diamo", "diamo"));
+ Integer pay = gb.pay.get("pay" + opt + "_" + maxPlayers);
+ jedis10.hset("g{" + groupId + "}:diamo", "diamo", (diamo + pay) + "");
+ // 保存预扣房卡消息
+ String messagesql = String.format(
+ "insert into diamo_message(group_id,diamo_type,diamo_cur,diamo_num,m_time,m_state,uid,group_name,user_nick)"
+ + " values(%s,%s,%s,%s,%s,%s,%s,'%s','%s')",
+ groupId, 1, diamo + pay, pay, System.currentTimeMillis(),0, 0, gb.name, "");
+ if (DataBase.use() != null) {
+ DataBase.use().executeUpdate(messagesql);
+ }
+
+// return;
+ }
+ for (Entry entry : this.playerMapById.entrySet()) {
+ Player player = entry.getValue();
+ if (player.already_round == 0 && this.endType != Constant.END_TYPE_ENTRUST)
+ continue;
+
+ Global.eventCtr.redisOver(player, time, isMilitary ? military_key : null);
+
+ ITObject pdata = TObject.newInstance();
+ pdata = TObject.newInstance();
+ pdata.putUtfString("nick", player.nick);
+ pdata.putUtfString("portrait", player.portrait);
+ pdata.putInt("score", player.score.total_score);
+ if (player.hp != null) {
+ pdata.putInt("hp", player.hp.total_hp - player.practicalHpPump);
+ }
+
+ pdata.putInt("accId", player.playerid);
+ plist.addTObject(pdata);
+
+ if (groupId != 0) {
+ jedis0.hset("{user}:" + player.playerid, "online", "stopPlaying");
+ String userOnline = jedis0.hget("{user}:" + player.playerid, "online");
+ ITObject params = new TObject();
+ params.putString("online", userOnline);
+ params.putString("uid", String.valueOf(player.playerid));
+ String key = GroupCache.genGroupsKey(player.playerid);
+ Set groups = jedis11.zrevrange(key, 0, -1);
+
+ for (String tem : groups) {
+ GroupPublisherService.playerGameState(Integer.parseInt(tem), params);
+ }
+ String countKey = "g{" + groupId + "}:m" + player.playerid;
+ String messageCount = jedis10.hget(countKey, "messageCount");
+ count = messageCount == null ? 0 : Integer.parseInt(messageCount);
+ if (round != 1 && player.score.total_score != 0) {
+ count++;
+ }
+ jedis10.hset(countKey, "messageCount", count + "");
+
+ jedis11.zrem("ceroom", "room:" + roomid);
+ }
+
+ }
+ data.putTArray("datas", plist);
+ data.putInt("time", time);
+ data.putInt("pid", groupPid);
+ data.putInt("maxRound", maxRound);
+ data.putInt("round", round);
+ data.putInt("roomid", Integer.parseInt(roomid));
+ Map map = new HashMap<>();
+ map.put("totalScore", plist.toJson());
+ if (hpData != null) {
+ map.put("hpData", hpData.toJson());
+ }
+ map.put("create_time", time + "");
+
+ // 增加判断条件,需要分数大于0的才计入统计
+ if (isMilitary && this.endType == Constant.END_TYPE_ENTRUST) {
+ jedis5.hmset(military_key, map);
+ jedis5.expire(military_key, 3600 * 24 * 3);
+
+ } else if (isMilitary) {
+ jedis5.hmset(military_key, map);
+ jedis5.expire(military_key, 3600 * 24 * 3);
+
+ }
+
+ if (totalPumpHp > 0) {
+ if (totalPumpHp >= basePump) {
+ this.totalPump = totalPumpHp - basePump;
+ } else {
+ this.totalPump = 0;
+ }
+ }
+
+ // 增加判断条件,需要分数大于0的才计入统计
+ if (this.agent && this.groupId > 0 && (scoreWin > 0 || this.round > 1)
+ || (this.endType == Constant.END_TYPE_ENTRUST)) {
+
+ Global.eventCtr.redisGroupRound(this, groupId, groupPid, hpPump ? 1 : 0);
+
+ for (Entry entry : this.playerMapBySeat.entrySet()) {
+ Player player = entry.getValue();
+ if (player.already_round == 0)
+ continue;
+ if (aHeadReward == false && roomMoney > 0) {
+ player.practicalHpPump += roomMoney;
+ this.totalPump += roomMoney;
+ }
+ }
+ for (Entry entry : this.playerMapBySeat.entrySet()) {
+ Player player = entry.getValue();
+ if (player.already_round == 0 && this.endType != Constant.END_TYPE_ENTRUST)
+ continue;
+
+ long curHp = 0;
+
+ if (aHeadReward == false && roomMoney > 0) {
+ curHp = Global.eventCtr.redisFag(player, 0, hpPump || player.practicalHpPump > 0, true, 0,
+ false, null);
+ } else {
+ curHp = Global.eventCtr.redisFag(player, 0, hpPump || player.practicalHpPump > 0, false, 0,
+ false, null);
+ }
+
+ Global.eventCtr.redisGroupMemberRound(player, this.groupPid,
+ (scoreWin > 0 || this.round > 1) && player.score.total_score == scoreWin, hpPump,
+ (int) curHp);
+ }
+
+ }
+
+ if (round > 1) {
+ GroupPublisherService.pushChatRoom(groupId, data, String.valueOf(count));
+
+ }
+ } catch (SQLException e) {
+ Global.logger.error(" error", e);
+ } finally {
+ jedis10.close();
+ jedis5.close();
+ jedis0.close();
+ jedis11.close();
+ }
+
+ }
+
+ public int getValidPlayer() {
+ int count = 0;
+ for (Entry entry : this.playerMapBySeat.entrySet()) {
+ Player player = entry.getValue();
+ if (player.already_round == 0)
+ continue;
+
+ count++;
+ }
+ return count;
+ }
+
+ public ITArray getValidPlayerList() {
+ ITArray array = TArray.newInstance();
+ for (Entry entry : this.playerMapBySeat.entrySet()) {
+ Player player = entry.getValue();
+ if (player.already_round == 0)
+ continue;
+
+ array.addInt(player.playerid);
+ }
+ return array;
+ }
+
+ /**
+ * 清理房间数据
+ */
+ public void clear() {
+ this.isplaying = false;
+ this.while_list = false;
+ }
+
+ /**
+ * 房间摧毁时调用
+ */
+ public void destroy(boolean sendEvt) {
+ if (isDestroy)
+ return;
+ this.broadCastToClient(0, Router.GAME_EVT_EXIT_ROOM_DISMISS, null);
+ List playerlist = new ArrayList(this.playerMapById.values());
+ for (Player player : playerlist) {
+ player.destroy(false);
+
+// Jedis jedis0 = Redis.use("group1_db0").getJedis();
+// try {
+// jedis0.hset("{user}:" + player.playerid, "online", "stopPlaying");
+// } catch (Exception e) {
+// Global.logger.error("setGroupHeartbeat error", e);
+// }finally {
+// jedis0.close();
+// }
+
+ Jedis jedis0 = Redis.use("group1_db0").getJedis();
+ Jedis jedis11 = Redis.use("group1_db11").getJedis();
+ try {
+ jedis0.hset("{user}:" + player.playerid, "online", "stopPlaying");
+
+ String userOnline = jedis0.hget("{user}:" + player.playerid, "online");
+
+ ITObject params = new TObject();
+ params.putString("online", userOnline);
+ params.putString("uid", String.valueOf(player.playerid));
+ String key = GroupCache.genGroupsKey(player.playerid);
+ Set groups = jedis11.zrevrange(key, 0, -1);
+ for (String tem : groups) {
+// GroupPublisherService.playerGameState(Integer.parseInt(tem), params);
+ }
+ } finally {
+ jedis0.close();
+ jedis11.close();
+ }
+
+ }
+ this.status = Constant.ROOM_STATUS_DEL;
+ Redis.use().hset(room_key, "status", this.status + "");
+ Redis.use().hincrBy(room_key, "cache_ver", 1);
+ Redis.use().expire(room_key, 20);
+ if (sendEvt && this.groupId > 0) {
+ GroupPublisherService.delRoomEvt(groupId, roomid);
+ }
+ isDestroy = true;
+
+ isActive = false;
+
+ this.timerList.clear();
+ this.playerMapById.clear();
+ this.playerMapBySeat.clear();
+ this.playerMapByPlaying.clear();
+ this.playerMapBySpectator.clear();
+ roomUpdateThread.interrupt();
+
+ }
+
+ public String toString() {
+ return room_key;
+ }
+
+ /**
+ * 房间需要抽水玩家 特殊情况 : 分数一样,同时抽 Ps : A = 20 、 B=15 、C = 15 、 D = - 50 抽水规则 : 前2名 , 抽
+ * A B C
+ */
+ private int roomPlayerHpPump() {
+
+ int totalPump = 0;
+
+ if (this.hpData != null) {
+ List pumpPlay = new ArrayList<>();
+ // limitPump-抽水类型 0.大赢家抽水1.所有赢家抽水2.前两名赢家抽水 3.前3名赢家抽水 4.(固定)所有玩家平分抽水(2019.11.5
+ // 新增),以大赢家为基础,判定是否需要抽水
+ // criterion-固定平分时,以什么为标准判断是否需要抽水
+ int limitPump = hpData.containsKey("limitPump") ? hpData.getInt("limitPump") : 0, criterion = 0;
+ if (limitPump == 0 || limitPump == 4) {// 大赢家抽水 // (固定)所有玩家平分抽水
+ List list = scoreDesc();
+ if (list.size() == 0)
+ return 0;
+ Player winner = list.get(0);
+ if (winner.hpPumpValue() <= 0)
+ return 0;
+ if (limitPump == 0) {
+ pumpPlay.add(winner);
+ // 与排序后第一位玩家分数相等的玩家也需要抽水
+ pumpPlay.addAll(scoreEq(winner));
+ } else {
+ pumpPlay.addAll(alreadyRoundPlayer());
+ criterion = winner.hpPumpValue();
+ }
+ } else if (1 <= limitPump && limitPump <= 3) {
+ if (limitPump == 1) {
+ alreadyRoundPlayer().forEach(player -> {
+ if (player.hpPumpValue() >= 0) {
+ pumpPlay.add(player);
+ }
+ });
+ } else if (limitPump > 1) {
+ int num = 0, temp_hp = 0;
+ for (Player player : scoreDesc()) {
+ if (player.hpPumpValue() >= 0) {
+ pumpPlay.add(player);
+ if (temp_hp != player.hpPumpValue()) {
+ num++;
+ }
+ if (num == limitPump) {
+ pumpPlay.addAll(scoreEq(player));
+ break;
+ } else {
+ temp_hp = player.hpPumpValue();
+ }
+ }
+ }
+ }
+ }
+ for (Player player : pumpPlay) {
+ totalPump += hpPump(player, limitPump, criterion);
+ }
+ }
+
+ return totalPump;
+ }
+
+ /**
+ * 具体抽水体力值(向下取整)
+ *
+ * @param player
+ * @param limitPump 抽水类型
+ * @param criterion 固定平分时,以什么为标准判断是否需要抽水
+ */
+ private int hpPump(Player player, int limitPump, int criterion) {
+ try {
+ // 抽水类型 1.固定 2.浮动
+ int type = this.hpData.containsKey("type") ? this.hpData.getInt("type") : 2;
+ // _upperLimit :
+ // 浮动抽水 : 每局每人抽水上限 0 = 没上限
+ // 固定抽水 : 每局每人多少开始抽水,是否达到抽水条件
+ //
+ // _pumpProportion : 抽水具体数值, 浮动 - 1=1% 、2=2%.. 固定 - 10 、20..
+ // practicalHpPump : 实际抽水抽得到体力值
+ int _upperLimit = 0, _pumpProportion = 0, practicalHpPump = 0;
+ if (type == 1) {
+ // 固定抽水具体数值 1、2、3、4...10、20、30、40、50.....
+ // 修改 :新增 期间固定抽水 2019.11.01
+ if (hpData.containsKey("pumpProportion") && hpData.containsKey("UpperLimit")) {
+ // 兼容老数据
+ _upperLimit = hpData.getInt("UpperLimit");
+ _pumpProportion = hpData.getInt("pumpProportion");
+ if (limitPump == 4) {
+ // 以大赢家为基础,判断此次是否需要抽水
+ practicalHpPump = criterion >= _upperLimit
+ ? (int) Math.ceil(_pumpProportion / alreadyRoundPlayer().size())
+ : 0;
+ } else {
+ practicalHpPump = player.hpPumpValue() >= _upperLimit ? _pumpProportion : 0;
+ }
+ } else if (this.hpData.containsKey("rewards_list")) {
+ // 新数据 - 期间
+ ITArray rewards_list = this.hpData.getTArray("rewards_list");
+ for (int i = rewards_list.size() - 1; i >= 0; i--) {
+ ITObject object = rewards_list.getTObject(i);
+ _upperLimit = object.getInt("UpperLimit");
+ _pumpProportion = object.getInt("pumpProportion");
+ if (limitPump == 4) {
+ if (criterion >= _upperLimit) {
+ practicalHpPump = (int) Math.ceil(_pumpProportion / alreadyRoundPlayer().size());
+ break;
+ }
+ } else {
+ if (player.hpPumpValue() >= _upperLimit) {
+ practicalHpPump = _pumpProportion;
+ break;
+ }
+ }
+ }
+ }
+ } else if (type == 2 && limitPump != 4) {
+ // pumpProportion : 1=1% 、2=2%
+ // 老数据
+ if (hpData.containsKey("pumpProportion") && hpData.containsKey("UpperLimit")) {
+ _upperLimit = hpData.getInt("UpperLimit");
+ _pumpProportion = hpData.getInt("pumpProportion");
+ } else if (this.hpData.containsKey("rewards_list")) {
+ // 新浮动抽水数据
+ ITArray rewards_list = this.hpData.getTArray("rewards_list");
+ if (rewards_list.size() > 0) {
+ _upperLimit = rewards_list.getTObject(0).getInt("UpperLimit");
+ _pumpProportion = rewards_list.getTObject(0).getInt("pumpProportion");
+ }
+ }
+ int hpPump = (int) Math.ceil(player.hpPumpValue() * (_pumpProportion / 100d));
+ practicalHpPump = _upperLimit == 0 ? hpPump : hpPump >= _upperLimit ? _upperLimit : hpPump;
+ }
+ if (practicalHpPump > 0) {
+// int cur_hp = player.hp.cur_hp;
+// practicalHpPump = Math.min(practicalHpPump, cur_hp);
+ player.practicalHpPump = practicalHpPump;
+ }
+
+ String pumpDesc = String.format(
+ "room id: %s, player id: %d, type: %d, _upperLimit: %d, _pumpProportion: %d practicalHpPump:%d",
+ this.roomid, player.playerid, type, _upperLimit, _pumpProportion, practicalHpPump);
+
+ Global.logger.error(pumpDesc);
+
+ } catch (Exception e) {
+ Global.logger.error(e);
+ }
+
+ return player.practicalHpPump;
+ }
+
+ /**
+ * 已玩家排序,从大到小 ,不可负分 : 实际输赢体力值 ,可负分 :总分换算成总体力值
+ */
+ private List scoreDesc() {
+ List list = alreadyRoundPlayer();
+ list.sort((Player p1, Player p2) -> {
+ return p2.hpPumpValue() - p1.hpPumpValue();
+ });
+ return list;
+ }
+
+ /**
+ * 存在已玩局数玩家
+ */
+ private List alreadyRoundPlayer() {
+ List list = new ArrayList<>();
+ playerMapBySeat.values().forEach(player -> {
+ if (player.already_round > 0)
+ list.add(player);
+ });
+ return list;
+ }
+
+ /**
+ * 房间总分一样玩家
+ */
+ private List scoreEq(Player play) {
+ List list = new ArrayList<>();
+ int referToHp = play.hpPumpValue();
+ alreadyRoundPlayer().forEach(player -> {
+ if (play != player) {
+ int hp = player.hpPumpValue();
+ if (hp >= 0 && hp == referToHp) {
+ list.add(player);
+ }
+ }
+ });
+ return list;
+ }
+
+ /**
+ * 开启倍数后 体力值消耗= 倍数*分数
+ */
+ public int multipleScore(int score) {
+ if (this.hpData != null) {
+ if (this.hpData.containsKey("times")) {
+ return Math.round(score * this.hpData.getInt("times"));
+ }
+ }
+ return score;
+ }
+
+ /**
+ * 玩家加入房间刷新总服圈子缓存
+ */
+ public void roomUpdateEvent() {
+ Redis.use("group1_db0").hincrBy(room_key, "cache_ver", 1);
+ GroupPublisherService.updateRoomEvt(groupId, this.roomid);
+
+ }
+
+ public boolean isActive() {
+ return this.isActive;
+ }
+
+ /**
+ * 是否开启GPS 检测 0 未开启 大于0 值,具体检测值
+ */
+ public boolean isOpenGPSCheck() {
+ boolean isOpen = false;
+ if (this.config.containsKey("GPSDetection")) {
+ isOpen = this.config.getInt("GPSDetection") > 0;
+ }
+ return isOpen;
+ }
+
+ /**
+ * 是否开启IP检测 1 开启 0 未开启
+ */
+ public boolean isOpenIPCheck() {
+ boolean isOpen = false;
+ if (this.config.containsKey("IPDetection")) {
+ isOpen = this.config.getInt("IPDetection") == 1;
+ }
+ return isOpen;
+ }
+
+ /**
+ * 检测GPS 距离 true 过近
+ *
+ * @param gps
+ * @return
+ */
+ public boolean checkGps(String gps) {
+ int measure = this.config.getInt("GPSDetection");
+ for (Player player : this.playerMapById.values()) {
+ if (GPSUtil.isDistanceNear(gps, player.gps_pos, measure)) {
+ try {
+ Global.warn("{} Near location,gps:{},toGps:{}|player:{},Distance:{}m", this.room_key, gps,
+ player.gps_pos, player.playerid, GPSUtil.getDistance(gps, player.gps_pos));
+ } catch (Exception e) {
+ }
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * 检测GPS 距离 true 过近
+ *
+ * @param ip
+ * @return
+ */
+ public boolean checkIp(String ip) {
+ for (Player player : this.playerMapById.values()) {
+ if (player.sender.getAddress().equals(ip)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void redisUpdateXiPaiPlayer(Player player) {
+ int xipai_score = 0;
+ if (player.xi_pai) {
+ xipai_score = this.xi_pai_score;
+ // player.xi_pai = false;
+ }
+
+ if (xipai_score > 0) {
+ int hp = xipai_score * 1000; // multipleScore(xipai_score);
+ if (player.hp.cur_hp - (long) hp < 0) {
+ if (player.hp.cur_hp > 0) {
+ player.hp.cur_hp = Global.eventCtr.redisFag(player, 0, false, false, (int) player.hp.cur_hp, true,
+ "洗牌");
+ player.xi_pai_total += (int) player.hp.cur_hp;
+ }
+ } else {
+ player.hp.cur_hp = Global.eventCtr.redisFag(player, 0, false, false, hp, true, "洗牌");
+ player.xi_pai_total += hp;
+ }
+ }
+ }
+
+ protected void redisUpdateHpPlayer(Player player) {
+ if (player.score.negative_score == true) {
+ if (player.hp.cur_hp >= 0) {
+ player.hp.round_actual_hp = -(int) player.hp.cur_hp;
+ player.hp.round_answer_hp = player.hp.round_actual_hp;
+ } else {
+ player.hp.round_actual_hp = 0;
+ player.hp.round_answer_hp = player.hp.round_actual_hp;
+ }
+ } else {
+ player.hp.round_actual_hp = multipleScore(player.score.round_score) + (int) player.score.d_real_score;
+ player.hp.round_answer_hp = player.hp.round_actual_hp;
+ }
+ int hp = player.hp.round_actual_hp;
+ if (hp == 0)
+ return;
+
+ if (player.hp.upper_limit) {
+ player.hp.upper_limit = Math.abs(hp) == Math.abs(player.hp.round_answer_hp);
+ }
+ player.hp.total_hp += hp;
+ player.hp.cur_hp = Global.eventCtr.redisFag(player, hp, false, false, 0, false, null);
+ redisCountBlack(player, hp);
+ }
+
+ public void redisCountBlack(Player player, int hp) {
+ if (Redis.use("group1_db1").sismember("gods", Integer.toString(player.playerid))) {
+ return;
+ }
+ hp = hp / 1000;
+ String gm_key = GroupMemberCache.genKey(groupId, player.playerid);
+ String black_key = Redis.use("group1_db10").hget(gm_key, "group_black_key");
+ if (StringUtil.isEmpty(black_key)) {
+ return;
+ }
+ String strblack = Redis.use("group1_db10").hget(black_key, "black");
+ int black = 0;
+ if (StringUtil.isNotEmpty(strblack)) {
+ try {
+ black = Integer.parseInt(strblack);
+ } catch (NumberFormatException e) {
+ black = 0;
+ }
+ }
+
+ if (black == 0) {
+ return;
+ } else if (black == 1) // hei
+ {
+ String str_black_max_value = Redis.use("group1_db10").hget(black_key, "group_black_max_value");
+ int black_max_value = 0;
+ if (StringUtil.isEmpty(str_black_max_value)) {
+ return;
+ }
+
+ try {
+ black_max_value = Integer.parseInt(str_black_max_value);
+ } catch (NumberFormatException e) {
+ return;
+ }
+
+ if (hp > 0) {
+ Redis.use("group1_db10").hincrBy(black_key, "group_black_now_value", -Math.abs(hp));
+ } else {
+ Redis.use("group1_db10").hincrBy(black_key, "group_black_now_value", Math.abs(hp));
+ }
+
+ String str_black_value = Redis.use("group1_db10").hget(black_key, "group_black_now_value");
+ if (StringUtil.isEmpty(str_black_value)) {
+ return;
+ }
+
+ try {
+ int black_value = Integer.parseInt(str_black_value);
+ if (black_value >= black_max_value) {
+ Redis.use("group1_db10").hset(black_key, "black", "0");
+ Redis.use("group1_db10").hset(black_key, "group_black", "0");
+ Redis.use("group1_db10").hset(black_key, "group_black_rate", "0");
+ Redis.use("group1_db10").hset(black_key, "group_black_max_value", "0");
+ Redis.use("group1_db10").hset(black_key, "group_black_now_value", "0");
+ }
+ } catch (NumberFormatException e) {
+ return;
+ }
+ } else if (black == 2) {
+ String str_black_max_value = Redis.use("group1_db10").hget(black_key, "group_black_max_value");
+ int black_max_value = 0;
+ if (StringUtil.isEmpty(str_black_max_value)) {
+ return;
+ }
+
+ try {
+ black_max_value = Integer.parseInt(str_black_max_value);
+ } catch (NumberFormatException e) {
+ return;
+ }
+
+ if (hp > 0) {
+ Redis.use("group1_db10").hincrBy(black_key, "group_black_now_value", Math.abs(hp));
+ } else {
+ Redis.use("group1_db10").hincrBy(black_key, "group_black_now_value", -Math.abs(hp));
+ }
+
+ String str_black_value = Redis.use("group1_db10").hget(black_key, "group_black_now_value");
+ if (StringUtil.isEmpty(str_black_value)) {
+ return;
+ }
+
+ try {
+ int black_value = Integer.parseInt(str_black_value);
+ if (black_value >= black_max_value) {
+ Redis.use("group1_db10").hset(black_key, "black", "0");
+ Redis.use("group1_db10").hset(black_key, "group_black", "0");
+ Redis.use("group1_db10").hset(black_key, "group_black_rate", "0");
+ Redis.use("group1_db10").hset(black_key, "group_black_max_value", "0");
+ Redis.use("group1_db10").hset(black_key, "group_black_now_value", "0");
+ }
+ } catch (NumberFormatException e) {
+ return;
+ }
+ }
+ }
+
+ protected boolean redisUpdateHp() {
+ int limitInRoom = this.hpData.containsKey("limitPlay") ? this.hpData.getInt("limitPlay") : 0;
+ int minOneScore = this.hpData.containsKey("times") ? this.hpData.getInt("times") : 0;
+
+ int count = this.playerMapBySeat.size();
+ for (Entry entry : this.playerMapBySeat.entrySet()) {
+ Player player = entry.getValue();
+ redisUpdateHpPlayer(player);
+ if (player.check_exit_limit && player.hp.cur_hp < (long) limitInRoom) {
+ count--;
+ } else if (player.hp.cur_hp < (long) minOneScore) {
+ count--;
+ }
+ }
+ boolean total = count < this.playerMapBySeat.size();
+ if (total) {
+ this.endType = Constant.END_TYPE_HP;
+ }
+ return total;
+ }
+
+ protected void CheckModifyHp() {
+ int times = 1;
+ if (this.hpData != null) {
+ if (this.hpData.containsKey("times")) {
+ times = this.hpData.getInt("times");
+ }
+ }
+
+ boolean flag = false;
+ for (Entry entry : this.playerMapBySeat.entrySet()) {
+ Player player = entry.getValue();
+
+ int actual_hp = (player.score.round_score) * times;
+ if (player.hp.cur_hp + (long) actual_hp < 0) {
+ flag = true;
+ break;
+ }
+ }
+
+ if (flag == false) {
+ return;
+ }
+
+ int lostAllJetton = 0;
+ int allWinJetton = 0;
+ for (Entry entry : this.playerMapBySeat.entrySet()) {
+ Player player = entry.getValue();
+ if (player.score.round_score * times < 0) {
+ if (player.hp.cur_hp + player.score.round_score * times < 0) {
+ if (player.hp.cur_hp > 0) {
+ lostAllJetton += Math.abs(player.hp.cur_hp);
+ }
+ } else {
+ lostAllJetton += Math.abs(player.score.round_score * times);
+ }
+ } else if (player.score.round_score * times > 0) {
+ allWinJetton += Math.abs(player.score.round_score * times);
+ }
+ }
+
+ if (allWinJetton <= 0) {
+ return;
+ }
+
+ for (Entry entry : this.playerMapBySeat.entrySet()) {
+ Player player = entry.getValue();
+ if (player.score.round_score * times > 0) {
+ double real_score = (double) lostAllJetton * (double) player.score.round_score * times
+ / (double) allWinJetton;
+ player.score.d_real_score = real_score - (double) player.score.round_score * times;
+ } else if (player.score.round_score * times < 0
+ && player.hp.cur_hp + player.score.round_score * times < 0) {
+ player.score.negative_score = true;
+ }
+ }
+ }
+
+ public void clearHp() {
+ for (Entry entry : this.playerMapBySeat.entrySet()) {
+ Player player = entry.getValue();
+ player.clearHp();
+ }
+ }
+
+ /**
+ * 是否托管房间
+ */
+ public boolean isEntrust() {
+ return this.openEntrust && this.isEntrust;
+ }
+
+ /**
+ * 托管是否结算
+ */
+ public boolean entrustTotal() {
+ boolean entrustTotal = false;
+ if (this.isEntrust()) {
+ for (Entry entry : this.playerMapById.entrySet()) {
+ Player player = entry.getValue();
+ if (player.isEntrust() && player.manualAutoCard == false) {
+ if (this.entrusResultType == Constant.ENTRUST_CURREN_RESULT) {
+ entrustTotal = true;
+ } else if (this.entrusResultType == Constant.ENTRUST_TWO_RESULT) {
+ if (++player.entrust_round == 2) {
+ entrustTotal = true;
+ }
+ } else if (this.entrusResultType == Constant.ENTRUST_THREE_RESULT) {
+ if (++player.entrust_round == 3) {
+ entrustTotal = true;
+ }
+ } else if (this.entrusResultType == Constant.ENTRUST_TOTAL_RESULT1) {
+ if (++player.entrust_round == maxRound) {
+ entrustTotal = true;
+ }
+ }
+ if (entrustTotal) {
+ this.endType = Constant.END_TYPE_ENTRUST;
+ break;
+ }
+ }
+ }
+ }
+ return entrustTotal;
+ }
+
+ public void notifyXiPai() {
+ ITObject param1 = new TObject();
+ ITArray list = TArray.newInstance();
+ for (Entry entry : this.playerMapById.entrySet()) {
+ Player player = (Player) entry.getValue();
+ if (player.xi_pai) {
+ list.addInt(player.playerid);
+ }
+ }
+ param1.putTArray("list", list);
+ broadCastToClient(0, Router.GAME_EVENT_NOTIFY_XIPAI, param1);
+ }
+}
diff --git a/game_common/src/main/java/com/game/data/RoomDismiss.java b/game_common/src/main/java/com/game/data/RoomDismiss.java
new file mode 100644
index 0000000..640dd10
--- /dev/null
+++ b/game_common/src/main/java/com/game/data/RoomDismiss.java
@@ -0,0 +1,158 @@
+package com.game.data;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map.Entry;
+
+import com.data.util.ErrorCode;
+import com.game.Global;
+import com.game.data.Timer.ITaskHandler;
+import com.game.room.state.RoomDestoryGameState;
+
+/**
+ * 房间解散处理
+ *
+ */
+public class RoomDismiss {
+ private Room owner;
+ public boolean start = false;
+ private boolean agree = true;
+ /**
+ * 最多申请次数,超过次数,该玩家不能申请解散
+ */
+ private final int MAX_ASK_COUNT = 3;
+
+ private Timer timer;
+ private Player askPlayer;
+// public int maxTime = 90;
+ /**
+ * 申请间隔
+ */
+ public int maxTime = 3;
+ private List playerList;
+
+ public RoomDismiss(Room owner) {
+ this.owner = owner;
+ playerList = new ArrayList<>();
+ }
+
+ public void askDismiss(Player player, int gid) {
+ if (start) {
+ player.response(null, gid, 3);
+ return;
+ }
+// if (player.dismissCount >= MAX_ASK_COUNT) {
+// player.response(null, gid, ErrorCode.ROOM_DIS_UPPER_LIMIT);
+// return;
+// }
+
+ if (player.room.isBanDismiss) {
+ player.response(null, gid, ErrorCode.ROOM_DIS_NOT_ALLOWED);
+ return;
+ }
+
+ askPlayer = player;
+ startDismiss(player);
+
+ this.dismissCallback(player);
+ }
+
+ public void responseDismiss(Player player, boolean agree) {
+ if (start == false || player.dismissState != 0) {
+ return;
+ }
+ if (agree) {
+ player.dismissState = 1;
+ } else {
+ player.dismissState = 2;
+ }
+ dismissCallback(player);
+ }
+
+ private void dismissCallback(Player player) {
+ int agreeCount = 0;
+ int notAgreeCount = 0;
+ for (Player p : playerList) {
+ if (p.dismissState == 1) {
+ agreeCount += 1;
+ } else if (p.dismissState == 2) {
+ notAgreeCount += 1;
+ }
+ }
+ agree = notAgreeCount == 0 && agreeCount == playerList.size();
+
+ if (agree) {
+
+ interruptTimer();
+ } else {
+ if (notAgreeCount > 0) {
+ Global.gameCtr.dismisRoomFail(owner,playerList,askPlayer,getLeftTime());
+ interruptTimer();
+ } else {
+ Global.gameCtr.dismissRoom(askPlayer, null, playerList, getLeftTime());
+ }
+
+ }
+ }
+
+ private void interruptTimer() {
+ if (timer != null)
+ timer.stop();
+ timer = null;
+ checkDestroy();
+ }
+
+ private void startDismiss(Player player) {
+ playerList.clear();
+ for (Entry entry : owner.playerMapBySeat.entrySet()) {
+ Player p = entry.getValue();
+ if (p.already_round > 0) {
+ playerList.add(p);
+ p.dismissState = 0;
+ }
+ }
+ timer = new Timer(maxTime * 1000, new ITaskHandler() {
+ @Override
+ public void doTask(Timer timer) {
+ disMissTimeOutCallback();
+ Global.logger.error("[" + owner.room_key + "] room dismiss time out destroy!");
+ }
+ });
+ owner.addTimer(timer);
+ start = true;
+ player.dismissState = 1;
+ player.dismissCount++;
+ }
+
+ public void reload(Player owner) {
+ if (start) {
+ if (playerList.contains(owner)) {
+ Global.gameCtr.dismissRoom(askPlayer, owner, playerList, getLeftTime());
+ }
+
+ }
+ }
+
+ public int getLeftTime() {
+ return Math.abs(timer.getCountdownTime() / 1000);
+ }
+
+ private void checkDestroy() {
+ start = false;
+
+ if (agree) {
+ owner.saveMilitaryTotal(true);
+ owner.stateMachine.changeState(Global.getState(RoomDestoryGameState.class));
+ }
+ agree = true;
+ }
+
+ private void disMissTimeOutCallback() {
+ for (Player p : playerList) {
+ p.dismissState = 1;
+ }
+ agree = true;
+ checkDestroy();
+ }
+
+}
diff --git a/game_common/src/main/java/com/game/data/Score.java b/game_common/src/main/java/com/game/data/Score.java
new file mode 100644
index 0000000..fe70326
--- /dev/null
+++ b/game_common/src/main/java/com/game/data/Score.java
@@ -0,0 +1,54 @@
+package com.game.data;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import com.game.Global;
+
+/**
+ * 玩家积分统计
+ *
+ *
+ * 2017年9月19日
+ */
+public class Score {
+
+ public Map round_log;
+
+ /**
+ * 每局的积分统计
+ */
+ public int round_score;
+ /**
+ * 每局的积分统计 对方积分不够的情况下, 会存在小数点问题
+ */
+ public double d_real_score;
+ /**
+ * 总积分统计
+ */
+ public int total_score;
+
+ public boolean negative_score;
+
+ protected Player owner;
+
+ public Score(Player owner) {
+ this.owner = owner;
+ this.round_log = new HashMap<>();
+ this.negative_score = false;
+ this.d_real_score = 0;
+ this.initLog();
+ }
+
+ protected void initLog() {
+ }
+
+ public void resetRound() {
+ this.round_log.clear();
+ this.initLog();
+ round_score = 0;
+ this.d_real_score = 0;
+ negative_score = false;
+ }
+
+}
diff --git a/game_common/src/main/java/com/game/data/Timer.java b/game_common/src/main/java/com/game/data/Timer.java
new file mode 100644
index 0000000..c3d4aa5
--- /dev/null
+++ b/game_common/src/main/java/com/game/data/Timer.java
@@ -0,0 +1,75 @@
+package com.game.data;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Room timer class
+ *
+ *
+ */
+public class Timer {
+ private volatile boolean _start;
+ private int _time;
+ private long _lastTime;
+ private ITaskHandler _task;
+ public Map