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(); }
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(); }