public CustomBasicList <CustomBasicList <bool> > RollDice(int howManySections = 7) { if (DiceList.Count == 0) { throw new BasicBlankException("There are no dice to even roll. Try FirstLoad"); } int counts = DiceList.Count(Items => Items.Value == false); CustomBasicList <CustomBasicList <bool> > output = new CustomBasicList <CustomBasicList <bool> >(); AsyncDelayer.SetDelayer(this, ref _delay !); IDiceContainer <bool> thisG = MainContainer !.Resolve <IDiceContainer <bool> >(); thisG.MainContainer = MainContainer; CustomBasicList <bool> possList = thisG.GetPossibleList; howManySections.Times(() => { CustomBasicList <bool> firsts = new CustomBasicList <bool>(); counts.Times(() => { firsts.Add(possList.GetRandomItem()); }); output.Add(firsts); }); return(output); }
public CustomBasicList <CustomBasicList <D> > RollDice(int howManySections = 6) { if (DiceList.Count() != HowManyDice) { RedoList(); } CustomBasicList <CustomBasicList <D> > output = new CustomBasicList <CustomBasicList <D> >(); AsyncDelayer.SetDelayer(this, ref _delay !); //try both places. IGenerateDice <int> ThisG = MainContainer !.Resolve <IGenerateDice <int> >(); CustomBasicList <int> possList = ThisG.GetPossibleList; possList.MainContainer = MainContainer; D tempDice; int chosen; howManySections.Times(() => { CustomBasicList <D> firsts = new CustomBasicList <D>(); for (int i = 0; i < HowManyDice; i++) { tempDice = DiceList[i]; if (tempDice.Hold == false) //its uncommon enough that has to be different for different types of dice games. { chosen = possList.GetRandomItem(); tempDice = new D(); tempDice.Index = i + 1; //i think tempDice.Populate(chosen); //so they can do what they need to. } firsts.Add(tempDice); } output.Add(firsts); }); return(output); }
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 async Task ShowRollingAsync(CustomBasicList <CustomBasicList <D> > diceCollection, bool showVisible) { CanShowDice = showVisible; AsyncDelayer.SetDelayer(this, ref _delay !); //because for multiplayer, they do this part but not the other. await diceCollection.ForEachAsync(async firsts => { DiceList.ReplaceDiceRange(firsts); int tempCount = DiceList.Count; if (DiceList.Any(Items => Items.Index > tempCount || Items.Index <= 0)) { throw new BasicBlankException("Index cannot be higher than the dicecount or less than 1"); } HasDice = true; if (CanShowDice == true) { Visible = true; await _delay.DelayMilli(50); } }); }