Beispiel #1
0
    // Randomizes the type of die we are
    // e.g. Brain, Shotgun, Footprints
    public void Roll()
    {
        int roll = UnityEngine.Random.Range(1, 7);

        if (roll < 4 && IsGreen)
        {
            m_Type = DieType.Brain;
            return;
        }

        if (roll < 3 && IsYellow)
        {
            m_Type = DieType.Brain;
            return;
        }

        if (roll < 2 && IsRed)
        {
            m_Type = DieType.Brain;
            return;
        }

        if (roll < 5)
        {
            m_Type = DieType.Shotgun;
            return;
        }

        m_Type = DieType.Footprints;
    }
        private void Populate_Charges(string DieType)
        {
            DieType dt = (DieType)System.Enum.Parse(typeof(DieType), DieType);

            List <DieCharge> DC_List = parent.Charge_Dictionary[dt];

            dataGridView1.Rows.Clear();

            foreach (DieCharge DC in DC_List)
            {
                dataGridView1.Rows.Add(DC.Name, DC.GetFormula());
            }

            // Add empty row
            dataGridView1.Rows.Add();

            // Remove last delete button
            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                DataGridViewCellStyle style = new DataGridViewCellStyle();
                style.Padding      = new Padding(0, 0, (row == dataGridView1.Rows[dataGridView1.Rows.Count - 1] ? 1000 : 0), 0);
                style.BackColor    = Color.FromArgb(76, 76, 76);
                style.ForeColor    = Color.White;
                row.Cells[2].Style = style;
            }
        }
        private void Save_Charges(string dieType_)
        {
            DieType          dieType = (DieType)System.Enum.Parse(typeof(DieType), dieType_);
            List <DieCharge> DC_List = new List <DieCharge>();

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                if (dataGridView1.Rows.IndexOf(row) < dataGridView1.Rows.Count)
                {
                    try
                    {
                        DieCharge DC = new DieCharge(dieType);
                        DC.Name    = row.Cells[0].Value.ToString();
                        DC.Formula = row.Cells[1].Value.ToString();

                        DC_List.Add(DC);
                    }
                    catch
                    {
                    }
                }
            }

            parent.Charge_Dictionary[dieType] = DC_List;
        }
        public static int GetMedianValue(this DieType die)
        {
            switch (die)
            {
            case DieType.d3:
            { return(2); }

            case DieType.d4:
            { return(3); }

            case DieType.d6:
            { return(4); }

            case DieType.d8:
            { return(5); }

            case DieType.d10:
            { return(6); }

            case DieType.d12:
            { return(7); }

            case DieType.d20:
            { return(11); }

            case DieType.d100:
            { return(51); }

            default:
            { return(0); }
            }
        }
        private string Get_Die_Prefix(DieType dt)
        {
            switch (dt)
            {
            case DieType.Solid:
                return("DI");

            case DieType.Hollow:
                return("HO");

            case DieType.Feeder:
                return("FE");

            case DieType.Bolster:
                return("BO");

            case DieType.Subbolster:
                return("SB");

            case DieType.Ring:
                return("RI");

            case DieType.Backer:
                return("BA");

            default:
                return("DI");
            }
        }
Beispiel #6
0
        public static int ToFacetCount(this DieType facetCount)
        {
            switch (facetCount)
            {
            case DieType.D4:
                return(4);

            case DieType.D6:
                return(6);

            case DieType.D8:
                return(8);

            case DieType.D10:
                return(10);

            case DieType.D12:
                return(12);

            case DieType.D20:
                return(20);

            case DieType.D100:
                return(100);

            default:
                throw new ArgumentException("Unsupported DieType");
            }
        }
        public int Roll(DieType dieSize, int count, int modifier)
        {
            var rng  = new Random();
            var roll = rng.Next((int)dieSize);

            return((count * roll) + modifier);
        }
        public static int ToInt(this DieType dieType)
        {
            switch (dieType)
            {
            case DieType.D4:
                return(4);

            case DieType.D6:
                return(6);

            case DieType.D8:
                return(8);

            case DieType.D10:
                return(10);

            case DieType.D12:
                return(12);

            case DieType.D20:
                return(20);

            default:
                throw new ArgumentOutOfRangeException(nameof(dieType), dieType, null);
            }
        }
        public static int GetMaxValue(this DieType die)
        {
            switch (die)
            {
            case DieType.d3:
            { return(3); }

            case DieType.d4:
            { return(4); }

            case DieType.d6:
            { return(6); }

            case DieType.d8:
            { return(8); }

            case DieType.d10:
            { return(10); }

            case DieType.d12:
            { return(12); }

            case DieType.d20:
            { return(20); }

            case DieType.d100:
            { return(100); }

            default:
            { return(0); }
            }
        }
