public ActionResult Edit([Bind(Include = "Id,VolunteerId,Name")] Models.Type type) { #region 验证登录 User loginUser = AccountHelper.LoginUser; if (loginUser == null) { return(RedirectToAction("Login", "Home", new { area = "" })); } ViewBag.LoginUser = loginUser; #endregion #region 验证权限 string pageId = "Edit_Type"; //站点目录中的id属性值 if (!Access.Validate(pageId)) { return(HttpNotFound()); } ViewBag.PageId = pageId; #endregion #region 无论编辑是否成功,页面显示所需的其余ViewBag数据绑定 #endregion ReturnValue returnValue = new ReturnValue(); #region 编辑 if (ModelState.IsValid) { #region 特殊数据验证 <不需要验证则注释或删除> if (db.Types.Where(s => s.Name == type.Name && s.Id != type.Id).Count() > 0) { returnValue.Type = ReturnType.EditFailure; returnValue.Message = "该xxxx已存在"; //针对需要显示导航属性的情形,重新查询数据库 //type = db.Types.FirstOrDefault(s => s.Id == type.Id); //Include所有需要的导航属性和导航集合(含多级导航),一次性查询数据库 <需修改> ViewBag.ReturnValue = returnValue.ToJson(); return(View(type)); } #endregion try { db.Entry(type).State = EntityState.Modified; db.SaveChanges(); returnValue.Type = ReturnType.EditSuccess; returnValue.Message = ResultMessage.EditSuccess; } catch { db.Entry(type).State = EntityState.Unchanged; returnValue.Type = ReturnType.EditFailure; returnValue.Message = ResultMessage.EditFailure; } } #endregion //针对需要显示导航属性的情形,重新查询数据库 //type = db.Types.FirstOrDefault(s => s.Id == type.Id); //Include所有需要的导航属性和导航集合(含多级导航),一次性查询数据库 <需修改> ViewBag.ReturnValue = returnValue.ToJson(); return(View(type)); }
public IHttpActionResult Post(string Type) { if (Type == null) { return(BadRequest("请指定照片种类")); } HttpFileCollection files = HttpContext.Current.Request.Files; if (files.Count == 0) { return(BadRequest("请上传文件")); } Models.Type type = db.Types.First(s => s.Name == Type); if (type == null) { return(BadRequest("不存在此照片种类")); } HttpPostedFile file = files[0]; string directory = null; string extension = new FileInfo(file.FileName).Extension; string fileName = Type + DateTime.Now.ToString("yyyyMMddHHmmssfff"); string result = null; directory = @"\Photos\" + type.Name; result = UploadFileHelper.UploadImage(file, directory, fileName, extension); if (!string.IsNullOrEmpty(result)) { return(BadRequest(result)); } string url = (directory + "/" + fileName + extension).Replace("\\", "/"); return(Ok(url)); }
public ActionResult Edit(Guid?id) { #region 验证登录 User loginUser = AccountHelper.LoginUser; if (loginUser == null) { return(RedirectToAction("Login", "Home", new { area = "" })); } ViewBag.LoginUser = loginUser; #endregion #region 验证权限 string pageId = "Edit_Type"; //站点目录中的id属性值 if (!Access.Validate(pageId)) { return(HttpNotFound()); } ViewBag.PageId = pageId; #endregion #region 其余ViewBag数据绑定 #endregion if (id == null) { return(HttpNotFound()); } Models.Type type = db.Types.FirstOrDefault(s => s.Id == id); //Include所有需要的导航属性和导航集合(含多级导航),一次性查询数据库 <需修改> if (type == null) { return(HttpNotFound()); } return(View(type)); }
public ActionResult Create([Bind(Include = "Id,VolunteerId,Name")] Models.Type type) { #region 验证登录 User loginUser = AccountHelper.LoginUser; if (loginUser == null) { return(RedirectToAction("Login", "Home", new { area = "" })); } ViewBag.LoginUser = loginUser; #endregion #region 验证权限 string pageId = "Create_Type"; //站点目录中的id属性值 if (!Access.Validate(pageId)) { return(HttpNotFound()); } ViewBag.PageId = pageId; #endregion #region 无论添加是否成功,页面显示所需的其余ViewBag数据绑定 #endregion #region 添加 ReturnValue returnValue = new ReturnValue(); if (ModelState.IsValid) { #region 特殊数据验证 <不需要验证则注释或删除> if (db.Types.Where(s => s.Name == type.Name).Count() > 0) { returnValue.Type = ReturnType.CreateFailure; returnValue.Message = "该xxxx已存在"; ViewBag.ReturnValue = returnValue.ToJson(); return(View(type)); } #endregion try { type.Id = Guid.NewGuid(); db.Types.Add(type); db.SaveChanges(); ModelState.Clear(); returnValue.Type = ReturnType.CreateSuccess; returnValue.Message = ResultMessage.CreateSuccess; ViewBag.ReturnValue = returnValue.ToJson(); return(View()); } catch { returnValue.Type = ReturnType.CreateFailure; returnValue.Message = ResultMessage.CreateFailure; ViewBag.ReturnValue = returnValue.ToJson(); return(View(type)); } } #endregion ViewBag.ReturnValue = returnValue.ToJson(); return(View(type)); }
public void AddNewType(string type, long electionId) { Models.Type newType = new Models.Type() { TypeName = type, ElectionId = electionId }; TypeDal.Add(newType); }
public ActionResult DeleteConfirmed(Guid id) { Models.Type type = db.Types.Find(id); type.IsDelete = true; type.DeleteDate = DateTime.Now; db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(Models.Type type) { if (ModelState.IsValid) { type.IsDelete = false; db.Entry(type).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(type)); }
public static Type GetType(string item) { var type = new Type(); var subTypeNames = BaseTypes.MainTypes.SelectMany(bt => bt.SpecificTypes).Select(st => st.Name); foreach (var subType in subTypeNames.Where(item.Contains)) { type.MainType = BaseTypes.MainTypes.First(mt => mt.SpecificTypes.Any(st => st.Name == subType)).Name; type.SubType = subType; } return type; }
// GET: Types/Delete/5 public ActionResult Delete(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Models.Type type = db.Types.Find(id); if (type == null) { return(HttpNotFound()); } return(View(type)); }
public ActionResult Create(Models.Type type) { if (ModelState.IsValid) { type.IsDelete = false; type.SubmitDate = DateTime.Now; type.Id = Guid.NewGuid(); db.Types.Add(type); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(type)); }
private static Type CreateTypeFromRequestBody(IFormCollection requestForm, long id) { var editType = new Type { Id = id }; if (requestForm.TryGetValue("Type.Name", out var name)) { editType.Name = name; } if (requestForm.TryGetValue("Type.Info", out var info)) { editType.Info = info; } if (requestForm.TryGetValue("Type.Location", out var location)) { editType.Location = location; } if (requestForm.TryGetValue("Type.Datasheet", out var dataSheet)) { editType.Datasheet = dataSheet; } if (requestForm.TryGetValue("Type.ImageUrl", out var imageUrl)) { editType.ImageUrl = imageUrl; } if (requestForm.TryGetValue("Type.Manufacturer", out var manufacturer)) { editType.Manufacturer = manufacturer; } if (requestForm.TryGetValue("Type.WikiLink", out var wikiLink)) { editType.WikiLink = wikiLink; } if (requestForm.TryGetValue("Type.AdminComment", out var adminComment)) { editType.AdminComment = adminComment; } if (requestForm.TryGetValue("Type.Status", out var status)) { if (Enum.TryParse(status, out ComponentTypeStatus statusEnum)) { editType.Status = statusEnum; } } return(editType); }
public void CheckFourOfAKind(ICharacter player, int[] cards, ref List<Type> strongestHands, ref Type winningHand) { if (player.CharacterType.Current >= PokerHand.HighCard) { for (int i = 0; i <= 3; i++) { if (cards[i] / 4 == cards[i + 1] / 4 && cards[i] / 4 == cards[i + 2] / 4 && cards[i] / 4 == cards[i + 3] / 4) { player.CharacterType.Current = PokerHand.FourOfAKind; player.CharacterType.Power = (cards[i] / 4) * 4 + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); } if (cards[i] / 4 == 0 && cards[i + 1] / 4 == 0 && cards[i + 2] / 4 == 0 && cards[i + 3] / 4 == 0) { player.CharacterType.Current = PokerHand.FourOfAKind; player.CharacterType.Power = 13 * 4 + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); } } } }
public ActionResult Index(OperationParam op) { #region 验证登录 User loginUser = AccountHelper.LoginUser; if (loginUser == null) { return(RedirectToAction("Login", "Home", new { area = "" })); } ViewBag.LoginUser = loginUser; #endregion #region 验证权限 string pageId = "Index_Type"; //站点目录中的id属性值 if (!Access.Validate(pageId)) { return(HttpNotFound()); } ViewBag.PageId = pageId; #endregion #region 翻页、查询、排序、显示全部、移动、删除 ReturnValue returnValue = new ReturnValue(); Models.Type deleteData = null; switch (op.OpType) { case OperationType.Pager: break; case OperationType.Query: break; case OperationType.Sort: break; case OperationType.ShowAll: break; case OperationType.RankUp: break; case OperationType.Delete: deleteData = db.Types.Find(Guid.Parse(op.OpArgument)); if (deleteData == null) { returnValue.Type = ReturnType.DeleteFailure; returnValue.Message = ResultMessage.DeleteFailure; } else { try { db.Types.Remove(deleteData); db.SaveChanges(); returnValue.Type = ReturnType.DeleteSuccess; returnValue.Message = ResultMessage.DeleteSuccess; } catch { db.Entry(deleteData).State = EntityState.Unchanged; returnValue.Type = ReturnType.DeleteFailure; returnValue.Message = ResultMessage.DeleteFailure; } } OperationParam.Reset(ModelState); break; case OperationType.Deletes: string[] ids = op.OpArgument.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); bool success = true; foreach (string id in ids) { deleteData = db.Types.Find(Guid.Parse(id)); if (deleteData == null) { continue; } else { db.Types.Remove(deleteData); } try { db.SaveChanges(); } catch { db.Entry(deleteData).State = EntityState.Unchanged; success = false; } } if (success) { returnValue.Type = ReturnType.DeletesSuccess; returnValue.Message = ResultMessage.DeletesSuccess; } else { returnValue.Type = ReturnType.DeletesFailure; returnValue.Message = ResultMessage.DeletesFailure; } OperationParam.Reset(ModelState); break; } #endregion IQueryable <Models.Type> datas = QueryHelper.ExecuteQuery(db.Types, op.OpQueryString); //执行前台查询条件(延迟)。若有附加条件,后续添加.Where()子句 Pager pager = new Pager(datas.Count(), op.OpPager, null); //页码相关对象 ViewBag.Pager = pager; if (string.IsNullOrEmpty(op.OpSortProperty)) { op.OpSortProperty = "xxxxx"; op.OpSortDirection = SortDirection.Ascending; } //首次打开页面的初始排序依据及方向 <需修改> IList <Models.Type> types = datas //.Include(s=>s.) //Include所有需要的导航属性和导航集合(含多级导航),一次性查询数据库 <需修改> .Sort(op.OpSortProperty, op.OpSortDirection) //排序 .GetPageData(pager) //选择当前页的数据 .ToList(); //执行查询 ViewBag.OperationParam = op; ViewBag.ReturnValue = returnValue.ToJson(); return(View(types)); }
public List <Tour> ReturnTourList(string urlparam) { if (urlparam == null) { return(db.Tours.Include(current => current.Airline).Include(current => current.TourCategory).Where( current => current.IsDelete == false && current.IsActive) .ToList()); } List <Tour> tours = null; TourCategory tourCategory = db.TourCategories.FirstOrDefault(current => current.UrlParam == urlparam && current.IsDelete == false); if (tourCategory != null) { if (tourCategory.ParentId != null) { tours = db.Tours.Include(current => current.Airline).Include(current => current.TourCategory).Where( current => current.IsDelete == false && current.TourCategoryId == tourCategory.Id && current.IsActive) .ToList(); } else { tours = db.Tours.Include(current => current.Airline).Include(current => current.TourCategory).Where( current => current.IsDelete == false && current.TourCategory.ParentId == tourCategory.Id && current.IsActive) .ToList(); if (tours.Count() == 0) { tours = db.Tours.Include(current => current.Airline).Include(current => current.TourCategory) .Where(current => current.IsDelete == false && current.TourCategoryId == tourCategory.Id && current.IsActive) .ToList(); } } ViewBag.coverImage = !string.IsNullOrEmpty(tourCategory.CoverImage) ? tourCategory.CoverImage : "/Images/header1.jpg"; if (!string.IsNullOrEmpty(tourCategory.PageTitle)) { ViewBag.Title = tourCategory.PageTitle; } else { ViewBag.Title = tourCategory.Title + " | قیمت " + tourCategory.Title + " ویژه نوروز و بهار | بکتاش سیر"; } if (!string.IsNullOrEmpty(tourCategory.PageDescription)) { ViewBag.Description = tourCategory.PageDescription; } else { ViewBag.Description = "برای اطلاع از قیمت " + tourCategory.Title + " وارد وب سایت بکتاش سیر شوید یا با شماره تلفن 02157952 تماس بگیرید. بکتاش ارائه دهنده تورهای متنوع آسیایی و اروپایی"; } ViewBag.OrginalTitle = tourCategory.Title; ViewBag.summery = tourCategory.Summery; } else { Models.Type type = db.Types.FirstOrDefault(current => current.UrlParam == urlparam && current.IsDelete == false); if (type != null) { tours = db.Tours .Where(current => (current.TourCategory.TypeId == type.Id || current.TourCategory.Parent.TypeId == type.Id) && current.IsDelete == false) .Include(current => current.Airline).Include(current => current.TourCategory).ToList(); if (!tours.Any()) { tours = db.Tours .Where(current => current.TourCategory.Parent.TypeId == type.Id && current.IsDelete == false) .Include(current => current.Airline).Include(current => current.TourCategory).ToList(); } if (!string.IsNullOrEmpty(type.PageTitle)) { ViewBag.Title = type.PageTitle; } else { ViewBag.Title = type.Title + " | قیمت " + type.Title + " ویژه نوروز و بهار"; } if (!string.IsNullOrEmpty(type.PageDescription)) { ViewBag.Description = type.PageDescription; } else { ViewBag.Description = "برای اطلاع از قیمت " + type.Title + " وارد وب سایت بکتاش سیر شوید یا با شماره تلفن 02157952 تماس بگیرید. بکتاش ارائه دهنده تورهای متنوع آسیایی و اروپایی"; } ViewBag.OrginalTitle = type.Title; ViewBag.summery = type.Summery; } } return(tours); }
public void CheckStraightFlush(ICharacter player, int[] spades, int[] hearts, int[] diamonds, int[] clubs, ref List<Type> strongestHands, ref Type winningHand) { if (player.CharacterType.Current >= PokerHand.HighCard) { if (spades.Length >= 5) { if (spades[0] + 4 == spades[4]) { player.CharacterType.Current = PokerHand.StraightFlush; player.CharacterType.Power = spades.Max() / 4 + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); } if (spades[0] == 0 && spades[1] == 9 && spades[2] == 10 && spades[3] == 11 && spades[0] + 12 == spades[4]) { player.CharacterType.Current = PokerHand.RoyalFlush; player.CharacterType.Power = spades.Max() / 4 + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); } } if (hearts.Length >= 5) { if (hearts[0] + 4 == hearts[4]) { player.CharacterType.Current = PokerHand.StraightFlush; player.CharacterType.Power = hearts.Max() / 4 + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); } if (hearts[0] == 0 && hearts[1] == 9 && hearts[2] == 10 && hearts[3] == 11 && hearts[0] + 12 == hearts[4]) { player.CharacterType.Current = PokerHand.RoyalFlush; player.CharacterType.Power = (hearts.Max()) / 4 + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); } } if (diamonds.Length >= 5) { if (diamonds[0] + 4 == diamonds[4]) { player.CharacterType.Current = PokerHand.StraightFlush; player.CharacterType.Power = (diamonds.Max()) / 4 + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = strongestHands .OrderByDescending(op1 => op1.Current) .ThenByDescending(op1 => op1.Power) .First(); } if (diamonds[0] == 0 && diamonds[1] == 9 && diamonds[2] == 10 && diamonds[3] == 11 && diamonds[0] + 12 == diamonds[4]) { player.CharacterType.Current = PokerHand.RoyalFlush; player.CharacterType.Power = (diamonds.Max()) / 4 + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); } } if (clubs.Length >= 5) { if (clubs[0] + 4 == clubs[4]) { player.CharacterType.Current = PokerHand.StraightFlush; player.CharacterType.Power = (clubs.Max()) / 4 + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); } if (clubs[0] == 0 && clubs[1] == 9 && clubs[2] == 10 && clubs[3] == 11 && clubs[0] + 12 == clubs[4]) { player.CharacterType.Current = PokerHand.RoyalFlush; player.CharacterType.Power = clubs.Max() / 4 + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); } } } }
protected override void Seed(BugTracker.Models.ApplicationDbContext context) { var roleManager = new RoleManager <IdentityRole>( new RoleStore <IdentityRole>(context)); if (!context.Roles.Any(r => r.Name == "Admin")) { roleManager.Create(new IdentityRole { Name = "Admin" }); } if (!context.Roles.Any(r => r.Name == "Project Manager")) { roleManager.Create(new IdentityRole { Name = "Project Manager" }); } if (!context.Roles.Any(r => r.Name == "Developer")) { roleManager.Create(new IdentityRole { Name = "Developer" }); } if (!context.Roles.Any(r => r.Name == "Submitter")) { roleManager.Create(new IdentityRole { Name = "Submitter" }); } var userManager = new UserManager <ApplicationUser>( new UserStore <ApplicationUser>(context)); if (!context.Users.Any(u => u.Email == "*****@*****.**")) { userManager.Create(new ApplicationUser { UserName = "******", Email = "*****@*****.**", FirstName = "Mekuanent", LastName = "Eyasu", }, "Abc&123"); } var userId = userManager.FindByEmail("*****@*****.**").Id; userManager.AddToRole(userId, "Admin"); ////////////////////////////////////////////////////// if (!context.Users.Any(u => u.Email == "*****@*****.**")) { userManager.Create(new ApplicationUser { UserName = "******", Email = "*****@*****.**", FirstName = "Project", LastName = "Manager", }, "password1"); } var pmuserId = userManager.FindByEmail("*****@*****.**").Id; userManager.AddToRole(pmuserId, "Project Manager"); /////////////////////////////////////////////////// if (!context.Users.Any(u => u.Email == "*****@*****.**")) { userManager.Create(new ApplicationUser { UserName = "******", Email = "*****@*****.**", FirstName = "Project", LastName = "Develper", }, "password1"); } var duserId = userManager.FindByEmail("*****@*****.**").Id; userManager.AddToRole(duserId, "Developer"); ///////////////////////////////////////////////////// if (!context.Users.Any(u => u.Email == "*****@*****.**")) { userManager.Create(new ApplicationUser { UserName = "******", Email = "*****@*****.**", FirstName = "project", LastName = "Submitter", }, "password1"); } var suserId = userManager.FindByEmail("*****@*****.**").Id; userManager.AddToRole(suserId, "Submitter"); /////////////////////////////////////////// /* Seeding the Priority table with lookup values */ if (!context.Priorities.Any(p => p.Name == "High")) { Models.Priority priority = new Models.Priority(); priority.Name = "High"; context.Priorities.Add(priority); } if (!context.Priorities.Any(p => p.Name == "Medium")) { Models.Priority priority = new Models.Priority(); priority.Name = "Medium"; context.Priorities.Add(priority); } if (!context.Priorities.Any(p => p.Name == "Low")) { Models.Priority priority = new Models.Priority(); priority.Name = "Low"; context.Priorities.Add(priority); } /* Seeding the Status table with lookup values */ if (!context.Statuses.Any(s => s.Name == "Open")) { Models.Status status = new Models.Status(); status.Name = "Open"; context.Statuses.Add(status); } if (!context.Statuses.Any(s => s.Name == "Pending")) { Models.Status status = new Models.Status(); status.Name = "Pending"; context.Statuses.Add(status); } if (!context.Statuses.Any(s => s.Name == "Resolved")) { Models.Status status = new Models.Status(); status.Name = "Resolved"; context.Statuses.Add(status); } if (!context.Statuses.Any(s => s.Name == "Closed")) { Models.Status status = new Models.Status(); status.Name = "Closed"; context.Statuses.Add(status); } /* Seeding the Type table with lookup values */ if (!context.Types.Any(t => t.Name == "Bug")) { Models.Type type = new Models.Type(); type.Name = "Bug"; context.Types.Add(type); } if (!context.Types.Any(t => t.Name == "Feature Request")) { Models.Type type = new Models.Type(); type.Name = "Feature Request"; context.Types.Add(type); } if (!context.Types.Any(t => t.Name == "Documentation")) { Models.Type type = new Models.Type(); type.Name = "Documentation"; context.Types.Add(type); } // This method will be called after migrating to the latest version. // You can use the DbSet<T>.AddOrUpdate() helper extension method // to avoid creating duplicate seed data. E.g. // // context.People.AddOrUpdate( // p => p.FullName, // new Person { FullName = "Andrew Peters" }, // new Person { FullName = "Brice Lambson" }, // new Person { FullName = "Rowan Miller" } // ); // }
public void CheckStraight(ICharacter player, int[] cards, ref List<Type> strongestHands, ref Type winningHand) { if (player.CharacterType.Current >= PokerHand.HighCard) { var straight = cards.Select(c => c / 4).Distinct().ToArray(); for (int i = 0; i < straight.Length - 4; i++) { if (straight[i] + 4 == straight[i + 4]) { if (straight.Max() - 4 == straight[i]) { player.CharacterType.Current = PokerHand.Straigth; player.CharacterType.Power = straight.Max() + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); } else { player.CharacterType.Current = PokerHand.Straigth; player.CharacterType.Power = straight[i + 4] + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); } } if (straight[i] == 0 && straight[i + 1] == 9 && straight[i + 2] == 10 && straight[i + 3] == 11 && straight[i + 4] == 12) { player.CharacterType.Current = PokerHand.Straigth; player.CharacterType.Power = 13 + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); } } } }
public void CheckThreeOfAKind(ICharacter player, int[] straight, ref List<Type> strongestHands, ref Type winningHand) { if (player.CharacterType.Current >= PokerHand.HighCard) { for (int i = 0; i <= 12; i++) { var threeOfAKind = straight.Where(o => o / 4 == i).ToArray(); if (threeOfAKind.Length == 3) { player.CharacterType.Current = PokerHand.ThreeOfAKind; if (threeOfAKind.Max() / 4 == 0) { player.CharacterType.Power = 13 * 3 + player.CharacterType.Current * 100; } else { player.CharacterType.Power = threeOfAKind[0] / 4 + threeOfAKind[1] / 4 + threeOfAKind[2] / 4 + player.CharacterType.Current * 100; } strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); } } } }
public void CheckFlush(ICharacter player, ref bool validFlush, int[] cards, ref List<Type> strongestHands, ref Type winningHand, IList<Card> reserve, int i) { if (player.CharacterType.Current >= PokerHand.HighCard) { var spadesFlush = cards.Where(s => s % 4 == 0).ToArray(); var heartsFlush = cards.Where(s => s % 4 == 1).ToArray(); var diamondsFlush = cards.Where(s => s % 4 == 2).ToArray(); var clubsFlush = cards.Where(s => s % 4 == 3).ToArray(); if (spadesFlush.Length == 3 || spadesFlush.Length == 4) { if (reserve[i].CardPower % 4 == reserve[i + 1].CardPower % 4 && reserve[i].CardPower % 4 == spadesFlush[0] % 4) { if (reserve[i].CardPower / 4 > spadesFlush.Max() / 4) { player.CharacterType.Current = PokerHand.Flush; player.CharacterType.Power = reserve[i].CardPower + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); validFlush = true; } if (reserve[i + 1].CardPower / 4 > spadesFlush.Max() / 4) { player.CharacterType.Current = PokerHand.Flush; player.CharacterType.Power = reserve[i + 1].CardPower + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); validFlush = true; } if (reserve[i].CardPower / 4 < spadesFlush.Max() / 4 && reserve[i + 1].CardPower / 4 < spadesFlush.Max() / 4) { player.CharacterType.Current = PokerHand.Flush; player.CharacterType.Power = spadesFlush.Max() + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); validFlush = true; } } } if (spadesFlush.Length == 4)//different cards in hand { if (reserve[i].CardPower % 4 != reserve[i + 1].CardPower % 4 && reserve[i].CardPower % 4 == spadesFlush[0] % 4) { player.CharacterType.Current = PokerHand.Flush; if (reserve[i].CardPower / 4 > spadesFlush.Max() / 4) { player.CharacterType.Power = reserve[i].CardPower + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); validFlush = true; } else { player.CharacterType.Power = spadesFlush.Max() + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); validFlush = true; } } if (reserve[i + 1].CardPower % 4 != reserve[i].CardPower % 4 && reserve[i + 1].CardPower % 4 == spadesFlush[0] % 4) { player.CharacterType.Current = PokerHand.Flush; if (reserve[i + 1].CardPower / 4 > spadesFlush.Max() / 4) { player.CharacterType.Power = reserve[i + 1].CardPower + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); validFlush = true; } else { player.CharacterType.Power = spadesFlush.Max() + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); validFlush = true; } } } if (spadesFlush.Length == 5) { if (reserve[i].CardPower % 4 == spadesFlush[0] % 4 && reserve[i].CardPower / 4 > spadesFlush.Min() / 4) { player.CharacterType.Current = PokerHand.Flush; player.CharacterType.Power = reserve[i].CardPower + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); validFlush = true; } if (reserve[i + 1].CardPower % 4 == spadesFlush[0] % 4 && reserve[i + 1].CardPower / 4 > spadesFlush.Min() / 4) { player.CharacterType.Current = PokerHand.Flush; player.CharacterType.Power = reserve[i + 1].CardPower + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); validFlush = true; } if (reserve[i].CardPower / 4 < spadesFlush.Min() / 4 && reserve[i + 1].CardPower / 4 < spadesFlush.Min()) { player.CharacterType.Current = PokerHand.Flush; player.CharacterType.Power = spadesFlush.Max() + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); validFlush = true; } } if (heartsFlush.Length == 3 || heartsFlush.Length == 4) { if (reserve[i].CardPower % 4 == reserve[i + 1].CardPower % 4 && reserve[i].CardPower % 4 == heartsFlush[0] % 4) { if (reserve[i].CardPower / 4 > heartsFlush.Max() / 4) { player.CharacterType.Current = PokerHand.Flush; player.CharacterType.Power = reserve[i].CardPower + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); validFlush = true; } if (reserve[i + 1].CardPower / 4 > heartsFlush.Max() / 4) { player.CharacterType.Current = PokerHand.Flush; player.CharacterType.Power = reserve[i + 1].CardPower + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); validFlush = true; } if (reserve[i].CardPower / 4 < heartsFlush.Max() / 4 && reserve[i + 1].CardPower / 4 < heartsFlush.Max() / 4) { player.CharacterType.Current = PokerHand.Flush; player.CharacterType.Power = heartsFlush.Max() + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); validFlush = true; } } } if (heartsFlush.Length == 4)//different cards in hand { if (reserve[i].CardPower % 4 != reserve[i + 1].CardPower % 4 && reserve[i].CardPower % 4 == heartsFlush[0] % 4) { player.CharacterType.Current = PokerHand.Flush; if (reserve[i].CardPower / 4 > heartsFlush.Max() / 4) { player.CharacterType.Power = reserve[i].CardPower + player.CharacterType.Current * 100; } else { player.CharacterType.Power = heartsFlush.Max() + player.CharacterType.Current * 100; } strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); validFlush = true; } if (reserve[i + 1].CardPower % 4 != reserve[i].CardPower % 4 && reserve[i + 1].CardPower % 4 == heartsFlush[0] % 4) { player.CharacterType.Current = PokerHand.Flush; if (reserve[i + 1].CardPower / 4 > heartsFlush.Max() / 4) { player.CharacterType.Power = reserve[i + 1].CardPower + player.CharacterType.Current * 100; } else { player.CharacterType.Power = heartsFlush.Max() + player.CharacterType.Current * 100; } strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); validFlush = true; } } if (heartsFlush.Length == 5) { if (reserve[i].CardPower % 4 == heartsFlush[0] % 4 && reserve[i].CardPower / 4 > heartsFlush.Min() / 4) { player.CharacterType.Current = PokerHand.Flush; player.CharacterType.Power = reserve[i].CardPower + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); validFlush = true; } if (reserve[i + 1].CardPower % 4 == heartsFlush[0] % 4 && reserve[i + 1].CardPower / 4 > heartsFlush.Min() / 4) { player.CharacterType.Current = PokerHand.Flush; player.CharacterType.Power = reserve[i + 1].CardPower + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); validFlush = true; } if (reserve[i].CardPower / 4 < heartsFlush.Min() / 4 && reserve[i + 1].CardPower / 4 < heartsFlush.Min()) { player.CharacterType.Current = PokerHand.Flush; player.CharacterType.Power = heartsFlush.Max() + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); validFlush = true; } } if (diamondsFlush.Length == 3 || diamondsFlush.Length == 4) { if (reserve[i].CardPower % 4 == reserve[i + 1].CardPower % 4 && reserve[i].CardPower % 4 == diamondsFlush[0] % 4) { if (reserve[i].CardPower / 4 > diamondsFlush.Max() / 4) { player.CharacterType.Current = PokerHand.Flush; player.CharacterType.Power = reserve[i].CardPower + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); validFlush = true; } if (reserve[i + 1].CardPower / 4 > diamondsFlush.Max() / 4) { player.CharacterType.Current = PokerHand.Flush; player.CharacterType.Power = reserve[i + 1].CardPower + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); validFlush = true; } if (reserve[i].CardPower / 4 < diamondsFlush.Max() / 4 && reserve[i + 1].CardPower / 4 < diamondsFlush.Max() / 4) { player.CharacterType.Current = PokerHand.Flush; player.CharacterType.Power = diamondsFlush.Max() + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); validFlush = true; } } } if (diamondsFlush.Length == 4)//different cards in hand { if (reserve[i].CardPower % 4 != reserve[i + 1].CardPower % 4 && reserve[i].CardPower % 4 == diamondsFlush[0] % 4) { player.CharacterType.Current = PokerHand.Flush; if (reserve[i].CardPower / 4 > diamondsFlush.Max() / 4) { player.CharacterType.Power = reserve[i].CardPower + player.CharacterType.Current * 100; } else { player.CharacterType.Power = diamondsFlush.Max() + player.CharacterType.Current * 100; } strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); validFlush = true; } if (reserve[i + 1].CardPower % 4 != reserve[i].CardPower % 4 && reserve[i + 1].CardPower % 4 == diamondsFlush[0] % 4) { player.CharacterType.Current = PokerHand.Flush; if (reserve[i + 1].CardPower / 4 > diamondsFlush.Max() / 4) { player.CharacterType.Power = reserve[i + 1].CardPower + player.CharacterType.Current * 100; } else { player.CharacterType.Power = diamondsFlush.Max() + player.CharacterType.Current * 100; } strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); validFlush = true; } } if (diamondsFlush.Length == 5) { if (reserve[i].CardPower % 4 == diamondsFlush[0] % 4 && reserve[i].CardPower / 4 > diamondsFlush.Min() / 4) { player.CharacterType.Current = PokerHand.Flush; player.CharacterType.Power = reserve[i].CardPower + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); validFlush = true; } if (reserve[i + 1].CardPower % 4 == diamondsFlush[0] % 4 && reserve[i + 1].CardPower / 4 > diamondsFlush.Min() / 4) { player.CharacterType.Current = PokerHand.Flush; player.CharacterType.Power = reserve[i + 1].CardPower + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); validFlush = true; } if (reserve[i].CardPower / 4 < diamondsFlush.Min() / 4 && reserve[i + 1].CardPower / 4 < diamondsFlush.Min()) { player.CharacterType.Current = PokerHand.Flush; player.CharacterType.Power = diamondsFlush.Max() + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); validFlush = true; } } if (clubsFlush.Length == 3 || clubsFlush.Length == 4) { if (reserve[i].CardPower % 4 == reserve[i + 1].CardPower % 4 && reserve[i].CardPower % 4 == clubsFlush[0] % 4) { if (reserve[i].CardPower / 4 > clubsFlush.Max() / 4) { player.CharacterType.Current = PokerHand.Flush; player.CharacterType.Power = reserve[i].CardPower + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); validFlush = true; } if (reserve[i + 1].CardPower / 4 > clubsFlush.Max() / 4) { player.CharacterType.Current = PokerHand.Flush; player.CharacterType.Power = reserve[i + 1].CardPower + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); validFlush = true; } if (reserve[i].CardPower / 4 < clubsFlush.Max() / 4 && reserve[i + 1].CardPower / 4 < clubsFlush.Max() / 4) { player.CharacterType.Current = PokerHand.Flush; player.CharacterType.Power = clubsFlush.Max() + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); validFlush = true; } } } if (clubsFlush.Length == 4)//different cards in hand { if (reserve[i].CardPower % 4 != reserve[i + 1].CardPower % 4 && reserve[i].CardPower % 4 == clubsFlush[0] % 4) { player.CharacterType.Current = PokerHand.Flush; if (reserve[i].CardPower / 4 > clubsFlush.Max() / 4) { player.CharacterType.Power = reserve[i].CardPower + player.CharacterType.Current * 100; } else { player.CharacterType.Power = clubsFlush.Max() + player.CharacterType.Current * 100; } strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); validFlush = true; } if (reserve[i + 1].CardPower % 4 != reserve[i].CardPower % 4 && reserve[i + 1].CardPower % 4 == clubsFlush[0] % 4) { player.CharacterType.Current = PokerHand.Flush; if (reserve[i + 1].CardPower / 4 > clubsFlush.Max() / 4) { player.CharacterType.Power = reserve[i + 1].CardPower + player.CharacterType.Current * 100; } else { player.CharacterType.Power = clubsFlush.Max() + player.CharacterType.Current * 100; } strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); validFlush = true; } } if (clubsFlush.Length == 5) { if (reserve[i].CardPower % 4 == clubsFlush[0] % 4 && reserve[i].CardPower / 4 > clubsFlush.Min() / 4) { player.CharacterType.Current = PokerHand.Flush; player.CharacterType.Power = reserve[i].CardPower + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); validFlush = true; } if (reserve[i + 1].CardPower % 4 == clubsFlush[0] % 4 && reserve[i + 1].CardPower / 4 > clubsFlush.Min() / 4) { player.CharacterType.Current = PokerHand.Flush; player.CharacterType.Power = reserve[i + 1].CardPower + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); validFlush = true; } if (reserve[i].CardPower / 4 < clubsFlush.Min() / 4 && reserve[i + 1].CardPower / 4 < clubsFlush.Min()) { player.CharacterType.Current = PokerHand.Flush; player.CharacterType.Power = clubsFlush.Max() + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); validFlush = true; } } //ace if (spadesFlush.Length > 0) { if (reserve[i].CardPower / 4 == 0 && reserve[i].CardPower % 4 == spadesFlush[0] % 4 && validFlush && spadesFlush.Length > 0) { player.CharacterType.Current = PokerHand.FlushWithAce; player.CharacterType.Power = 13 + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); } if (reserve[i + 1].CardPower / 4 == 0 && reserve[i + 1].CardPower % 4 == spadesFlush[0] % 4 && validFlush && spadesFlush.Length > 0) { player.CharacterType.Current = 5.5; player.CharacterType.Power = 13 + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); } } if (heartsFlush.Length > 0) { if (reserve[i].CardPower / 4 == 0 && reserve[i].CardPower % 4 == heartsFlush[0] % 4 && validFlush && heartsFlush.Length > 0) { player.CharacterType.Current = PokerHand.FlushWithAce; player.CharacterType.Power = 13 + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); } if (reserve[i + 1].CardPower / 4 == 0 && reserve[i + 1].CardPower % 4 == heartsFlush[0] % 4 && validFlush && heartsFlush.Length > 0) { player.CharacterType.Current = PokerHand.FlushWithAce; player.CharacterType.Power = 13 + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); } } if (diamondsFlush.Length > 0) { if (reserve[i].CardPower / 4 == 0 && reserve[i].CardPower % 4 == diamondsFlush[0] % 4 && validFlush && diamondsFlush.Length > 0) { player.CharacterType.Current = PokerHand.FlushWithAce; player.CharacterType.Power = 13 + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); } if (reserve[i + 1].CardPower / 4 == 0 && reserve[i + 1].CardPower % 4 == diamondsFlush[0] % 4 && validFlush && diamondsFlush.Length > 0) { player.CharacterType.Current = PokerHand.FlushWithAce; player.CharacterType.Power = 13 + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); } } if (clubsFlush.Length > 0) { if (reserve[i].CardPower / 4 == 0 && reserve[i].CardPower % 4 == clubsFlush[0] % 4 && validFlush && clubsFlush.Length > 0) { player.CharacterType.Current = PokerHand.FlushWithAce; player.CharacterType.Power = 13 + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); } if (reserve[i + 1].CardPower / 4 == 0 && reserve[i + 1].CardPower % 4 == clubsFlush[0] % 4 && validFlush) { player.CharacterType.Current = PokerHand.FlushWithAce; player.CharacterType.Power = 13 + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); } } } }
public void CheckFullHouse(ICharacter player, ref bool done, int[] cards, ref List<Type> strongestHands, ref Type winningHand) { if (player.CharacterType.Current >= PokerHand.HighCard) { double type = player.CharacterType.Power; for (int i = 0; i <= 12; i++) { var fullHouse = cards.Where(c => c / 4 == i).ToArray(); if (fullHouse.Length == 3 || done) { if (fullHouse.Length == 2) { if (fullHouse.Max() / 4 == 0) { player.CharacterType.Current = PokerHand.FullHouse; player.CharacterType.Power = 13 * 2 + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); break; } if (fullHouse.Max() / 4 > 0) { player.CharacterType.Current = PokerHand.FullHouse; player.CharacterType.Power = fullHouse.Max() / 4 * 2 + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); break; } } if (!done) { if (fullHouse.Max() / 4 == 0) { player.CharacterType.Power = 13; done = true; i = -1; } else { player.CharacterType.Power = fullHouse.Max() / 4; done = true; i = -1; } } } } if (player.CharacterType.Current != PokerHand.FullHouse) { player.CharacterType.Power = type; } } }
public void CheckPairTwoPair(ICharacter player, ref List<Type> strongestHands, ref Type winningHand, IList<Card> reserve, int i) { if (player.CharacterType.Current >= PokerHand.HighCard) { bool msgbox = false; bool msgbox1 = false; for (int tc = 16; tc >= 12; tc--) { int max = tc - 12; for (int k = 1; k <= max; k++) { if (tc - k < 12) { max--; } if (tc - k >= 12) { if (reserve[tc].CardPower / 4 == reserve[tc - k].CardPower / 4) { if (reserve[tc].CardPower / 4 != reserve[i].CardPower / 4 && reserve[tc].CardPower / 4 != reserve[i + 1].CardPower / 4 && player.CharacterType.Current == 1) { if (!msgbox) { if (reserve[i + 1].CardPower / 4 == 0) { player.CharacterType.Current = PokerHand.TwoPair; player.CharacterType.Power = (reserve[i].CardPower / 4) * 2 + 13 * 4 + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); } if (reserve[i].CardPower / 4 == 0) { player.CharacterType.Current = PokerHand.TwoPair; player.CharacterType.Power = (reserve[i + 1].CardPower / 4) * 2 + 13 * 4 + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); } if (reserve[i + 1].CardPower / 4 != 0) { player.CharacterType.Current = PokerHand.TwoPair; player.CharacterType.Power = (reserve[tc].CardPower / 4) * 2 + (reserve[i + 1].CardPower / 4) * 2 + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); } if (reserve[i].CardPower / 4 != 0) { player.CharacterType.Current = PokerHand.TwoPair; player.CharacterType.Power = (reserve[tc].CardPower / 4) * 2 + (reserve[i].CardPower / 4) * 2 + player.CharacterType.Current * 100; strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); } } msgbox = true; } if (player.CharacterType.Current == PokerHand.HighCard) { if (!msgbox1) { if (reserve[i].CardPower / 4 > reserve[i + 1].CardPower / 4) { player.CharacterType.Current = PokerHand.PairTable; if (reserve[tc].CardPower / 4 == 0) { player.CharacterType.Power = 13 + reserve[i].CardPower / 4 + player.CharacterType.Current * 100; } else { player.CharacterType.Power = reserve[tc].CardPower / 4 + reserve[i].CardPower / 4 + player.CharacterType.Current * 100; } strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = 1 //?? }); winningHand = GetWinningHand(strongestHands); } else { player.CharacterType.Current = PokerHand.PairTable; if (reserve[tc].CardPower / 4 == 0) { player.CharacterType.Power = 13 + reserve[i + 1].CardPower + player.CharacterType.Current * 100; } else { player.CharacterType.Power = reserve[tc].CardPower / 4 + reserve[i + 1].CardPower / 4 + player.CharacterType.Current * 100; } strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = 1 //?? }); winningHand = GetWinningHand(strongestHands); } } msgbox1 = true; } } } } } } }
public void CheckHighCard(ICharacter player, ref List<Type> strongestHands, ref Type winningHand, IList<Card> reserve, int i) { if (player.CharacterType.Current == PokerHand.HighCard) { if (reserve[i].CardPower / 4 == 0 || reserve[i + 1].CardPower / 4 == 0) { player.CharacterType.Power = 13; } else if (reserve[i].CardPower / 4 > reserve[i + 1].CardPower / 4) { player.CharacterType.Power = reserve[i].CardPower / 4; } else { player.CharacterType.Power = reserve[i + 1].CardPower / 4; } strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); } }
public void CheckPairFromHand(ICharacter player, ref List<Type> strongestHands, ref Type winningHand, IList<Card> reserve, int i) { if (player.CharacterType.Current >= PokerHand.HighCard) { bool msgbox = false; if (reserve[i].CardPower / 4 == reserve[i + 1].CardPower / 4) { if (!msgbox) { player.CharacterType.Current = PokerHand.PairFromHand; if (reserve[i].CardPower / 4 == 0) { player.CharacterType.Power = 13 * 4 + player.CharacterType.Current * 100; } else { player.CharacterType.Power = (reserve[i + 1].CardPower / 4) * 4 + player.CharacterType.Current * 100; } strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); } msgbox = true; } for (int tc = 16; tc >= 12; tc--) { if (reserve[i + 1].CardPower / 4 == reserve[tc].CardPower / 4) { if (!msgbox) { player.CharacterType.Current = PokerHand.PairFromHand; if (reserve[i + 1].CardPower / 4 == 0) { player.CharacterType.Power = 13 * 4 + reserve[i].CardPower / 4 + player.CharacterType.Current * 100; } else { player.CharacterType.Power = (reserve[i + 1].CardPower / 4) * 4 + reserve[i].CardPower / 4 + player.CharacterType.Current * 100; } strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); } msgbox = true; } if (reserve[i].CardPower / 4 == reserve[tc].CardPower / 4) { if (!msgbox) { player.CharacterType.Current = PokerHand.PairFromHand; if (reserve[i].CardPower / 4 == 0) { player.CharacterType.Power = 13 * 4 + reserve[i + 1].CardPower / 4 + player.CharacterType.Current * 100; } else { player.CharacterType.Power = (reserve[tc].CardPower / 4) * 4 + reserve[i + 1].CardPower / 4 + player.CharacterType.Current * 100; } strongestHands.Add(new Type() { Power = player.CharacterType.Power, Current = player.CharacterType.Current }); winningHand = GetWinningHand(strongestHands); } msgbox = true; } } } }