Ejemplo n.º 1
0
        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 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 static EnumShapes GetShapeChosen()
        {
            CustomBasicList <int> tempList = new CustomBasicList <int> {
                1, 2, 3, 4
            };
            int output = tempList.GetRandomItem();

            return((EnumShapes)output);
        }
Ejemplo n.º 4
0
        public static CustomBasicList <T> GetSingleRolledDice <T>(int howManySections, IGenerateDice <T> dice) where T : IConvertible
        {
            CustomBasicList <T> thisList  = new CustomBasicList <T>();
            CustomBasicList <T> otherList = dice.GetPossibleList;

            howManySections.Times(items =>
            {
                thisList.Add(otherList.GetRandomItem());
            });
            return(thisList);
        }
        public MoveInfo MoveToMake()
        {
            CustomBasicList <MoveInfo> newList = new CustomBasicList <MoveInfo>();

            _gameContainer.SingleInfo !.MainHandList.ForEach(thisCard =>
            {
                newList.AddRange(MoveList(thisCard.Deck));
                MoveInfo thisMove  = new MoveInfo();
                thisMove.ToDiscard = true;
                thisMove.Deck      = thisCard.Deck;
                newList.Add(thisMove);
            });
            return(newList.GetRandomItem());
        }
Ejemplo n.º 6
0
        public D GetRandomDice(int upTo)
        {
            SetContainer();
            IDiceContainer <int> thisG = MainContainer !.Resolve <IDiceContainer <int> >();

            thisG.MainContainer = MainContainer;
            CustomBasicList <int> possList = thisG.GetPossibleList;

            possList.MainContainer = MainContainer; //this is needed because you are using a random function.
            int Chosen  = possList.GetRandomItem();
            D   newDice = new D();

            newDice.Populate(Chosen);
            newDice.Index = upTo;
            return(newDice);
        }
