コード例 #1
0
        /// <summary>
        /// 插入当日数据
        /// </summary>
        /// <param name="?"></param>
        /// <returns></returns>
        public int InsertShopActive(ActiveStatus model)
        {
            if (CheckShopActive(model.ShowDate) == 1)
            {
                UpdateTodayActive(model);
            }

            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Sys_TempActiveStatus " +
                          "(ShowDate,AllUsr,NewReg,UnknownUsr,RegAttention,Attention,LoginUsr," +
                          "RegUsr,ActiveUsr,FaithUsr,SleepUsr,OutUsr,Time) " +
                          "Values(@ShowDate,@AllUsr,@NewReg,@UnknownUsr," +
                          "@RegAttention,@Attention,@LoginUsr,@RegUsr,@ActiveUsr,@FaithUsr,@SleepUsr,@OutUsr,@Time);");

            return(DapperHelper.Execute(strSql.ToString(), new
            {
                ShowDate = model.ShowDate,
                AllUsr = model.AllUsr,
                NewReg = model.NewReg,
                UnknownUsr = model.UnknownUsr,
                RegAttention = model.RegAttention,
                Attention = model.Attention,
                LoginUsr = model.LoginUsr,
                RegUsr = model.RegUsr,
                ActiveUsr = model.ActiveUsr,
                FaithUsr = model.FaithUsr,
                SleepUsr = model.SleepUsr,
                OutUsr = model.OutUsr,
                Time = model.Time
            }));
        }
コード例 #2
0
 public Account(string username, decimal balance, string fullName, ActiveStatus status)
 {
     _username = username;
     _balance  = balance;
     _fullName = fullName;
     _status   = status;
 }
コード例 #3
0
ファイル: HandSnapshotModel.cs プロジェクト: ddksaku/rzr
        public HandSnapshotModel(HoldemHandRound round, int button, bool[] active, ActiveStatus[] status, float[] bets, float[] stacks, int? currentPlayer)
        {
            Round = round;
            Button = button;
            Active = active;
            Stacks = stacks;
            Bets = bets;
            Status = status;
            CurrentPlayer = currentPlayer;

            for (int i = 0; i < active.Length; i++)
            {
                if (!active[i])
                {
                    Status[i] = ActiveStatus.HasFolded;
                    Bets[i] = 0;
                }
            }

            int start = CurrentPlayer != null ? (int)CurrentPlayer : BetPolicyService.GetRoundStart(round, button, stacks.Length);
            NextPlayer = BetPolicyService.GetNextActivePlayer(status, bets, start);

            NumPlayersInHand = status.Count(x => x != ActiveStatus.HasFolded);
            NumPlayersActive = status.Count(x => x != ActiveStatus.HasFolded && x != ActiveStatus.AllIn);
            IsRoundEnd = NextPlayer == null;
            IsHandEnd = NumPlayersActive == 0 || NumPlayersInHand == 1 || IsRoundEnd && round == HoldemHandRound.River;
        }
コード例 #4
0
        public DataSet GetAllActiveCountries(ActiveStatus status)
        {
            SqlParameter pPKCountryId = new SqlParameter("@PKCountryId", SqlDbType.Int);

            pPKCountryId.Value = (int)status;
            return(SqlHelper.ExecuteDataset(Helper.ConnectionString, CommandType.StoredProcedure, "spGetAllCountry", pPKCountryId));
        }
コード例 #5
0
        public bool ChangeStatus(Guid userId, ActiveStatus newStatus)
        {
            var connection = DbService.GetConnection();

            string sql = "UPDATE Users SET ActiveStatus = @ActiveStatus Where Id = @Id";

            var affectedRowsCount = connection.Execute(sql, new { ActiveStatus = (byte)newStatus, Id = userId });

            return(affectedRowsCount > 0);
        }
コード例 #6
0
 public Account(string username, string password, string salt, string accountNumber, decimal balance, string fullName, ActiveStatus status)
 {
     _username      = username;
     _password      = password;
     _salt          = salt;
     _accountNumber = accountNumber;
     _balance       = balance;
     _fullName      = fullName;
     _status        = status;
 }
