Ejemplo n.º 1
0
        public static void ShowHoldbackDialog(Contract contract, AAR_SalvageScreen salvageScreen)
        {
            List <string> heldbackItemsDesc = new List <string>();

            foreach (SalvageDef sDef in ModState.HeldbackParts)
            {
                string localItemName        = new Text(sDef.Description.Name).ToString();
                string localItemAndQuantity =
                    new Text(
                        Mod.Config.DialogText[ModConfig.DT_ITEM_AND_QUANTITY], new object[] { localItemName, sDef.Count }
                        ).ToString();
                localItemAndQuantity = AppendExistingPartialCount(localItemAndQuantity, sDef);
                heldbackItemsDesc.Add(localItemAndQuantity);
            }
            string heldbackDescs = " -" + string.Join("\n -", heldbackItemsDesc.ToArray());

            List <string> compItemsDesc = new List <string>();

            foreach (SalvageDef sDef in ModState.CompensationParts)
            {
                string localItemName        = new Text(sDef.Description.Name).ToString();
                string localItemAndQuantity =
                    new Text(
                        Mod.Config.DialogText[ModConfig.DT_ITEM_AND_QUANTITY], new object[] { localItemName, sDef.Count }
                        ).ToString();
                compItemsDesc.Add(localItemAndQuantity);
            }
            string compDescs = " -" + string.Join("\n -", compItemsDesc.ToArray());

            int acceptRepMod  = LootMagnet.Random.Next(Mod.Config.Holdback.ReputationRange[0], Mod.Config.Holdback.ReputationRange[1]);
            int refuseRepMod  = LootMagnet.Random.Next(Mod.Config.Holdback.ReputationRange[0], Mod.Config.Holdback.ReputationRange[1]);
            int disputeRepMod = LootMagnet.Random.Next(Mod.Config.Holdback.ReputationRange[0], Mod.Config.Holdback.ReputationRange[1]);

            Mod.Log.Debug($"Reputation modifiers - accept:{acceptRepMod} refuse:{refuseRepMod} dispute:{disputeRepMod}");

            Dispute dispute = new Dispute(contract.InitialContractValue, contract.Name);

            void acceptAction()
            {
                AcceptAction(salvageScreen, acceptRepMod);
            }

            void refuseAction()
            {
                RefuseAction(salvageScreen, refuseRepMod);
            }

            void disputeAction()
            {
                DisputeAction(contract, salvageScreen, dispute);
            }

            string localDialogTitle = new Text(Mod.Config.DialogText[ModConfig.DT_DISPUTE_TITLE]).ToString();
            string localDialogText  = new Text(
                Mod.Config.DialogText[ModConfig.DT_DISPUTE_TEXT], new object[] {
                ModState.Employer, heldbackDescs, compDescs, refuseRepMod, acceptRepMod,
                SimGameState.GetCBillString(dispute.MRBFees), dispute.SuccessChance,
                Mod.Config.Holdback.DisputePicks[0], Mod.Config.Holdback.DisputePicks[1],
                (100 - dispute.SuccessChance),
                Mod.Config.Holdback.DisputePicks[0], Mod.Config.Holdback.DisputePicks[1],
            }
                ).ToString();
            string       localButtonRefuse  = new Text(Mod.Config.DialogText[ModConfig.DT_BUTTON_REFUSE]).ToString();
            string       localButtonAccept  = new Text(Mod.Config.DialogText[ModConfig.DT_BUTTON_ACCEPT]).ToString();
            string       localButtonDispute = new Text(Mod.Config.DialogText[ModConfig.DT_BUTTON_DISPUTE]).ToString();
            GenericPopup gp = GenericPopupBuilder.Create(localDialogTitle, localDialogText)
                              .AddButton(localButtonRefuse, refuseAction, true, null)
                              .AddButton(localButtonAccept, acceptAction, true, null)
                              .AddButton(localButtonDispute, disputeAction, true, null)
                              .Render();

            TextMeshProUGUI contentText = (TextMeshProUGUI)Traverse.Create(gp).Field("_contentText").GetValue();

            contentText.alignment = TextAlignmentOptions.Left;
        }
