예제 #1
0
        internal void AddLootRecord(LootRecord record, double beginTime)
        {
            Helpers.AddAction(AllLootBlocks, record, beginTime);

            if (!record.IsCurrency && record.Quantity == 1 && AssignedLoot.Count > 0)
            {
                var found = AssignedLoot.FindLastIndex(item => item.Player == record.Player && item.Item == record.Item);
                if (found > -1)
                {
                    AssignedLoot.RemoveAt(found);

                    foreach (var block in AllLootBlocks.OrderByDescending(block => block.BeginTime))
                    {
                        found = block.Actions.FindLastIndex(item => item is LootRecord loot && loot.Player == record.Player && loot.Item == record.Item);
                        if (found > -1)
                        {
                            lock (block.Actions)
                            {
                                block.Actions.RemoveAt(found);
                            }
                        }
                    }
                }
            }
            else if (!record.IsCurrency && record.Quantity == 0)
            {
                AssignedLoot.Add(record);
            }
        }
예제 #2
0
 private static LootRow CreateRow(LootRecord looted, double time = 0)
 {
     return(new LootRow()
     {
         Time = time,
         Item = looted.Item,
         Quantity = looted.Quantity,
         Player = looted.Player,
         IsCurrency = looted.IsCurrency,
         Npc = string.IsNullOrEmpty(looted.Npc) ? "-" : looted.Npc
     });
 }
예제 #3
0
        private static void UpdateTotals(List <LootRow> totalRecords, LootRecord looted)
        {
            var row = CreateRow(looted);

            if (totalRecords.AsParallel().FirstOrDefault(item => !looted.IsCurrency && !item.IsCurrency && looted.Player == item.Player && looted.Item == item.Item) is LootRow existingItem)
            {
                existingItem.Quantity += looted.Quantity;
            }
            else if (totalRecords.AsParallel().FirstOrDefault(item => looted.IsCurrency && item.IsCurrency && looted.Player == item.Player) is LootRow existingMoney)
            {
                existingMoney.Quantity += looted.Quantity;
                existingMoney.Item      = GetMoneyDescription(existingMoney.Quantity);
            }
            else
            {
                totalRecords.Add(row);
            }
        }
예제 #4
0
 internal void AddLootRecord(LootRecord record, double beginTime) => Helpers.AddAction(AllLootBlocks, record, beginTime);
