Exemplo n.º 1
0
        private int figureScore()
        {
            int _score = 300;

            if (Rolls.Length > 12)
            {
                if (!Rolls.Contains('/') && !Rolls.Contains('X'))
                {
                    if (Rolls.Contains('-'))
                    {
                        List <char> rolls     = Rolls.ToList <char>();
                        List <int>  scoreList = (from roll in rolls where roll != '-' select int.Parse(roll + "")).ToList();
                        _score = scoreList.Sum();
                    }
                }
                else
                {
                    if (Rolls.Contains('-'))
                    {
                        _score = processScore(Rolls);
                    }
                    else
                    {
                        _score = 150;
                    }
                }
            }

            return(_score);
        }
Exemplo n.º 2
0
        public Frame Roll(uint pins)
        {
            if (IsFull)
            {
                if (NextFrame != null)
                {
                    return(NextFrame.Roll(pins));
                }

                return(null);
            }

            if (!IsValidRoll(pins))
            {
                throw new InvalidRollException($"Invalid roll > {MaxValidRoll}");
            }

            var roll = new Roll(pins);

            Rolls.Add(roll);

            if (IsFull)
            {
                return(NextFrame);
            }

            return(this);
        }
Exemplo n.º 3
0
        async void initRoll_Clicked(System.Object sender, System.EventArgs e)
        {
            Random rand         = new Random();
            int    randomRoll   = rand.Next(1, 21);
            int    randomDexMod = Convert.ToInt32(modsEntry.Text);
            int    initRoll     = randomRoll + randomDexMod;

            rollOutput.Text = initRoll.ToString();
            dmInitRoll.Text = initRoll.ToString();

            Rolls roll = new Rolls()
            {
                RollNum     = Convert.ToInt32(rollOutput.Text),
                RollType    = "Initiative",
                CharacterId = "DUNGEON MASTER",
                CampaignId  = campaign.Id,
                UserId      = campaign.UserId
            };

            await App.MobileService.GetTable <Rolls>().InsertAsync(roll);

            campaign.DMRoll     = Convert.ToInt32(rollOutput.Text);
            campaign.DMRollType = "Initiative";

            await App.MobileService.GetTable <Campaigns>().UpdateAsync(campaign);
        }
        public Rolls GetRollsNumber(int numberList)
        {
            Logger.Logger.LoggerCreat("Project_minibot.Database", " GetRollsNumber", Logger.Logger.LogStatus.DEBUG, "Считывание данных объекта из базы данных");
            SqlConnection connection = new SqlConnection(_connection);
            SqlCommand    command    = new SqlCommand($"select * from Rolls where Rolls.number={numberList}", connection);
            Rolls         rollsGet   = new Rolls();

            connection.Open();
            SqlDataReader reader = command.ExecuteReader();

            using (reader)
            {
                while (reader.Read())
                {
                    rollsGet.Number = (int)reader["number"];
                    rollsGet.Name   = (string)reader["name"];

                    if (!(reader[name : "price"] is DBNull))
                    {
                        rollsGet.Price = (int)reader[name : "price"];
                    }
                    else
                    {
                        Logger.Logger.LoggerCreat("Project_minibot.Database", "GetRollsNumber", Logger.Logger.LogStatus.ERROR, "Пустая ссылка. Значение NULL");
                        throw new MyExceptionMessage(message: "Попытка использовать пустую ссылку");
                    }
                }

                return(rollsGet);
            }
        }
