public void Empty_WhenSetIsHasValues_ReturnsFalse()
        {
            var list = new List <string>();

            list.Add("IHAVEABIGSPOON");
            list.Empty().Should().BeFalse();
        }
示例#2
0
    private void UpdateHistory()
    {
        if (InputSystem.Instance.GetKeyCode(CustomKeyCode.RestoreHistory) &&
            !_historyList.Empty())
        {
            History history = _historyList[_historyList.Count - 1];
            if (history != null)
            {
                HandleHistory(history);

                _frontHistoryList.Add(history);
                _historyList.Remove(history);
            }
        }
        else if (InputSystem.Instance.GetKeyCode(CustomKeyCode.FrontRestoreHistory) &&
                 !_frontHistoryList.Empty())
        {
            History history = _frontHistoryList[_frontHistoryList.Count - 1];
            if (history != null)
            {
                HandleHistory(history);
                _frontHistoryList.Remove(history);
                _historyList.Add(history);
            }
        }
    }
示例#3
0
        private void ProcessImportResults(TrackedDownload trackedDownload, String outputPath, List <ImportResult> importResults)
        {
            if (importResults.Empty())
            {
                UpdateStatusMessage(trackedDownload, LogLevel.Error, "No files found are eligible for import in {0}", outputPath);
            }
            else if (importResults.Any(v => v.Result == ImportResultType.Imported) && importResults.All(v => v.Result == ImportResultType.Imported || v.Result == ImportResultType.Rejected))
            {
                UpdateStatusMessage(trackedDownload, LogLevel.Info, "Imported {0} files.", importResults.Count(v => v.Result == ImportResultType.Imported));

                trackedDownload.State = TrackedDownloadState.Imported;
            }
            else
            {
                var errors = importResults
                             .Where(v => v.Result == ImportResultType.Skipped || v.Result == ImportResultType.Rejected)
                             .Select(v => v.Errors.Aggregate(Path.GetFileName(v.ImportDecision.LocalEpisode.Path), (a, r) => a + "\r\n- " + r))
                             .Aggregate("Failed to import:", (a, r) => a + "\r\n" + r);

                trackedDownload.StatusMessages = importResults.Where(v => v.Result == ImportResultType.Skipped || v.Result == ImportResultType.Rejected)
                                                 .Select(v => new TrackedDownloadStatusMessage(Path.GetFileName(v.ImportDecision.LocalEpisode.Path), v.Errors)).ToList();

                UpdateStatusMessage(trackedDownload, LogLevel.Error, errors);
            }
        }
示例#4
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            int result = 3.Pow(3);

            Console.WriteLine(result);

            var list = new List <string>();

            list.Empty();
            var str = list.ToString();

            list.ToList();

            list.AddRange(new string[] { "a", "b", "b", "asdgffdgjdfgg" });

            int sum = 0;

            foreach (var s in list)
            {
                sum += s.Length;
            }
            double averageStringLength = sum / list.Count;

            averageStringLength = list.Average(s => s.Length);

            Console.WriteLine(averageStringLength);



            Func <string, int> numberOfAs = x => x.Count(c => c == 'a');
            var numbofAllAs = list.Sum(numberOfAs);
        }
示例#5
0
        public static string ToOrderByClause(this List <string> input, string defaultOrder = null)
        {
            var output = new List <string>();

            if (input.Empty() && defaultOrder.NotNullOrEmpty())
            {
                input.Add(defaultOrder);
            }

            foreach (var orderBy in input)
            {
                var a = orderBy.Split(',').Select(x => x.Trim()).Where(x => x.NotNullOrEmpty());

                output.AddRange(a);
            }

            var values = output.Select(x =>
            {
                var parts        = x.Split(' ');
                var column       = parts[0].ToLower();
                var hasDirection = parts.Length == 2;
                var direction    = hasDirection ? parts[1].ToUpper() : "ASC";

                var orderBy = $"{column} {direction}";

                return(orderBy);
            });

            var orderByValues = string.Join($", ", values);
            var clause        = output.Any() ? $"ORDER BY {orderByValues}" : String.Empty;

            return(clause);
        }