コード例 #7
0
        public async Task <IActionResult> ActiveStatus(string name)
        {
            var activeStatus = new ActiveStatus()
            {
                Status = name,
            };

            await unitOfWork.GetRepository <ActiveStatus>().InsertAsync(activeStatus);

            return(ApiResponder.RespondSuccessTo(HttpStatusCode.Ok, "ADDED"));
        }
コード例 #8
0
ファイル: Account.cs プロジェクト: trauvmfpt/C-_assignment
 public Account(string username, string password, string confirmPassword, string identityCard, string phone, string email, string fullName, ActiveStatus status)
 {
     _username        = username;
     _password        = password;
     _confirmPassword = confirmPassword;
     _identityCard    = identityCard;
     _phone           = phone;
     _email           = email;
     _fullName        = fullName;
     _status          = status;
 }
コード例 #9
0
 public HL_Transaction(string id, decimal amount, string content, string senderAccountNumber, string receiverAccountNumber, TransactionType type, string createdAt, ActiveStatus status)
 {
     this.id                    = id;
     this.amount                = amount;
     this.content               = content;
     this.senderAccountNumber   = senderAccountNumber;
     this.receiverAccountNumber = receiverAccountNumber;
     this.type                  = type;
     this.createdAt             = createdAt;
     this.status                = status;
 }
コード例 #10
0
        public static bool GetActiveStatusValue(this ActiveStatus value)
        {
            switch (value)
            {
            case ActiveStatus.Published: return(true);

            case ActiveStatus.Draft: return(false);

            default: throw new ArgumentOutOfRangeException("value");
            }
        }
コード例 #11
0
 public Transaction(string id, decimal amount, string content, string senderAccountNumber, string receiverAccountNumber, TransactionType type, string createdAt, ActiveStatus status)
 {
     _id                    = id;
     _amount                = amount;
     _content               = content;
     _senderAccountNumber   = senderAccountNumber;
     _receiverAccountNumber = receiverAccountNumber;
     _type                  = type;
     _createdAt             = createdAt;
     _status                = status;
 }
コード例 #12
0
        ///<inheritdoc/>
        public override int GetHashCode()
        {
            int hash = 17;

            // Overflow is fine, just wrap
            unchecked
            {
                hash = (hash * 29) + MinefieldType.GetHashCode();
                hash = (hash * 29) + ActiveStatus.GetHashCode();
                hash = (hash * 29) + Lane.GetHashCode();
                hash = (hash * 29) + State.GetHashCode();
            }

            return(hash);
        }
コード例 #13
0
 public Account(string username, string password, string salt, string accountNumber, string identityCard, decimal balance, string phone, string email, string fullName, string createdAt, string updatedAt, ActiveStatus status)
 {
     _username      = username;
     _password      = password;
     _salt          = salt;
     _accountNumber = accountNumber;
     _identityCard  = identityCard;
     _balance       = balance;
     _phone         = phone;
     _email         = email;
     _fullName      = fullName;
     _createdAt     = createdAt;
     _updatedAt     = updatedAt;
     _status        = status;
 }
コード例 #14
0
ファイル: ListFilter.cs プロジェクト: GTravesty/QBSDK
                public virtual XElement GenerateQueryRq()
                {
                    XElement xElement = new XElement(typeof(T).Name + "QueryRq");

                    xElement.Add(ListID?.ToQBXML(nameof(ListID)));
                    xElement.Add(FullName?.ToQBXML(nameof(FullName)));
                    xElement.Add(MaxReturned?.ToQBXML(nameof(MaxReturned)));
                    xElement.Add(ActiveStatus?.ToQBXML(nameof(ActiveStatus)));
                    xElement.Add(FromModifiedDate?.ToQBXML(nameof(FromModifiedDate)));
                    xElement.Add(ToModifiedDate?.ToQBXML(nameof(ToModifiedDate)));
                    xElement.Add(NameFilter?.ToQBXML(nameof(NameFilter)));
                    xElement.Add(NameRangeFilter?.ToQBXML(nameof(NameRangeFilter)));
                    xElement.Add(IncludeRetElement?.ToQBXML(nameof(IncludeRetElement)));
                    return(xElement);
                }
