Пример #1
0
        private double GetCost(Materia m)
        {
            int index1 = 1;
            if (m.Type == MateriaType.Control)
            {
                index1 = 2;
            }
            else if (m.Type == MateriaType.CP)
            {
                index1 = 3;
            }

            int index2 = (int)m.Rank;

            return Convert.ToDouble(this.Controls.Find("txtMat" + index1 + index2, true).FirstOrDefault().Text);
        }
Пример #2
0
        private Materia[,] GetAllOrderings(LinkedList<Materia> baseOptions)
        {
            if (baseOptions == null || baseOptions.Count == 0)
            {
                throw new ArgumentException("baseOptions can't be null or have zero elements");
            }

            Materia[,] permutationSet = new Materia[Factorial(baseOptions.Count), baseOptions.Count];
            LinkedList<Materia> permutationPrefix = new LinkedList<Materia>();
            int permutationIndex = 0;

            return GetAllOrderingsRecursion(permutationPrefix, baseOptions, permutationSet, ref permutationIndex);
        }
Пример #3
0
 private Materia[,] GetAllOrderingsRecursion(LinkedList<Materia> permutationPrefix, LinkedList<Materia> remainingOptions, Materia[,] permutationSet, ref int permutationIndex)
 {
     if (remainingOptions.Count == 0) {
         // permutationPrefix is now a full permutation
         LinkedListNode<Materia> node = permutationPrefix.First;
         for (int i = 0; i < permutationPrefix.Count; i++)
         {
             permutationSet[permutationIndex, i] = node.Value;
             node = node.Next;
         }
         permutationIndex++;
     }
     else
     {
         foreach (Materia m in remainingOptions)
         {
             permutationPrefix.AddLast(m);
             LinkedList<Materia> newRemaining = new LinkedList<Materia>(remainingOptions);
             newRemaining.Remove(m);
             GetAllOrderingsRecursion(permutationPrefix, newRemaining, permutationSet, ref permutationIndex);
             permutationPrefix.RemoveLast();
         }
     }
     return permutationSet;
 }
Пример #4
0
 private LinkedList<LinkedList<Materia>> FindPossibleMateriaCombos(int scoreNeeded, MateriaType mType)
 {
     int scoreBump = mType.GetBump();
     LinkedList<LinkedList<Materia>> allPossibles = new LinkedList<LinkedList<Materia>>();
     int tally = 0;
     if (scoreNeeded > 0)
     {
         for (int slot1 = 4; slot1 > 0; slot1--)
         {
             tally = slot1 + scoreBump;
             Materia m1 = new Materia((MateriaRank)slot1, mType);
             if (tally < scoreNeeded)
             {
                 for (int slot2 = slot1; slot2 > 0; slot2--)
                 {
                     tally = slot1 + slot2 + scoreBump * 2;
                     Materia m2 = new Materia((MateriaRank)slot2, mType);
                     if (tally < scoreNeeded)
                     {
                         for (int slot3 = slot2; slot3 > 0; slot3--)
                         {
                             tally = slot1 + slot2 + slot3 + scoreBump * 3;
                             Materia m3 = new Materia((MateriaRank)slot3, mType);
                             if (tally < scoreNeeded)
                             {
                                 for (int slot4 = slot3; slot4 > 0; slot4--)
                                 {
                                     tally = slot1 + slot2 + slot3 + slot4 + scoreBump * 4;
                                     Materia m4 = new Materia((MateriaRank)slot4, mType);
                                     if (tally < scoreNeeded)
                                     {
                                         for (int slot5 = slot4; slot5 > 0; slot5--)
                                         {
                                             tally = slot1 + slot2 + slot3 + slot4 + slot5 + scoreBump * 5;
                                             Materia m5 = new Materia((MateriaRank)slot5, mType);
                                             if (tally >= scoreNeeded)
                                             {
                                                 LinkedList<Materia> poss = new LinkedList<Materia>();
                                                 poss.AddLast(m1);
                                                 poss.AddLast(m2);
                                                 poss.AddLast(m3);
                                                 poss.AddLast(m4);
                                                 poss.AddLast(m5);
                                                 allPossibles.AddLast(poss);
                                             }
                                         }
                                     }
                                     else
                                     {
                                         LinkedList<Materia> poss = new LinkedList<Materia>();
                                         poss.AddLast(m1);
                                         poss.AddLast(m2);
                                         poss.AddLast(m3);
                                         poss.AddLast(m4);
                                         allPossibles.AddLast(poss);
                                     }
                                 }
                             }
                             else
                             {
                                 LinkedList<Materia> poss = new LinkedList<Materia>();
                                 poss.AddLast(m1);
                                 poss.AddLast(m2);
                                 poss.AddLast(m3);
                                 allPossibles.AddLast(poss);
                             }
                         }
                     }
                     else
                     {
                         LinkedList<Materia> poss = new LinkedList<Materia>();
                         poss.AddLast(m1);
                         poss.AddLast(m2);
                         allPossibles.AddLast(poss);
                     }
                 }
             }
             else
             {
                 LinkedList<Materia> poss = new LinkedList<Materia>();
                 poss.AddLast(m1);
                 allPossibles.AddLast(poss);
             }
         }
     }
     return allPossibles;
 }