示例#6
0
        public bool IsImported(TrackedDownload trackedDownload, List <MovieHistory> historyItems)
        {
            _logger.Trace("Checking if all movies for '{0}' have been imported", trackedDownload.DownloadItem.Title);

            if (historyItems.Empty())
            {
                _logger.Trace("No history for {0}", trackedDownload.DownloadItem.Title);
                return(false);
            }

            var movie = trackedDownload.RemoteMovie.Movie;

            var lastHistoryItem = historyItems.FirstOrDefault(h => h.MovieId == movie.Id);

            if (lastHistoryItem == null)
            {
                _logger.Trace("No history for movie: {0}", movie.ToString());
                return(false);
            }

            var allMoviesImportedInHistory = lastHistoryItem.EventType == MovieHistoryEventType.DownloadFolderImported;

            _logger.Trace("Last event for movie: {0} is: {1}", movie, lastHistoryItem.EventType);

            _logger.Trace("All movies for '{0}' have been imported: {1}", trackedDownload.DownloadItem.Title, allMoviesImportedInHistory);
            return(allMoviesImportedInHistory);
        }
示例#7
0
        void EmpowerCultist()
        {
            if (summons.Empty())
            {
                return;
            }

            List <Creature> temp = new List <Creature>();

            foreach (var guid in summons)
            {
                Creature cre = ObjectAccessor.GetCreature(me, guid);
                if (cre)
                {
                    if (cre.IsAlive() && (cre.GetEntry() == CreatureIds.CultFanatic || cre.GetEntry() == CreatureIds.CultAdherent))
                    {
                        temp.Add(cre);
                    }
                }
            }

            // noone to empower
            if (temp.Empty())
            {
                return;
            }

            // select random cultist
            Creature cultist = temp.SelectRandom();

            DoCast(cultist, cultist.GetEntry() == CreatureIds.CultFanatic ? LadySpells.DARK_TRANSFORMATION_T : LadySpells.DARK_EMPOWERMENT_T, true);
            Talk(cultist.GetEntry() == CreatureIds.CultFanatic ? LadyTexts.SAY_DARK_TRANSFORMATION : LadyTexts.SAY_DARK_EMPOWERMENT);
        }
示例#8
0
        void ReanimateCultist()
        {
            if (summons.Empty())
            {
                return;
            }

            List <Creature> temp = new List <Creature>();

            foreach (var guid in summons)
            {
                Creature cre = ObjectAccessor.GetCreature(me, guid);
                if (cre)
                {
                    if (cre.IsAlive() && (cre.GetEntry() == CreatureIds.CultFanatic || cre.GetEntry() == CreatureIds.CultAdherent))
                    {
                        temp.Add(cre);
                    }
                }
            }

            if (temp.Empty())
            {
                return;
            }

            Creature cultist = temp.SelectRandom();

            DoCast(cultist, LadySpells.DARK_MARTYRDOM_T, true);
        }
示例#9
0
        public bool BuildPacket(out UpdateObject packet)
        {
            packet = new UpdateObject();

            packet.NumObjUpdates = BlockCount;
            packet.MapID         = (ushort)MapId;

            WorldPacket buffer = new WorldPacket();

            if (buffer.WriteBit(!outOfRangeGUIDs.Empty()))
            {
                buffer.WriteUInt16(0); // object limit to instantly destroy - objects before this index on m_outOfRangeGUIDs list get "smoothly phased out"
                buffer.WriteInt32(outOfRangeGUIDs.Count);

                foreach (var guid in outOfRangeGUIDs)
                {
                    buffer.WritePackedGuid(guid);
                }
            }
            var bytes = data.GetData();

            buffer.WriteInt32(bytes.Length);
            buffer.WriteBytes(bytes);

            packet.Data = buffer.GetData();
            return(true);
        }