Ejemplo n.º 2
0
        public static void DisputeAction(Contract contract, AAR_SalvageScreen salvageScreen, Dispute dispute)
        {
            Mod.Log.Info($"Player disputed holdback.");

            SimGameState sgs = UnityGameInstance.BattleTechGame.Simulation;

            Mod.Log.Info($"  Dispute legal fees:{dispute.MRBFees}");
            sgs.AddFunds(dispute.MRBFees, $"MRB Legal Fees re: {contract.Name}", false);

            Dispute.Outcome outcome = dispute.GetOutcome();
            if (outcome == Dispute.Outcome.SUCCESS)
            {
                Mod.Log.Info($"DISPUTE SUCCESS: Player keeps disputed salvage and gains {dispute.Picks} items from compensation pool.");

                // Update quantities of compensation parts
                Mod.Log.Debug("  -- Updating quantities on compensation parts.");
                List <string> compItemsDesc = new List <string>();
                int           loopCount     = 0;
                foreach (SalvageDef compSDef in State.CompensationParts)
                {
                    if (loopCount < dispute.Picks)
                    {
                        loopCount++;
                    }
                    else
                    {
                        break;
                    }

                    Mod.Log.Debug($"   compensation salvageDef:{compSDef.Description.Name} with quantity:{compSDef.Count}");
                    foreach (SalvageDef sDef in State.PotentialSalvage)
                    {
                        Mod.Log.Debug($"   salvageDef:{sDef.Description.Name} with quantity:{sDef.Count}");

                        if (compSDef.RewardID == sDef.RewardID)
                        {
                            Mod.Log.Debug($"   Matched compensation target, updating quantity to: {compSDef.Count + sDef.Count}");
                            compItemsDesc.Add($"{compSDef.Description.Name} [QTY:{compSDef.Count}]");
                            sDef.Count = sDef.Count + compSDef.Count;
                            break;
                        }
                    }
                }
                string compDescs = " -" + string.Join("\n -", compItemsDesc.ToArray());

                // Display the confirmation screen
                GenericPopupBuilder.Create(
                    "SUCCESSFUL DISPUTE",
                    $"<b>Cause 193 of the negotiated mercenary contract clearly states...</b>\n\n" +
                    $"Your laywer deftly defend your claim with the MRB. You keep your salvage, and gain the following compensation items:" +
                    $"\n\n{compDescs}\n\n"
                    )
                .AddButton("OK")
                .Render();
            }
            else
            {
                Mod.Log.Info($"DISPUTE FAILURE: Player loses disputed items, and {dispute.Picks} items from the salvage pool.");

                // Remove the disputed items
                Mod.Log.Debug("  -- Removing disputed items.");
                foreach (SalvageDef sDef in State.HeldbackParts)
                {
                    Helper.RemoveSalvage(sDef);
                }

                // Update quantities of compensation parts
                Mod.Log.Debug("  -- Determining dispute failure picks.");
                List <SalvageDef> disputePicks = new List <SalvageDef>();
                List <SalvageDef> components   = State.PotentialSalvage.Where(sd => sd.Type == SalvageDef.SalvageType.COMPONENT).ToList();
                components.Sort(new Helper.SalvageDefByCostDescendingComparer());
                int loopCount = 0;
                foreach (SalvageDef compDef in components)
                {
                    if (loopCount < dispute.Picks)
                    {
                        loopCount++;
                    }
                    else
                    {
                        break;
                    }

                    Mod.Log.Debug($"   dispute fail salvageDef:{compDef.Description.Name} with quantity:{compDef.Count}");
                    disputePicks.Add(compDef);
                    State.PotentialSalvage.Remove(compDef);
                }

                List <string> heldbackItemsDesc = new List <string>();
                foreach (SalvageDef sDef in State.HeldbackParts)
                {
                    heldbackItemsDesc.Add($"{sDef.Description.Name} [QTY:{sDef.Count}]");
                }
                string heldbackDescs = " -" + string.Join("\n -", heldbackItemsDesc.ToArray());

                List <string> disputeDesc = new List <string>();
                foreach (SalvageDef sDef in disputePicks)
                {
                    disputeDesc.Add($"{sDef.Description.Name} [QTY:{sDef.Count}]");
                }
                string disputeDescs = " -" + string.Join("\n -", disputeDesc.ToArray());

                // Display the configmration screen
                GenericPopupBuilder.Create(
                    "FAILED DISPUTE",
                    $"<b>Judge</b>: Counselor, what evidence do you offer for this new plea of insanity?\n\n" +
                    $"<b>Attorney</b>: Well, for one, they done hired me to represent them.\n\n" +
                    $"<b>Judge</b>: Insanity plea is accepted.\n\n" +
                    $"{State.Employer}'s legal team completely ran away with the proceeding, painting {sgs.CompanyName} in the worst possible light." +
                    $"You lose salvage rights to all of the following:" +
                    $"\n\n{heldbackDescs}\n\n" +
                    $"In addition they claim the following as compensation for legal fees:" +
                    $"\n\n{disputeDescs}\n\n"
                    )
                .AddButton("OK")
                .Render();
            }

            // Roll up any remaining salvage and widget-tize it
            List <SalvageDef> rolledUpSalvage = Helper.RollupSalvage(State.PotentialSalvage);

            Helper.CalculateAndAddAvailableSalvage(salvageScreen, rolledUpSalvage);

            State.Reset();
        }
