Search in sources :

Example 1 with GameOfResult

use of com.code.server.constant.response.GameOfResult in project summer by foxsugar.

the class GameDouDiZhuPlus method sendResult.

protected void sendResult(boolean isReopen, boolean isDizhuWin) {
    GameResultDouDizhu gameResultDouDizhu = new GameResultDouDizhu();
    gameResultDouDizhu.setGoldRoomType(room.getGoldRoomType() * tableScore);
    gameResultDouDizhu.setMultiple(multiple);
    gameResultDouDizhu.setSpring(isSpring);
    gameResultDouDizhu.setDizhuWin(isDizhuWin);
    gameResultDouDizhu.setReopen(isReopen);
    gameResultDouDizhu.setTableCards(tableCards);
    /*        for (PlayerCardInfoDouDiZhu playerCardInfo : playerCardInfos.values()) {
            gameResultDouDizhu.getPlayerCardInfos().add(playerCardInfo.toVo());
        }
        //分数结算到房卡

        this.users.forEach(userId -> {
            RedisManager.getUserRedisService().addUserMoney(userId, this.room.getUserScores().get(userId));
        });*/
    ArrayList<Long> tempList = new ArrayList<>();
    tempList.addAll(this.users);
    tempList.remove(dizhu);
    double dizhuOfHave = RedisManager.getUserRedisService().getUserMoney(dizhu);
    double person1OfHave = RedisManager.getUserRedisService().getUserMoney(tempList.get(0));
    double person2OfHave = RedisManager.getUserRedisService().getUserMoney(tempList.get(1));
    double dizhuOfGame = this.room.getUserScores().get(dizhu);
    double person1OfGame = this.room.getUserScores().get(tempList.get(0));
    double person2OfGame = this.room.getUserScores().get(tempList.get(1));
    if (dizhuOfGame > 0) {
        // 地主赢
        if (person1OfGame + person1OfHave <= 0) {
            // 豆不够
            RedisManager.getUserRedisService().addUserMoney(tempList.get(0), -person1OfHave);
            RedisManager.getUserRedisService().addUserMoney(dizhu, person1OfHave);
        } else {
            RedisManager.getUserRedisService().addUserMoney(tempList.get(0), person1OfGame);
            RedisManager.getUserRedisService().addUserMoney(dizhu, -person1OfGame);
        }
        if (person2OfGame + person2OfHave <= 0) {
            RedisManager.getUserRedisService().addUserMoney(tempList.get(1), -person2OfHave);
            RedisManager.getUserRedisService().addUserMoney(dizhu, person2OfHave);
        } else {
            RedisManager.getUserRedisService().addUserMoney(tempList.get(1), person2OfGame);
            RedisManager.getUserRedisService().addUserMoney(dizhu, -person2OfGame);
        }
    } else {
        // 地主输
        if (dizhuOfGame + dizhuOfHave >= 0) {
            // 豆充足
            RedisManager.getUserRedisService().addUserMoney(dizhu, dizhuOfGame);
            RedisManager.getUserRedisService().addUserMoney(tempList.get(0), person1OfGame);
            RedisManager.getUserRedisService().addUserMoney(tempList.get(1), person2OfGame);
        } else {
            RedisManager.getUserRedisService().addUserMoney(dizhu, -dizhuOfHave);
            RedisManager.getUserRedisService().addUserMoney(tempList.get(0), person1OfGame / (person1OfGame + person2OfGame) * dizhuOfHave);
            RedisManager.getUserRedisService().addUserMoney(tempList.get(1), person2OfGame / (person1OfGame + person2OfGame) * dizhuOfHave);
        }
    }
    for (Long l : this.room.getUserScores().keySet()) {
        this.room.getUserScores().put(l, this.room.getUserScores().get(l));
    }
    // 将room保存到playerCardInfos
    for (PlayerCardInfoDouDiZhu playerCardInfo : playerCardInfos.values()) {
        playerCardInfo.setScore(this.room.getUserScores().get(playerCardInfo.getUserId()));
        gameResultDouDizhu.getPlayerCardInfos().add(playerCardInfo.toVo());
    }
    gameResultDouDizhu.getUserScores().putAll(this.room.getUserScores());
    MsgSender.sendMsg2Player("gameService", "gameResult", gameResultDouDizhu, users);
    replay.setResult(gameResultDouDizhu);
    pushScoreChange();
    a: for (Long l : room.getUsers()) {
        if (RedisManager.getUserRedisService().getUserMoney(l) < RoomDouDiZhuPlus.needsMoney.get(room.getGoldRoomType())) {
            room.clearReadyStatus(true);
            List<UserOfResult> userOfResultList = this.room.getUserOfResult();
            // 存储返回
            GameOfResult gameOfResult = new GameOfResult();
            gameOfResult.setUserList(userOfResultList);
            MsgSender.sendMsg2Player("gameService", "gameFinalResult", gameOfResult, users);
            RoomManager.removeRoom(room.getRoomId());
            // 战绩
            this.room.genRoomRecord();
            break a;
        }
    }
}
Also used : GameResultDouDizhu(com.code.server.constant.response.GameResultDouDizhu) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) GameOfResult(com.code.server.constant.response.GameOfResult)