示例#10
0
            void HandleSpikes(uint effIndex)
            {
                PreventHitDefaultEffect(effIndex);
                Creature marrowgar = GetCaster().ToCreature();

                if (marrowgar)
                {
                    CreatureAI marrowgarAI    = marrowgar.GetAI();
                    byte       boneSpikeCount = (byte)(Convert.ToBoolean((int)GetCaster().GetMap().GetDifficultyID() & 1) ? 3 : 1);

                    List <Unit> targets = marrowgarAI.SelectTargetList(new BoneSpikeTargetSelector(marrowgarAI), boneSpikeCount, SelectAggroTarget.Random);
                    if (targets.Empty())
                    {
                        return;
                    }

                    uint i = 0;
                    foreach (var target in targets)
                    {
                        target.CastSpell(target, Misc.BoneSpikeSummonId[i], true);
                        i++;
                    }

                    marrowgarAI.Talk(Texts.SayBonespike);
                }
            }
示例#11
0
                /// <summary>
                /// Finds a solution to the goal using A*
                /// </summary>
                /// <param name="actions"></param>
                /// <param name="goal"></param>
                /// <returns></returns>
                public Path FindSolution()
                {
                    while (!OpenList.Empty())
                    {
                        // Pop the cheapest node off the open list
                        var parent = FindCheapest();
                        if (Tracing)
                        {
                            StratusDebug.Log("Iteration #" + CurrentIteration + " | Parent = " + parent.Description);
                        }

                        // if the a route to the starting node was found...
                        if (IsFinished(parent))
                        {
                            if (Tracing)
                            {
                                StratusDebug.Log("Valid path found!");
                            }
                            return(BuildPath(parent));
                        }
                        // For all neighboring child nodes...
                        var neighbors = FindNeighbors(parent);
                        foreach (var child in neighbors)
                        {
                            // If the node is unexplored
                            if (child.Status == Node.ListStatus.Unexplored)
                            {
                                child.Cost   = child.GivenCost + CalculateHeuristicCost(child, this.DestinationNode);
                                child.Parent = parent;
                                PutOnList(child, Node.ListStatus.Open);
                            }
                            // Else if the node is on the open or closed list
                            else
                            {
                                // If the new cost is lesser
                                var cost = child.GivenCost + CalculateHeuristicCost(child, this.DestinationNode);
                                if (cost < child.Cost)
                                {
                                    child.Parent = parent;
                                    child.Cost   = cost;
                                }
                            }
                        }

                        // Place the parent node on the closed list
                        PutOnList(parent, Node.ListStatus.Closed);
                        CurrentIteration++;
                        if (CurrentIteration > 10)
                        {
                            break;
                        }
                    }

                    // If the open list is empty, no path was found
                    if (Tracing)
                    {
                        StratusDebug.Log("No valid path found!");
                    }
                    return(null);
                }
示例#12
0
        void FilterTargets(List <WorldObject> targets)
        {
            if (GetCaster().ToPlayer().GetGroup() == null)
            {
                targets.Clear();
                targets.Add(GetCaster());
            }
            else
            {
                targets.Remove(GetExplTargetUnit());
                List <Unit> tempTargets = new List <Unit>();
                foreach (var obj in targets)
                {
                    if (obj.IsTypeId(TypeId.Player) && GetCaster().IsInRaidWith(obj.ToUnit()))
                    {
                        tempTargets.Add(obj.ToUnit());
                    }
                }

                if (tempTargets.Empty())
                {
                    targets.Clear();
                    FinishCast(SpellCastResult.DontReport);
                    return;
                }

                Unit target = tempTargets.SelectRandom();
                targets.Clear();
                targets.Add(target);
            }
        }
