public Gambler(string id, GambleChoose choose, float contributeMoney, DeleGetReward getReward)
 {
     this.ID              = id;
     this.Choose          = choose;
     this.ContributeMoney = contributeMoney;
     this.GetReward       = getReward;
 }
    /// 分配赌资
    private void DistributeMoney(GambleChoose winChoose)
    {
        List <Gambler> winners = new List <Gambler>();

        float winnersContribute = 0;

        foreach (var gambler in Gamblers)
        {
            if (gambler.Choose == winChoose)
            {
                winnersContribute += gambler.ContributeMoney;
                winners.Add(gambler);
            }
        }
        winners.Sort();
        for (int i = 0; i < winners.Count; i++)
        {
            if (i == winners.Count - 1)
            {
                winners[i].Reward = (float)Math.Round(GamblingMoney, 2);
                GamblingMoney     = 0;
                break;
            }
            DistributeGamblerMoney(winners[i], winnersContribute);
            winnersContribute -= winners[i].ContributeMoney;
        }
    }
Exemple #3
0
 protected void SmallButton_OnClick(object sender, EventArgs e)
 {
     _userChoose = GambleChoose.Small;
     LaunchGamble();
 }
 /// 赌徒入局
 public void AddGambler(BasicUser gambler, float money, GambleChoose choose)
 {
     Gamblers.Add(new Gambler(gambler.UserID, choose, money, gambler.ChangeMoney));
     gambler.ChangeMoney(-money);
     GamblingMoney += money;
 }