Exemplo n.º 5
0
        public bool Roll(int roll)
        {
            Rolls.Add(roll);

            Score += roll;

            if (IsStrike || IsSpare)
            {
                if (IsLast && Rolls.Count() == MaxRollsPerFrame)
                {
                    return(false);
                }
            }

            if (Previous != null)
            {
                if (Previous.IsSpare && Rolls.Count == 1)
                {
                    Previous.AddSpareScore(roll);
                }
                else if (Previous.IsStrike)
                {
                    Previous.AddSpareScore(roll);
                }

                var prePrevious = Previous.Previous;

                if (!IsLast && prePrevious != null && prePrevious.IsStrike)
                {
                    prePrevious.AddSpareScore(roll);
                }
            }

            return(!IsStrike && !IsLast && Rolls.Count < 2);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Serializes the DiceState object.
        /// </summary>
        /// <param name="writer">The xml writer to use when writing.</param>
        public void WriteXml(XmlWriter writer)
        {
            writer.WriteStartElement(GetType().Name);

            writer.WriteAttributeString("Rolls", Rolls.ToString());
            writer.WriteAttributeString("ValidForTurn", ValidForTurn.ToString());

            // Serialize rolling dice
            writer.WriteStartElement("RollingDice");

            for (int i = 0; i < DieAmount; i++)
            {
                writer.WriteAttributeString("D" + i.ToString(),
                                            RollingDice[i] == null ? "" : ((int)RollingDice[i].Value).ToString());
            }

            writer.WriteEndElement();

            // Serialize held dice
            writer.WriteStartElement("HoldingDice");

            for (int i = 0; i < DieAmount; i++)
            {
                writer.WriteAttributeString("D" + i.ToString(),
                                            HoldingDice[i] == null ? "" : ((int)HoldingDice[i].Value).ToString());
            }

            writer.WriteEndElement();

            // End element for the "DiceState" element
            writer.WriteEndElement();
        }
        public void CreatRolls(Rolls rolls)
        {
            Logger.Logger.LoggerCreat("Project_minibot.Database", "CreatRolls", Logger.Logger.LogStatus.DEBUG, "Создание объекта в базе данных");
            string query = $"insert into Rolls values('{rolls.Name}',{rolls.Price},{rolls.Number})";

            ConnectionAndCommand(query);
        }
Exemplo n.º 8
0
        public HttpResponseMessage AddFrame(string id, [FromBody] Rolls frame)
        {
            gameLogic = new GameLogic();
            gameLogs  = new GameLogs();

            if (frame == null)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "No Input"));
            }
            frameList = gameLogs.GameId(id);
            if (frameList == null)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Please create a game first!"));
            }

            try
            {
                gameLogic.ControllInput(frame);
                frameList.RollsList.Add(frame);
                AddRollsFrame(frame);
            }

            catch (Exception e)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, e.Message));
            }
            gameLogs.SaveLogs();

            return(Request.CreateResponse(HttpStatusCode.Created, frameList));
        }
Exemplo n.º 9
0
        public void AddRollsFrame(Rolls frame)
        {
            if (frameList.RollsList.Count == 10)
            {
                throw new Exception("Game over");
            }

            for (int i = 0; i < frameList.RollsList.Count; i++)
            {
                if (frameList.RollsList[i].RollOne == 10 && i != frames - 1)
                {
                    score += frameList.RollsList[i].RollOne + gameLogic.Strike(i, frameList);
                }
                else if (frameList.RollsList[i].RollOne + frameList.RollsList[i].RollTwo == 10 && i != frames - 1)
                {
                    score += frameList.RollsList[i].RollOne + frameList.RollsList[i].RollTwo + gameLogic.Spare(i, frameList);
                }
                else
                {
                    score += frameList.RollsList[i].RollOne + frameList.RollsList[i].RollTwo + frameList.RollsList[i].RollThree;
                }
                frameList.RollsList[i].TotalScore = score;
            }
            frameList.TotalScore = score;
        }
Exemplo n.º 10
0
        async void initRoll_Clicked(System.Object sender, System.EventArgs e)
        {
            Random rand          = new Random();
            int    randomRoll    = rand.Next(1, 21);
            int    randomDexMod  = Convert.ToInt32(dexMod.Text);
            int    randomInitMod = character.CharInit;
            int    initRoll      = randomRoll + randomDexMod + randomInitMod;

            rollOutput.Text = initRoll.ToString();

            Rolls roll = new Rolls()
            {
                RollNum     = Convert.ToInt32(rollOutput.Text),
                RollType    = "Initiative",
                CharacterId = character.Id,
                CampaignId  = character.CampaignId,
                UserId      = character.UserId
            };

            await App.MobileService.GetTable <Rolls>().InsertAsync(roll);

            character.CharRoll           = Convert.ToInt32(rollOutput.Text);
            character.CharRollType       = "Initiative";
            character.CharInitiativeRoll = Convert.ToInt32(rollOutput.Text);

            await App.MobileService.GetTable <Characters>().UpdateAsync(character);
        }