示例#13
0
        void ExpandPermissions(List <uint> permissions)
        {
            List <uint> toCheck = new List <uint>(permissions);

            permissions.Clear();

            while (!toCheck.Empty())
            {
                // remove the permission from original list
                uint permissionId = toCheck.FirstOrDefault();
                toCheck.RemoveAt(0);

                RBACPermission permission = Global.AccountMgr.GetRBACPermission(permissionId);
                if (permission == null)
                {
                    continue;
                }

                // insert into the final list (expanded list)
                permissions.Add(permissionId);

                // add all linked permissions (that are not already expanded) to the list of permissions to be checked
                List <uint> linkedPerms = permission.GetLinkedPermissions();
                foreach (var id in linkedPerms)
                {
                    if (!permissions.Contains(id))
                    {
                        toCheck.Add(id);
                    }
                }
            }

            //Log.outDebug(LogFilter.General, "RBACData:ExpandPermissions: Expanded: {0}", GetDebugPermissionString(permissions));
        }
示例#14
0
        public static string ConcatenateGuids(List <ObjectGuid> guids)
        {
            if (guids.Empty())
            {
                return("");
            }

            // need the guids in order to avoid duplicates
            StringBuilder val = new StringBuilder();

            guids.Sort();
            var it = guids.First();

            val.Append(it);
            foreach (var guid in guids)
            {
                if (guid == it)
                {
                    continue;
                }
                val.AppendFormat("|{0}", guid);
            }

            return(val.ToString());
        }
示例#15
0
        List <NotNormalLootItem> FillNonQuestNonFFAConditionalLoot(Player player, bool presentAtLooting)
        {
            List <NotNormalLootItem> ql = new List <NotNormalLootItem>();

            for (byte i = 0; i < items.Count; ++i)
            {
                LootItem item = items[i];
                if (!item.is_looted && !item.freeforall && item.AllowedForPlayer(player))
                {
                    if (presentAtLooting)
                    {
                        item.AddAllowedLooter(player);
                    }
                    if (!item.conditions.Empty())
                    {
                        ql.Add(new NotNormalLootItem(i));
                        if (!item.is_counted)
                        {
                            ++unlootedCount;
                            item.is_counted = true;
                        }
                    }
                }
            }
            if (ql.Empty())
            {
                return(null);
            }

            PlayerNonQuestNonFFAConditionalItems[player.GetGUID()] = ql;
            return(ql);
        }
示例#16
0
 void FilterTargets(List <WorldObject> targets)
 {
     if (targets.Empty() || GetCaster().GetVehicleBase())
     {
         FinishCast(SpellCastResult.OutOfRange);
     }
 }
        public void Handle(EmailReceivedMessage emailMessage)
        {
            Data.EmailReceivedMessage = emailMessage;

            var requestersDtoToCreate = new List <RequesterDTO>();

            var fromAddress = new MailAddressLite {
                Address = emailMessage.Mail.FromAddress, DisplayName = emailMessage.Mail.FromDisplayName
            };

            ProcessAddress(fromAddress, requestersDtoToCreate);

            if (emailMessage.Mail.CC != null)
            {
                foreach (var ccAddress in emailMessage.Mail.CC)
                {
                    ProcessAddress(ccAddress, requestersDtoToCreate);
                }
            }

            if (requestersDtoToCreate.Empty())
            {
                var fromRequester = GetRequesterByAddress(fromAddress.Address);
                InvokeRules(fromRequester.Id);
            }
            else
            {
                SendLocal(new CreateRequestersForMessageCommandInternal {
                    RequestersDto = requestersDtoToCreate.ToArray(), OuterSagaId = Data.Id
                });
            }
        }