コード例 #15
0
ファイル: Transaction.cs プロジェクト: SlowV/ASSM
 public Transaction(int stt, string id, string createdAt, string updatedAt, TransactionType type, decimal amount, string content, string senderAccountNumber, string senderAccountName, string receiverAccountNumber, string receiverAccountName, ActiveStatus status)
 {
     _stt                   = stt;
     _id                    = id;
     _createdAt             = createdAt;
     _updatedAt             = updatedAt;
     _type                  = type;
     _amount                = amount;
     _content               = content;
     _senderAccountNumber   = senderAccountNumber;
     _senderAccountName     = senderAccountName;
     _receiverAccountNumber = receiverAccountNumber;
     _receiverAccountName   = receiverAccountName;
     _status                = status;
 }
コード例 #16
0
 public virtual void RollBack()
 {
     if (myHistory.Count == 0)
     {
         Destroy(this.gameObject);
     }
     else if (myHistory.Count > 0)
     {
         History rollbackHistory = myHistory.Pop();
         currentPos         = rollbackHistory.Pos;
         transform.position = currentPos.ToVector3();
         currentStatus      = rollbackHistory.Status;
         activatingPoint    = rollbackHistory.ActivatingPoint;
         SetSortingOrder();
         ActivateCheck();
     }
 }
コード例 #17
0
ファイル: HL_Account.cs プロジェクト: Ly111999/AsmC-
 public HL_Account(string username, string password, string salt, string accountNumber, string identityCard,
                   decimal balance, string phoneNumber, string email, string fullname, string createdAt, string updateAt,
                   ActiveStatus status)
 {
     this.username      = username;
     this.password      = password;
     this.salt          = salt;
     this.accountNumber = accountNumber;
     this.identityCard  = identityCard;
     this.balance       = balance;
     this.phoneNumber   = phoneNumber;
     this.email         = email;
     this.fullname      = fullname;
     this.createdAt     = createdAt;
     this.updateAt      = updateAt;
     this.status        = status;
 }
コード例 #18
0
ファイル: RMCMessage.cs プロジェクト: akboyd88/DotnetNMEA
        /// <inheritdoc />
        protected override void SetIndexValue(int idx, ReadOnlySpan <char> val)
        {
            switch (idx)
            {
            case 0:
                UTCTime = GetTimeSpanFromHHMMSS(val);
                break;

            case 1:
                ActiveStatus = GetActiveStatus(val);
                break;

            case 2:
                Latitude = GetDecimalDegrees(val);
                break;

            case 3:
                NorthSouth = GetNorthSouth(val);
                break;

            case 4:
                Longitude = GetDecimalDegrees(val);
                break;

            case 5:
                EastWest = GetEastWest(val);
                break;

            case 6:
                Knots = GetDecimal(val);
                break;

            case 7:
                TrackAngle = GetDecimal(val);
                break;

            case 8:
                Date = GetDateTimeDDMMYY(val);
                break;

            case 9:
                MagneticVariation = GetDecimal(val);
                break;
            }
        }
コード例 #19
0
        public async Task <bool> ChangeStatusAsync(ActiveStatus status)
        {
            if (status.Id == null || status.Id == Guid.Empty)
            {
                throw new ArgumentNullException("Id", "Id is missing");
            }

            var item = await _context.ProductCategories
                       .FindAsync(status.Id);

            if (item != null)
            {
                item.Active = status.Active;
                _context.ProductCategories.Update(item);
                await _context.SaveChangesAsync();

                return(true);
            }
            throw new KeyNotFoundException("Product category not found");
        }
コード例 #20
0
ファイル: UnitRepository.cs プロジェクト: fanda-org/fanda-cs
        public async Task <bool> ChangeStatusAsync(ActiveStatus status)
        {
            if (status.Id == null || status.Id == Guid.Empty)
            {
                throw new ArgumentNullException("Id", "Id is missing");
            }

            var unit = await _context.Units
                       .FindAsync(status.Id);

            if (unit != null)
            {
                unit.Active = status.Active;
                _context.Units.Update(unit);
                await _context.SaveChangesAsync();

                return(true);
            }
            throw new KeyNotFoundException("Unit not found");
        }
