示例#1
0
        public ApiResult <bool> CreateDivision(CreateDivisionReqs request)
        {
            if (_divisionRepository.QueryByCityId(request.CityId) != null)
            {
                return(new ApiResult <bool>(ResultStatus.FAIL, "该城市分部已创建"));
            }

            Wizards wizard = _wizardRepository.Query(request.CreatorId);

            if (wizard == null)
            {
                return(new ApiResult <bool>(ResultStatus.FAIL, "你是谁"));
            }

            long divisionId = NewId.GenerateId();

            var division = new Divisions(divisionId, request.CityId, request.Name, request.CreatorId);

            if (_divisionRepository.Insert(division) <= 0)
            {
                return(new ApiResult <bool>(ResultStatus.FAIL, "保存时出错,请稍后再试"));
            }

            return(new ApiResult <bool>(ResultStatus.SUCCESS, true));
        }
示例#2
0
        public ApiResult <bool> ChangeDivision(ChangeDivisionReqs request)
        {
            Wizards wizard = _wizardRepository.Query(request.CreatorId);

            if (wizard == null)
            {
                return(new ApiResult <bool>(ResultStatus.FAIL, "你是谁"));
            }

            Divisions division = _divisionRepository.Query(request.DivisionId);

            if (division == null)
            {
                return(new ApiResult <bool>(ResultStatus.FAIL, "找不到该分部"));
            }

            division.Change(request.Name, request.CityId, request.CreateTime);

            if (_divisionRepository.Update(division) <= 0)
            {
                return(new ApiResult <bool>(ResultStatus.FAIL, "没有任何更改"));
            }

            return(new ApiResult <bool>(ResultStatus.SUCCESS, true));
        }
示例#3
0
        public List <Divisions> ViewDivisions()
        {
            List <Divisions> DivisionList = new List <Divisions>();

            using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["KID"].ConnectionString))
            {
                using (SqlCommand command = new SqlCommand())
                {
                    command.Connection  = connection;
                    command.CommandText = "SELECT * FROM Divisons";
                    command.CommandType = CommandType.Text;
                    connection.Open();
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            Divisions Div = new Divisions();
                            Div.DivisionID = reader["DivisionID"].ToString();
                            Div.Rate       = decimal.Parse(reader["Rate"].ToString());
                            Div.StatusID1  = reader["StatusID1"].ToString();
                            Div.StatusID2  = reader["StatusID2"].ToString();
                            Div.StatusID3  = reader["StatusID3"].ToString();
                            Div.StatusID4  = reader["StatusID4"].ToString();
                            Div.StatusID5  = reader["StatusID5"].ToString();
                            Div.StatusID6  = reader["StatusID6"].ToString();
                            Div.StatusID7  = reader["StatusID7"].ToString();
                            Div.StatusID8  = reader["StatusID8"].ToString();

                            DivisionList.Add(Div);
                        }
                    }
                }
            }
            return(DivisionList);
        }
示例#4
0
        public ApiResult <bool> Change(UpdateActivityReqs request)
        {
            try
            {
                Divisions division = _divisionRepository.Query(request.DivisionId);
                if (division == null)
                {
                    return(new ApiResult <bool>(ResultStatus.FAIL, "找不到分部"));
                }

                Activity activity = _activityRepository.Query(request.ActivityId);
                if (activity == null)
                {
                    return(new ApiResult <bool>(ResultStatus.FAIL, "找不到该活动"));
                }

                activity.Change(request.DivisionId, request.Name, request.Summary, request.Thumbnail, request.Description, request.Address,
                                request.BeginTime, request.FinishTime, request.RegistrationBeginTime,
                                request.RegistrationFinishTime,
                                request.Price, request.People);

                if (_activityRepository.Update(activity) <= 0)
                {
                    return(new ApiResult <bool>(ResultStatus.FAIL, "保存时出现问题,请稍后再试"));
                }

                return(new ApiResult <bool>(ResultStatus.SUCCESS, true));
            }
            catch (Exception ex)
            {
                _logger.LogError("修改活动异常", ex);
                return(new ApiResult <bool>(ResultStatus.EXCEPTION, ex.Message));
            }
        }