示例#18
0
        bool VisitPackageVersions(PackageDependency dependency)
        {
            KeyValuePair <PackageIdentifier, IPackageInfo>?packageVersion;
            var seen = new List <PackageIdentifier>();

            while ((packageVersion = NextAvailablePackageVersion(seen, dependency)) != null)
            {
                seen.Add(packageVersion.Value.Key);
                _selectionContext.Trying(packageVersion.Value.Key);
                PushStack(packageVersion.Value.Key);

                IPackageInfo package = packageVersion.Value.Value;
                if (package != null && VisitDependencies(package.Dependencies))
                {
                    _selectionContext.PackageSucceeds(packageVersion.Value.Key, CurrentCallStack);
                    WriteDebug("dependency: version found");
                    PopStack();
                    return(true);
                }
                _selectionContext.PackageHasChildrenConflicting(packageVersion.Value.Key);
                WriteDebug("dependency: version didn't match");
                PopStack();
            }
            WriteDebug("dependency: no version matches");
            if (seen.Empty())
            {
                _notFound.Add(new KeyValuePair <PackageDependency, CallStack>(dependency, CurrentCallStack));
            }
            return(false);
        }
示例#19
0
        public override void Visit(ICollection <WorldObject> objs)
        {
            List <Garrison.Plot> plots = i_garrison.GetPlots().ToList();

            if (!plots.Empty())
            {
                CellCoord cellCoord = i_cell.GetCellCoord();
                foreach (Garrison.Plot plot in plots)
                {
                    Position spawn = plot.PacketInfo.PlotPos;
                    if (cellCoord != GridDefines.ComputeCellCoord(spawn.GetPositionX(), spawn.GetPositionY()))
                    {
                        continue;
                    }

                    GameObject go = plot.CreateGameObject(i_map, i_garrison.GetFaction());
                    if (!go)
                    {
                        continue;
                    }

                    var cell = new Cell(cellCoord);
                    i_map.AddToGrid(go, cell);
                    go.AddToWorld();
                    ++i_gameObjects;
                }
            }
        }
示例#20
0
        void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo)
        {
            PreventDefaultAction();

            HealInfo healInfo = eventInfo.GetHealInfo();

            if (healInfo == null || healInfo.GetHeal() == 0)
            {
                return;
            }

            uint heal = MathFunctions.CalculatePct(healInfo.GetHeal(), aurEff.GetAmount());

            var auras = GetCaster().GetSingleCastAuras();

            foreach (var eff in auras)
            {
                if (eff.GetId() == SpellIds.BeaconOfLight)
                {
                    List <AuraApplication> applications = eff.GetApplicationList();
                    if (!applications.Empty())
                    {
                        eventInfo.GetActor().CastCustomSpell(SpellIds.BeaconOfLightHeal, SpellValueMod.BasePoint0, (int)heal, applications.First().GetTarget(), true);
                    }
                    return;
                }
            }
        }
        public bool IsImported(TrackedDownload trackedDownload, List <History.History> historyItems)
        {
            if (historyItems.Empty())
            {
                return(false);
            }

            if (trackedDownload.RemoteBook == null || trackedDownload.RemoteBook.Books == null)
            {
                return(true);
            }

            var allAlbumsImportedInHistory = trackedDownload.RemoteBook.Books.All(book =>
            {
                var lastHistoryItem = historyItems.FirstOrDefault(h => h.BookId == book.Id);

                if (lastHistoryItem == null)
                {
                    return(false);
                }

                return(new[] { HistoryEventType.DownloadImported, HistoryEventType.BookFileImported }.Contains(lastHistoryItem.EventType));
            });

            return(allAlbumsImportedInHistory);
        }
示例#22
0
        public ItemInstance(Item item)
        {
            ItemID = item.GetEntry();
            List <uint> bonusListIds = item.m_itemData.BonusListIDs;

            if (!bonusListIds.Empty())
            {
                ItemBonus.HasValue = true;
                ItemBonus.Value.BonusListIDs.AddRange(bonusListIds);
                ItemBonus.Value.Context = item.GetContext();
            }

            uint mask = item.m_itemData.ModifiersMask;

            if (mask != 0)
            {
                Modifications.HasValue = true;

                for (int i = 0; mask != 0; mask >>= 1, ++i)
                {
                    if ((mask & 1) != 0)
                    {
                        Modifications.Value.Insert(i, (int)item.GetModifier((ItemModifier)i));
                    }
                }
            }
        }