Exemplo n.º 11
0
        public void DivideRollsByZero()
        {
            var rolls = new double[] { -10, 0, 10 };

            var actual = Rolls.ApplyOperation(rolls, DiceOperation.Divide, 0).ToArray();

            CollectionAssert.AreEqual(new double[] { 0, 0, 0 }, actual, "Division by zero was applied incorrectly to rolls.");
        }
Exemplo n.º 12
0
        /// <summary> Performs a single roll and returns its value. </summary>
        /// <param name="rollCount">The roll count for current node.</param>
        /// <returns> Roll value. </returns>
        private double Roll(out int rollCount)
        {
            var previousRoll = GetPreviousRoll();
            var nodeRoll     = GetNodeRoll();

            rollCount = nodeRoll.Count;
            return(Rolls.PerformRollCombination(previousRoll.Value, Operation, nodeRoll.Value, previousRoll.Count));
        }
Exemplo n.º 13
0
 public DiceRollBatch(Dice dice, int amount)
 {
     Dice   = dice;
     amount = Ensure(amount);
     Amount = amount;
     Rolls  = RandomProvider.Instance.RollMany(Dice, amount);
     Result = Rolls.Tally();
     Max    = (ulong)(Amount * Dice.Sides);
 }
Exemplo n.º 14
0
 public ActionResult Put(int id, [FromBody] Rolls cat)
 {
     if (id != cat.Id)
     {
         return(BadRequest());
     }
     _Data.Entry(cat).State = EntityState.Modified;
     _Data.SaveChanges();
     return(Ok());
 }
Exemplo n.º 15
0
        public void TrailingLuckyTens()
        {
            // With helper method:
            var rolls = Rolls.SpawnContinuously(Dice.D10.Roll(2), roll => roll == 9 || roll == 10, () => Dice.D10.Roll(1));

            // Manual way would be:
            var d10 = new Die(10);

            rolls = PropagateLuckyRolls(d10.Roll(2));
        }
Exemplo n.º 16
0
        async void attackRoll2_Clicked(System.Object sender, System.EventArgs e)
        {
            Random rand         = new Random();
            int    randomRoll   = rand.Next(1, 21);
            int    randomDexMod = Convert.ToInt32(dexMod.Text);
            int    randomStrMod = Convert.ToInt32(strMod.Text);


            if (w2attackBonus.Text == null)
            {
                w2attackBonus.Text = 0.ToString();
            }

            int randomAttMod = Convert.ToInt32(w2attackBonus.Text);
            int dexAttRoll   = randomRoll + randomDexMod + randomAttMod;
            int strAttRoll   = randomRoll + randomStrMod + randomAttMod;

            if (dexSwitch.IsToggled)
            {
                rollOutput.Text = dexAttRoll.ToString();
            }
            else
            {
                rollOutput.Text = strAttRoll.ToString();
            }

            if (randomRoll == 20)
            {
                criticalRoll = "HIT";
                await DisplayAlert("CRIT", "YOU MADE A CRITICAL HIT", "OK");
            }
            if (randomRoll == 1)
            {
                criticalRoll = "MISS";
                await DisplayAlert("MISS", "YOU MADE A CRITICAL MISS", "OK");
            }

            Rolls roll = new Rolls()
            {
                RollNum     = Convert.ToInt32(rollOutput.Text),
                RollType    = "Attack2",
                CharacterId = character.Id,
                CampaignId  = character.CampaignId,
                UserId      = character.UserId,
                CritHit     = criticalRoll
            };

            await App.MobileService.GetTable <Rolls>().InsertAsync(roll);

            character.CharRoll     = Convert.ToInt32(rollOutput.Text);
            character.CharRollType = "Attack2";
            character.CharCritHit  = criticalRoll;

            await App.MobileService.GetTable <Characters>().UpdateAsync(character);
        }