Ejemplo n.º 3
0
        public static void DisputeAction(Contract contract, AAR_SalvageScreen salvageScreen, Dispute dispute)
        {
            Mod.Log.Info($"Player disputed holdback.");

            SimGameState sgs = UnityGameInstance.BattleTechGame.Simulation;

            Mod.Log.Info($"  Dispute legal fees:{dispute.MRBFees}");
            sgs.AddFunds(dispute.MRBFees, $"MRB Legal Fees re: {contract.Name}", false);

            Dispute.Outcome outcome = dispute.GetOutcome();
            if (outcome == Dispute.Outcome.SUCCESS)
            {
                Mod.Log.Info($"DISPUTE SUCCESS: Player keeps disputed salvage and gains {dispute.Picks} items from compensation pool.");

                // Update quantities of compensation parts
                Mod.Log.Debug("  -- Updating quantities on compensation parts.");
                List <string> compItemsDesc = new List <string>();
                int           loopCount     = 0;
                foreach (SalvageDef compSDef in ModState.CompensationParts)
                {
                    if (loopCount < dispute.Picks)
                    {
                        loopCount++;
                    }
                    else
                    {
                        break;
                    }

                    Mod.Log.Debug($"   compensation salvageDef:{compSDef.Description.Name} with quantity:{compSDef.Count}");
                    foreach (SalvageDef sDef in ModState.PotentialSalvage)
                    {
                        Mod.Log.Debug($"   salvageDef:{sDef.Description.Name} with quantity:{sDef.Count}");

                        if (compSDef.RewardID == sDef.RewardID)
                        {
                            Mod.Log.Debug($"   Matched compensation target, updating quantity to: {compSDef.Count + sDef.Count}");

                            string localItemName        = new Text(compSDef.Description.Name).ToString();
                            string localItemAndQuantity =
                                new Text(
                                    Mod.Config.DialogText[ModConfig.DT_ITEM_AND_QUANTITY], new object[] { localItemName, compSDef.Count }
                                    ).ToString();
                            compItemsDesc.Add(localItemAndQuantity);
                            sDef.Count = sDef.Count + compSDef.Count;
                            break;
                        }
                    }
                }
                string compDescs = " -" + string.Join("\n -", compItemsDesc.ToArray());

                // Display the confirmation screen
                string localDialogTitle = new Text(Mod.Config.DialogText[ModConfig.DT_SUCCESS_TITLE]).ToString();
                string localDialogText  = new Text(
                    Mod.Config.DialogText[ModConfig.DT_SUCCESS_TEXT], new object[] { compDescs }
                    ).ToString();
                string localButtonOk = new Text(Mod.Config.DialogText[ModConfig.DT_BUTTON_OK]).ToString();
                GenericPopupBuilder.Create(localDialogTitle, localDialogText)
                .AddButton("OK")
                .Render();
            }
            else
            {
                Mod.Log.Info($"DISPUTE FAILURE: Player loses disputed items, and {dispute.Picks} items from the salvage pool.");

                // Remove the disputed items
                Mod.Log.Debug("  -- Removing disputed items.");
                foreach (SalvageDef sDef in ModState.HeldbackParts)
                {
                    Helper.RemoveSalvage(sDef);
                }

                // Update quantities of compensation parts
                Mod.Log.Debug("  -- Determining dispute failure picks.");
                List <SalvageDef> disputePicks = new List <SalvageDef>();
                List <SalvageDef> components   = ModState.PotentialSalvage.Where(sd => sd.Type == SalvageDef.SalvageType.COMPONENT).ToList();
                components.Sort(new Helper.SalvageDefByCostDescendingComparer());
                int loopCount = 0;
                foreach (SalvageDef compDef in components)
                {
                    if (loopCount < dispute.Picks)
                    {
                        loopCount++;
                    }
                    else
                    {
                        break;
                    }

                    Mod.Log.Debug($"   dispute fail salvageDef:{compDef.Description.Name} with quantity:{compDef.Count}");
                    disputePicks.Add(compDef);
                    ModState.PotentialSalvage.Remove(compDef);
                }

                List <string> heldbackItemsDesc = new List <string>();
                foreach (SalvageDef sDef in ModState.HeldbackParts)
                {
                    heldbackItemsDesc.Add($"{sDef.Description.Name} [QTY:{sDef.Count}]");
                }
                string heldbackDescs = " -" + string.Join("\n -", heldbackItemsDesc.ToArray());

                List <string> disputeDesc = new List <string>();
                foreach (SalvageDef sDef in disputePicks)
                {
                    disputeDesc.Add($"{sDef.Description.Name} [QTY:{sDef.Count}]");
                }
                string disputeDescs = " -" + string.Join("\n -", disputeDesc.ToArray());

                // Display the configmration screen
                string localDialogTitle = new Text(Mod.Config.DialogText[ModConfig.DT_FAILED_TITLE]).ToString();
                string localDialogText  = new Text(
                    Mod.Config.DialogText[ModConfig.DT_FAILED_TEXT], new object[] {
                    ModState.Employer, sgs.CompanyName, heldbackDescs, disputeDescs
                }).ToString();
                string localButtonOk = new Text(Mod.Config.DialogText[ModConfig.DT_BUTTON_OK]).ToString();
                GenericPopupBuilder.Create(localDialogTitle, localDialogText)
                .AddButton(localButtonOk)
                .Render();
            }

            // Roll up any remaining salvage and widget-tize it
            List <SalvageDef> rolledUpSalvage = Helper.RollupSalvage(ModState.PotentialSalvage);

            Helper.CalculateAndAddAvailableSalvage(salvageScreen, rolledUpSalvage);

            ModState.Reset();
        }