コード例 #21
0
        public async Task <bool> ChangeStatusAsync(ActiveStatus status)
        {
            if (status.Id == null || status.Id == Guid.Empty)
            {
                throw new ArgumentNullException("id", "Year id is missing");
            }

            AccountYear year = await _context.AccountYears
                               .FindAsync(status.Id);

            if (year != null)
            {
                year.Active = status.Active;
                _context.AccountYears.Update(year);
                await _context.SaveChangesAsync();

                return(true);
            }
            throw new KeyNotFoundException("Account year not found");
        }
コード例 #22
0
        public async Task <bool> ChangeStatusAsync(ActiveStatus status)
        {
            if (status.Id == null || status.Id == Guid.Empty)
            {
                throw new ArgumentNullException("Id", "Id is missing");
            }

            Organization org = await _context.Organizations
                               .FindAsync(status.Id);

            if (org != null)
            {
                org.Active = status.Active;
                _context.Organizations.Update(org);
                await _context.SaveChangesAsync();

                return(true);
            }
            throw new NotFoundException("Organization not found");
        }
コード例 #23
0
        /// <summary>
        /// 获取某天店铺状态
        /// </summary>
        /// <param name="dayDate"></param>
        /// <returns></returns>
        public ActiveStatus GetdailyStatus(DateTime dayDate)
        {
            ActiveStatus model = new ActiveStatus();
            DateTime     dt    = DateTime.Now;
            DateTime     fDt   = DateTime.Now.AddDays(-1);

            bool isToday     = dayDate.ToShortDateString() == dt.ToShortDateString() ? true : false;
            bool isYesterday = dayDate.AddDays(-1).ToShortDateString() == fDt.ToShortDateString() ? true : false;

            if (CheckShopActive(dayDate) == 0 || isToday || isYesterday)
            {
                model = GenerateActiveModel(dayDate);
            }
            else
            {
                model = GetShopActive(dayDate);
            }


            return(model);
        }
コード例 #24
0
ファイル: HL_TransactionModel.cs プロジェクト: Ly111999/AsmC-
        public HashSet <HL_Transaction> TransactionLog(string acountNumber)
        {
            DbConnection.Instance().OpenConnection();
            string          checkTransacLog = "SELECT id, fromAccountNumber, amount, content, toAccountNumber, type, createdAt, status FROM transaction WHERE fromAccountNumber = '" + Program.currentLoggedIn.AccountNumber + "'";
            MySqlCommand    cmd = new MySqlCommand(checkTransacLog, DbConnection.Instance().Connection);
            string          id = "", senderAccountNumber = "", content = "", receiveBankNumber = "";
            decimal         amount;
            int             type1       = 0;
            int             status1     = 0;
            string          createdAt   = "";
            HL_Transaction  transaction = null;
            MySqlDataReader reader      = cmd.ExecuteReader();

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    id = reader.GetString("id");
                    senderAccountNumber = reader.GetString("fromAccountNumber");
                    amount            = reader.GetDecimal("amount");
                    content           = reader.GetString("content");
                    receiveBankNumber = reader.GetString("toAccountNumber");
                    type1             = reader.GetInt32("type");
                    createdAt         = reader.GetString("createdAt");
                    status1           = reader.GetInt32("status");

                    // cast int sang enum.
                    TransactionType type   = (TransactionType)type1;
                    ActiveStatus    status = (ActiveStatus)status1;

                    transaction = new HL_Transaction(id, amount, content, senderAccountNumber, receiveBankNumber, type, createdAt, status);
                    hashList.Add(transaction);
                }
            }

            reader.Close();
            return(hashList);
        }
