public int WhoWon(CustomBasicList <YahtzeeResults> resultList) // either 1 or 2. { if (resultList.Count == 1) { return(1);// can be only 1 } if (resultList.Count != 2) { throw new BasicBlankException("Must have 2 items to show the best hands from the players; not " + resultList.Count); } if (resultList.First().Points > resultList.Last().Points) { return(1); } if (resultList.Last().Points > resultList.First().Points) { return(2); } if (resultList.First().NumberUsed > resultList.Last().NumberUsed) { return(1); } if (resultList.Last().NumberUsed > resultList.First().NumberUsed) { return(2); } return(1); }
public async Task ShowRollingAsync(CustomBasicList <CustomBasicList <bool> > thisCol) { bool isLast = false; AsyncDelayer.SetDelayer(this, ref _delay !); //has to be here to learn lesson from other dice games. await thisCol.ForEachAsync(async firstList => { if (thisCol.Last() == firstList) { isLast = true; } int x; x = 0; firstList.ForEach(items => { SingleDiceInfo thisDice = FindNextPin(ref x); thisDice.Populate(items); thisDice.Index = DiceList.IndexOf(thisDice) + 1; if (isLast == true) //animations has to show value { thisDice.DidHit = items; } }); await _delay.DelayMilli(50); //decided to have here less performance problem when rolling bowling dice. }); if (isLast == false) { throw new BasicBlankException("Was never last for showing rolling. Rethink"); } }
public string GetWord() { if (CompletedWord() == false) { throw new BasicBlankException("Has to complete a word before it can get the word"); } return(_completeList.First().ToString().ToLower() + _completeList[1].ToString().ToLower() + _completeList.Last().ToString().ToLower()); }
private void HighLow(ref CustomBasicList <R> firstList, ICustomBasicList <R> colObj, int intHowMany, bool minonly, int lngUnUsedWild, ref int intHigh, ref int intLow) { int intObjectNumber; int intAvailableObject; int intAvailableWild; intHigh = 0; intLow = 0; if (colObj.Count <= 0) { return; } if (HasWild) { intAvailableWild = lngUnUsedWild; } else { intAvailableWild = 0; } intAvailableObject = colObj.Count; if (UseSecond == false) { firstList = (from Items in colObj orderby Items.ReadMainValue select Items).ToCustomBasicList(); } else { firstList = (from Items in colObj orderby Items.GetSecondNumber select Items).ToCustomBasicList(); } if (UseSecond == false) { intObjectNumber = firstList.Last().ReadMainValue; } else { intObjectNumber = firstList.Last().GetSecondNumber; } if (intObjectNumber < HighNumber) { if (intAvailableWild > 0) { if (minonly) { if (intHowMany > intAvailableObject) { if (intHowMany - intAvailableObject > HighNumber - intObjectNumber) { intHigh = HighNumber; intAvailableWild -= HighNumber - intObjectNumber; intAvailableObject += HighNumber - intObjectNumber; } else { intHigh = intObjectNumber + intHowMany - intAvailableObject; intAvailableWild -= intHowMany - intAvailableObject; intAvailableObject = intHowMany; } } else if (HighNumber - intObjectNumber > intAvailableWild) { intHigh = intObjectNumber + intAvailableWild; intAvailableWild = 0; } else { intHigh = HighNumber; intAvailableWild -= HighNumber - intObjectNumber; } } else { intHigh = intObjectNumber; } } } if (UseSecond == false) { intObjectNumber = colObj.First().ReadMainValue; } else { intObjectNumber = colObj.First().GetSecondNumber; } if (intObjectNumber >= LowNumber) { if (intAvailableWild > 0) { if (minonly) { if (intHowMany > intAvailableObject) { if (intHowMany - intAvailableObject > intObjectNumber - LowNumber) { intLow = LowNumber; intAvailableWild -= intObjectNumber - LowNumber; intAvailableObject += intObjectNumber - LowNumber; } else { intLow = intObjectNumber - (intHowMany - intAvailableObject); intAvailableWild -= intHowMany - intAvailableObject; intAvailableObject = intHowMany; } } else if (intObjectNumber - LowNumber > intAvailableWild) { intLow = intObjectNumber - intAvailableWild; intAvailableWild = 0; } else { intLow = LowNumber; intAvailableWild -= intObjectNumber - LowNumber; } } else { intLow = intObjectNumber; } } } }