Exemplo n.º 17
0
        public void ModifyRollsWithEach()
        {
            var rolls = new double[] { 5, 10, 15, 20 };

            var actual = Rolls.ApplyOperation(rolls, DiceOperation.EachPlus, 5).ToArray();

            CollectionAssert.AreEqual(rolls.Select(roll => roll + 5), actual, "Plus to each roll was applied incorrectly to rolls.");

            actual = Rolls.ApplyOperation(rolls, DiceOperation.EachMinus, 10).ToArray();
            CollectionAssert.AreEqual(rolls.Select(roll => roll - 10), actual, "Minus to each roll was applied incorrectly to rolls.");
        }
Exemplo n.º 18
0
        public void ModifyEmptyWithEach()
        {
            var emptyRolls = Enumerable.Empty <double>().ToArray();

            var actual = Rolls.ApplyOperation(emptyRolls, DiceOperation.EachPlus, 10).ToArray();

            CollectionAssert.AreEqual(new double[0], actual, "Plus to each roll was applied incorrectly to empty rolls.");

            actual = Rolls.ApplyOperation(emptyRolls, DiceOperation.EachMinus, 10).ToArray();
            CollectionAssert.AreEqual(new double[0], actual, "Minus to each roll was applied incorrectly to empty rolls.");
        }
Exemplo n.º 19
0
        public IModifier Add(IModifier other)
        {
            Assert.IsNotNull(other);
            int             sumBase  = BaseMod + other.BaseMod;
            List <RollType> sumRolls = Rolls.ToList();
            Rng             rngToUse = Rng ?? other.Rng;

            sumRolls.AddRange(other.Rolls);

            return(new Modifier(rngToUse, sumRolls, sumBase));
        }
Exemplo n.º 20
0
        private bool IsSpare()
        {
            if (Rolls.Count < 2)
            {
                return(false);
            }

            var lastTwoRolls = Rolls.Reverse().Take(2);

            return(NumPins == lastTwoRolls.Sum(r => r.Pins) &&
                   !lastTwoRolls.Any(r => r.IsStrike));
        }
Exemplo n.º 21
0
        public virtual void Roll(int pins)
        {
            if (pins < 0 || pins > NumPins)
            {
                throw new Exception("Can only roll 0-10 pins");
            }

            var roll = new Roll(pins);

            Rolls.Add(roll);
            roll.IsSpare = IsSpare();
        }