示例#5
0
        static internal int QualMaxEarning(Divisions division)
        {
            int maxEarning = 0;

            switch (division)
            {
            case Divisions.Elite:
                maxEarning = 2500000;
                break;

            case Divisions.Master:
                maxEarning = 2000000;
                break;

            case Divisions.Pro:
                maxEarning = 1500000;
                break;

            case Divisions.Amateur:
                maxEarning = 1000000;
                break;

            case Divisions.Rookie:
                maxEarning = 500000;
                break;
            }

            return(maxEarning);
        }
示例#6
0
        public ApiResult <bool> Create(CreateActivityReqs request)
        {
            try
            {
                Divisions division = _divisionRepository.Query(request.DivisionId);
                if (division == null)
                {
                    return(new ApiResult <bool>(ResultStatus.FAIL, "找不到分部"));
                }

                long id       = NewId.GenerateId();
                var  activity = new Activity(id, request.DivisionId, request.Name, request.Summary, request.Thumbnail, request.Description, request.Address,
                                             request.BeginTime, request.FinishTime, request.RegistrationBeginTime, request.RegistrationFinishTime,
                                             request.Price, request.People, request.CreatorId);

                if (_activityRepository.Insert(activity) <= 0)
                {
                    return(new ApiResult <bool>(ResultStatus.FAIL, "保存时出现问题,请稍后再试"));
                }

                return(new ApiResult <bool>(ResultStatus.SUCCESS, true));
            }
            catch (Exception ex)
            {
                _logger.LogError("创建活动异常", ex);
                return(new ApiResult <bool>(ResultStatus.EXCEPTION, ex.Message));
            }
        }
示例#7
0
        public Divisions Get(string DivisionID)
        {
            Divisions p = null;

            using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["KID"].ConnectionString))
            {
                using (SqlCommand command = new SqlCommand())
                {
                    command.Connection  = connection;
                    command.CommandText = "SELECT * FROM Divisons";
                    command.CommandType = CommandType.Text;
                    connection.Open();
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            p            = new Divisions();
                            p.DivisionID = reader["DivisionID"].ToString();
                            p.Rate       = decimal.Parse(reader["Rate"].ToString());
                            p.StatusID1  = reader["StatusID1"].ToString();
                            p.StatusID2  = reader["StatusID2"].ToString();
                            p.StatusID3  = reader["StatusID3"].ToString();
                            p.StatusID4  = reader["StatusID4"].ToString();
                            p.StatusID5  = reader["StatusID5"].ToString();
                            p.StatusID6  = reader["StatusID6"].ToString();
                            p.StatusID7  = reader["StatusID7"].ToString();
                            p.StatusID8  = reader["StatusID8"].ToString();
                        }
                    }
                }
            }
            return(p);
        }
 /// <summary>
 /// Builds the file To Generate Game Data
 /// </summary>
 /// <param name="divisions">All Division information</param>
 /// <param name="prizeLevels">All Prize Level information</param>
 /// <param name="gameInfo">All game Inforamtion</param>
 /// <param name="fileName">The full output file name and pat</param>
 public void buildGameData(
     Divisions.DivisionsModel divisions,
     PrizeLevels.PrizeLevels prizeLevels,
     GameSetup.GameSetupModel gameInfo,
     string fileName)
 {
     int numberOfDivisions = divisions.getNumberOfDivisions() + 1;
     List<int[]>[] divisionLevels = new List<int[]>[numberOfDivisions];
     List<Thread> threads = new List<Thread>();
     for (int i = 0; i < numberOfDivisions; i++)
     {
         int divisionIndex = i;
         Thread t;
         if (divisionIndex == numberOfDivisions - 1)
         {
             t = new Thread(() => divisionLevels[divisionIndex] = getDivisionLossingPermutations(gameInfo, prizeLevels, divisions).OrderBy(a => Guid.NewGuid()).ToList());
         }
         else
         {
             int temp = i;
             t = new Thread(() => divisionLevels[divisionIndex] = getDivisionWinningPermutations(divisionIndex, gameInfo.totalPicks, divisions.getDivision(temp).MaxPermutations, divisions.getDivision(divisionIndex), prizeLevels).OrderBy(a => Guid.NewGuid()).ToList());
         }
         t.Start();
         threads.Add(t);
     }
     for (int i = 0; i < threads.Count; i++)
     {
         threads.ElementAt(i).Join();
     }
     writeFile(fileName, divisionLevels, new List<string>());
 }