Example 2 with GameOfResult

use of com.code.server.constant.response.GameOfResult in project summer by foxsugar.

the class RoomDouDiZhu method dissolutionRoom.

// @Override
// protected Game getGameInstance() {
// switch (gameType) {
// case GAMETYPE_LINFEN:
// return new GameDouDiZhuLinFen();
// case GAMETYPE_QIANAN:
// return new GameDouDiZhuQianAn();
// case GAMETYPE_LONGQI:
// return new GameDouDiZhu();
// case GAMETYPE_LONGQI_LINFEN:
// return new GameDouDiZhuLinFenLongQi();
// case GAMETYPE_LONGQI_LINFEN_NO_QIANG:
// return new GameDouDiZhuLinFenNoQiang();
// 
// case GAMETYPE_LONGQI_NO_QIANG:
// return new GameDouDiZhuNoQiang();
// default:
// return new GameDouDiZhu();
// }
// 
// }
public void dissolutionRoom() {
    if (RoomManager.getRoom(this.roomId) == null) {
        return;
    }
    RoomManager.removeRoom(this.roomId);
    // 结果类
    List<UserOfResult> userOfResultList = getUserOfResult();
    // 代开房 并且游戏未开始
    if (!isCreaterJoin && !this.isInGame && this.curGameNumber == 1) {
        drawBack();
        GameTimer.removeNode(this.prepareRoomTimerNode);
    }
    if ((this.isInGame || !isCreaterJoin) && this.curGameNumber == 1) {
        drawBack();
    }
    this.isInGame = false;
    // 存储返回
    GameOfResult gameOfResult = new GameOfResult();
    gameOfResult.setUserList(userOfResultList);
    gameOfResult.setEndTime(LocalDateTime.now().toString());
    MsgSender.sendMsg2Player(new ResponseVo("gameService", "askNoticeDissolutionResult", gameOfResult), users);
    // 战绩
    genRoomRecord();
}
Also used : UserOfResult(com.code.server.constant.response.UserOfResult) GameOfResult(com.code.server.constant.response.GameOfResult) ResponseVo(com.code.server.constant.response.ResponseVo)

Example 3 with GameOfResult

use of com.code.server.constant.response.GameOfResult in project summer by foxsugar.

the class GameInfo method noticeDissolutionResult.

public void noticeDissolutionResult() {
    if (isRoomOver()) {
        List<UserOfResult> userOfResultList = this.room.getUserOfResult();
        // 存储返回
        GameOfResult gameOfResult = new GameOfResult();
        gameOfResult.setUserList(userOfResultList);
        RoomManager.removeRoom(room.getRoomId());
        MsgSender.sendMsg2Player("gameService", "noticeDissolutionResult", gameOfResult, users);
        // 战绩
        this.room.genRoomRecord();
    }
}
Also used : UserOfResult(com.code.server.constant.response.UserOfResult) GameOfResult(com.code.server.constant.response.GameOfResult)

Example 4 with GameOfResult

use of com.code.server.constant.response.GameOfResult in project summer by foxsugar.

the class GameGoldPaijiu method sendFinalResult.

/**
 * 最终结算版
 */