Exemplo n.º 22
0
    void InitialiseData()
    {
        // http://www.momentsbymelaniect.com/wp-content/uploads/2013/02/bowling-score.jpg
        testArray[0] = new Rolls();
        testArray[0].pinFallArray = new int[] { 1, 6, 6, 3, 5, 4, 5, 3, 7, 0, 10, 7, 1 };
        testArray[0].totalScore   = 66;       // Player D to frame 7 only

        // http://www.momentsbymelaniect.com/wp-content/uploads/2013/02/bowling-score.jpg
        testArray[1] = new Rolls();
        testArray[1].pinFallArray = new int[] { 1, 6, 6, 3, 5, 4, 5, 3, 7, 0, 10, 7, 1, 10, 4, 5, 3, 7, 7 };
        testArray[1].totalScore   = 111;       // Player D, full game

        // Perfect score
        testArray[2] = new Rolls();
        testArray[2].pinFallArray = new int[] { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 };
        testArray[2].totalScore   = 300;

        // Source http://sunycortlandedu255.pbworks.com/f/1322793288/Bowling%20Score%20Sheet.jpg
        testArray[3] = new Rolls();
        testArray[3].pinFallArray = new int[] { 7, 2, 8, 0, 10, 10, 10, 10, 9, 0, 7, 1, 1, 9, 7, 0 };
        testArray[3].totalScore   = 166;       // First M player

        // Source http://sunycortlandedu255.pbworks.com/f/1322793288/Bowling%20Score%20Sheet.jpg
        testArray[4] = new Rolls();
        testArray[4].pinFallArray = new int[] { 7, 3, 10, 8, 1, 7, 0, 8, 1, 8, 0, 10, 9, 0, 10, 7, 2 };
        testArray[4].totalScore   = 128;       // Player "T"

        // Trying to log ILLEGAL 3rd bowl in 10th frame
        testArray[5] = new Rolls();
        testArray[5].pinFallArray = new int[] { 7, 3, 10, 8, 1, 7, 0, 8, 1, 8, 0, 10, 9, 0, 10, 7, 2, 3 };
        testArray[5].totalScore   = 128;

        //http://www.teendrama.com/dens/journal/2006/thanksg06/bowling_score1.jpg
        testArray[6] = new Rolls();
        testArray[6].pinFallArray = new int[] { 3, 7, 0, 0, 9, 0, 10, 8, 0, 1, 5, 9, 1, 8, 0, 3, 0, 1, 6 };
        testArray[6].totalScore   = 87;       // Dennis

        //http://www.teendrama.com/dens/journal/2006/thanksg06/bowling_score1.jpg
        testArray[7] = new Rolls();
        testArray[7].pinFallArray = new int[] { 0, 10, 6, 0, 5, 5, 9, 0, 3, 2, 10, 7, 2, 9, 0, 1, 8, 7 };
        testArray[7].totalScore   = 108;       // Mike

        //http://www.teendrama.com/dens/journal/2006/thanksg06/bowling_score1.jpg
        testArray[8] = new Rolls();
        testArray[8].pinFallArray = new int[] { 0, 0, 7, 3, 0, 8, 0, 7, 0, 0, 1, 6, 7, 0, 6, 0, 4, 0 };
        testArray[8].totalScore   = 49;       // Becca

        // Should disallow final 2 bowls
        testArray[9] = new Rolls();
        testArray[9].pinFallArray = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
        testArray[9].totalScore   = 87;
    }
Exemplo n.º 23
0
    void InitialiseData()
    {
        // http://www.momentsbymelaniect.com/wp-content/uploads/2013/02/bowling-score.jpg
        testArray[0] = new Rolls ();
        testArray[0].pinFallArray = new int[] {1,6, 6,3, 5,4, 5,3, 7,0, 10,7,1};
        testArray[0].totalScore = 66; // Player D to frame 7 only

        // http://www.momentsbymelaniect.com/wp-content/uploads/2013/02/bowling-score.jpg
        testArray[1] = new Rolls ();
        testArray[1].pinFallArray = new int[] {1,6, 6,3, 5,4, 5,3, 7,0, 10, 7,1, 10, 4,5, 3,7,7};
        testArray[1].totalScore = 111; // Player D, full game

        // Perfect score
        testArray[2] = new Rolls ();
        testArray[2].pinFallArray = new int[] {10,10,10,10,10,10,10,10,10,10,10,10};
        testArray[2].totalScore = 300;

        // Source http://sunycortlandedu255.pbworks.com/f/1322793288/Bowling%20Score%20Sheet.jpg
        testArray[3] = new Rolls ();
        testArray[3].pinFallArray = new int[] {7,2, 8,0, 10, 10, 10, 10, 9,0, 7,1, 1,9, 7,0};
        testArray[3].totalScore = 166; // First M player

        // Source http://sunycortlandedu255.pbworks.com/f/1322793288/Bowling%20Score%20Sheet.jpg
        testArray[4] = new Rolls ();
        testArray[4].pinFallArray = new int[] {7,3, 10, 8,1, 7,0, 8,1, 8,0, 10, 9,0, 10, 7,2};
        testArray[4].totalScore = 128; // Player "T"

        // Trying to log ILLEGAL 3rd bowl in 10th frame
        testArray[5] = new Rolls ();
        testArray[5].pinFallArray = new int[] {7,3, 10, 8,1, 7,0, 8,1, 8,0, 10, 9,0, 10, 7,2,3};
        testArray[5].totalScore = 128;

        //http://www.teendrama.com/dens/journal/2006/thanksg06/bowling_score1.jpg
        testArray[6] = new Rolls ();
        testArray[6].pinFallArray = new int[] {3,7, 0,0, 9,0, 10, 8,0, 1,5, 9,1, 8,0, 3,0, 1,6};
        testArray[6].totalScore = 87; // Dennis

        //http://www.teendrama.com/dens/journal/2006/thanksg06/bowling_score1.jpg
        testArray[7] = new Rolls ();
        testArray[7].pinFallArray = new int[] {0, 10, 6,0, 5,5, 9,0, 3,2, 10, 7,2, 9,0, 1,8, 7};
        testArray[7].totalScore = 108; // Mike

        //http://www.teendrama.com/dens/journal/2006/thanksg06/bowling_score1.jpg
        testArray[8] = new Rolls ();
        testArray[8].pinFallArray = new int[] {0,0, 7,3, 0,8, 0,7, 0,0, 1,6, 7,0, 6,0, 4,0};
        testArray[8].totalScore = 49; // Becca

        // Should disallow final 2 bowls
        testArray[9] = new Rolls ();
        testArray[9].pinFallArray = new int[] {0,0,0,0,0,0,0,0,0,0,0,0};
        testArray[9].totalScore = 87;
    }