Beispiel #10
0
 public DieCharge(DieType dt)
 {
     Dietype  = dt;
     Name     = "";
     Notes    = "";
     Quantity = 0;
     Formula  = "";
 }
        public void OnClassChanged(Class class_)
        {
            _dieType          = CharacterSheetModel.GetHitDieTypeByClass(class_);
            dieAvailable.text = _dieType.ToString();

            // Invalidate any previous rolls
            dieResult.text = InvalidDieResult;
        }
Beispiel #12
0
    public override void Die(DieType type = DieType.explode)
    {
        isAlive = false;
        CharacterDeath death = new CharacterDeath {
        };

        EventAggregator.Publish(death);
    }
        private static void CheckRoll(DiceRollManager manager, DieType die, ushort upperBound)
        {
            //Act
            var rolls = manager.RollDie(die, 1000);

            //Assert
            rolls.ForEach(roll => roll.RollValue.Should().BeInRange(0, upperBound));
        }
Beispiel #14
0
        /// <summary>
        /// Returns the values from the number of specified dice, of the specified type.  Results are sorted in the specified sort order.
        /// </summary>
        /// <param name="dieType">The type of die rolled</param>
        /// <param name="numberOfDice">The number of dice to be rolled</param>
        /// <param name="sortOrder">The order to sort the results in the returned array</param>
        /// <returns>An array of integers representing the values of the dice rolls</returns>
        public static int[] Roll(DieType dieType, int numberOfDice, SortOrder sortOrder)
        {
            int[] results = Roll(dieType, numberOfDice);

            results = Sort(results, sortOrder);

            return(results);
        }
Beispiel #15
0
 public PharoahDie NewDie(DieType dieType)
 {
     PharoahDie newDie = GameObject.Instantiate(prefabDice[(int)dieType]);
     if (newDie.isSetDie()) {
         newDie.MoveToSetDieArea();
     }
     return newDie;
 }
 public void AddHitPoints(DieType hitDieType, CharacterCoreAttribute statisticSource, int additionalHitPoints, bool enforceMinimumGain = true)
 {
     if (enforceMinimumGain)
     {
         additionalHitPoints = Math.Min(hitDieType.GetMedianValue(), additionalHitPoints);
     }
     this.StatisticBase = this.StatisticBase + additionalHitPoints + statisticSource.StatisticValue;
 }
Beispiel #17
0
        public static int GetRandomHPDieTotal(int level, DieType type)
        {
            int total = 0;

            for (int i = 1; i <= level; i++)
                total += GetRandomNumber(type);

            return total;
        }
        private void AddRolls(DieType dieType, uint count, List <DiceRolls> diceRolls)
        {
            var rollRequest = new Dictionary <string, uint> {
                { dieType.ToString(), count }
            };
            var result = _manager.RollDice(rollRequest);

            diceRolls.Add(result);
        }
Beispiel #19
0
        /// <summary>
        /// Returns the value from a single rolled die of the specified type
        /// </summary>
        /// <param name="dieType">The type of die rolled</param>
        /// <returns>An integer representing the value of a dice roll</returns>
        public static int RollDie(DieType dieType)
        {
            int result = 0;
            int max    = (int)dieType;

            result = GetRandomNumber(MinimumDieValue, max);

            return(result);
        }
Beispiel #20
0
    public PharoahDie NewDie(DieType dieType)
    {
        PharoahDie newDie = GameObject.Instantiate(prefabDice[(int)dieType]);

        if (newDie.isSetDie())
        {
            newDie.MoveToSetDieArea();
        }
        return(newDie);
    }