示例#9
0
        public DivisionsCollec Get()
        {
            try
            {
                DataTable dt = Execute.RunSP_DataTable(Connection, "SPGET_Division");

                DivisionsCollec objDepCollec = new DivisionsCollec();


                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    Divisions objDivisions = new Divisions();
                    objDivisions.DivisionID   = Convert.ToInt64(dt.Rows[i]["DivisionID"]);
                    objDivisions.DivisionName = Convert.ToString(dt.Rows[i]["DivisionName"]);
                    objDivisions.DivisionType = Convert.ToString(dt.Rows[i]["DivisionType"]);

                    objDepCollec.Add(objDivisions);
                }
                return(objDepCollec);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }
示例#10
0
 private void btnBasicProductAdd_Click(object sender, EventArgs e)
 {
     try
     {
         long ID = 0;
         if (!txtID.Text.Equals("[Auto]"))
         {
             ID = Convert.ToInt64(txtID.Text);
         }
         Divisions obj = new Divisions();
         obj.DivisionID   = ID;
         obj.DivisionName = txtName.Text;
         obj.DivisionType = cmbType.SelectedItem.ToString();
         long NewID = objDivisionDL.Add(obj);
         if (NewID > 0)
         {
             txtID.Text              = NewID.ToString();
             gvDivisions.DataSource  = objDivisionDL.GetDataView();
             btnManagerAdd.Enabled   = true;
             btnMangerDelete.Enabled = true;
             btnManagerClear.Enabled = true;
             MessageBox.Show(this, "Successfully Saved", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, "Error occured while saving", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
        public JsonResult InsertOrUpdate(Divisions divisions, int id)
        {
            try
            {
                var json        = JsonConvert.SerializeObject(divisions);
                var buffer      = System.Text.Encoding.UTF8.GetBytes(json);
                var byteContent = new ByteArrayContent(buffer);
                byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");

                var token = HttpContext.Session.GetString("token");           //tambahan
                http.DefaultRequestHeaders.Add("Authorization", token);       //tambahan

                if (divisions.Id == 0)
                {
                    var result = http.PostAsync("division", byteContent).Result;
                    return(Json(result));
                }
                else if (divisions.Id != 0)
                {
                    var result = http.PutAsync("division/" + id, byteContent).Result;
                    return(Json(result));
                }

                return(Json(404));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#12
0
 public void UpdateRankings()
 {
     Divisions.ToList().ForEach(division =>
     {
         SeasonRanking.UpdateDivisionRankings(division);
     });
 }
示例#13
0
        public void AddDivision(SeasonDivision division)
        {
            division.Season = this;

            if (division.GetTeamsThatBelongToDivision() != null)
            {
                division.GetTeamsThatBelongToDivision().ToList().ForEach(t =>
                {
                    if (Teams.Where(team => team.Parent.Id == t.Parent.Id).FirstOrDefault() == null)
                    {
                        AddTeam(t);
                    }
                });
            }

            if (Divisions.Where(d => d.Name.Equals(division.Name)).FirstOrDefault() == null)
            {
                Divisions.Add(division);

                division.Children.ToList().ForEach(cd =>
                {
                    AddDivision(cd);
                });
            }
            else
            {
                //throw new SeasonException("Division was already added. " + division.Name);
            }
        }
示例#14
0
        public void Delete(int index)
        {
            if (index >= Divisions.Count)
            {
                return;
            }
            var d      = Divisions[index];
            var offset = d.Offset;
            var length = d.Length;

            if (index > 0)
            {
                offset--;
                length++;
            }
            else
            {
                var endOfDivision = Divisions.Max(e => e.Offset);
                if (offset < endOfDivision)
                {
                    length++;
                }
            }
            Replace(offset, length, StringDividerOperations.EmptyChars);
        }
示例#15
0
文件: Group.cs 项目: Yarpii/MTGRP
        public bool TryGetRank(Character member, out GroupRank rank)
        {
            GroupDivision div = Divisions.Find(x => x.DatabaseId == member.DivisionId);

            rank = div.Ranks.Find(x => x.DatabaseId == member.RankId);
            return(rank != null);
        }
示例#16
0
        public void UpdateDivision(int DivisionId, string Name, DateTime?Beginning, DateTime?Ending, int?DivisionTypeId, int?CourseId)
        {
            Divisions div = _context.Divisions.First(a => a.DivisionId == DivisionId);

            if (Beginning != null)
            {
                div.Beginning = Beginning.Value;
            }
            if (Name != null)
            {
                div.Name = Name;
            }
            if (Ending != null)
            {
                div.Ending = Ending.Value;
            }
            if (DivisionTypeId != null)
            {
                div.DivisionTypeId = DivisionTypeId.Value;
            }
            if (CourseId != null)
            {
                div.CourseId = CourseId.Value;
            }
            _context.SaveChanges();
        }
示例#17
0
        public async Task <IActionResult> PutDivisions([FromRoute] int id, [FromBody] Divisions divisions)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != divisions.DivisionId)
            {
                return(BadRequest());
            }

            _context.Entry(divisions).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DivisionsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
示例#18
0
        /// <summary>
        /// Get division data
        /// </summary>
        /// <returns></returns>
        private DataTable GetDivisionData(string sRegionID)
        {
            DataTable dtDivision;

            try
            {
                Divisions divisionManager = new Divisions();
                //Binding Division
                string sCondition = " Enabled='true'";
                if (sRegionID != "" && sRegionID != "0")
                {
                    sCondition += " AND RegionID = " + sRegionID;
                }
                dtDivision = divisionManager.GetList(sCondition).Tables[0];

                DataRow drNewDivision = dtDivision.NewRow();
                drNewDivision["DivisionId"] = 0;
                drNewDivision["Name"]       = "All Divisions";
                dtDivision.Rows.InsertAt(drNewDivision, 0);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(dtDivision);
        }
示例#19
0
        public ApiResult <bool> UpdateWizard(UpdateWizardReqs request)
        {
            Wizards wizard = _wizardRepository.Query(request.WizardId);

            if (wizard == null)
            {
                return(new ApiResult <bool>(ResultStatus.FAIL, "找不到这名巫师的记录"));
            }

            Divisions division = _divisionRepository.Query(request.DivisionId);

            if (division == null)
            {
                return(new ApiResult <bool>(ResultStatus.FAIL, "所选分部不存在"));
            }

            wizard.Change(request.Account, request.DivisionId, request.Passward);

            if (_wizardRepository.Update(wizard) <= 0)
            {
                return(new ApiResult <bool>(ResultStatus.FAIL, "没有更新任何信息"));
            }

            return(new ApiResult <bool>(ResultStatus.SUCCESS, true));
        }
示例#20
0
        private void gvDivisions_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.RowIndex >= 0)
                {
                    long ID = Convert.ToInt64(gvDivisions.Rows[e.RowIndex].Cells["colDivisionID"].Value);

                    Divisions obj = objDivisionDL.Get(ID);
                    if (obj != null)
                    {
                        txtID.Text              = obj.DivisionID.ToString();
                        txtName.Text            = obj.DivisionName;
                        cmbType.SelectedItem    = obj.DivisionType;
                        bindManagers.DataSource = objDivisionManageDL.Get(obj.DivisionID);
                        btnManagerAdd.Enabled   = true;
                        btnMangerDelete.Enabled = true;
                        btnManagerClear.Enabled = true;
                        IsSelect = true;
                        if (cmbManagers.Items.Count > 0)
                        {
                            cmbManagers.SelectedIndex = -1;
                        }
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show(this, "Error occured while loading", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
示例#21
0
        static internal float GetAvgCarLevel(Divisions division)
        {
            float carLvl;

            switch (division)
            {
            case Divisions.Elite: carLvl = 9;
                break;

            case Divisions.Master: carLvl = 8;
                break;

            case Divisions.Pro: carLvl = 7;
                break;

            case Divisions.Amateur: carLvl = 5.5f;
                break;

            case Divisions.Rookie: carLvl = 2;
                break;

            default: carLvl = 5;
                break;
            }

            return(carLvl);
        }
 public ActionResult Edit([Bind(Include = "DivisionID,Name,Abbreviation")] Divisions divisions)
 {
     if (Session["User"] != null)
     {
         var user = (Gamification.Models.Users)Session["User"];
         if (user.Role == "Admin")
         {
             if (ModelState.IsValid)
             {
                 db.Entry(divisions).State = EntityState.Modified;
                 db.SaveChanges();
                 return(RedirectToAction("Index"));
             }
             return(View(divisions));
         }
         else
         {
             return(RedirectToAction("Index", "Home"));
         }
     }
     else
     {
         return(RedirectToAction("Index", "Home"));
     }
 }
示例#23
0
        static internal int GetAvgOA(Divisions division)
        {
            int oa;

            switch (division)
            {
            case Divisions.Elite: oa = 210;
                break;

            case Divisions.Master: oa = 170;
                break;

            case Divisions.Pro: oa = 145;
                break;

            case Divisions.Amateur: oa = 110;
                break;

            case Divisions.Rookie: oa = 85;
                break;

            default: oa = 100;
                break;
            }

            return(oa);
        }
 // GET: Divisions/Details/5
 public ActionResult Details(int?id)
 {
     if (Session["User"] != null)
     {
         var user = (Gamification.Models.Users)Session["User"];
         if (user.Role == "Admin")
         {
             if (id == null)
             {
                 return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
             }
             Divisions divisions = db.Divisions.Find(id);
             if (divisions == null)
             {
                 return(HttpNotFound());
             }
             return(View(divisions));
         }
         else
         {
             return(RedirectToAction("Index", "Home"));
         }
     }
     else
     {
         return(RedirectToAction("Index", "Home"));
     }
 }
示例#25
0
        private string CreateDivision(string sDivisionName)
        {
            string sError = string.Empty;

            sDivisionName = sDivisionName.Trim();
            #region 检查是否存在

            Divisions divManager = new Divisions();
            bool      bIsExist   = divManager.IsExist_CreateBase(sDivisionName);
            if (bIsExist == true)
            {
                sError = "The name is already used by another group. Please use another group name.";
                return(sError);
            }

            #endregion

            try
            {
                sError = divManager.CreateDivision(sDivisionName).ToString();
            }
            catch
            {
                sError = "Fail to Create Division.";
            }

            return(sError);
        }
示例#26
0
        internal void Add(string name, int parentId)
        {
            int id = DivisionSQL.Add(name, parentId);

            Divisions.Add(new Division {
                Id = id, Name = name, ParentId = parentId
            });
        }
示例#27
0
        internal void Remove(Division division)
        {
            WorkerSQL.DeleteByDivisiontId(division.Id);
            DivisionSQL.DeleteById(division.Id);
            Division deleteDivision = Divisions.Find(d => d.Id == division.Id);

            Divisions.Remove(division);
        }
示例#28
0
 private void DataBindLocale()
 {
     DataContext = _localization;
     PrizeLevels.SetLocalization(_localization.PrizeLevelsPanel);
     GameSetup.SetLocalization(_localization.GameSetupPanel);
     Divisions.SetLocalization(_localization.DivisionPanel);
     SetErrorText();
 }
示例#29
0
        private async Task LoadDivisions()
        {
            var list = await Proxy.GetAllDivisions();

            foreach (var item in list)
            {
                Divisions.Add(item);
            }
        }
        public IActionResult Insert(Divisions divisions)
        {
            TestContext context = new TestContext();

            context.Divisions.Add(divisions);
            context.SaveChanges();

            return(Json(divisions));
        }
示例#31
0
        private PlayoffSpots getPlayoffSpot(Conferences conference, Divisions division, int?conferenceRank, int?divisionRank)
        {
            var playoffSpot = string.Empty;

            if (divisionRank <= PlayoffRules.LastDivisionRankToGetQualified)
            {
                switch (division)
                {
                case Divisions.Atlantic:
                    playoffSpot = "A";
                    break;

                case Divisions.Metropolitan:
                    playoffSpot = "M";
                    break;

                case Divisions.Central:
                    playoffSpot = "C";
                    break;

                case Divisions.Pacific:
                    playoffSpot = "P";
                    break;
                }

                playoffSpot += divisionRank;
            }
            else if (divisionRank <= PlayoffRules.LastDivisionRankToBeAWildcard && conferenceRank <= PlayoffRules.LastConferenceRankToBeAWildcard)
            {
                switch (conference)
                {
                case Conferences.Eastern:
                    playoffSpot = "EWC";
                    break;

                case Conferences.Westnern:
                    playoffSpot = "WWC";
                    break;
                }

                if (divisionRank <= PlayoffRules.LastDivisionRankToBeFirstWildcard && conferenceRank <= PlayoffRules.LastConferenceRankToBeFirstWildcard)
                {
                    playoffSpot += "1";
                }
                else
                {
                    playoffSpot += "2";
                }
            }
            else
            {
                return(PlayoffSpots.Unqualified);
            }

            return((PlayoffSpots)Enum.Parse(typeof(PlayoffSpots), playoffSpot));
        }
示例#32
0
 public static Divisions CreateDivisions(int divisionID_pk)
 {
     Divisions divisions = new Divisions();
     divisions.divisionID_pk = divisionID_pk;
     return divisions;
 }
示例#33
0
 public void AddToDivisions(Divisions divisions)
 {
     base.AddObject("Divisions", divisions);
 }
示例#34
0
        /// <summary>
        /// Builds the header information for the file
        /// </summary>
        /// <param name="prizes">All prize informaiton</param>
        /// <param name="divisions">All division information</param>
        /// <returns>Returns a list of string representing each line of the header</returns>
        private List<string> buildHeader(PrizeLevels.PrizeLevels prizes, Divisions.DivisionsModel divisions)
        {
            List<string> headerLines = new List<string>();
            headerLines.Add("The first number is the division indicator.");
            headerLines.Add("Prize level indicators and values:");
            int prizeLevel = 1;
            StringBuilder sb;
            foreach (PrizeLevels.PrizeLevel p in prizes.prizeLevels)
            {
                sb = new StringBuilder();
                sb.Append("Prize Level Character: " + charFromInt(prizes.getLevelOfPrize(p) + 1));
                sb.Append(" Value: " + p.prizeValue);
                headerLines.Add(sb.ToString());
            }
            headerLines.Add("Division level indicators and values:");
            foreach (Divisions.DivisionModel div in divisions.divisions)
            {
                sb = new StringBuilder();
                sb.Append("Division Number: " + prizeLevel++);
                sb.Append(" Value: " + div.TotalPrizeValue);
                sb.Append(" Prize Levels at Division: ");
                foreach (PrizeLevels.PrizeLevel p in div.getPrizeLevelsAtDivision())
                {
                    sb.Append(charFromInt(prizes.getLevelOfPrize(p) + 1));
                }

                headerLines.Add(sb.ToString());
            }
            sb = new StringBuilder();
            sb.Append("Division Level Number: " + prizeLevel++);
            sb.Append(" Value: " + 0);
            headerLines.Add(sb.ToString());
            return headerLines;
        }
示例#35
0
 /// <summary>
 /// Fill the extra spots of a permutation with non winning picks.
 /// </summary>
 /// <param name="nonWinningPermutations">The non winning permutations</param>
 /// <param name="extraPicks">The extra picks to fill in for a division</param>
 /// <param name="div">The division</param>
 /// <param name="prizeLevels">All prize levels</param>
 /// <param name="maxNumberOfpermutations">Max number of permutations to reach.</param>
 /// <returns>Returns filled permutations.</returns>
 private List<int[]> fillBlankDivisionPermutationsWithNonWinningData(
     List<int[]> nonWinningPermutations,
     int[] extraPicks,
     Divisions.DivisionModel div,
     PrizeLevels.PrizeLevels prizeLevels,
     int maxNumberOfPermutations)
 {
     List<int[]> filledPermutations = new List<int[]>();
     filledPermutations = createExtraPermutations(nonWinningPermutations, maxNumberOfPermutations, prizeLevels);
     return filledPermutations;
 }
示例#36
0
 /// <summary>
 /// Generates losing permutations for a game
 /// </summary>
 /// <param name="gameInfo">All game Information</param>
 /// <param name="prizeLevels">All prizeLevels</param>
 /// <returns>List of int arrays representing losing permutations</returns>
 private List<int[]> getDivisionLossingPermutations(
     GameSetup.GameSetupModel gameInfo,
     PrizeLevels.PrizeLevels prizeLevels,
     Divisions.DivisionsModel divisions
     )
 {
     List<int[]> lossPermutations = new List<int[]>();
     List<int> extraPicks = getExtraPicks(new int[1], prizeLevels).ToList();
     List<int[]> baseLossconditions = new List<int[]>();
     int numberOfPermutationsForNearWinAmount = divisions.LossMaxPermutations;
     if (gameInfo.isNearWin)
     {
         baseLossconditions.AddRange(getBaseNearWinLossPermutations(gameInfo.nearWins, gameInfo.totalPicks, prizeLevels));
     }
     else
     {
         int[] baseLoss = new int[gameInfo.totalPicks];
         baseLossconditions.Add(baseLoss);
     }
     lossPermutations = getAllLossPermutations(baseLossconditions, prizeLevels, gameInfo.nearWins, numberOfPermutationsForNearWinAmount);
     List<int[]> Losses = lossPermutations.Take(divisions.LossMaxPermutations).ToList();
     return Losses;
 }
示例#37
0
        /// <summary>
        /// Creates all the winning permutations of a divisions
        /// </summary>
        /// <param name="divisionIndicator">Selected Division</param>
        /// <param name="totalNumberOfPicks">Number of picks for a division</param>
        /// <param name="numberOfPermutations">number of permutations to genreate for a division</param>
        /// <param name="division">Division informaiton</param>
        /// <param name="prizeLevels">Prize level informaiton</param>
        /// <returns>Returns the list of winning permutaitons for a division</returns>
        private List<int[]> getDivisionWinningPermutations(
            int divisionIndicator,
            short totalNumberOfPicks,
            int numberOfPermutations,
            Divisions.DivisionModel division,
            PrizeLevels.PrizeLevels prizeLevels)
        {
            List<int[]> divisionIncompleteWinPermutations = new List<int[]>();
            List<PrizeLevels.PrizeLevel> divisionPrizeLevels = division.getPrizeLevelsAtDivision();
            int maxNumberOfNeededPicksForDivision = 0;
            bool isInstantWinPresent = false;
            foreach (PrizeLevels.PrizeLevel p in divisionPrizeLevels)
            {
                maxNumberOfNeededPicksForDivision += p.numCollections;
                if (p.isInstantWin)
                {
                    isInstantWinPresent = true;
                }
            }

            int[] picks = getNeededPicksForDivision(true, division, prizeLevels).ToArray();
            divisionIncompleteWinPermutations.AddRange(getAllBasePermutations(totalNumberOfPicks, numberOfPermutations, getBaseCombinaiton(totalNumberOfPicks, picks).ToArray()));
            int[] nonWinningPicks = getExtraPicks(divisionIncompleteWinPermutations[0], prizeLevels);
            if (nonWinningPicks.Length + picks.Length < totalNumberOfPicks && isInstantWinPresent)
            {
                divisionIncompleteWinPermutations.Clear();
            }
            if (maxNumberOfNeededPicksForDivision <= totalNumberOfPicks && isInstantWinPresent)
            {
                divisionIncompleteWinPermutations.AddRange(getAllBasePermutations(totalNumberOfPicks, numberOfPermutations, getBaseCombinaiton(totalNumberOfPicks, getNeededPicksForDivision(false, division, prizeLevels).ToArray()).ToArray()));
            }

            List<int[]> maximumPermutations = fillBlankDivisionPermutationsWithNonWinningData(
                divisionIncompleteWinPermutations,
                nonWinningPicks,
                division,
                prizeLevels,
                (numberOfPermutations + extraPermutationBuffer)).OrderBy(a => Guid.NewGuid()).ToList();
            List<int[]> finalPermutations = maximumPermutations.Take(numberOfPermutations).ToList();
            return finalPermutations;
        }
示例#38
0
 /// <summary>
 /// Gets the needed picks to win all prize levels of a given division
 /// </summary>
 /// <param name="division">The division is the division containing the winning prize levels</param>
 /// <param name="prizeLevels">All prize levels in the game used to get the index of the prize level</param>
 /// <returns>Returns a list of ints containing the needed picks to win a division</returns>
 private List<int> getNeededPicksForDivision(
     bool useInstantWin,
     Divisions.DivisionModel division,
     PrizeLevels.PrizeLevels prizeLevels)
 {
     List<int> neededPicks = new List<int>();
     List<PrizeLevels.PrizeLevel> pls = division.getPrizeLevelsAtDivision();
     foreach (PrizeLevels.PrizeLevel pl in pls)
     {
         int numberToCollect = pl.numCollections;
         int indexInPrizeLevels = prizeLevels.getLevelOfPrize(pl) + 1;
         if ((pl.isInstantWin || pl.numCollections == 0) && useInstantWin)
         {
             numberToCollect = 1;
             neededPicks.Add(-indexInPrizeLevels);
         }
         else
         {
             numberToCollect = pl.numCollections;
             for (int i = 0; i < numberToCollect; i++)
             {
                 neededPicks.Add(indexInPrizeLevels);
             }
         }
     }
     return neededPicks;
 }