public void SumTheStrong(RollModel roll)
        {
            int Lowest;

            for (int i = 0; i < roll.numOfStats; i++)
            {
                Lowest                    = roll.Rolls[i, 0];
                roll.SumOfRolls[i]        = 0;
                roll.LowestRollIndexes[i] = 0;
                for (int j = 0; j < roll.numOfRolls; j++)
                {
                    if (Lowest > roll.Rolls[i, j])
                    {
                        Lowest = roll.Rolls[i, j];
                        roll.LowestRollIndexes[i] = j;
                    }
                }
                for (int j = 0; j < roll.numOfRolls; j++)
                {
                    if (j != roll.LowestRollIndexes[i])
                    {
                        roll.SumOfRolls[i] += roll.Rolls[i, j];
                    }
                }
            }
        }
        public void CheckReroll(RollModel roll)
        {
            int modifierSum = 0, Highest = 0, currentCheckedSum;

            for (int i = 0; i < roll.numOfStats; i++)
            {
                if (roll.SumOfRolls[i] > Highest)
                {
                    Highest = roll.SumOfRolls[i];
                }

                currentCheckedSum  = (roll.SumOfRolls[i] % 2 == 0) ? roll.SumOfRolls[i] : roll.SumOfRolls[i] - 1;
                currentCheckedSum -= 10;
                modifierSum        = currentCheckedSum / 2;
            }

            roll.CanReroll = ((modifierSum < 0) || (Highest <= 13)) ? true : false;
        }
Пример #3
0
        private void HandleAttitude(MsgOfAttitude msg)
        {
            DateTime dt = new DateTime(msg.year, msg.month, msg.day, msg.hour, msg.minute, (int)msg.second);

            if (rollPoints.Count > 3600)
            {
                rollPoints.RemoveRange(0, 3600);
                rollModel.Axes[0].Minimum = DateTimeAxis.ToDouble(DateTime.Now);
                rollModel.Axes[0].Maximum = DateTimeAxis.ToDouble(DateTime.Now.AddMinutes(60));
            }
            if (yawPoints.Count > 3600)
            {
                yawPoints.RemoveRange(0, 3600);
                yawModel.Axes[0].Minimum = DateTimeAxis.ToDouble(DateTime.Now);
                yawModel.Axes[0].Maximum = DateTimeAxis.ToDouble(DateTime.Now.AddMinutes(60));
            }
            if (pitchPoints.Count > 3600)
            {
                pitchPoints.RemoveRange(0, 3600);
                pitchModel.Axes[0].Minimum = DateTimeAxis.ToDouble(DateTime.Now);
                pitchModel.Axes[0].Maximum = DateTimeAxis.ToDouble(DateTime.Now.AddMinutes(60));
            }

            Roll = Math.Round(msg.roll, 2);
            rollPoints.Add(new DataPoint(DateTimeAxis.ToDouble(dt), Roll));
            LineSeries rollSerial = new LineSeries()
            {
                Title = "滚动角"
            };

            rollSerial.Points.AddRange(rollPoints);

            RollModel.Series.Clear();
            RollModel.Series.Add(rollSerial);
            RollModel.InvalidatePlot(true);  //刷新

            Yaw = Math.Round(msg.yaw, 2);
            yawPoints.Add(new DataPoint(DateTimeAxis.ToDouble(dt), Yaw));
            LineSeries yawSerial = new LineSeries()
            {
                Title = "偏航角"
            };

            yawSerial.Points.AddRange(yawPoints);

            YawModel.Series.Clear();
            YawModel.Series.Add(yawSerial);
            YawModel.InvalidatePlot(true);  //刷新

            Pitch = Math.Round(msg.pitch, 2);
            pitchPoints.Add(new DataPoint(DateTimeAxis.ToDouble(dt), Pitch));
            LineSeries pitchSerial = new LineSeries()
            {
                Title = "俯仰角"
            };

            pitchSerial.Points.AddRange(pitchPoints);

            PitchModel.Series.Clear();
            PitchModel.Series.Add(pitchSerial);
            PitchModel.InvalidatePlot(true);  //刷新
        }