public bool SetEvolutions(List <ExportEntry> availableEvolutions)
            {
                // 1. Calculate the number of required bonus evolutions
                var numToPick = Powers.Count(x => x.HasEvolution()) * 2;

                while (numToPick > 0)
                {
                    var numAttempts      = availableEvolutions.Count;
                    var evolutionToCheck = new Talent(availableEvolutions.PullFirstItem(), true);
                    while (numAttempts > 0 && EvolvedPowers.Any(x => x.PowerExport.InstancedFullPath == evolutionToCheck.PowerExport.InstancedFullPath)) // Ensure there are no duplicate power exports
                    {
                        // Repick
                        availableEvolutions.Add(evolutionToCheck.BasePower);
                        evolutionToCheck = new Talent(availableEvolutions.PullFirstItem(), true);
                        numAttempts--;
                        if (numAttempts == 0)
                        {
                            Debug.WriteLine("Could not find suitable evolution for talentset!");
                            return(false); // There is no viable solution
                        }
                    }

                    EvolvedPowers.Add(evolutionToCheck);
                    numToPick--;
                }

                return(true);
            }
Example #2
0
        public void Save()
        {
            if (Powers.Count(gen => gen.Id == Id) != 0)
            {
                Update();
                return;
            }

            using (IDbConnection cnn = new SQLiteConnection(DBPath))
            {
                cnn.Execute($"INSERT INTO Powers VALUES(@Id, @GeneralId, @InputOutputId, @PowerUse, @PowerGeneration, @PowerCapacity);", this);
            }
        }
Example #3
0
 public static Power GetPower(string id) => Powers.Count(power => power.Id == id) != 0 ? Powers.First(power => power.Id == id) : null;