Exemplo n.º 24
0
        public void Roll(Dice dice, IDiceRoller diceRoller)
        {
            _rolled = true;

            for (int i = 0; i < dice.Number; i++)
            {
                Rolls.Add(diceRoller.Roll(dice.Type));
                Total += Rolls[i];
            }

            Total += dice.Modifier;
            WriteRollString(dice);
        }
Exemplo n.º 25
0
 private Crit CheckIfCrit()
 {
     if (Rolls.Max() == 20 && DiceType == 20 && VantageType != VantageType.Disadvantage)
     {
         return(Crit.CriticalSuccess);
     }
     else if (Rolls.Min() == 1 && DiceType == 20 && VantageType != VantageType.Advantage)
     {
         return(Crit.CriticalFail);
     }
     else
     {
         return(Crit.False);
     }
 }
Exemplo n.º 26
0
        public async Task PBDBGRoll()
        {
            Rolls rolls = Rolls.Create();

            StringBuilder diceRolled = new StringBuilder();

            foreach (int i in rolls.DiceRolled.SkipLast(1))
            {
                diceRolled.Append(i + ",");
            }

            diceRolled.Append(rolls.DiceRolled.Last());

            String rollOutput = string.Format("{0}|+{1}|++{2}|-{3}|--{4}", rolls.NormalRoll, rolls.AdvantageRoll, rolls.GreatAdvantageRoll, rolls.DisadvantageRoll, rolls.GreatDisadvantageRoll);

            await ReplyAsync(Context.User.Mention + ", you rolled: " + diceRolled.ToString() + Environment.NewLine + rollOutput);
        }
Exemplo n.º 27
0
        public void ModifyEmptyWithTotals()
        {
            var emptyRolls = Enumerable.Empty <double>().ToArray();

            var actual = Rolls.ApplyOperation(emptyRolls, DiceOperation.Plus, 10).ToArray();

            CollectionAssert.AreEqual(new double[] { 10 }, actual, "Plus was applied incorrectly to empty rolls.");

            actual = Rolls.ApplyOperation(emptyRolls, DiceOperation.Minus, 10).ToArray();
            CollectionAssert.AreEqual(new double[] { -10 }, actual, "Minus was applied incorrectly to empty rolls.");

            actual = Rolls.ApplyOperation(emptyRolls, DiceOperation.Multiply, 10).ToArray();
            CollectionAssert.AreEqual(new double[0], actual, "Multiply was applied incorrectly to empty rolls.");

            actual = Rolls.ApplyOperation(emptyRolls, DiceOperation.Divide, 10).ToArray();
            CollectionAssert.AreEqual(new double[0], actual, "Divide was applied incorrectly to empty rolls.");
        }