예제 #5
0
        public static void Process(LineData lineData)
        {
            bool handled = false;

            try
            {
                string[] split = lineData.Action.Split(' ');

                if (split != null && split.Length >= 2)
                {
                    // [Sun Mar 01 22:20:36 2020] A shaded torch has been awakened by Drogbaa.
                    // [Sun Mar 01 20:35:55 2020] The master looter, Qulas, looted 32426 platinum from the corpse.
                    // [Sun Mar 01 23:51:02 2020] You receive 129 platinum, 2 gold and 1 copper as your split (with a lucky bonus).
                    // [Sun Feb 02 22:43:51 2020] You receive 28 platinum, 7 gold, 2 silver and 5 copper as your split.
                    // [Sun Feb 02 23:31:23 2020] You receive 57 platinum as your split.
                    // [Fri Feb 07 22:01:20 2020] --Kizant has looted a Lesser Engraved Velium Rune from Velden Dragonbane's corpse.--
                    // [Sat Feb 08 01:20:26 2020] --Proximoe has looted a Velium Infused Spider Silk from a restless devourer's corpse.--
                    // [Sat Feb 08 21:21:36 2020] --You have looted a Cold-Forged Cudgel from Queen Dracnia's corpse.--
                    // [Mon Apr 27 22:32:04 2020] Restless Tijoely resisted your Stormjolt Vortex Effect!
                    // [Mon Apr 27 20:51:22 2020] Kazint's Scorching Beam Rk. III spell has been reflected by a shadow reflection.
                    // [Sun Mar 28 19:42:46 2021] A Draconic Lava Chain Feet Ornament was given to Aldryn.

                    string looter          = null;
                    int    awakenedIndex   = -1;
                    int    lootedIndex     = -1;
                    int    masterLootIndex = -1;
                    int    receiveIndex    = -1;
                    int    resistedIndex   = -1;
                    int    isIndex         = -1;

                    for (int i = 0; i < split.Length && !handled; i++)
                    {
                        if (i == 0 && split[0].StartsWith("--", StringComparison.OrdinalIgnoreCase))
                        {
                            looter = split[0] == "--You" ? ConfigUtil.PlayerName : split[0].TrimStart('-');
                        }
                        else
                        {
                            switch (split[i])
                            {
                            case "awakened":
                                awakenedIndex = i;
                                break;

                            case "is":
                                isIndex = i;
                                break;

                            case "looted":
                                lootedIndex = i;
                                break;

                            case "looter,":
                                masterLootIndex = (i == 2 && split[1] == "master" && split[0] == "The") ? masterLootIndex = i + 1 : -1;
                                break;

                            case "receive":
                                receiveIndex = (i == 1 && split[0] == "You") ? i : -1;
                                break;

                            case "reflected":
                                if (split.Length > 6 && i >= 6 && i + 2 < split.Length && split[0].StartsWith(ConfigUtil.PlayerName, StringComparison.Ordinal) &&
                                    split[i - 1] == "been" && split[i - 2] == "has" && split[i - 3] == "spell" && split[i + 1] == "by")
                                {
                                    // var spell = string.Join(" ", split, 1, i - 4);
                                    var npc = string.Join(" ", split, i + 2, split.Length - i - 2).TrimEnd('.');
                                    DataManager.Instance.UpdateNpcSpellReflectStats(npc);
                                    handled = true;
                                }
                                break;

                            case "resisted":
                                resistedIndex = i;
                                break;

                            case "your":
                                if (resistedIndex > 0 && resistedIndex + 1 == i && split.Length > i + 1 && split[split.Length - 1].EndsWith("!", StringComparison.Ordinal))
                                {
                                    string npc   = string.Join(" ", split, 0, resistedIndex);
                                    string spell = string.Join(" ", split, i + 1, split.Length - i - 1).TrimEnd('!');
                                    DataManager.Instance.AddResistRecord(new ResistRecord()
                                    {
                                        Defender = npc, Spell = spell
                                    }, DateUtil.ParseLogDate(lineData.Line));
                                    handled = true;
                                }
                                break;

                            case "by":
                                if (awakenedIndex > -1 && awakenedIndex == (i - 1) && split.Length > 5 && split[i - 2] == "been" && split[i - 3] == "has")
                                {
                                    string awakened = string.Join(" ", split, 0, i - 3);
                                    string breaker  = string.Join(" ", split, i + 1, split.Length - i - 1).TrimEnd('.');
                                    DataManager.Instance.AddMiscRecord(new MezBreakRecord {
                                        Breaker = breaker, Awakened = awakened
                                    }, DateUtil.ParseLogDate(lineData.Line));
                                    handled = true;
                                }
                                else if (isIndex > 0 && StruckByTypes.ContainsKey(split[i - 1]))
                                {
                                    // ignore common lines like: is struck by
                                    handled = true;
                                }
                                break;

                            case "from":
                                if (masterLootIndex > -1 && lootedIndex > masterLootIndex && split.Length > lootedIndex + 1 && split.Length > 3)
                                {
                                    string name = split[3].TrimEnd(',');
                                    if (ParseCurrency(split, lootedIndex + 1, i, out string item, out uint count))
                                    {
                                        PlayerManager.Instance.AddVerifiedPlayer(name);
                                        LootRecord record = new LootRecord()
                                        {
                                            Item = item, Player = name, Quantity = count, IsCurrency = true
                                        };
                                        DataManager.Instance.AddLootRecord(record, DateUtil.ParseLogDate(lineData.Line));
                                        handled = true;
                                    }
                                }
                                else if (!string.IsNullOrEmpty(looter) && lootedIndex == 2 && split.Length > 4)
                                {
                                    // covers "a" or "an"
                                    uint   count = split[3][0] == 'a' ? 1 : StatsUtil.ParseUInt(split[3]);
                                    string item  = string.Join(" ", split, 4, i - 4);
                                    string npc   = string.Join(" ", split, i + 1, split.Length - i - 1).TrimEnd(LootedFromTrim).Replace("'s corpse", "");

                                    if (count > 0 && count != ushort.MaxValue)
                                    {
                                        PlayerManager.Instance.AddVerifiedPlayer(looter);
                                        LootRecord record = new LootRecord()
                                        {
                                            Item = item, Player = looter, Quantity = count, IsCurrency = false, Npc = npc
                                        };
                                        DataManager.Instance.AddLootRecord(record, DateUtil.ParseLogDate(lineData.Line));
                                        handled = true;
                                    }
                                }
                                break;

                            case "given":
                                if (split[i - 1] == "was" && split.Length == (i + 3) && split[i + 1] == "to")
                                {
                                    string player = split[i + 2];
                                    if (player.Length > 3)
                                    {
                                        looter = player.Substring(0, player.Length - 1);
                                        looter = looter.Equals("you", StringComparison.OrdinalIgnoreCase) ? ConfigUtil.PlayerName : looter;
                                        string     item   = string.Join(" ", split, 1, i - 2);
                                        LootRecord record = new LootRecord()
                                        {
                                            Item = item, Player = looter, Quantity = 0, IsCurrency = false, Npc = "Assigned (Not Looted)"
                                        };
                                        DataManager.Instance.AddLootRecord(record, DateUtil.ParseLogDate(lineData.Line));
                                        handled = true;
                                    }
                                }
                                break;

                            case "split.":
                            case "split":
                                if (receiveIndex > -1 && split[i - 1] == "your" && split[i - 2] == "as")
                                {
                                    if (ParseCurrency(split, 2, i - 2, out string item, out uint count))
                                    {
                                        LootRecord record = new LootRecord()
                                        {
                                            Item = item, Player = ConfigUtil.PlayerName, Quantity = count, IsCurrency = true
                                        };
                                        DataManager.Instance.AddLootRecord(record, DateUtil.ParseLogDate(lineData.Line));
                                        handled = true;
                                    }
                                }
                                break;
                            }
                        }
                    }
                }
            }
            catch (ArgumentNullException ne)
            {
                LOG.Error(ne);
            }
            catch (NullReferenceException nr)
            {
                LOG.Error(nr);
            }
            catch (ArgumentOutOfRangeException aor)
            {
                LOG.Error(aor);
            }
            catch (ArgumentException ae)
            {
                LOG.Error(ae);
            }

            DebugUtil.UnregisterLine(lineData.LineNumber, handled);
        }