Beispiel #21
0
 public Weapon(string label, DieType damageDie, DamageTypes damageType, int dieNum, int rangeMin, int rangeMax, WeaponProperties[] weaponProps)
 {
     Label       = label;
     DamageDie   = damageDie;
     DamageType  = damageType;
     DieNum      = dieNum;
     RangeMin    = rangeMin;
     RangeMax    = rangeMax;
     WeaponProps = weaponProps;
 }
Beispiel #22
0
        public void ToFacetCount_Returns_Correct_Value(DieType die, int expected)
        {
            //Arrange

            //Act
            var actual = die.ToFacetCount();

            //Assert
            actual.Should().Be(expected);
        }
Beispiel #23
0
        public void ToDieType_Returns_Correct_Value(int facetCount, DieType expected)
        {
            //Arrange

            //Act
            var actual = facetCount.ToDieType();

            //Assert
            actual.Should().Be(expected);
        }
        // Return the next biggest
        public baseCharges getDiaThk(double refDia, double refThk, DieType dt, bool isOddDimensions = true)
        {
            if (refDia * refThk == 0) // If either dimensions are based 0, call for quote
            {
                return(null);
            }
            baseCharges Ref_Base = parent.baseCharge_List.FirstOrDefault(x => x.Diameter * (isOddDimensions ? 1 : MetricFactor) >= refDia - (parent.isMetric ? parent.metricTolerance : 0) && x.Thickness * (isOddDimensions ? 1 : MetricFactor) >= refThk - (parent.isMetric ? parent.metricTolerance : 0) && x.Prefix == parent.Get_Die_Prefix(dt));

            return(Ref_Base);
        }
Beispiel #25
0
    public static int RollDie(DieType die, int numberOfDie)
    {
        int value = 0;

        for (int i = 0; i < numberOfDie; i++)
        {
            value += RollDie(die);
        }

        return value;
    }
        public ActionResult <List <Die> > GetSingle(DieType dieType, uint count)
        {
            if (count == 0)
            {
                return(BadRequest("Invalid Count"));
            }

            var result = _manager.RollDie(dieType, count);

            return(result);
        }
    public static int RollDie(DieType die, int numberOfDie)
    {
        int value = 0;

        for (int i = 0; i < numberOfDie; i++)
        {
            value += RollDie(die);
        }

        return(value);
    }
Beispiel #28
0
        /// <summary>
        /// Returns the values from the number of specified dice, of the specified type
        /// </summary>
        /// <param name="dieType">The type of die rolled</param>
        /// <param name="numberOfDice">The number of dice to be rolled</param>
        /// <returns>An array of integers representing the values of the dice rolls</returns>
        public static int[] Roll(DieType dieType, int numberOfDice)
        {
            int[] results = new int[numberOfDice];

            for (int i = 0; i < numberOfDice; i++)
            {
                results[i] = RollDie(dieType);
            }

            return(results);
        }
        // load file
        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog file = new OpenFileDialog();

            file.Title       = "Import charges file";
            file.Multiselect = false;
            file.DefaultExt  = ".ecf";
            file.Filter      = "Exco Charges File (*.ecf)|*.ecf";

            if (file.ShowDialog() == DialogResult.OK)
            {
                Grey_Out();
                Application.DoEvents();

                if (File.Exists(file.FileName))
                {
                    List <string> Lines = new List <string>();

                    var text = File.ReadAllText(file.FileName).Trim();
                    text  = parent.Decrypt_Line(text);
                    Lines = text.Split(new string[] { Environment.NewLine }, StringSplitOptions.None).ToList();// Save customers

                    // Create new instance
                    parent.Charge_Dictionary = new Dictionary <DieType, List <DieCharge> >();

                    foreach (string line in Lines)
                    {
                        if (line.StartsWith("DC"))
                        {
                            DieType dieType = (DieType)System.Enum.Parse(typeof(DieType), parent.Parse_Line_Information(line, "D"));

                            // Add entry if does not exist
                            if (!parent.Charge_Dictionary.ContainsKey(dieType))
                            {
                                parent.Charge_Dictionary.Add(dieType, new List <DieCharge>());
                            }

                            parent.Charge_Dictionary[dieType].Add(new DieCharge(dieType)
                            {
                                Name    = parent.Parse_Line_Information(line, "N"),
                                Formula = parent.Parse_Line_Information(line, "F")
                            });
                        }
                    }

                    Populate_Charges(dieTypes.Text);
                }
                Grey_In();
            }
        }