Ejemplo n.º 7
0
        public async Task NewGameAsync(GameBoardViewModel guess)
        {
            //hopefully no need to hide solution anymore since another class is responsible for it now.
            bool canRepeat = _level.LevelChosen == 2 || _level.LevelChosen == 4 || _level.LevelChosen == 6;
            int  level     = _level.LevelChosen;
            CustomBasicList <Bead> possibleList = new CustomBasicList <Bead>();

            if (level == 5 || level == 6)
            {
                possibleList.Add(new Bead(EnumColorPossibilities.Aqua));
                possibleList.Add(new Bead(EnumColorPossibilities.Black));
            }
            possibleList.Add(new Bead(EnumColorPossibilities.Blue));
            possibleList.Add(new Bead(EnumColorPossibilities.Green));
            if (level > 2)
            {
                possibleList.Add(new Bead(EnumColorPossibilities.Purple));
            }
            possibleList.Add(new Bead(EnumColorPossibilities.Red));
            possibleList.Add(new Bead(EnumColorPossibilities.White));
            if (level > 2)
            {
                possibleList.Add(new Bead(EnumColorPossibilities.Yellow));
            }
            ICustomBasicList <Bead> tempList;

            if (canRepeat == false)
            {
                tempList = possibleList.GetRandomList(false, 4);
            }
            else
            {
                int x;
                tempList = new CustomBasicList <Bead>();
                for (x = 1; x <= 4; x++)
                {
                    var ThisBead = possibleList.GetRandomItem();
                    tempList.Add(ThisBead); // can have repeat
                }
            }
            _global.Solution = tempList.ToCustomBasicList();
            await guess.NewGameAsync();

            await guess.StartNewGuessAsync();

            _global.ColorList = possibleList.Select(items => items.ColorChosen).ToCustomBasicList();
        }
        protected override async Task ComputerTurnAsync()
        {
            if (Test !.NoAnimations == false)
            {
                await Delay !.DelayMilli(500);
            }
            if (PlayerList.DidChooseColors() == false)
            {
                await base.ComputerTurnAsync(); //because this handles the choosing of colors.

                return;
            }
            if (SaveRoot.GameStatus == EnumWhatStatus.NeedChooseGender)
            {
                //choose gender computer choose.
                if (_gameContainer.ComputerChooseGenderAsync == null)
                {
                    //throw new BasicBlankException("No processes handling computer choosing gender");
                    return; //hopefully goes back again (?)
                }
                await _gameContainer.ComputerChooseGenderAsync.Invoke();

                return;
            }
            if (Test !.NoAnimations == false)
            {
                await Delay !.DelayMilli(500);
            }
            switch (SaveRoot.GameStatus)
            {
            case EnumWhatStatus.NeedChooseFirstOption:
                await _boardProcesses.OpeningOptionAsync(EnumStart.Career);     //the computer will always choose career.

                break;

            case EnumWhatStatus.NeedChooseFirstCareer:
            case EnumWhatStatus.NeedNewCareer:
                await _careerProcesses.ChoseCareerAsync(_model.GetRandomCard);

                break;

            case EnumWhatStatus.NeedChooseStock:
                await _chooseStockProcesses.ChoseStockAsync(_model.GetRandomCard);

                break;

            case EnumWhatStatus.NeedChooseSalary:
                await _basicSalaryProcesses.ChoseSalaryAsync(_model.GetRandomCard);

                break;

            case EnumWhatStatus.NeedToSpin:
                if (SingleInfo !.CarIsInsured == false)
                {
                    await _boardProcesses.PurchaseCarInsuranceAsync();

                    return;
                }
                if (SingleInfo.FirstStock == 0 && SingleInfo.SecondStock == 0)
                {
                    await _boardProcesses.PurchaseStockAsync();

                    return;
                }
                if (SingleInfo.Salary < 80000 && _gameContainer.CanTradeForBig(true))
                {
                    await _boardProcesses.Trade4TilesAsync();

                    return;
                }
                await _spinnerProcesses.StartSpinningAsync();     //hopefully this simple.

                break;

            case EnumWhatStatus.NeedReturnStock:
                if (_model.HandList.HandList.Count != 2)
                {
                    throw new BasicBlankException("Must have 2 choices to return.  Otherwise; should have returned automatically");
                }
                await _returnStockProcesses.StockReturnedAsync(_model.GetRandomCard);

                break;

            case EnumWhatStatus.NeedToChooseSpace:
                int firstNumber  = _gameBoard.FirstPossiblePosition;
                int secondNumber = _gameBoard.SecondPossiblePosition;
                if (firstNumber == 0)
                {
                    throw new BasicBlankException("The first possible position cannot be 0. Check this out");
                }
                if (secondNumber == 0)
                {
                    throw new BasicBlankException("The second possible position cannot be 0.  Otherwise, should have made move automatically");
                }
                CustomBasicList <int> posList = new CustomBasicList <int> {
                    firstNumber, secondNumber
                };
                int numberChosen;
                if (Test.DoubleCheck)
                {
                    numberChosen = secondNumber;     //the problem only happens with second.
                }
                else
                {
                    numberChosen = posList.GetRandomItem();
                }
                await MakeMoveAsync(numberChosen);

                //await _boardProcesses.ComputerChoseSpaceAsync(posList.GetRandomItem());
                break;

            case EnumWhatStatus.NeedNight:
            case EnumWhatStatus.NeedToEndTurn:
                if (BasicData.MultiPlayer)
                {
                    await Network !.SendEndTurnAsync();
                }
                await EndTurnAsync();

                break;

            case EnumWhatStatus.NeedStealTile:
                await _stolenTileProcesses.ComputerStealTileAsync();

                break;

            case EnumWhatStatus.NeedChooseRetirement:
                await _boardProcesses.RetirementAsync(EnumFinal.MillionaireEstates);     //always choose millionaire for computer;

                break;

            case EnumWhatStatus.NeedChooseHouse:
            case EnumWhatStatus.NeedSellBuyHouse:
                await _spinnerProcesses.StartSpinningAsync();     //computer will never choose to sell or buy house.

                break;

            case EnumWhatStatus.NeedTradeSalary:
                await _tradeSalaryProcesses.ComputerTradeAsync();

                break;

            default:
                throw new BasicBlankException("Rethink for computer turn");
            }
        }