Beispiel #1
0
 public override async Task StartNewTurnAsync()
 {
     if (PlayerList.DidChooseColors())
     {
         PrepStartTurn(); //if you did not choose colors, no need to prepstart because something else will do it.
         //code to run but only if you actually chose color.
         Cup !.DiceList.ForEach(thisDice => thisDice.Visible = true);
         if (SingleInfo !.PlayerCategory == EnumPlayerCategory.OtherHuman)
         {
             Check !.IsEnabled = true;
             return;                     //because waiting for other player to roll dice.
         }
         await Roller !.RollDiceAsync(); //hopefully this simple.
         return;
     }
     await ContinueTurnAsync(); //most of the time, continue turn.  can change to what is needed
 }
        protected override async Task ProtectedAfterRollingAsync()
        {
            CountdownVMData.ShowHints = false; //you have to choose it everytime.
            int DiceValue = _model !.Cup !.DiceList.Sum(items => items.Value);

            if (DiceValue == 12)
            {
                await UIPlatform.ShowMessageAsync($"{SingleInfo!.NickName}  has to start over again for rolling a 12");
                await StartOverAsync(SingleInfo);

                return;
            }
            if (DiceValue == 11)
            {
                CountdownPlayerItem thisPlayer;
                if (WhoTurn == 1)
                {
                    thisPlayer = PlayerList ![2];
Beispiel #3
0
    public bool RemoveType(DieSide type)
    {
        // Select a die that matches the type, prioritize those that aren't uncancellable
        Die dieToCancel = DiceList
                          .OrderBy(d => d.IsUncancelable)
                          .FirstOrDefault(d => d.Side == type);

        if (dieToCancel != null)
        {
            dieToCancel.Cancel();
            dieToCancel.RemoveModel();
            DiceList.Remove(dieToCancel);
            return(true);
        }
        else
        {
            return(false);
        }
    }
Beispiel #4
0
    public int Change(DieSide oldSide, DieSide newSide, int count, bool cannotBeRerolled = false, bool cannotBeModified = false)
    {
        var changedDiceCount = 0;

        if (count == 0) // change all
        {
            changedDiceCount += ChangeDice(oldSide, newSide, false, cannotBeRerolled, cannotBeModified);
        }
        else
        {
            count = Math.Min(count, DiceList.Count(n => n.Side == oldSide));
            for (int i = 0; i < count; i++)
            {
                changedDiceCount += ChangeDice(oldSide, newSide, true, cannotBeRerolled, cannotBeModified);
            }
        }

        UpdateDiceCompareHelperPrediction();
        return(changedDiceCount);
    }
Beispiel #5
0
    public int Change(DieSide oldSide, DieSide newSide, int count = 0, bool cannotBeRerolled = false, bool cannotBeModified = false)
    {
        var changedDiceCount = 0;

        if (count == 0) // = change all
        {
            changedDiceCount += ChangeAll(oldSide, newSide, cannotBeRerolled, cannotBeModified);
        }
        else
        {
            changedDiceCount = Math.Min(count, DiceList.Count(n => n.Side == oldSide));
            for (int i = 0; i < changedDiceCount; i++)
            {
                ChangeOne(oldSide, newSide, cannotBeRerolled, cannotBeModified);
            }
        }

        OrganizeDicePositions();
        return(changedDiceCount);
    }
Beispiel #6
0
        public override async Task EndTurnAsync()
        {
            SingleInfo !.Score = _model.Cup !.DiceList.Sum(Items => Items.Value);
            if (_wasAuto == true && Test !.NoAnimations == false)
            {
                await Delay !.DelaySeconds(1); //if auto is done, needs to see what happened.
            }
            if (WhoTurn == WhoStarts)
            {
                SaveRoot !.MaxRolls = SaveRoot.RollNumber - 1;
            }
            WhoTurn = await PlayerList !.CalculateWhoTurnAsync(); //i think
            if (WhoTurn == WhoStarts)
            {
                await GameOverAsync();

                return;
            }
            await StartNewTurnAsync();
        }
Beispiel #7
0
        //since its easy enough, no need for interface.
        public int CalculateScore()
        {
            int index = _model.ItemSelected;

            if (index == -1)
            {
                throw new BasicBlankException("Cannot calculate the score because nothing was selected");
            }
            if (_gameContainer.SaveRoot !.CategoryRolled == -1)
            {
                throw new BasicBlankException("Cannot calculate the score because the category dice has not been rolled");
            }
            if (_gameContainer.SaveRoot.WhichMulti == 0)
            {
                return(0);
            }
            bool sameCategory;

            sameCategory = WasSameCategory();
            int newMulti = MultiToUse(sameCategory);
            CustomBasicList <SimpleDice> tempList;

            tempList = _model.Cup !.DiceList.ToCustomBasicList(); //i think
            CustomBasicList <int> mainList = new CustomBasicList <int>();

            foreach (var thisDice in tempList)
            {
                mainList.Add(thisDice.Value);
            }
            int scoress;

            scoress = FirstScore(mainList, out bool Additionals);
            if (Additionals == true)
            {
                scoress *= 2;
            }
            return(scoress * newMulti);
        }
Beispiel #8
0
 private int HowMany()
 {
     return(_saveRoot !.DiceList.Count(Items => Items.Value == _saveRoot.WhatNumber));
 }
Beispiel #9
0
 private bool HasThree()
 {
     return(_saveRoot !.DiceList.DistinctCount(Items => Items.Value) == 1); //needs to be 1 distinct.
 }
Beispiel #10
0
 public bool HasResult(DieSide side)
 {
     return(DiceList.Any(n => n.Side == side));
 }
Beispiel #11
0
 public void KeepDie(DiceList dieId) => _dice.KeepDie(dieId);
        private bool CanRemoveSelectedDice()
        {
            var thisList = _model.Cup !.DiceList.GetSelectedItems();

            return(thisList.Sum(Items => Items.Value) == 6);
        }
        public async Task <string> SaveGameAsync()
        {
            CustomBasicList <bool> thisList = DiceList.Select(Items => Items.DidHit).ToCustomBasicList();

            return(await js.SerializeObjectAsync(thisList));
        }
Beispiel #14
0
 private void AddDice(DiceSide side = DiceSide.Unknown)
 {
     DiceList.Add(new Dice(Type, side));
 }
Beispiel #15
0
 private bool HasSix()
 {
     return(_model.Cup !.DiceList.Any(items => items.Value == 6));
 }
Beispiel #16
0
 public void KeepDie(DiceList index) => _keep.Add(_dice[(int)index]);