Beispiel #30
0
    public void SetDieType(DieType die)
    {
        dieType = die;

        if (dieType == DieType.ATTACKER)
        {
            sprRend.color = Color.red;
        }

        else
        {
            sprRend.color = Color.white;
        }
    }
        internal void SetTypeByDie(DieType dieType)
        {
            switch (dieType.ToString())
            {
                case "d8":
                    this.comboBox1.SelectedIndex = 0;
                    break;

                case "d10":
                    this.comboBox1.SelectedIndex = 1;
                    break;

                case "d12":
                    this.comboBox1.SelectedIndex = 2;
                    break;
            }
        }
Beispiel #32
0
        internal void SetTypeByDie(DieType dieType)
        {
            switch (dieType.ToString())
            {
            case "d8":
                this.comboBox1.SelectedIndex = 0;
                break;

            case "d10":
                this.comboBox1.SelectedIndex = 1;
                break;

            case "d12":
                this.comboBox1.SelectedIndex = 2;
                break;
            }
        }
Beispiel #33
0
        /// <summary>
        /// Spawn in dead center (dialog convection)
        /// </summary>
        /// <param name="_parent"></param>
        /// <param name="g"></param>
        /// <param name="s"></param>
        public Extra_Charges(Main _parent, List <DieCharge> ref_list, DieType dt, double BasePrice, Point g = new Point(), Size s = new Size())
        {
            Cur_DieType         = dt;
            Cur_BasePrice       = BasePrice;
            this.AutoScaleMode  = AutoScaleMode.Font; InitializeComponent();
            this.DoubleBuffered = true;
            this.SetStyle(ControlStyles.ResizeRedraw, true);
            parent = _parent;
            Set_Form_Color(parent.Frame_Color);
            Transferred_List = ref_list;
            this.Location    = new Point(g.X + 10, g.Y + 10);

            // Create charge list
            foreach (DieCharge dC in parent.Charge_Dictionary[dt])
            {
                Ref_List.Add(dC.Clone());
            }
        }
Beispiel #34
0
 private void LoadDice(int numOfDice, DieType type)
 {
     for (int i = 0; i < numOfDice; i++)
     {
         if (type == DieType.Green)
         {
             _dice.Add(new GreenDie());
         }
         else if (type == DieType.Yellow)
         {
             _dice.Add(new YellowDie());
         }
         else if (type == DieType.Red)
         {
             _dice.Add(new RedDie());
         }
     }
 }
Beispiel #35
0
 public void AddType(long offset, DieType type)
 {
     types.Add (offset, type);
 }
Beispiel #36
0
            protected override TargetType CreateType()
            {
                reference = GetReference (type_offset);
                if (reference == null) {
                    Console.WriteLine (
                        "UNKNOWN POINTER: {0}",
                        comp_unit.RealStartOffset + type_offset);
                    return null;
                }

                TargetType ref_type = reference.ResolveType ();
                if (ref_type == null)
                    return null;

                #if false
                /* not sure we want this */
                if (ref_type.TypeHandle == typeof (char))
                    return new NativeStringType (byte_size);
                #endif

                string name;
                if (Name != null)
                    name = Name;
                else
                    name = String.Format ("{0} []", ref_type.Name);

                List<DieSubrangeType> list = new List<DieSubrangeType> ();

                foreach (Die die in Children) {
                    DieSubrangeType subrange = die as DieSubrangeType;
                    if (subrange != null)
                        list.Add (subrange);
                }

                TargetArrayBounds bounds;
                if (list.Count == 0)
                    bounds = TargetArrayBounds.MakeUnboundArray ();
                else if ((list.Count == 1) && (list [0].UpperBound == null))
                    bounds = TargetArrayBounds.MakeUnboundArray ();
                else if ((list.Count == 1) && ((list [0].LowerBound ?? 0) == 0))
                    bounds = TargetArrayBounds.MakeSimpleArray ((int) list [0].UpperBound + 1);
                else {
                    int[] lower = new int [list.Count];
                    int[] upper = new int [list.Count];

                    for (int i = 0; i < list.Count; i++) {
                        lower [i] = list [i].LowerBound ?? 0;
                        upper [i] = (int) list [i].UpperBound;
                    }

                    bounds = TargetArrayBounds.MakeMultiArray (lower, upper);
                }

                return new NativeArrayType (
                    language, name, ref_type, bounds, byte_size);
            }