コード例 #25
0
        /// <summary>
        /// 更新今日活跃状态
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int UpdateTodayActive(ActiveStatus model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Sys_TempActiveStatus set " +
                          "AllUsr=@AllUsr," +
                          "NewReg=@NewReg," +
                          "UnknownUsr=@UnknownUsr," +
                          "RegAttention=@RegAttention," +
                          "Attention=@Attention," +
                          "LoginUsr=@LoginUsr," +
                          "RegUsr=@RegUsr," +
                          "ActiveUsr=@ActiveUsr," +
                          "FaithUsr=@FaithUsr," +
                          "SleepUsr=@SleepUsr," +
                          "OutUsr=@OutUsr," +
                          "Time=@Time " +
                          "where datediff(day,ShowDate,@date)=0;");

            return(DapperHelper.Execute(strSql.ToString(), new
            {
                date = model.ShowDate,
                AllUsr = model.AllUsr,
                NewReg = model.NewReg,
                UnknownUsr = model.UnknownUsr,
                RegAttention = model.RegAttention,
                Attention = model.Attention,
                LoginUsr = model.LoginUsr,
                RegUsr = model.RegUsr,
                ActiveUsr = model.ActiveUsr,
                FaithUsr = model.FaithUsr,
                SleepUsr = model.SleepUsr,
                OutUsr = model.OutUsr,
                Time = model.Time
            }));
        }
コード例 #26
0
        private void bunifuFlatButtonConfirmNewSubject_Click(object sender, EventArgs e)
        {
            ActiveStatus status = new ActiveStatus();

            try
            {
                DataGridViewSelectedRowCollection selected = this.bunifuCustomDataGridSubjects.SelectedRows;
                if (selected.Count == 0)
                {
                    MessageBox.Show("Seleccione la nueva asignatura", "Información");
                    return;
                }
                foreach (DataGridViewRow row in selected)
                {
                    Subject newSubject = new Subject();
                    newSubject.SubjectID           = Convert.ToInt32(row.Cells[0].Value);
                    newSubject.Name                = row.Cells[1].Value.ToString();
                    newSubject.Year                = Convert.ToInt32(row.Cells[2].Value);
                    newSubject.Status              = status;
                    newSubject.PeriodType          = row.Cells[4].Value.ToString();
                    newSubject.CorrespondingPeriod = Convert.ToInt32(row.Cells[5].Value);

                    BusinessSubject.CreateSubject(newSubject);
                }

                MessageBox.Show("Alta realizada correctamente", "Información");
                ListSubjects(false);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ocurrio un error en el alta de la asignatura", "Contactese con un administrador");
                Console.WriteLine(ex.Message);
            }

            this.bunifuFlatButtonConfirmNewSubject.Visible = false;
        }
コード例 #27
0
 /// <summary>
 /// convert currentStatus to true
 /// </summary>
 protected virtual void Activate()
 {
     currentStatus = ActiveStatus.activating;
 }
コード例 #28
0
ファイル: Accounts.cs プロジェクト: evgeniynet/APIBeta
 public Filter()
 {
     UserSetting _c = UserSetting.GetSettings("AcctList");
     if (!_c.IsDefined) return;
     if (!string.IsNullOrEmpty(_c["AF"]))
     {
         if (_c["AF"] == "1") m_ActiveStatus = ActiveStatus.Active;
         else if (_c["AF"] == "0") m_ActiveStatus = ActiveStatus.Inactive;
         else m_ActiveStatus = ActiveStatus.NoFilter;
     }
     if (!string.IsNullOrEmpty(_c["SrANa"])) m_AccName = HttpUtility.UrlDecode(_c["SrANa"]);
 }