Exemplo n.º 28
0
        public void ModifyRolls()
        {
            var rolls = new double[] { -10, 0, 10 };

            var actual = Rolls.ApplyOperation(rolls, DiceOperation.Plus, 5).ToArray();

            CollectionAssert.AreEqual(new double[] { -5, 0, 10 }, actual, "Plus was applied incorrectly to rolls.");

            actual = Rolls.ApplyOperation(rolls, DiceOperation.Minus, 10).ToArray();
            CollectionAssert.AreEqual(new double[] { -20, 0, 10 }, actual, "Minus was applied incorrectly to rolls.");

            actual = Rolls.ApplyOperation(rolls, DiceOperation.Divide, 5).ToArray();
            CollectionAssert.AreEqual(new double[] { -2, 0, 2 }, actual, "Divide was applied incorrectly to rolls.");

            actual = Rolls.ApplyOperation(rolls, DiceOperation.Multiply, 4).ToArray();
            CollectionAssert.AreEqual(new double[] { -40, 0, 40 }, actual, "Multiply was applied incorrectly to rolls.");
        }
Exemplo n.º 29
0
        async void dmgRoll2_Clicked(System.Object sender, System.EventArgs e)
        {
            Random rand = new Random();
            string dice = w2dmg.Text;

            string[] splitDice = dice.Split('d');
            int      numDice   = Convert.ToInt32(splitDice[0]);
            int      sizeDice  = Convert.ToInt32(splitDice[1]);

            //This is the damage calculated with weapon before MODS
            int dmgNoMod = numDice * rand.Next(1, sizeDice + 1);

            int randomDexMod = Convert.ToInt32(dexMod.Text);
            int randomStrMod = Convert.ToInt32(strMod.Text);

            int dexDmgRoll = dmgNoMod + randomDexMod;
            int strDmgRoll = dmgNoMod + randomStrMod;

            if (dexSwitch.IsToggled)
            {
                rollOutput.Text = dexDmgRoll.ToString();
            }
            else
            {
                rollOutput.Text = strDmgRoll.ToString();
            }

            Rolls roll = new Rolls()
            {
                RollNum     = Convert.ToInt32(rollOutput.Text),
                RollType    = "Damage2",
                CharacterId = character.Id,
                CampaignId  = character.CampaignId,
                UserId      = character.UserId
            };

            await App.MobileService.GetTable <Rolls>().InsertAsync(roll);

            character.CharRoll     = Convert.ToInt32(rollOutput.Text);
            character.CharRollType = "Damage2";

            await App.MobileService.GetTable <Characters>().UpdateAsync(character);
        }
Exemplo n.º 30
0
 public void ControllInput(Rolls frame)
 {
     if (frame.RollOne < 0 || frame.RollOne > 10)
     {
         throw new ArgumentException("The number should be between 0 - 10");
     }
     if (frame.RollTwo < 0 || frame.RollTwo > 10)
     {
         throw new ArgumentException("The number should be between 0 - 10");
     }
     if (frame.RollThree < 0 || frame.RollThree > 10)
     {
         throw new ArgumentException("The number should be between 0 - 10");
     }
     if (frame.RollOne + frame.RollTwo > 10)
     {
         throw new ArgumentException("Roll 1 and 2 should be 10");
     }
 }
Exemplo n.º 31
0
        public void Free()
        {
            if (Rolls != null)
            {
                foreach (var r in Rolls.Values.Where(r => r.HasValue))
                {
                    r.Value.Free();
                }

                Rolls.Clear();
                Rolls = null;
            }

            if (Item != null && !Item.Movable)
            {
                Item.Movable = true;
            }

            Item = null;
        }