Beispiel #37
0
            protected override TargetType CreateType()
            {
                reference = GetReference (type_offset);
                if (reference == null)
                    return null;

                return reference.ResolveType ();
            }
Beispiel #38
0
            protected TargetType ResolveType(DieStructureType die_struct)
            {
                if ((TypeOffset == 0) || (Name == null))
                    return null;

                if ((location == null) && !die_struct.IsUnion)
                    return null;

                type_die = comp_unit.GetType (TypeOffset);
                if (type_die == null)
                    return null;

                if ((location != null) && !read_location ())
                    return null;

                type = type_die.ResolveType ();
                return type;
            }
Beispiel #39
0
            protected override TargetType CreateType()
            {
                TargetType ref_type;
                if (type_offset == 0)
                    ref_type = language.VoidType;
                else {
                    reference = GetReference (type_offset);
                    if (reference == null) {
                        Console.WriteLine (
                            "UNKNOWN POINTER: {0}",
                            comp_unit.RealStartOffset + type_offset);
                        return null;
                    }

                    ref_type = reference.ResolveType ();
                    if (ref_type == null)
                        return null;
                }

                TargetFundamentalType fundamental = ref_type as TargetFundamentalType;
                if ((fundamental != null) && (fundamental.Name == "char"))
                    return new NativeStringType (language, byte_size);

                TargetFunctionType func = ref_type as TargetFunctionType;
                if (func != null)
                    return new NativeFunctionPointer (language, func);

                string name;
                if (Name != null)
                    name = Name;
                else
                    name = NativePointerType.MakePointerName (ref_type);

                return new NativePointerType (language, name, ref_type, byte_size);
            }
Beispiel #40
0
            protected override TargetType CreateType()
            {
                if (type_offset != 0) {
                    return_type = GetReference (type_offset);
                    if (return_type == null)
                        return null;
                }

                function_type = new NativeFunctionType (language);
                return function_type;
            }
Beispiel #41
0
 public static int RollDie(DieType die)
 {
     return random.Next(0, (int) die) + 1;
 }
Beispiel #42
0
 public static int DieRoll(DieType dieType)
 {
     Random random = new Random();
     return random.Next(0, (int)dieType);
 }
