public void gameOver(int userId, SingleRoom room, int whichwin) { UserModel um = userCache.GetModelById(userId); ClientPeer client = userCache.GetClientPeer(userId); int wager = room.Wager; SingleOverDto odto = new SingleOverDto(); switch (whichwin) { case 1: { int dealerWeight = room.GetDealerWeight(); odto.dealerWeight = dealerWeight; //21点,和庄家比 获胜或平局 if (dealerWeight != 21) //获胜 { um.Been += (int)(1.5 * wager); um.Exp += 150; odto.dealerState = 3; odto.playerStateList.Add(1); odto.playerWeightList.Add(room.GetPlayerWeight()); odto.playerWinBeenList.Add((int)(1.5 * wager)); } else { um.Exp += 75; odto.dealerState = 1; odto.playerStateList.Add(0); odto.playerWeightList.Add(room.GetPlayerWeight()); odto.playerWinBeenList.Add((int)(0)); } break; } case 2: //闲家爆牌 case 4: //庄家获胜 { int dealerWeight = room.GetDealerWeight(); odto.dealerWeight = dealerWeight; odto.dealerState = 3; um.Been -= wager * room.Multiple; um.Exp += 50; odto.playerWeightList.Add(room.GetPlayerWeight()); odto.playerWinBeenList.Add(-(wager * room.Multiple)); if (room.Multiple == 2) { if (room.GetPlayerWeight() > 21) //加倍爆牌 { odto.playerStateList.Add(3); } else { odto.playerStateList.Add(5); //加倍输 } } else { if (room.GetPlayerWeight() > 21) //加倍爆牌 { odto.playerStateList.Add(2); } else { odto.playerStateList.Add(7); //加倍输 } } break; } case 3: //庄家爆牌,闲家获胜 case 5: { int dealerWeight = room.GetDealerWeight(); odto.dealerWeight = dealerWeight; if (room.GetDealerWeight() > 21) //爆牌 { odto.dealerState = 2; } else { odto.dealerState = 3; } um.Been += wager * room.Multiple; odto.playerWinBeenList.Add(wager * room.Multiple); odto.playerWeightList.Add(room.GetPlayerWeight()); if (room.Multiple == 2) //加倍赢 { odto.playerStateList.Add(4); } else { odto.playerStateList.Add(6); //赢 } um.Exp += 100; break; } case 6: { int dealerWeight = room.GetDealerWeight(); odto.dealerWeight = dealerWeight; odto.dealerState = 3; odto.playerWinBeenList.Add(0); odto.playerWeightList.Add(room.GetPlayerWeight()); odto.playerStateList.Add(8); //平 um.Exp += 75; break; } case 7: { //看看是不是全爆牌了 bool isallboom = room.isAllBoom(); //这个是让客户端翻面 client.Send(OpCode._21Single, _21SingleCode.NGET_SRES, null); if (!isallboom) { while (room.GetDealerWeight() < 17) { CardDto carddto = room.GetOneDealerCard(); client.Send(OpCode._21Single, _21SingleCode.ADD_DCARD_SRES, carddto); } } int dealerWeight = room.GetDealerWeight(); odto.dealerWeight = dealerWeight; if (room.DealerCardList.Count == 2 && room.GetDealerWeight() == 21) //庄家是21点 { odto.dealerState = 1; } else if (room.GetDealerWeight() > 21) { odto.dealerState = 2; } else { odto.dealerState = 3; } for (int j = 0; j < room.player.SpliteCardListList.Count; j++) { int multi = 1; PlayerCardDto tempPlayerCardDto = room.player.SpliteCardListList[j]; int tempWeight = tempPlayerCardDto.Weight; odto.playerWeightList.Add(tempWeight); int tempState = tempPlayerCardDto.CardState; bool tempIsDouble = tempPlayerCardDto.isDouble; if (tempIsDouble) { multi = 2; } //21点 if (tempState == 1) { if (dealerWeight == 1) //平局 { odto.playerWinBeenList.Add(0); odto.playerStateList.Add(0); um.Exp += 75; } else { um.Been += (int)(wager * 1.5); odto.playerWinBeenList.Add((int)(wager * 1.5)); odto.playerStateList.Add(1); um.Exp += 150; } } //闲家爆牌 else if (tempState == 2) { um.Been -= wager * multi; odto.playerWinBeenList.Add(-wager * multi); if (multi == 1) { odto.playerStateList.Add(2); } else { odto.playerStateList.Add(3); } um.Exp += 50; } //不要 权值小于 else if (tempState == 3) { //庄家爆牌 if (dealerWeight > 21) { um.Been += wager * multi; odto.playerWinBeenList.Add(wager * multi); if (multi == 1) { odto.playerStateList.Add(6); } else { odto.playerStateList.Add(4); } um.Exp += 100; } //闲家点大 else if (dealerWeight < tempWeight) { um.Been += wager * multi; odto.playerWinBeenList.Add(wager * multi); if (multi == 1) { odto.playerStateList.Add(6); } else { odto.playerStateList.Add(4); } um.Exp += 100; } //庄家点大 else if (dealerWeight > tempWeight) { um.Been -= wager * multi; odto.playerWinBeenList.Add(-wager * multi); if (multi == 1) { odto.playerStateList.Add(7); } else { odto.playerStateList.Add(5); } um.Exp += 50; } //平局 else { odto.playerWinBeenList.Add(0); odto.playerStateList.Add(8); um.Exp += 75; } } } //double sum = room.computeWinOrLoss(); //um.Been += (int)(sum * wager); //um.Exp += 50 * room.player.SplitNum; //清理工作 room.player.SplitNum = 1; room.splitClear(); break; } default: break; } int maxExp = um.Lv * 100; while (maxExp <= um.Exp) { um.Lv++; um.Exp -= maxExp; maxExp = um.Lv * 100; } userCache.Update(um); UserDto dto = new UserDto(um.Id, um.Name, um.Been, um.WinCount, um.LoseCount, um.RunCount, um.Lv, um.Exp); //SingleOverDto odto = new SingleOverDto(dto, whichwin); odto.userDto = dto; client.Send(OpCode._21Single, _21SingleCode.OVER_SRES, odto); room.player.CardList.Clear(); room.DealerCardList.Clear(); Thread.Sleep(100); CountStrategyDto countStrategyDto = room.libraryModel.GetCountStrategyDto(); client.Send(OpCode._21Single, _21SingleCode.COUNT_STRATEGY_SRES, countStrategyDto); }