public static string PlayerChosen(PaydayGameContainer mainGame, PaydayVMData model) { if (model.PopUpList !.Count() == 1) { return(model.PopUpList.GetText(1)); //i think. } CustomBasicList <PaydayPlayerItem> tempList = GetPossiblePlayerList(mainGame, model); MailCard thisMail = model.MailPile.GetCardInfo(); return(thisMail.MailType switch { EnumMailType.MadMoney => tempList.OrderByDescending(Items => Items.NetIncome()).Take(1).Single().NickName, EnumMailType.PayNeighbor => tempList.OrderBy(Items => Items.NetIncome()).Take(1).Single().NickName, _ => throw new BasicBlankException($"Must be madmoney or payneighbor, not {thisMail.CardCategory.ToString()}"), });
public int StraightDistance(ref ICustomBasicList <R> objectList, int whatNum) { int output = default; GetTempList(objectList); int highAmount = default; int lowAmount = default; int firstInfo = default; int secondInfo = default; if (NeedMatch == true) { _tempList = _tempList.OrderBy(Items => Items.GetSuit).ThenBy(Items => Items.ReadMainValue).ToCustomBasicList(); } else { _tempList = _tempList.OrderBy(Items => Items.ReadMainValue).ToCustomBasicList(); //this was the best way to handle sorting. } int x = 0; int newNum = 0; do //0 based { if (x > _tempList.Count) { break; } newNum = _tempList[x].ReadMainValue; if (newNum == whatNum) { if (x > 0) { lowAmount = _tempList[x].ReadMainValue; firstInfo = lowAmount; lowAmount = whatNum - lowAmount; } else { lowAmount = 0; firstInfo = 0; } if (x + 1 < objectList.Count) { highAmount = _tempList[x + 1].ReadMainValue; secondInfo = highAmount; if (highAmount > 15) { highAmount = 0; secondInfo = 0; } else { highAmount -= whatNum; } } else { highAmount = 0; } break; } x += 1; }while (true); if (highAmount == 0) { output = lowAmount; FirstUsed = firstInfo; } else if (lowAmount == 0) { output = highAmount; FirstUsed = secondInfo; } else if (highAmount < lowAmount) { output = highAmount; FirstUsed = secondInfo; } else { output = lowAmount; FirstUsed = secondInfo; } if (HasSecond == false) { return(output); } GetTempList(objectList); if (NeedMatch == true) { _tempList = _tempList.OrderBy(Items => Items.GetSuit).ThenBy(Items => Items.GetSecondNumber).ToCustomBasicList(); } else { _tempList = _tempList.OrderBy(Items => Items.GetSecondNumber).ToCustomBasicList(); //this was the best way to handle sorting. } x = 0; do //0 based { if (x > _tempList.Count) { break; } newNum = _tempList[x].GetSecondNumber; if (newNum == whatNum) { if (x > 0) { lowAmount = _tempList[x].GetSecondNumber; firstInfo = lowAmount; lowAmount = whatNum - lowAmount; } else { lowAmount = 0; firstInfo = 0; } if (x + 1 < objectList.Count) { highAmount = _tempList[x + 1].GetSecondNumber; secondInfo = highAmount; if (highAmount > 15) { highAmount = 0; secondInfo = 0; } else { highAmount -= whatNum; } } else { highAmount = 0; } break; } x += 1; }while (true); if (output == 0 & highAmount == 0 & lowAmount > 0) { output = lowAmount; FirstUsed = firstInfo; } else if (output == 0 & lowAmount == 0 & highAmount > 0) { output = highAmount; FirstUsed = secondInfo; } else if (highAmount == 0 & lowAmount < output & lowAmount > 0) { output = lowAmount; FirstUsed = firstInfo; } else if (lowAmount == 0 & highAmount < output & highAmount > 0) { output = highAmount; FirstUsed = secondInfo; } else if (highAmount < lowAmount & highAmount < output & highAmount > 0) { output = highAmount; FirstUsed = secondInfo; } else if (lowAmount < highAmount & lowAmount < output & highAmount > 0) { output = lowAmount; FirstUsed = firstInfo; } return(output); }
private ICustomBasicList <R> StraightSet(ICustomBasicList <R> objectList, int howMany, bool minOnly, ICustomBasicList <R> wildList, bool noWilds = false) { ICustomBasicList <R> output = new CustomBasicList <R>(); bool tempwilds = HasWild; if (noWilds == true) { HasWild = false; } else if (HasWild == false) { HasWild = false; } else { HasWild = true; } IEnumerable <R> firstLinq; //we may need that unfortunately. if (UseSecond == false) { firstLinq = from Objects in _tempList where Objects.IsObjectIgnored == false && Objects.IsObjectWild == false orderby Objects.ReadMainValue select Objects; } else { firstLinq = from Objects in _tempList where Objects.IsObjectIgnored == false && Objects.IsObjectWild == false select Objects; } CustomBasicList <R> firstList = new CustomBasicList <R>(); firstList.AddRange(firstLinq); var exps = firstLinq.GroupBy(Items => Items.ReadMainValue).ToCustomBasicList(); CustomBasicList <R> temps; if (NeedMatch == false) { temps = firstList.GroupBy(Items => Items.ReadMainValue).Select(Items => Items.First()).ToCustomBasicList(); } else { temps = firstList.GroupBy(Items => new { Items.ReadMainValue, Items.GetSuit }).Select(Items => Items.First()).ToCustomBasicList(); } firstList.ReplaceRange(temps); if (NeedMatch == true) { firstList = firstList.OrderBy(Items => Items.GetSuit).ThenBy(Items => Items.ReadMainValue).ToCustomBasicList(); } else { firstList = firstList.OrderBy(Items => Items.ReadMainValue).ToCustomBasicList(); } int[]? aObjectIndex; aObjectIndex = new int[1]; bool bStraightFound = default; int lngUnUsedWild = default; int Start = default; if (HasValidStraight(firstList, wildList, false, howMany, minOnly, ref aObjectIndex, ref lngUnUsedWild, ref Start)) { bStraightFound = true; } else { aObjectIndex = null; if (HasSecond == true) { firstList = new CustomBasicList <R>(); firstList.AddRange(firstLinq); if (NeedMatch == true) { firstList = (from Items in firstList orderby Items.GetSuit ascending, Items.GetSecondNumber ascending select Items).ToCustomBasicList(); } else { firstList = (from Items in firstList orderby Items.GetSecondNumber select Items).ToCustomBasicList(); } } if (HasValidStraight(firstList, wildList, true, howMany, minOnly, ref aObjectIndex, ref lngUnUsedWild, ref Start)) { UseSecond = true; bStraightFound = true; } } int lngObjectInStraight; int lngIndex; if (bStraightFound == true) { lngObjectInStraight = aObjectIndex !.GetUpperBound(0) - 1; // i think var loopTo = (long)Start + lngObjectInStraight; for (lngIndex = Start; lngIndex <= loopTo; lngIndex++) { output.Add(firstList[lngIndex]); if (output.Count == _maxStraight) { break; } } int intHigh = default; int intLow = default; HighLow(ref firstList, output, howMany, minOnly, lngUnUsedWild, ref intHigh, ref intLow); FirstUsed = intLow; if (HasWild == true) { var loopTo1 = wildList.Count() - 1; for (lngIndex = 0; lngIndex <= loopTo1; lngIndex++) { if (lngIndex + 1 <= wildList.Count()) { if (output.Count < howMany | minOnly == false) { output.Add(wildList[lngIndex]); } } if (output.Count == _maxStraight) { return(output); } } } } if (output.Count == objectList.Count & UseAll == false) { firstLinq = from Objects in output where Objects.ReadMainValue == FirstUsed select Objects; if (firstLinq.Count() > 0) { output.RemoveSpecificItem(firstLinq.First()); } else { output.RemoveLastItem(); } } aObjectIndex = null; int newnum; newnum = FirstUsed + output.Count - 1; newnum = HighNumber - newnum; if (FirstUsed > 0 & newnum < 0) { FirstUsed += newnum; } HasWild = tempwilds; return(output); }