Beispiel #43
0
        /// <summary>
        /// Simple Die factory that calls a generic roller method
        /// using a base class reference.
        /// </summary>
        /// <param name="dieToRoll"></param>
        /// <returns></returns>
        private int[] RollDie(DieType dieToRoll)
        {
            DieBase dieBase = null;

            switch (dieToRoll)
            {
                case DieType.D4:
                    dieBase = new D4();
                    break;

                case DieType.D6:
                    dieBase = new D6();
                    break;

                case DieType.D8:
                    dieBase = new D8();
                    break;

                case DieType.D10:
                    dieBase = new D10();
                    break;

                case DieType.D12:
                    dieBase = new D12();
                    break;

                case DieType.D20:
                    dieBase = new D20();
                    break;
            }

            return GenericRoller(dieBase);
        }
 public GrimoireAbility(GrimoireLine line)
 {
     this.System = line.System;
     this.Job = line.Job;
     this.Name = line.Name;
     switch (this.System)
     {
         case "Class":
             //too complicated
             this.SlotCost = ResolveClassSlotCosts(line.Job, line.APOrSlotCost, line.Keywords);
             break;
         case "Job":
             if (line.APOrSlotCost <= 100)
             {
                 this.SlotCost = 2;
             }
             else if (line.APOrSlotCost < 150)
             {
                 this.SlotCost = 3;
             }
             else
             {
                 //150 or more AP
                 this.SlotCost = 4;
             }
             break;
         case "Crystal":
             if (line.APOrSlotCost < 4)
             {
                 this.SlotCost = 2;
             }
             else if (line.APOrSlotCost == 4)
             {
                 this.SlotCost = 3;
             }
             else
             {
                 //5 or more slots
                 this.SlotCost = 4;
             }
             break;
     }
     try
     {
         this.AbilityType = (AbilityType)Enum.Parse(typeof(AbilityType), line.Type);
     }
     catch
     {
         this.AbilityType = AbilityType.Support;
     }
     this.Delay = line.Delay;
     this.Floor = line.Floor;
     this.MP = line.MP;
     this.MPPerTier = line.MPPerTier;
     this.CT = line.CT;
     this.CoS = line.CoS;
     try
     {
         this.Target = (TargetType)Enum.Parse(typeof(TargetType), line.Target);
     }
     catch
     {
         this.Target = TargetType.Null;
     }
     this.AttackType = AttackType.Null;
     if (line.Stat == "ATK") this.AttackType = AttackType.Physical;
     if (line.Stat == "MAG") this.AttackType = AttackType.Magical;
     if (this.AttackType == AttackType.Null)
     {
         if (line.Keywords.Contains("Magic"))
         {
             this.AttackType = AttackType.MagicalEffect;
         }
         else if(line.Keywords.Contains("Technique"))
         {
             this.AttackType = AttackType.PhysicalEffect;
         }
     }
     this.Power = line.Power;
     this.PowerPerTier = line.PowerPerTier;
     this.Dice = line.Dice;
     this.DicePerTier = line.DicePerTier;
     string buildDieType = "d" + line.DieType.ToString();
     try
     {
         this.DieType = (DieType)Enum.Parse(typeof(DieType), buildDieType);
     }
     catch
     {
         this.DieType = DieType.Null;
     }
     this.Multiplier = line.Multiplier;
     this.Notes = line.Notes;
     List<String> keywordsBroken = line.Keywords.Split(',').ToList<String>();
     Regex rgx = new Regex("[^a-zA-Z:]");
     this.Element = Element.Null;
     foreach (String key in keywordsBroken)
     {
         //do preprocessing to mung Elemental, Status, and Effect keywords
         String toAdd = rgx.Replace(key, "");
         if (key.Contains("Elemental"))
         {
             //split at colon, element will be in split[1]
             string[] parts = key.Split(':');
             toAdd = "Elemental";
             try
             {
                 this.Element = (Element)Enum.Parse(typeof(Element), parts[1]);
             }
             catch
             {
                 this.Element = Element.Null;
             }
         }
         if (key.Contains("Status") || key.Contains("Effect"))
         {
             toAdd = "StatusEffect";
         }
         if (key.Contains("Enhancement"))
         {
             toAdd = "Enhancement";
         }
         try
         {
             this.Keywords.Add((Keyword)Enum.Parse(typeof(Keyword), toAdd));
         }
         catch
         {
             //couldn't recognise the keyword, do nothing.
             Console.WriteLine("Could not recognise keyword " + toAdd);
         }
     }
 }
Beispiel #45
0
 public static short GetRandomNumber(DieType die)
 {
     return (short)rnd.Next(1, (int)die + 1);
 }
Beispiel #46
0
            protected override TargetType CreateType()
            {
                reference = GetReference (type_offset);
                if (reference == null)
                    return null;

                type = new NativeTypeAlias (language, Name, reference.Name);
                return type;
            }
Beispiel #47
0
 protected void AddType(DieType type)
 {
     bfd.NativeLanguage.AddType (type);
 }
Beispiel #48
0
        private int GetIndexForType(DieType type)
        {
            int count = 0;
            foreach (string name in Enum.GetNames(typeof(DieType)))
            {
                if (name == type.ToString())
                    return count;

                count += 1;
            }

            return -1;
        }
Beispiel #49
0
 public static int RollDie(DieType die)
 {
     return Random.Range(0, (int)die) + 1;
 }
Beispiel #50
0
 protected override void ProcessAttribute(Attribute attribute)
 {
     switch (attribute.DwarfAttribute) {
     case DwarfAttribute.name:
         name = (string) attribute.Data;
         break;
     case DwarfAttribute.specification:
         specification = comp_unit.GetType ((long) attribute.Data);
         break;
     }
 }