示例#23
0
        Player GetNextRandomRaidMember(float radius)
        {
            Group group = GetGroup();

            if (!group)
            {
                return(null);
            }

            List <Player> nearMembers = new List <Player>();

            for (GroupReference refe = group.GetFirstMember(); refe != null; refe = refe.Next())
            {
                Player Target = refe.GetSource();

                // IsHostileTo check duel and controlled by enemy
                if (Target && Target != this && IsWithinDistInMap(Target, radius) &&
                    !Target.HasInvisibilityAura() && !IsHostileTo(Target))
                {
                    nearMembers.Add(Target);
                }
            }

            if (nearMembers.Empty())
            {
                return(null);
            }

            int randTarget = RandomHelper.IRand(0, nearMembers.Count - 1);

            return(nearMembers[randTarget]);
        }
示例#24
0
        public bool BuildPacket(out UpdateObject packet)
        {
            packet = new UpdateObject();

            packet.NumObjUpdates = BlockCount;
            packet.MapID         = (ushort)MapId;

            WorldPacket buffer = new WorldPacket();

            if (buffer.WriteBit(!outOfRangeGUIDs.Empty() || !destroyGUIDs.Empty()))
            {
                buffer.WriteUInt16((ushort)destroyGUIDs.Count);
                buffer.WriteInt32(destroyGUIDs.Count + outOfRangeGUIDs.Count);

                foreach (var destroyGuid in destroyGUIDs)
                {
                    buffer.WritePackedGuid(destroyGuid);
                }

                foreach (var outOfRangeGuid in outOfRangeGUIDs)
                {
                    buffer.WritePackedGuid(outOfRangeGuid);
                }
            }

            var bytes = data.GetData();

            buffer.WriteInt32(bytes.Length);
            buffer.WriteBytes(bytes);

            packet.Data = buffer.GetData();
            return(true);
        }
示例#25
0
        /// <summary>
        /// Initializes all available file systems by searching for
        /// valid partitions on the available disk devices.
        /// </summary>
        public static void Init()
        {
            Partitions.Empty();
            FileSystemMappings.Empty();

            for (int i = 0; i < DeviceManager.Devices.Count; i++)
            {
                Device aDevice = (Device)DeviceManager.Devices[i];
                if (aDevice is DiskDevice)
                {
                    try
                    {
                        InitDisk((DiskDevice)aDevice);
                    }
                    catch
                    {
                        BasicConsole.WriteLine("Error initializing disk: " + (FOS_System.String)i);
                        BasicConsole.WriteLine(ExceptionMethods.CurrentException.Message);
                        //BasicConsole.DelayOutput(20);
                    }
                }
            }

            InitPartitions();
        }
示例#26
0
        /// <summary>
        /// Select the best target (in <targetType> order) satisfying <predicate> from the threat list.
        /// If <offset> is nonzero, the first <offset> entries in <targetType> order (or MAXTHREAT order, if <targetType> is RANDOM) are skipped.
        /// </summary>
        public Unit SelectTarget(SelectAggroTarget targetType, uint offset, ICheck <Unit> selector)
        {
            ThreatManager mgr = GetThreatManager();

            // shortcut: if we ignore the first <offset> elements, and there are at most <offset> elements, then we ignore ALL elements
            if (mgr.GetThreatListSize() <= offset)
            {
                return(null);
            }

            List <Unit> targetList = SelectTargetList((uint)mgr.GetThreatListSize(), targetType, offset, selector);

            // maybe nothing fulfills the predicate
            if (targetList.Empty())
            {
                return(null);
            }

            switch (targetType)
            {
            case SelectAggroTarget.MaxThreat:
            case SelectAggroTarget.MinThreat:
            case SelectAggroTarget.MaxDistance:
            case SelectAggroTarget.MinDistance:
                return(targetList[0]);

            case SelectAggroTarget.Random:
                return(targetList.SelectRandom());

            default:
                return(null);
            }
        }