Ejemplo n.º 4
0
        public static void ShowHoldbackDialog(Contract contract, AAR_SalvageScreen salvageScreen)
        {
            List <string> heldbackItemsDesc = new List <string>();

            foreach (SalvageDef sDef in State.HeldbackParts)
            {
                heldbackItemsDesc.Add($"{sDef.Description.Name} [QTY:{sDef.Count}]");
            }
            string heldbackDescs = " -" + string.Join("\n -", heldbackItemsDesc.ToArray());

            List <string> compItemsDesc = new List <string>();

            foreach (SalvageDef sDef in State.CompensationParts)
            {
                compItemsDesc.Add($"{sDef.Description.Name} [QTY:{sDef.Count}]");
            }
            string compDescs = " -" + string.Join("\n -", compItemsDesc.ToArray());

            int acceptRepMod  = LootMagnet.Random.Next(Mod.Config.Holdback.ReputationRange[0], Mod.Config.Holdback.ReputationRange[1]);
            int refuseRepMod  = LootMagnet.Random.Next(Mod.Config.Holdback.ReputationRange[0], Mod.Config.Holdback.ReputationRange[1]);
            int disputeRepMod = LootMagnet.Random.Next(Mod.Config.Holdback.ReputationRange[0], Mod.Config.Holdback.ReputationRange[1]);

            Mod.Log.Debug($"Reputation modifiers - accept:{acceptRepMod} refuse:{refuseRepMod} dispute:{disputeRepMod}");

            Dispute dispute = new Dispute(contract);

            void acceptAction()
            {
                AcceptAction(salvageScreen, acceptRepMod);
            }

            void refuseAction()
            {
                RefuseAction(salvageScreen, refuseRepMod);
            }

            void disputeAction()
            {
                DisputeAction(contract, salvageScreen, dispute);
            }

            GenericPopup gp = GenericPopupBuilder.Create(
                "DISPUTED SALVAGE",
                $"<b>I'm sorry commander, but Section A, Sub-Section 3, Paragraph ii...</b>\n\n" +
                $"As the salvage crew picks over the battlefield, you are contacted by the {State.Employer} representative. " +
                $"They insist the contract terms allows them first rights to the following items:" +
                $"\n\n{heldbackDescs}\n\n" +
                $"They offer to add the following to the <b>salvage pool</b> in exchange:" +
                $"\n\n{compDescs}\n\n" +
                $"You may choose to:\n" +
                $"<b>Refuse</b>: the disputed salvage is retained, you <b>lose</b> <color=#FF0000>{refuseRepMod}</color> rep.\n" +
                $"<b>Accept</b>: the disputed salvage is lost, exchanged items are added to the <b>salvage pool</b>, " +
                $"you gain <b>gain</b> <color=#00FF00>{acceptRepMod:+0}</color> rep.\n" +
                $"<b>Dispute</b>: you pay <color=#FF0000>{SimGameState.GetCBillString(dispute.MRBFees)}</color> in legal fees, and have:\n" +
                $"<line-indent=2px> - {dispute.SuccessChance}% to keep the disputed salvage, and the salvage pool" +
                $"gains {Mod.Config.Holdback.DisputePicks[0]}-{Mod.Config.Holdback.DisputePicks[1]} from the compensation offer.\n" +
                $"<line-indent=2px> - {100 - dispute.SuccessChance}% to lose the disputed salvage, and " +
                $"an additional {Mod.Config.Holdback.DisputePicks[0]}-{Mod.Config.Holdback.DisputePicks[1]} selections in the salvage pool.\n"
                )
                              .AddButton("Refuse", refuseAction, true, null)
                              .AddButton("Accept", acceptAction, true, null)
                              .AddButton("Dispute", disputeAction, true, null)
                              .Render();

            TextMeshProUGUI contentText = (TextMeshProUGUI)Traverse.Create(gp).Field("_contentText").GetValue();

            contentText.alignment = TextAlignmentOptions.Left;
        }