public void Settlement() { LogHelper.DebugLog("Settlement begin1..."); //自动结算,如果当前只有一个玩家,这个玩家赢得所有,如果不只一个就开始比牌 List <PokerSide> winSides = new List <PokerSide>(); foreach (var s in Battle.Sides) { if (s.IsFlipCard) { continue; } if (winSides.Count == 0) { winSides.Add(s); } else { PokerSide oneSide = winSides.FirstOrDefault(); List <PokerCard> currentSiderCards = new List <PokerCard>(oneSide.Cards); List <PokerCard> targetSiderCards = new List <PokerCard>(s.Cards); int compareResult = PokerHelper.CardGroupCompare(ref currentSiderCards, ref targetSiderCards); if (compareResult == 0) { winSides.Add(s); } else if (compareResult < 0) { winSides.Clear(); winSides.Add(s); } } } //开始结算金币 LogHelper.DebugLog("Settlement begin2..."); if (winSides.Count > 0) { int winGold = Battle.BetGoldNum / winSides.Count; foreach (var s in winSides) { s.WinGold = winGold; s.Gold += winGold; try { new AccountService().WinGold(int.Parse(s.AccountID), winGold); } catch (Exception ex) { LogHelper.LogError(ex.StackTrace); } } } LogHelper.DebugLog("Settlement begin3..."); ToPokerCleintCommand.SendToClient(PokerCommand.Settlement, Battle); CleanUpAndRestart(); }
public void OperationBack(string accountID, PokerOperationType operationType, bool look, string par1) { Countdown.ClearCommand(); PokerSide currentSider = Battle.Sides.FirstOrDefault(c => c.AccountID == accountID); int uid = Convert.ToInt32(accountID); if (operationType == PokerOperationType.Bet) { int goldnum = Convert.ToInt32(par1); if (look && !currentSider.IsFlipCard) { goldnum = goldnum + this.Battle.CurrentNoteNum; currentSider.IsFlipCard = true; } currentSider.BatGold = goldnum; currentSider.Gold -= goldnum; this.Battle.CurrentNoteNum = goldnum; } else if (operationType == PokerOperationType.CompareCard) { string targetAccountID = par1; PokerSide targetSider = Battle.Sides.FirstOrDefault(c => c.AccountID == targetAccountID); int goldnum = this.Battle.CurrentNoteNum * 2; if (currentSider.IsFlipCard && targetSider.IsFlipCard) { goldnum = this.Battle.CurrentNoteNum; } if (look) { currentSider.IsFlipCard = true; } List <PokerCard> currentSiderCards = new List <PokerCard>(currentSider.Cards); List <PokerCard> targetSiderCards = new List <PokerCard>(targetSider.Cards); int compareResult = PokerHelper.CardGroupCompare(ref currentSiderCards, ref targetSiderCards); if (compareResult <= 0) { currentSider.IsDisCard = true; } else { targetSider.IsDisCard = true; } currentSider.BatGold = goldnum; currentSider.Gold -= goldnum; } else if (operationType == PokerOperationType.Discard) { currentSider.IsDisCard = true; } else if (operationType == PokerOperationType.Follow) { int goldnum = this.Battle.CurrentNoteNum; if (look && !currentSider.IsFlipCard) { goldnum = goldnum + this.Battle.CurrentNoteNum; currentSider.IsFlipCard = true; } currentSider.BatGold = goldnum; currentSider.Gold -= goldnum; this.Battle.CurrentNoteNum = goldnum; } Battle.OperationType = operationType; Battle.OperationLook = look; Battle.OperationPar1 = par1; ToPokerCleintCommand.SendToClient(PokerCommand.OperationBack, Battle); //每回合扣玩家金币,把金币放到战斗托管中心 ThisTrunOperationNum++; if (ThisTrunOperationNum >= Battle.Sides.Count) { Battle.TrunNum++; ThisTrunOperationNum = 0; foreach (var s in Battle.Sides) { if (s.BatGold > 0) { this.Battle.BetGoldNum += s.BatGold; new AccountService().DeductedGold(int.Parse(s.AccountID), s.BatGold); } s.BatGold = 0; } ToPokerCleintCommand.SendToClient(PokerCommand.OneTrunComplated, Battle); } Operation(); }