示例#27
0
            static bool HandleCharacterDeletedDeleteCommand(StringArguments args, CommandHandler handler)
            {
                // It is required to submit at least one argument
                if (args.Empty())
                {
                    return(false);
                }

                List <DeletedInfo> foundList = new List <DeletedInfo>();

                if (!GetDeletedCharacterInfoList(foundList, args.NextString()))
                {
                    return(false);
                }

                if (foundList.Empty())
                {
                    handler.SendSysMessage(CypherStrings.CharacterDeletedListEmpty);
                    return(false);
                }

                handler.SendSysMessage(CypherStrings.CharacterDeletedDelete);
                HandleCharacterDeletedListHelper(foundList, handler);

                // Call the appropriate function to delete them (current account for deleted characters is 0)
                foreach (var info in foundList)
                {
                    Player.DeleteFromDB(info.guid, 0, false, true);
                }

                return(true);
            }
示例#28
0
            static bool HandleCharacterDeletedRestoreCommand(StringArguments args, CommandHandler handler)
            {
                // It is required to submit at least one argument
                if (args.Empty())
                {
                    return(false);
                }

                string searchString = args.NextString();
                string newCharName  = args.NextString();
                uint   newAccount   = args.NextUInt32();

                List <DeletedInfo> foundList = new List <DeletedInfo>();

                if (!GetDeletedCharacterInfoList(foundList, searchString))
                {
                    return(false);
                }

                if (foundList.Empty())
                {
                    handler.SendSysMessage(CypherStrings.CharacterDeletedListEmpty);
                    return(false);
                }

                handler.SendSysMessage(CypherStrings.CharacterDeletedRestore);
                HandleCharacterDeletedListHelper(foundList, handler);

                if (newCharName.IsEmpty())
                {
                    // Drop not existed account cases
                    foreach (var info in foundList)
                    {
                        HandleCharacterDeletedRestoreHelper(info, handler);
                    }
                }
                else if (foundList.Count == 1 && ObjectManager.NormalizePlayerName(ref newCharName))
                {
                    DeletedInfo delInfo = foundList[0];

                    // update name
                    delInfo.name = newCharName;

                    // if new account provided update deleted info
                    if (newAccount != 0 && newAccount != delInfo.accountId)
                    {
                        delInfo.accountId = newAccount;
                        Global.AccountMgr.GetName(newAccount, out delInfo.accountName);
                    }

                    HandleCharacterDeletedRestoreHelper(delInfo, handler);
                }
                else
                {
                    handler.SendSysMessage(CypherStrings.CharacterDeletedErrRename);
                }

                return(true);
            }
