多人麻将 开始游戏 (后台)

来源:互联网 发布:nginx lua 修改header 编辑:程序博客网 时间:2024/04/30 15:29

当客户端所有人都进入大厅,并且都点了准备完毕 按钮,那么服务器这边就触发开始游戏


RoomLogic类


 /**     * 开始一回合新的游戏     */    private void startGameRound()    {         if(count <= 0){            //房间次数用完了,通知所有玩家            for (Avatar avatar : playerList) {                try {                    avatar.getSession().sendMsg(new ErrorResponse(ErrorCode.Error_000010) );                } catch (IOException e) {                    e.printStackTrace();                }            }        }else{            count--;            roomVO.setCurrentRound(roomVO.getCurrentRound() +1);            if((count +1) != roomVO.getRoundNumber()){                //说明不是第一局                Avatar avatar = playCardsLogic.bankerAvatar;                playCardsLogic = new PlayCardsLogic();                playCardsLogic.bankerAvatar = avatar;                //摸牌玩家索引初始值为庄家索引                playCardsLogic.setPickAvatarIndex(playerList.indexOf(avatar));            }            else{                         playCardsLogic = new PlayCardsLogic();                playCardsLogic.setPickAvatarIndex(0);            }            playCardsLogic.setCreateRoomRoleId(createAvator.getUuId());            playCardsLogic.setPlayerList(playerList);            playCardsLogic.initCard(roomVO);                    Avatar avatar;            Account account ;            for(int i=0;i<playerList.size();i++){                //清除各种数据  1:本局胡牌时返回信息组成对象 ,                avatar = playerList.get(i);                avatar.avatarVO.setIsReady(false);//重置是否准备状态 10-11新增                avatar.avatarVO.setHuReturnObjectVO(new HuReturnObjectVO());                avatar.getSession().sendMsg(new StartGameResponse(1,avatar.avatarVO.getPaiArray(),playerList.indexOf(playCardsLogic.bankerAvatar)));                //修改玩家是否玩一局游戏的状态                account = AccountService.getInstance().selectByPrimaryKey(avatar.avatarVO.getAccount().getId());                if(account.getIsGame().equals("0")){                    account.setIsGame("1");                    AccountService.getInstance().updateByPrimaryKeySelective(account);                    avatar.avatarVO.getAccount().setIsGame("1");                }            }        }    }



FR:海涛高软(徐海涛)

原创粉丝点击