コード例 #29
0
        /// <summary>
        /// 根据当日时间生成新的活跃数据
        /// </summary>
        /// <param name="dt"></param>
        /// <returns></returns>
        public ActiveStatus GenerateActiveModel(DateTime dt)
        {
            ActiveStatus  model  = new ActiveStatus();
            StringBuilder strSql = new StringBuilder();

            model.ShowDate = dt;
            model.Time     = dt;

            strSql.Append("select active,COUNT(distinct accid) cnt from Sys_I200.dbo.SysRpt_ShopActive " +
                          "where startTime<=@dayDate and updatetime>=@dayDate " +
                          "group by active");

            List <ActiveModel> modelData =
                DapperHelper.Query <ActiveModel>(strSql.ToString(), new { dayDate = dt }).ToList();

            foreach (var item in modelData)
            {
                switch (item.active)
                {
                case -3:
                    //流失用户
                    model.OutUsr = item.cnt;
                    break;

                case -1:
                    //休眠用户
                    model.SleepUsr = item.cnt;
                    break;

                case 1:
                    //新注册用户
                    model.NewReg = item.cnt;
                    break;

                case 3:
                    //需关怀用户
                    model.RegAttention = item.cnt;
                    break;

                case 4:
                    //流失需关怀用户
                    model.Attention = item.cnt;
                    break;

                case 5:
                    //活跃用户
                    model.ActiveUsr = item.cnt;
                    break;

                case 7:
                    //忠诚用户
                    model.FaithUsr = item.cnt;
                    break;
                }
            }

            //获取当日注册人数
            strSql.Clear();
            strSql.Append("select count(*) from i200.dbo.T_Account where datediff(day,regtime,@dayDate)=0 and state=1;");

            model.RegUsr = DapperHelper.ExecuteScalar <int>(strSql.ToString(), new { dayDate = dt });

            //获取当日登录人数
            strSql.Clear();
            strSql.Append(
                "select COUNT(distinct Accountid) from i200.dbo.T_LOG where DATEDIFF(DAY,OperDate,@dayDate)=0;");

            model.LoginUsr = DapperHelper.ExecuteScalar <int>(strSql.ToString(), new { dayDate = dt });

            strSql.Clear();
            strSql.Append(
                "select COUNT(distinct ID) from i200.dbo.T_Account where state=1 and regtime<=@dayDate;");

            model.AllUsr = DapperHelper.ExecuteScalar <int>(strSql.ToString(), new { dayDate = dt });

            if (CheckShopActive(dt) == 0)
            {
                InsertShopActive(model);
            }
            else
            {
                UpdateTodayActive(model);
            }

            return(model);
        }
コード例 #30
0
 public Product(string name, ActiveStatus status)
 {
     Name   = name;
     Status = status.ToString();
 }
コード例 #31
0
ファイル: Accounts.cs プロジェクト: evgeniynet/APIBeta
 public Filter(ActiveStatus ActiveStatus, string AccName)
 {
     m_ActiveStatus = ActiveStatus;
     m_AccName = AccName;
 }
コード例 #32
0
ファイル: HandSnapshotModel.cs プロジェクト: ddksaku/rzr
 private ActiveStatus GetStatusForNextRound(ActiveStatus previousStatus)
 {
     if (previousStatus == ActiveStatus.AllIn) return ActiveStatus.AllIn;
     else if (previousStatus == ActiveStatus.HasFolded) return ActiveStatus.HasFolded;
     else return ActiveStatus.StillToBet;
 }
コード例 #33
0
        public void ChangeActiveStatusOrganization(int organizationId, ActiveStatus activeStatus)
        {
            string sql = "update public.\"Organization\" set \"ActiveStatus\" = @activeStatus where \"Id\" = @organizationId ";

            _connection.Execute(sql, new { activeStatus = activeStatus, organizationId = organizationId });
        }
コード例 #34
0
 public static ActiveStatus SetActiveStatusValue(this ActiveStatus key, bool value)
 {
     return(value == true ? ActiveStatus.Published : ActiveStatus.Draft);
 }