示例#29
0
        static BlueprintProgression createCurseProgression(BlueprintProgression oracle_curse)
        {
            var features = new BlueprintFeature[] { oracle_curse.LevelEntries[0].Features[0] as BlueprintFeature, //1 -> 5
                                                    oracle_curse.LevelEntries[1].Features[0] as BlueprintFeature, //5 -> 10,
                                                    oracle_curse.LevelEntries[2].Features[0] as BlueprintFeature, //10 -> 20
            };

            var curse = Helpers.CreateProgression("PactWizard" + oracle_curse.name,
                                                  oracle_curse.Name,
                                                  oracle_curse.Description,
                                                  "",
                                                  features[0].Icon,
                                                  FeatureGroup.None);
            List <BlueprintAbility> curse_spells = new List <BlueprintAbility>();

            for (int i = 0; i < features.Length; i++)
            {
                features[i] = library.CopyAndAdd(features[i], "PactWizard" + features[i].name, "");
                foreach (var af in features[i].GetComponents <AddFeatureOnClassLevel>())
                {
                    features[i].ReplaceComponent(af, af.CreateCopy(c => { c.Class = archetype.GetParentClass(); c.Level = c.Level * 2; }));
                }

                foreach (var aks in features[i].GetComponents <AddKnownSpell>())
                {
                    features[i].ReplaceComponent(aks, aks.CreateCopy(c =>
                    {
                        c.CharacterClass = archetype.GetParentClass();
                        if (archetype.GetParentClass().Spellbook.SpellList.Contains(c.Spell) &&
                            archetype.GetParentClass().Spellbook.SpellList.GetLevel(c.Spell) != c.SpellLevel)
                        {
                            c.Spell = SpellDuplicates.addDuplicateSpell(c.Spell, "PactWizard" + c.Spell.name, "");
                        }
                        curse_spells.Add(c.Spell);
                    }
                                                                     )
                                                 );
                }
            }

            if (!curse_spells.Empty())
            {
                var feature2 = Helpers.CreateFeature(oracle_curse.name + "CurseMetamagicFeature",
                                                     "",
                                                     "",
                                                     "",
                                                     null,
                                                     FeatureGroup.None,
                                                     Helpers.Create <NewMechanics.MetamagicMechanics.ReduceMetamagicCostForSpecifiedSpells>(r => { r.reduction = 1; r.spells = curse_spells.ToArray(); })
                                                     );
                feature2.HideInCharacterSheetAndLevelUp = true;
                patron_metamagic.AddComponent(Common.createAddFeatureIfHasFact(curse, feature2));
            }

            curse.LevelEntries = new LevelEntry[] { Helpers.LevelEntry(5, features[0]), Helpers.LevelEntry(10, features[1]), Helpers.LevelEntry(20, features[2]) };
            curse.UIGroups     = Helpers.CreateUIGroups(features);
            curse.Classes      = new BlueprintCharacterClass[] { archetype.GetParentClass() };
            return(curse);
        }
 public virtual void removeBuff(Fact buff)
 {
     buffs.Remove(buff);
     if (buffs.Empty())
     {
         Aux.removePart(this);
     }
 }
示例#31
0
        bool VisitPackageVersions(PackageDependency dependency)
        {
            KeyValuePair<PackageIdentifier, IPackageInfo>? packageVersion;
            var seen = new List<PackageIdentifier>();
            while ((packageVersion = NextAvailablePackageVersion(seen, dependency)) != null)
            {
                seen.Add(packageVersion.Value.Key);
                _selectionContext.Trying(packageVersion.Value.Key);
                PushStack(packageVersion.Value.Key);

                IPackageInfo package = packageVersion.Value.Value;
                if (package != null && VisitDependencies(package.Dependencies))
                {
                    _selectionContext.PackageSucceeds(packageVersion.Value.Key, CurrentCallStack);
                    PopStack();
                    WriteDebug("VisitPackage version Succeeded");
                    return true;
                }
                _selectionContext.PackageHasChildrenConflicting(packageVersion.Value.Key);
                PopStack();
                WriteDebug("VisitPackage version failed");
            }
            WriteDebug("VisitPackage failed");
            if (seen.Empty())
            {
                _notFound.Add(new KeyValuePair<PackageDependency, CallStack>(dependency, CurrentCallStack));
            }
            return false;
        }
示例#32
0
        bool VisitPackageVersions(PackageDependency dependency)
        {
            IPackageInfo packageVersion;
            var seen = new List<PackageIdentifier>();
            while ((packageVersion = NextAvailablePackageVersion(seen, dependency)) != null)
            {
                seen.Add(packageVersion.Identifier);
                _selectionContext.Trying(packageVersion.Identifier);
                PushStack(packageVersion.Identifier);

                if (VisitDependencies(packageVersion.Dependencies))
                {
                    _selectionContext.PackageSucceeds(packageVersion.Identifier, CurrentCallStack);
                    WriteDebug("dependency: version found");
                    PopStack();
                    return true;
                }
                _selectionContext.PackageHasChildrenConflicting(packageVersion.Identifier);
                WriteDebug("dependency: version didn't match");
                PopStack();
            }
            WriteDebug("dependency: no version matches");
            if (seen.Empty())
            {
                _notFound.Add(new KeyValuePair<PackageDependency, CallStack>(dependency, CurrentCallStack));
            }
            return false;
        }