예제 #6
0
        public static void Process(LineData lineData)
        {
            try
            {
                string[] split = lineData.Action.Split(' ');

                if (split != null && split.Length > 2)
                {
                    // [Sun Mar 01 22:20:36 2020] A shaded torch has been awakened by Drogbaa.
                    // [Sun Mar 01 22:34:58 2020] You have entered The Eastern Wastes.
                    // [Sun Mar 01 20:35:55 2020] The master looter, Qulas, looted 32426 platinum from the corpse.
                    // [Sun Mar 01 23:51:02 2020] You receive 129 platinum, 2 gold and 1 copper as your split (with a lucky bonus).
                    // [Sun Feb 02 22:43:51 2020] You receive 28 platinum, 7 gold, 2 silver and 5 copper as your split.
                    // [Sun Feb 02 23:31:23 2020] You receive 57 platinum as your split.
                    // [Fri Feb 07 22:01:20 2020] --Kizant has looted a Lesser Engraved Velium Rune from Velden Dragonbane's corpse.--
                    // [Sat Feb 08 01:20:26 2020] --Proximoe has looted a Velium Infused Spider Silk from a restless devourer's corpse.--
                    // [Sat Feb 08 21:21:36 2020] --You have looted a Cold-Forged Cudgel from Queen Dracnia's corpse.--

                    string looter          = null;
                    int    awakenedIndex   = -1;
                    int    lootedIndex     = -1;
                    int    masterLootIndex = -1;
                    int    receiveIndex    = -1;
                    bool   handled         = false;

                    for (int i = 0; i < split.Length && !handled; i++)
                    {
                        if (i == 0 && split[0].StartsWith("--"))
                        {
                            looter = split[0] == "--You" ? ConfigUtil.PlayerName : split[0].TrimStart('-');
                        }
                        else
                        {
                            switch (split[i])
                            {
                            case "awakened":
                                awakenedIndex = i;
                                break;

                            case "looted":
                                lootedIndex = i;
                                break;

                            case "looter,":
                                masterLootIndex = (i == 2 && split[1] == "master" && split[0] == "The") ? masterLootIndex = i + 1 : -1;
                                break;

                            case "receive":
                                receiveIndex = (i == 1 && split[0] == "You") ? i : -1;
                                break;

                            case "by":
                                if (awakenedIndex > -1 && awakenedIndex == (i - 1) && split.Length > 5 && split[i - 2] == "been" && split[i - 3] == "has")
                                {
                                    string awakened = string.Join(" ", split, 0, i - 3);
                                    string breaker  = string.Join(" ", split, i + 1, split.Length - i - 1).TrimEnd('.');
                                    DataManager.Instance.AddMiscRecord(new MezBreakRecord()
                                    {
                                        Breaker = breaker, Awakened = awakened
                                    }, DateUtil.ParseLogDate(lineData.Line));
                                    handled = true;
                                }
                                break;

                            case "entered":
                                if (i == 2 && split[1] == "have" && split[0] == "You" && split.Length > 2)
                                {
                                    string zone = string.Join(" ", split, 3, split.Length - 3).TrimEnd('.');
                                    DataManager.Instance.AddMiscRecord(new ZoneRecord()
                                    {
                                        Zone = zone
                                    }, DateUtil.ParseLogDate(lineData.Line));
                                    handled = true;
                                }
                                break;

                            case "from":
                                if (masterLootIndex > -1 && lootedIndex > masterLootIndex && split.Length > lootedIndex + 1 && split.Length > 3)
                                {
                                    string name = split[3].TrimEnd(',');
                                    if (ParseCurrency(split, lootedIndex + 1, i, out string item, out uint count))
                                    {
                                        PlayerManager.Instance.AddVerifiedPlayer(name);
                                        LootRecord record = new LootRecord()
                                        {
                                            Item = item, Player = name, Quantity = count, IsCurrency = true
                                        };
                                        DataManager.Instance.AddLootRecord(record, DateUtil.ParseLogDate(lineData.Line));
                                        handled = true;
                                    }
                                }
                                else if (!string.IsNullOrEmpty(looter) && lootedIndex == 2 && split.Length > 4)
                                {
                                    // covers "a" or "an"
                                    uint   count = split[3][0] == 'a' ? 1 : StatsUtil.ParseUInt(split[3]);
                                    string item  = string.Join(" ", split, 4, i - 4);
                                    string npc   = string.Join(" ", split, i + 1, split.Length - i - 1).TrimEnd(LootedFromTrim).Replace("'s corpse", "");

                                    if (count > 0 && count != ushort.MaxValue)
                                    {
                                        PlayerManager.Instance.AddVerifiedPlayer(looter);
                                        LootRecord record = new LootRecord()
                                        {
                                            Item = item, Player = looter, Quantity = count, IsCurrency = false, Npc = npc
                                        };
                                        DataManager.Instance.AddLootRecord(record, DateUtil.ParseLogDate(lineData.Line));
                                        handled = true;
                                    }
                                }
                                break;

                            case "split":
                                if (receiveIndex > -1 && split[i - 1] == "your" && split[i - 2] == "as")
                                {
                                    if (ParseCurrency(split, 2, i - 2, out string item, out uint count))
                                    {
                                        LootRecord record = new LootRecord()
                                        {
                                            Item = item, Player = ConfigUtil.PlayerName, Quantity = count, IsCurrency = true
                                        };
                                        DataManager.Instance.AddLootRecord(record, DateUtil.ParseLogDate(lineData.Line));
                                        handled = true;
                                    }
                                }
                                break;
                            }
                        }
                    }
                }
            }
            catch (ArgumentNullException ne)
            {
                LOG.Error(ne);
            }
            catch (NullReferenceException nr)
            {
                LOG.Error(nr);
            }
            catch (ArgumentOutOfRangeException aor)
            {
                LOG.Error(aor);
            }
            catch (ArgumentException ae)
            {
                LOG.Error(ae);
            }
        }