Exemplo n.º 1
0
        private static string WriteLisbethSubOrder(Leve leve, int numLeves)
        {
            var amount = (leve.Repeats > 0) ? leve.NumItems * (leve.Repeats + 1) : leve.NumItems;

            if (numLeves > 1)
            {
                amount *= numLeves;
            }

            return($@"
            {{'Item': {leve.ItemId},
               'Group': 0,
               'Amount': {amount},
               'Collectable': false,
               'QuickSynth': false,
               'SuborderQuickSynth': false,
               'Hq': false,
               'Food': 0,
               'Primary': true,
               'Type': '{leve.Classes}',
               'Enabled': true,
               'Manual': 0,
               'Medicine': 0}},");
        }
Exemplo n.º 2
0
        public override async Task <bool> InvokeAsync(string paramList)
        {
            if (string.IsNullOrEmpty(paramList) || !File.Exists(paramList))
            {
                OutputInformation($"Please specify db location {paramList}");
                return(false);
            }
            if (File.Exists($"{paramList}.backup"))
            {
                File.Delete($"{paramList}.backup");
            }
            File.Copy(paramList, $"{paramList}.backup");
            var existing = JsonConvert.DeserializeObject <LeveDatabase>(File.ReadAllText(paramList));

            var items    = _Realm.GameData.GetSheet <SaintCoinach.Xiv.CraftLeve>();
            var levenpcs = _Realm.GameData.GetSheet <SaintCoinach.Xiv.Level>();

            foreach (var ir in items)
            {
                var t = ir.Leve;
                if (t.LeveAssignmentType.Key > 4 && t.LeveAssignmentType.Key < 13 && existing.Leves.All(i => i.LeveId != t.Key))
                {
                    var item = ir.Items.First().Item;
                    var next = new Leve
                    {
                        Classes  = t.LeveAssignmentType.Name,
                        ItemId   = item.Key,
                        ItemName = item.Name,
                        LeveId   = t.Key,
                        //Level = t.CharacterLevel, //t.StartLevel.Map.TerritoryType.Key,
                        Name     = t.Name,
                        NumItems = ir.Items.Sum(i => i.Count),
                        //PickUpNpc = (t.ZonePlaceName.Key == 2404) ? 1018997 : 0,
                        TurnInNpc = t.LevemeteLevel.Object.Key
                    };
                    if (next.PickUpNpc == 0)
                    {
                        continue;
                    }

                    existing.Leves.Add(next);
                    OutputInformation($"Added Leve # {next.LeveId} - {next.Name} - {next.Classes}");
                    if (existing.Npcs.All(i => i.NpcId != next.TurnInNpc))
                    {
                        var x = levenpcs.First(i => i.Object.Key == next.TurnInNpc);

                        var nnpc = new LeveNpc
                        {
                            LocationName = x.Map.PlaceName.Name,
                            MapId        = x.Map.Key,
                            NpcId        = next.TurnInNpc,
                            Pos          = new Vector3(x.X, x.Y, x.Z)
                        };
                        OutputInformation($"Added Turn In NPC # {nnpc.NpcId} - {nnpc.LocationName} - {nnpc.Pos}");
                        existing.Npcs.Add(nnpc);
                    }

                    if (next.PickUpNpc != 0 && existing.Npcs.All(i => i.NpcId != next.PickUpNpc))
                    {
                        var x = levenpcs.First(i => i.Object.Key == next.PickUpNpc);

                        var nnpc = new LeveNpc {
                            LocationName = x.Map.PlaceName.Name,
                            MapId        = x.Map.Key,
                            NpcId        = next.PickUpNpc,
                            Pos          = new Vector3(x.X, x.Y, x.Z)
                        };
                        OutputInformation($"Added Turn In NPC # {nnpc.NpcId} - {nnpc.LocationName} - {nnpc.Pos}");
                        existing.Npcs.Add(nnpc);
                    }
                }
            }

            OutputInformation($"Validating NPC data...");
            var copy = new List <LeveNpc>();

            foreach (var nnpc in existing.Npcs)
            {
                OutputInformation($"Checking {nnpc.NpcId}");
                var x = levenpcs.FirstOrDefault(i => i.Object.Key == nnpc.NpcId);
                if (x == null)
                {
                    continue;
                }
                OutputInformation($"Found {levenpcs.Count(i => i.Object.Key == nnpc.NpcId)}");

                if (nnpc.Pos.X != x.X || nnpc.Pos.Y != x.Y || nnpc.Pos.Z != x.Z || nnpc.MapId != x.Map.Key)
                {
                    OutputInformation($"Updating {nnpc.NpcId}");
                    OutputInformation($"Updating {x.X} {x.Y} {x.Z}");
                    OutputInformation($"Updating {x.Map.Key}");
                    OutputInformation($"Updating {x.Map.PlaceName.Name}");
                    copy.Add(new LeveNpc {
                        LocationName = x.Map.PlaceName.Name,
                        MapId        = x.Map.Key,
                        NpcId        = x.Object.Key,
                        Pos          = new Vector3(x.X, x.Y, x.Z)
                    });
                    OutputInformation($"Done Updating {nnpc.NpcId}");
                }
            }
            OutputInformation($"Before Remove");
            existing.Npcs.RemoveAll(x => copy.Any(i => i.NpcId == x.NpcId));
            OutputInformation($"After Remove");
            existing.Npcs.AddRange(copy);
            OutputInformation($"After Add Range");
            File.WriteAllText(paramList, JsonConvert.SerializeObject(existing, Formatting.Indented));

            return(true);
        }
Exemplo n.º 3
0
        private static string WriteOrder(LeveDatabase db, Leve leve, bool continueOnLevel, bool hqOnly, bool generateLisbeth)
        {
            var pickup       = db.Npcs.First(i => i.NpcId == leve.PickUpNpc);
            var pickuploc    = $"{formatFloat(pickup.Pos.X)},{formatFloat(pickup.Pos.Y)},{formatFloat(pickup.Pos.Z)}";
            var turnin       = db.Npcs.First(i => i.NpcId == leve.TurnInNpc);
            var turninloc    = $"{formatFloat(turnin.Pos.X)},{formatFloat(turnin.Pos.Y)},{formatFloat(turnin.Pos.Z)}";
            var itemcount    = hqOnly ? "HqItemCount" : "ItemCount";
            var hqonlyattrib = hqOnly ? @"HqOnly=""true""" : string.Empty;

            ClassJobType leveClass;

            ClassJobType.TryParse(leve.Classes, out leveClass);
            var col = (continueOnLevel) ? $" and Core.Me.Levels[ClassJobType.{leveClass}] &lt; " + (leve.Level >= 50 ? leve.Level + 2 : leve.Level + 5) : "";
            // Default to 5 leves (5 items for single turnins, 15 items for triple turnins)
            int numLeves = 5;
            // ExpReward * 2.0 is assuming all of the items are HQ'd and .5 for the exp crafting suborders.
            var rewardModifier = 2.5;

            var output = "";

#if RB_CN
            var LeveTag = "YesText=\"继续交货\""; //
#else
            var LeveTag = @"";
#endif

            var outputTurnin = $@"
        <LgSwitchGearset Job=""{leve.Classes}"" />
        <While Condition=""ExBuddy.Windows.GuildLeve.Allowances &gt; 0 and {itemcount}({leve.ItemId}) &gt; {leve.NumItems - 1}{col} and Core.Me.Levels[ClassJobType.{leveClass}] &gt;= {leve.Level}"">
            <If Condition=""not IsOnMap({pickup.MapId})"">
                <GetTo ZoneId=""{pickup.MapId}"" XYZ=""{pickuploc}"" />
            </If>
            <ExPickupGuildLeve LeveIds=""{leve.LeveId}"" LeveType=""{Localization.Localization.Tradecraft}"" NpcId=""{pickup.NpcId}"" NpcLocation=""{pickuploc}"" Timeout=""5"" />
            <If Condition=""not IsOnMap({turnin.MapId})"">
                <GetTo ZoneId=""{turnin.MapId}"" XYZ=""{turninloc}"" />
            </If>
            <ExTurnInGuildLeve NpcId=""{turnin.NpcId}"" NpcLocation=""{turninloc}"" {hqonlyattrib} {LeveTag} />
        </While>";

            if (generateLisbeth)
            {
                // Optimize EXP is checked, figure out optimal orders to craft.
                if (continueOnLevel)
                {
                    var currentLevel  = Core.Me.Levels[leveClass];
                    var nextLeveJump  = leve.Level >= 50 ? 2 : 5;
                    var nextLeveLevel = leve.Level + nextLeveJump;
                    var requiredExp   = 0;

                    for (var i = 0; i < (nextLeveLevel - currentLevel); i++)
                    {
                        requiredExp += ExpRequired[currentLevel + i];
                    }

                    numLeves = (int)(requiredExp / (leve.ExpReward * rewardModifier));

                    output += $@"
        <While Condition=""Core.Me.Levels[ClassJobType.{leveClass}] &gt;= {leve.Level} and Core.Me.Levels[ClassJobType.{leveClass}] &lt; {nextLeveLevel}"">";
                }
                output += $@"
        <If Condition=""ItemCount({leve.ItemId}) &lt; {leve.NumItems}"">
            {WriteLisbeth(db, leve, numLeves)}
        </If>
        {outputTurnin}
        ";
                if (continueOnLevel)
                {
                    output += $@"
        </While>";
                }
            }
            else
            {
                output += outputTurnin;
            }

            return(output);
        }
Exemplo n.º 4
0
 private static string WriteLisbeth(LeveDatabase db, Leve leve, int numLeves)
 {
     return($@"
 <Lisbeth Json=""[{WriteLisbethSubOrder(leve, numLeves)}]"" />");
 }