public void sendFinalResult() {
    List<UserOfResult> userOfResultList = this.roomPaijiu().getUserOfResult();
    for (UserOfResult u : userOfResultList) {
        double d = Double.parseDouble(u.getScores());
        if (u.getUserId() == roomPaijiu().getBankerId()) {
            u.setScores(d + "");
            // userId-money
            RedisManager.getUserRedisService().addUserMoney(u.getUserId(), d - this.roomPaijiu().bankerInitScore());
        } else {
            u.setScores(d - RedisManager.getUserRedisService().getUserMoney(u.getUserId()) + "");
            // userId-money
            RedisManager.getUserRedisService().addUserMoney(u.getUserId(), d - RedisManager.getUserRedisService().getUserMoney(u.getUserId()));
        }
        MsgSender.sendMsg2Player(new ResponseVo("userService", "refresh", 0), u.getUserId());
    }
    // 存储返回
    GameOfResult gameOfResult = new GameOfResult();
    gameOfResult.setUserList(userOfResultList);
    MsgSender.sendMsg2Player("gameService", "gamePaijiuFinalResult", gameOfResult, users);
    RoomManager.removeRoom(this.roomPaijiu().getRoomId());
    // 庄家初始分 再减掉
    this.roomPaijiu().addUserSocre(this.roomPaijiu().getBankerId(), -this.roomPaijiu().bankerInitScore());
    // 战绩
    this.roomPaijiu().genRoomRecord();
/*for (Long l:this.roomPaijiu().userScores.keySet()) {
            RedisManager.getUserRedisService().setUserMoney(l, roomPaijiu().userScores.get(l));//userId-money
        }*/
}
Also used : UserOfResult(com.code.server.constant.response.UserOfResult) GameOfResult(com.code.server.constant.response.GameOfResult) ResponseVo(com.code.server.constant.response.ResponseVo)

Example 5 with GameOfResult

use of com.code.server.constant.response.GameOfResult in project summer by foxsugar.

the class RoomGoldPaijiu method dissolutionRoom.

/**
 * 解散房间
 */
@Override
public void dissolutionRoom() {
    // 庄家初始分 再减掉
    RoomManager.removeRoom(this.roomId);
    // 结果类
    List<UserOfResult> userOfResultList = getUserOfResult();
    // 代开房 并且游戏未开始
    if (!isCreaterJoin && !this.isInGame && (this.curGameNumber == 1)) {
        drawBack();
        GameTimer.removeNode(this.prepareRoomTimerNode);
    }
    this.isInGame = false;
    // 存储返回
    GameOfResult gameOfResult = new GameOfResult();
    for (UserOfResult u : userOfResultList) {
        double d = Double.parseDouble(u.getScores());
        if (u.getUserId() == this.getBankerId()) {
            u.setScores(d + "");
            // userId-money
            RedisManager.getUserRedisService().addUserMoney(u.getUserId(), d - this.bankerInitScore());
        } else {
            u.setScores(d - RedisManager.getUserRedisService().getUserMoney(u.getUserId()) + "");
            // userId-money
            RedisManager.getUserRedisService().addUserMoney(u.getUserId(), d - RedisManager.getUserRedisService().getUserMoney(u.getUserId()));
        }
        MsgSender.sendMsg2Player(new ResponseVo("userService", "refresh", 0), u.getUserId());
    }
    gameOfResult.setUserList(userOfResultList);
    gameOfResult.setEndTime(LocalDateTime.now().toString());
    MsgSender.sendMsg2Player(new ResponseVo("gameService", "askNoticeDissolutionResult", gameOfResult), users);
    // 庄家初始分 再减掉
    this.addUserSocre(this.getBankerId(), -this.bankerInitScore());
    // 战绩
    genRoomRecord();
}
Also used : UserOfResult(com.code.server.constant.response.UserOfResult) GameOfResult(com.code.server.constant.response.GameOfResult) ResponseVo(com.code.server.constant.response.ResponseVo)

Aggregations

GameOfResult (com.code.server.constant.response.GameOfResult)6 UserOfResult (com.code.server.constant.response.UserOfResult)5 ResponseVo (com.code.server.constant.response.ResponseVo)3 GameResultDouDizhu (com.code.server.constant.response.GameResultDouDizhu)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1