コード例 #35
0
ファイル: BetPolicyService.cs プロジェクト: ddksaku/rzr
        /// <summary>
        /// Applies a bet and adjusts the players status according to the bet
        /// </summary>
        private static void ApplyBet(BetAction action, int playerIndex, float amount, ActiveStatus[] status, float[] bets, float[] stacks)
        {
            switch (action)
            {
                case BetAction.Bet:
                case BetAction.Raise:
                    bets[playerIndex] += amount;
                    for (int i = 0; i < status.Length; i++)
                        if (status[i] == ActiveStatus.LastToRaise)
                            status[i] = ActiveStatus.HasBet;
                    status[playerIndex] = ActiveStatus.LastToRaise;
                    break;
                case BetAction.Call:
                    bets[playerIndex] += amount;
                    status[playerIndex] = ActiveStatus.HasBet;
                    break;
                case BetAction.Check:
                    status[playerIndex] = ActiveStatus.HasBet;
                    break;
                case BetAction.Fold:
                    status[playerIndex] = ActiveStatus.HasFolded;
                    break;
                case BetAction.AllIn:
                    bets[playerIndex] += amount;
                    for (int i = 0; i < status.Length; i++)
                        if (status[i] == ActiveStatus.LastToRaise)
                            status[i] = ActiveStatus.HasBet;
                    status[playerIndex] = ActiveStatus.AllIn;
                    break;
            }

            if (bets[playerIndex] == stacks[playerIndex])
                status[playerIndex] = ActiveStatus.AllIn;
        }
コード例 #36
0
ファイル: BetPolicyService.cs プロジェクト: ddksaku/rzr
 private static ActiveStatus[] GetNextRoundStatus(ActiveStatus[] activeStatus)
 {
     ActiveStatus[] status = activeStatus.Select(x =>
         (x == ActiveStatus.HasFolded || x == ActiveStatus.AllIn) ? x : ActiveStatus.StillToBet).ToArray();
     return status;
 }
コード例 #37
0
ファイル: BetPolicyService.cs プロジェクト: ddksaku/rzr
 /// <summary>
 /// Returns true if the player at the designated index needs to bet more chips to stay in the hand
 /// </summary>
 private static bool NeedsToBet(ActiveStatus[] status, float[] amounts, float amount, int index)
 {
     bool needsToBet = amounts[index] < amount;
     needsToBet &= status[index] != ActiveStatus.HasFolded;
     needsToBet &= status[index] != ActiveStatus.AllIn;
     return needsToBet;
 }
コード例 #38
0
ファイル: BetPolicyService.cs プロジェクト: ddksaku/rzr
        /// <summary>
        /// Get the next active player
        /// </summary>
        /// <param name="status"></param>
        /// <param name="amounts"></param>
        /// <param name="start"></param>
        /// <returns></returns>
        public static int? GetNextActivePlayer(ActiveStatus[] status, float[] amounts, int start)
        {
            int index = start;

            //-------------------------------------------------------------------------------------
            // If there is a player who has yet to play, then the first player left of the start
            // player who has yet to play is the next player to play
            //-------------------------------------------------------------------------------------
            if (status.Contains(ActiveStatus.StillToBet))
            {
                while (status[index] != ActiveStatus.StillToBet)
                {
                    if (status[index] == ActiveStatus.StillToBet)
                        return index;

                    index = (index + 1) % status.Length;
                }
                return index;
            }
            //-------------------------------------------------------------------------------------
            // Otherwise, if another player has raised, then the first player after that player
            // who is still active and has not met that value is the next to play
            //-------------------------------------------------------------------------------------
            else if (status.Contains(ActiveStatus.LastToRaise))
            {
                while (status[index] != ActiveStatus.LastToRaise)
                {
                    index = (index + 1) % status.Length;
                }

                float amount = amounts[index];
                int startIndex = index;
                while (!NeedsToBet(status, amounts, amount, index))
                {
                    index = (index + 1) % status.Length;
                    if (index == startIndex) break;
                }

                return status[index] == ActiveStatus.LastToRaise ? null : (int?)index;
            }
            //-------------------------------------------------------------------------------------
            // Otherwise, if there is an all in player, check that nobody else needs to call
            //-------------------------------------------------------------------------------------
            else if (status.Contains(ActiveStatus.AllIn))
            {
                int startIndex = index;
                while (status[index] != ActiveStatus.AllIn)
                {
                    index = (index + 1) % status.Length;
                    if (index == startIndex) break;
                }

                float amount = amounts[index];
                while (!NeedsToBet(status, amounts, amount, index))
                {
                    index = (index + 1) % status.Length;
                    if (index == startIndex) break;
                }
                return (status[index] == ActiveStatus.AllIn || status[index] == ActiveStatus.HasFolded) ? null : (int?)index;
            }

            return null;
        }