private void Unequip(int slot) { Behaviour implant; if (slot == 1) { implant = equipmentSlot1; implant.enabled = false; equipmentSlot1 = null; } if (slot == 2) { implant = equipmentSlot2; implant.enabled = false; equipmentSlot2 = null; } if (slot == 3) { implant = equipmentSlot3; implant.enabled = false; equipmentSlot3 = null; } inventoryWindow.SendBackToInventory(slot); }
/// <summary> /// Update the comboboxes' selections. /// </summary> private void UpdateSlots() { SerializableSettingsImplantSet set = GetSelectedSet(); // No set selected or row name empty? if (set == null || String.IsNullOrEmpty(set.Name)) { foreach (DropDownMouseMoveComboBox combo in Controls.OfType <DropDownMouseMoveComboBox>()) { // Disable the combo with the <None> implant combo.SelectedIndex = 0; combo.Visible = true; combo.Enabled = false; // Hide the label used for read-only sets ImplantSlots slot = (ImplantSlots)combo.Tag; Label label = m_labels[(int)slot]; label.Visible = false; } return; } // Scroll through comboboxes bool isReadOnly = set == m_sets.ActiveClone || m_sets.JumpClones.Any(x => x == set); foreach (DropDownMouseMoveComboBox combo in Controls.OfType <DropDownMouseMoveComboBox>()) { // Enable the combo with the <None> implant combo.SelectedIndex = 0; combo.Visible = !isReadOnly; combo.Enabled = true; ImplantSlots slot = (ImplantSlots)combo.Tag; Implant selectedImplant = GetImplant(set, slot); // Scroll through every implant and check whether it is the selected one. int index = 0; foreach (Implant implant in combo.Items) { if (implant == selectedImplant) { combo.SelectedIndex = index; break; } index++; } // Set "none" when the implant was not found. if (index == combo.Items.Count) { combo.SelectedIndex = 0; } // Updates the label displayed for read-only sets. Label label = m_labels[(int)slot]; label.Visible = isReadOnly; label.Text = selectedImplant.Name; label.Tag = selectedImplant; } }
/// <summary> /// When the mouse moves over the implants combos (used for writable sets), we display a tooltip on the right of the combo. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void combo_MouseMove(object sender, MouseEventArgs e) { var combo = (DropDownMouseMoveComboBox)sender; var implant = combo.SelectedItem as Implant; if (implant == null) { return; } if (m_fakeToolTip.Visible && m_fakeToolTip.Implant == implant) { return; } Point point = new Point(); point.X = combo.Width + 5; point.Y = 1; m_fakeToolTip.Location = combo.PointToScreen(point); m_fakeToolTip.Implant = implant; m_fakeToolTip.ShowInactiveTopmost(); m_lastImplant = implant; }
public void DegenerateLadderProcessWhenNoFinalLadderImplants() { var finalImplantTemplates = new[] { ImplantTemplate.GetImplantTemplate(ImplantSlot.Head, Skill.MatterCrea, Skill.NanoPool, Skill.Tutoring), // Intelligence ImplantTemplate.GetImplantTemplate(ImplantSlot.LeftWrist, Skill.MultMelee, Skill.RunSpeed, Skill.NanoResist), // Agility ImplantTemplate.GetImplantTemplate(ImplantSlot.RightArm, Skill.OneHandBlunt, ArmorClass.ChemicalAC, ArmorClass.RadiationAC), // Strength ImplantTemplate.GetImplantTemplate(ImplantSlot.Waist, ArmorClass.ChemicalAC, MaxHealthOrNano.MaxNano, Skill.BioMetamor) // Sense }; var ladderProcess = new DegenerateLadderProcess(_character, finalImplantTemplates); Assert.AreEqual( Implant.GetMaxImplantQL(_character.GetAbilityValue(Ability.Intelligence), _character.TreatmentValue), ladderProcess.OrderedFinalImplants.Single(i => i.ImplantTemplate == finalImplantTemplates[0]).QL); Assert.AreEqual( Implant.GetMaxImplantQL(_character.GetAbilityValue(Ability.Agility), _character.TreatmentValue), ladderProcess.OrderedFinalImplants.Single(i => i.ImplantTemplate == finalImplantTemplates[1]).QL); Assert.AreEqual( Implant.GetMaxImplantQL(_character.GetAbilityValue(Ability.Strength), _character.TreatmentValue), ladderProcess.OrderedFinalImplants.Single(i => i.ImplantTemplate == finalImplantTemplates[2]).QL); Assert.AreEqual( Implant.GetMaxImplantQL(_character.GetAbilityValue(Ability.Sense), _character.TreatmentValue), ladderProcess.OrderedFinalImplants.Single(i => i.ImplantTemplate == finalImplantTemplates[3]).QL); // Implants should be unequipped right now and stats should be the same as they were before laddering. Assert.AreEqual(0, _character.GetAverageImplantQL()); Assert.AreEqual(0, _character.GetTotalImplantQL()); Assert.AreEqual(91, _character.GetAbilityValue(Ability.Agility)); Assert.AreEqual(91, _character.GetAbilityValue(Ability.Stamina)); Assert.AreEqual(281.4, _character.TreatmentValue); }
public void GetMaxImplantQLForTreatmentValue() { Assert.AreEqual(0, Implant.GetMaxImplantQLForTreatmentValue(10)); Assert.AreEqual(1, Implant.GetMaxImplantQLForTreatmentValue(11)); Assert.AreEqual(1, Implant.GetMaxImplantQLForTreatmentValue(13)); Assert.AreEqual(1, Implant.GetMaxImplantQLForTreatmentValue(15)); Assert.AreEqual(2, Implant.GetMaxImplantQLForTreatmentValue(16)); Assert.AreEqual(19, Implant.GetMaxImplantQLForTreatmentValue(100.9)); Assert.AreEqual(20, Implant.GetMaxImplantQLForTreatmentValue(101)); Assert.AreEqual(21, Implant.GetMaxImplantQLForTreatmentValue(109)); Assert.AreEqual(22, Implant.GetMaxImplantQLForTreatmentValue(110.9)); Assert.AreEqual(22, Implant.GetMaxImplantQLForTreatmentValue(114.5)); Assert.AreEqual(23, Implant.GetMaxImplantQLForTreatmentValue(115.5)); Assert.AreEqual(158, Implant.GetMaxImplantQLForTreatmentValue(756.4)); Assert.AreEqual(159, Implant.GetMaxImplantQLForTreatmentValue(757.9)); Assert.AreEqual(159, Implant.GetMaxImplantQLForTreatmentValue(761)); Assert.AreEqual(160, Implant.GetMaxImplantQLForTreatmentValue(762)); Assert.AreEqual(188, Implant.GetMaxImplantQLForTreatmentValue(898.9)); Assert.AreEqual(189, Implant.GetMaxImplantQLForTreatmentValue(899)); Assert.AreEqual(189, Implant.GetMaxImplantQLForTreatmentValue(903.9)); Assert.AreEqual(190, Implant.GetMaxImplantQLForTreatmentValue(904.9)); Assert.AreEqual(191, Implant.GetMaxImplantQLForTreatmentValue(912.9)); Assert.AreEqual(192, Implant.GetMaxImplantQLForTreatmentValue(915)); Assert.AreEqual(192, Implant.GetMaxImplantQLForTreatmentValue(917.9)); Assert.AreEqual(193, Implant.GetMaxImplantQLForTreatmentValue(918)); Assert.AreEqual(199, Implant.GetMaxImplantQLForTreatmentValue(950)); Assert.AreEqual(200, Implant.GetMaxImplantQLForTreatmentValue(951)); Assert.AreEqual(200, Implant.GetMaxImplantQLForTreatmentValue(1001)); }
public static TimePeriod CreateTimePeriodFromModel(TimePeriodModel model) { TimePeriod tp; switch (model.Type) { case "Cultivate": { tp = new Cultivate(); break; } case "Implant": { tp = new Implant(); break; } case "Bloom": { tp = new Bloom(); break; } case "Sowing": { tp = new Sowing(); break; } case "Harvest": { tp = new Harvest(); break; } case "SeedMaturity": { tp = new SeedMaturity(); break; } case "LifeTime": { tp = new LifeTime(); break; } default: tp = new LifeTime(); break; } tp.Id = model.Id; tp.Start = model.Start; tp.StartArea = model.StartArea; tp.StartMonth = model.StartMonth; tp.EndArea = model.EndArea; tp.EndMonth = model.EndMonth; if (model.Next != null) { tp.Next = CreateTimePeriodFromModel(model.Next); } return(tp); }
public void CanEquipQL50StoreBoughtEyeImplantAfterEquippingIntelligenceImplant() { var eye = Implant.GetImplant(ImplantSlot.Eye, Skill.Tutoring, Skill.PsychoModi, Skill.TimeAndSpace, 50); var head = Implant.GetImplant(ImplantSlot.Head, Ability.Intelligence, null, null, 20); Assert.IsTrue(_character.TryEquipImplant(head)); Assert.IsTrue(_character.TryEquipImplant(eye)); }
public StepModel(Implant implant) { ImplantQL = implant.QL; ImplantSlot = implant.ImplantSlot?.Name; ShinyStat = implant.ShinyStat?.Name; BrightStat = implant.BrightStat?.Name; FadedStat = implant.FadedStat?.Name; }
void OnEnable() { _Implant = target as Implant; CreateUI(); if (_Implant.Points == null || _Implant.Points.Length != _Implant.Density) { Shuffle(); } }
public void GetRequiredAbilityValues() { Assert.AreEqual(6, Implant.GetRequiredAbilityValue(1)); Assert.AreEqual(30, Implant.GetRequiredAbilityValue(13)); Assert.AreEqual(112, Implant.GetRequiredAbilityValue(54)); Assert.AreEqual(114, Implant.GetRequiredAbilityValue(55)); Assert.AreEqual(116, Implant.GetRequiredAbilityValue(56)); Assert.AreEqual(202, Implant.GetRequiredAbilityValue(99)); Assert.AreEqual(404, Implant.GetRequiredAbilityValue(200)); }
public void EquipMaxImplantUnequipsFirst() { _character.SetAbilityValue(Ability.Agility, 300); // Max sure it's not the limiting factor. var lowHead = Implant.GetImplant(ImplantSlot.Head, Skill.Treatment, null, Ability.Sense, 20); var maxHead1 = _character.GetMaxImplant(lowHead.ImplantTemplate); _character.SetImplant(lowHead); var maxHead2 = _character.GetMaxImplant(lowHead.ImplantTemplate); var impossibleHotswapQL = Implant.GetMaxImplantQL(_character.GetAbilityValue(Ability.Agility), _character.TreatmentValue); Assert.AreEqual(maxHead1.QL, maxHead2.QL); Assert.IsTrue(impossibleHotswapQL > maxHead1.QL); }
public void GetsTotalTreatmentIncrease() { var leftHand = Implant.GetImplant(ImplantSlot.LeftHand, Skill.FastAttack, ArmorClass.FireAC, Skill.MartialArts, 155); Assert.AreEqual(0, leftHand.TotalTreatmentIncrease); var head1 = Implant.GetImplant(ImplantSlot.Head, Skill.Treatment, null, Ability.Sense, 200); Assert.AreEqual(106.1, head1.TotalTreatmentIncrease); var head2 = Implant.GetImplant(ImplantSlot.Head, Ability.Intelligence, null, Ability.Sense, 200); Assert.AreEqual(7.975, head2.TotalTreatmentIncrease); }
public void GetRequiredTreatmentValues() { Assert.AreEqual(11, Implant.GetRequiredTreatmentValue(1)); Assert.AreEqual(35, Implant.GetRequiredTreatmentValue(6)); Assert.AreEqual(162, Implant.GetRequiredTreatmentValue(33)); Assert.AreEqual(460, Implant.GetRequiredTreatmentValue(96)); Assert.AreEqual(549, Implant.GetRequiredTreatmentValue(115)); Assert.AreEqual(554, Implant.GetRequiredTreatmentValue(116)); Assert.AreEqual(559, Implant.GetRequiredTreatmentValue(117)); Assert.AreEqual(564, Implant.GetRequiredTreatmentValue(118)); Assert.AreEqual(568, Implant.GetRequiredTreatmentValue(119)); Assert.AreEqual(573, Implant.GetRequiredTreatmentValue(120)); Assert.AreEqual(946, Implant.GetRequiredTreatmentValue(199)); Assert.AreEqual(951, Implant.GetRequiredTreatmentValue(200)); }
/// <summary> /// When the mouse moves over one of the items of the combobox dropdown, we display a tooltip on the right of the dropdown. /// </summary> /// <param name="sender"></param> /// <param name="item"></param> /// <param name="point"></param> void combo_DropDownMouseMove(object sender, object item, Point point) { var implant = (Implant)item; //if (toolTip.Active && m_lastImplant == implant) return; var control = (Control)sender; point.X = control.ClientRectangle.Right + 20; point.Y = control.ClientRectangle.Top; m_fakeToolTip.Location = control.PointToScreen(point); m_fakeToolTip.Implant = implant; m_fakeToolTip.ShowInactiveTopmost(); m_lastImplant = implant; }
/// <summary> /// When the mouse moves over one of the items of the combobox dropdown, we display a tooltip on the right of the dropdown. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="DropDownMouseMoveEventArgs"/> instance containing the event data.</param> private void combo_DropDownMouseMove(object sender, DropDownMouseMoveEventArgs e) { Implant implant = e.Item as Implant; if (implant == null) { return; } Control control = (Control)sender; Point point = new Point(control.ClientRectangle.Right + 20, control.ClientRectangle.Top); m_fakeToolTip.Location = control.PointToScreen(point); m_fakeToolTip.Implant = implant; m_fakeToolTip.ShowInactiveTopmost(); }
public void DegenerateLadderProcessWhenASingleFinalLadderImplant() { var finalImplantTemplates = new[] { ImplantTemplate.GetImplantTemplate(ImplantSlot.Head, Skill.QuantumFT, null, Skill.Tutoring), // Agility ImplantTemplate.GetImplantTemplate(ImplantSlot.LeftWrist, Skill.MultMelee, Skill.RunSpeed, Skill.NanoResist), // Agility ImplantTemplate.GetImplantTemplate(ImplantSlot.RightArm, Skill.OneHandBlunt, ArmorClass.ChemicalAC, ArmorClass.RadiationAC), // Strength ImplantTemplate.GetImplantTemplate(ImplantSlot.Leg, Ability.Agility, Ability.Stamina, null), // Stamina ImplantTemplate.GetImplantTemplate(ImplantSlot.Waist, ArmorClass.ChemicalAC, null, Skill.BioMetamor) // Stamina }; var ladderProcess = new DegenerateLadderProcess(_character, finalImplantTemplates); Assert.AreEqual( Implant.GetMaxImplantQL(_character.GetAbilityValue(Ability.Stamina), _character.TreatmentValue), ladderProcess.OrderedFinalImplants[0].QL); Assert.AreEqual(finalImplantTemplates[3], ladderProcess.OrderedFinalImplants[0].ImplantTemplate); Assert.AreEqual( Implant.GetMaxImplantQL(_character.GetAbilityValue(Ability.Agility) + ladderProcess.OrderedFinalImplants[0].ShinyStatIncrease.Value, _character.TreatmentValue), ladderProcess.OrderedFinalImplants.Single(i => i.ImplantTemplate == finalImplantTemplates[0]).QL); Assert.AreEqual(51, ladderProcess.OrderedFinalImplants.Single(i => i.ImplantTemplate == finalImplantTemplates[0]).QL); Assert.AreEqual( Implant.GetMaxImplantQL(_character.GetAbilityValue(Ability.Agility) + ladderProcess.OrderedFinalImplants[0].ShinyStatIncrease.Value, _character.TreatmentValue), ladderProcess.OrderedFinalImplants.Single(i => i.ImplantTemplate == finalImplantTemplates[1]).QL); Assert.AreEqual( Implant.GetMaxImplantQL(_character.GetAbilityValue(Ability.Strength), _character.TreatmentValue), ladderProcess.OrderedFinalImplants.Single(i => i.ImplantTemplate == finalImplantTemplates[2]).QL); Assert.AreEqual( Implant.GetMaxImplantQL(_character.GetAbilityValue(Ability.Stamina) + ladderProcess.OrderedFinalImplants[0].ShinyStatIncrease.Value, _character.TreatmentValue), Implant.GetMaxImplantQL(_character.GetAbilityValue(Ability.Sense), _character.TreatmentValue), ladderProcess.OrderedFinalImplants.Single(i => i.ImplantTemplate == finalImplantTemplates[4]).QL); // Implants should be unequipped right now and stats should be the same as they were before laddering. Assert.AreEqual(0, _character.GetAverageImplantQL()); Assert.AreEqual(0, _character.GetTotalImplantQL()); Assert.AreEqual(91, _character.GetAbilityValue(Ability.Agility)); Assert.AreEqual(91, _character.GetAbilityValue(Ability.Stamina)); Assert.AreEqual(281.4, _character.TreatmentValue); // Using the order the ladder process outlines, all equips should be possible and maximal. foreach (var finalImplant in ladderProcess.OrderedFinalImplants) { Assert.IsTrue(_character.CanEquipImplant(finalImplant)); var maxImplant = _character.EquipMaxImplant(finalImplant.ImplantTemplate); Assert.AreEqual(maxImplant, finalImplant); } }
/// <summary> /// Gets the multiplier of an implant. /// </summary> /// <param name="implantType"></param> /// <returns></returns> private double GetImplantMultiplier(string implantType) { ImplantSet implantSet = (ImplantSet)cbImplantSet.Tag; string implantSubname = String.Format("Zainou 'Beancounter' {0}", implantType); Implant implant = implantSet.FirstOrDefault(x => x.Name.Contains(implantSubname)); if (implant == null) { return(1.0d); } double bonus = implant.Properties.FirstOrDefault(x => Array.IndexOf(DBConstants.IndustryModifyingPropertyIDs, x.Property.ID) != -1).IValue; double multiplier = 1.0d + (bonus / 100); return(multiplier); }
/// <summary> /// Gets the multiplier of an implant. /// </summary> /// <returns></returns> private double GetImplantMultiplier(ICollection <int> implantIDs) { ImplantSet implantSet = (ImplantSet)cbImplantSet.Tag; Implant implant = implantSet?.FirstOrDefault(x => implantIDs.Contains(x.ID)); if (implant == null) { return(1.0d); } double bonus = implant.Properties .FirstOrDefault(x => DBConstants.IndustryModifyingPropertyIDs.IndexOf(x.Property.ID) != -1) .Int64Value; double multiplier = 1.0d + bonus / 100; return(multiplier); }
/// <summary> /// When the mouse moves over the implants labels (used for read-only sets), we display a tooltip. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void label_MouseMove(object sender, MouseEventArgs e) { Label label = (Label)sender; Implant implant = label.Tag as Implant; if (implant == null) { return; } Point point = e.Location; point.Y += 10; m_fakeToolTip.Location = label.PointToScreen(point); m_fakeToolTip.Implant = implant; m_fakeToolTip.ShowInactiveTopmost(); }
/// <summary> /// Disables an implant /// </summary> /// <param name="implant">Name of implant to disable</param> public void DisableImplant(string implant, int equipmentSlot) { //get a reference to the component to disable Behaviour toDisable = ((Behaviour)transform.GetComponent(Type.GetType(implant))); //ensure base implants overriden by the disabled implant are re enabled after it is removed foreach (Type type in ((Implant)toDisable).IncompatibleTypes) { if (type == typeof(Jump) && toDisable != (Behaviour)jump) { jump.enabled = true; } //etc... } ////remove from the list of enabled implants //switch(equipmentSlot) //{ // case 1: // equipmentSlot1 = null; // break; // case 2: // equipmentSlot2 = null; // break; // case 3: // equipmentSlot3 = null; // break; //} if (equipmentSlot1 != null && equipmentSlot1 == ((Implant)toDisable)) { equipmentSlot1 = null; } if (equipmentSlot2 != null && equipmentSlot2 == ((Implant)toDisable)) { equipmentSlot2 = null; } if (equipmentSlot3 != null && equipmentSlot3 == ((Implant)toDisable)) { equipmentSlot3 = null; } //disable the implant toDisable.enabled = false; }
public void SetImplantIgnoresRequirementsButUnequipsFirst() { var lowHead = Implant.GetImplant(ImplantSlot.Head, Skill.Treatment, null, Ability.Sense, 20); var highHead = Implant.GetImplant(ImplantSlot.Head, Skill.Treatment, null, Ability.Sense, 200); Assert.IsTrue(_character.TryEquipImplant(lowHead)); Assert.IsFalse(_character.TryEquipImplant(highHead)); Assert.AreEqual(296, (int)_character.TreatmentValue); Assert.AreEqual(98, _character.GetAbilityValue(Ability.Sense)); Assert.IsTrue(_character.IsImplantSlotFull(ImplantSlot.Head)); Assert.IsFalse(_character.IsImplantSlotFull(ImplantSlot.LeftArm)); _character.SetImplant(highHead); Assert.AreEqual(highHead, _character.GetImplant(ImplantSlot.Head)); Assert.AreEqual(387.5, _character.TreatmentValue); Assert.AreEqual(116, _character.GetAbilityValue(Ability.Sense)); Assert.IsTrue(_character.IsImplantSlotFull(ImplantSlot.Head)); Assert.IsFalse(_character.IsImplantSlotFull(ImplantSlot.LeftArm)); }
public void VerifiesAbilityAndTreatmentRequirements() { var leftHand = Implant.GetImplant(ImplantSlot.LeftHand, Skill.FastAttack, ArmorClass.FireAC, Skill.MartialArts, 155); Assert.AreEqual(Ability.Agility, leftHand.RequiredAbility); Assert.AreEqual(314, leftHand.RequiredAbilityValue); Assert.AreEqual(738, leftHand.RequiredTreatmentValue); var feet = Implant.GetImplant(ImplantSlot.Feet, Skill.EvadeClsC, Skill.MartialArts, Skill.DuckExp, 144); Assert.AreEqual(Ability.Agility, feet.RequiredAbility); Assert.AreEqual(292, feet.RequiredAbilityValue); Assert.AreEqual(686, feet.RequiredTreatmentValue); var eye = Implant.GetImplant(ImplantSlot.Eye, Skill.AimedShot, Skill.SensoryImpr, Skill.SharpObj, 132); Assert.AreEqual(Ability.Agility, eye.RequiredAbility); Assert.AreEqual(268, eye.RequiredAbilityValue); Assert.AreEqual(630, eye.RequiredTreatmentValue); }
public void GetMaxImplantQLForAbilityValue() { Assert.AreEqual(0, Implant.GetMaxImplantQLForAbilityValue(5)); Assert.AreEqual(1, Implant.GetMaxImplantQLForAbilityValue(7)); Assert.AreEqual(4, Implant.GetMaxImplantQLForAbilityValue(13)); Assert.AreEqual(7, Implant.GetMaxImplantQLForAbilityValue(19)); Assert.AreEqual(33, Implant.GetMaxImplantQLForAbilityValue(70)); Assert.AreEqual(33, Implant.GetMaxImplantQLForAbilityValue(71)); Assert.AreEqual(34, Implant.GetMaxImplantQLForAbilityValue(72)); Assert.AreEqual(34, Implant.GetMaxImplantQLForAbilityValue(73)); Assert.AreEqual(35, Implant.GetMaxImplantQLForAbilityValue(74)); Assert.AreEqual(35, Implant.GetMaxImplantQLForAbilityValue(75)); Assert.AreEqual(36, Implant.GetMaxImplantQLForAbilityValue(76)); Assert.AreEqual(36, Implant.GetMaxImplantQLForAbilityValue(77)); Assert.AreEqual(178, Implant.GetMaxImplantQLForAbilityValue(361)); Assert.AreEqual(197, Implant.GetMaxImplantQLForAbilityValue(399)); Assert.AreEqual(199, Implant.GetMaxImplantQLForAbilityValue(403)); Assert.AreEqual(200, Implant.GetMaxImplantQLForAbilityValue(404)); Assert.AreEqual(200, Implant.GetMaxImplantQLForAbilityValue(450)); }
public void DegenerateLadderProcessEquipsImplantsInTheProperThreePhases() { // The three phases are // 1. the final ladder implants in initially empty slots, // 2. the final non-ladder implants in initially empty slots, // 3. the final implants in initially full slots. var alreadyEquippedImplants = new[] { Implant.GetImplant(ImplantSlot.Head, Skill.Treatment, null, Ability.Sense, 200), Implant.GetImplant(ImplantSlot.Leg, Ability.Agility, Ability.Stamina, null, 200), Implant.GetImplant(ImplantSlot.Ear, Skill.Perception, null, Ability.Intelligence, 200) }; _character.SetImplants(alreadyEquippedImplants); var finalImplantTemplates = new[] { ImplantTemplate.GetImplantTemplate(ImplantSlot.Chest, Ability.Sense, Ability.Psychic, Ability.Strength), // 1 ImplantTemplate.GetImplantTemplate(ImplantSlot.RightArm, Skill.Burst, null, null), // 2 ImplantTemplate.GetImplantTemplate(ImplantSlot.Head, Skill.Treatment, null, null), // 3 ImplantTemplate.GetImplantTemplate(ImplantSlot.Eye, null, Skill.Treatment, null), // 1 ImplantTemplate.GetImplantTemplate(ImplantSlot.RightHand, null, null, Skill.Grenade), // 2 ImplantTemplate.GetImplantTemplate(ImplantSlot.LeftArm, Skill.Brawling, null, null), // 2 ImplantTemplate.GetImplantTemplate(ImplantSlot.Feet, null, Ability.Agility, null), // 1 ImplantTemplate.GetImplantTemplate(ImplantSlot.Ear, null, null, Skill.PsychoModi) // 3 }; var ladderProcess = new DegenerateLadderProcess(_character, finalImplantTemplates); CollectionAssert.AreEquivalent( new[] { finalImplantTemplates[0], finalImplantTemplates[3], finalImplantTemplates[6] }, ladderProcess.OrderedFinalImplants.Take(3).Select(i => i.ImplantTemplate).ToArray()); CollectionAssert.AreEquivalent( new[] { finalImplantTemplates[1], finalImplantTemplates[4], finalImplantTemplates[5] }, ladderProcess.OrderedFinalImplants.Skip(3).Take(3).Select(i => i.ImplantTemplate).ToArray()); CollectionAssert.AreEquivalent( new[] { finalImplantTemplates[2], finalImplantTemplates[7] }, ladderProcess.OrderedFinalImplants.Skip(6).Take(2).Select(i => i.ImplantTemplate).ToArray()); }
public void EquipsAndUnequipsSomeRandomImplants() { var head = Implant.GetImplant(ImplantSlot.Head, Skill.Treatment, null, Ability.Sense, 20); var ear = Implant.GetImplant(ImplantSlot.Ear, null, null, Ability.Intelligence, 20); var chest = Implant.GetImplant(ImplantSlot.Chest, Ability.Stamina, Ability.Psychic, Ability.Strength, 20); var eye = Implant.GetImplant(ImplantSlot.Eye, null, Skill.Treatment, null, 20); var leg = Implant.GetImplant(ImplantSlot.Leg, Ability.Agility, null, null, 20); var feet = Implant.GetImplant(ImplantSlot.Feet, null, Ability.Agility, null, 20); Assert.IsTrue(_character.TryEquipImplant(head)); Assert.AreEqual(296, (int)_character.TreatmentValue); Assert.AreEqual(98, _character.GetAbilityValue(Ability.Sense)); Assert.IsTrue(_character.TryEquipImplant(ear)); Assert.AreEqual(297, (int)_character.TreatmentValue); Assert.AreEqual(107, _character.GetAbilityValue(Ability.Intelligence)); Assert.AreEqual(head, _character.UnequipImplant(ImplantSlot.Head)); Assert.AreEqual(281, (int)_character.TreatmentValue); Assert.AreEqual(94, _character.GetAbilityValue(Ability.Sense)); Assert.IsTrue(_character.TryEquipImplant(head)); Assert.AreEqual(297, (int)_character.TreatmentValue); Assert.AreEqual(107, _character.GetAbilityValue(Ability.Intelligence)); Assert.IsTrue(_character.TryEquipImplant(chest)); Assert.IsTrue(_character.TryEquipImplant(eye)); Assert.IsTrue(_character.TryEquipImplant(leg)); Assert.IsTrue(_character.TryEquipImplant(feet)); Assert.AreEqual(307, (int)_character.TreatmentValue); Assert.AreEqual(107, _character.GetAbilityValue(Ability.Agility)); Assert.AreEqual(107, _character.GetAbilityValue(Ability.Intelligence)); Assert.AreEqual(104, _character.GetAbilityValue(Ability.Psychic)); Assert.AreEqual(98, _character.GetAbilityValue(Ability.Sense)); Assert.AreEqual(101, _character.GetAbilityValue(Ability.Stamina)); Assert.AreEqual(95, _character.GetAbilityValue(Ability.Strength)); var ql50Eye = Implant.GetImplant(ImplantSlot.Eye, null, Skill.SensoryImpr, Skill.MatterCrea, 50); Assert.AreEqual(50, Implant.GetMaxImplantQLForAbilityValue(_character.GetAbilityValue(Ability.Psychic))); Assert.IsTrue(_character.TryEquipImplant(ql50Eye)); Assert.AreEqual(298, (int)_character.TreatmentValue); }
public void DegenerateLadderProcessUnequipsWeakLadderImplantsFirst() { // The head and ear are strong ladder implants and shouldn't be equipped before the weaker leg, eye, and feet. var alreadyEquippedImplants = new[] { Implant.GetImplant(ImplantSlot.Head, Skill.Treatment, null, Ability.Sense, 200), Implant.GetImplant(ImplantSlot.Leg, Ability.Agility, Ability.Stamina, null, 1), Implant.GetImplant(ImplantSlot.Ear, Skill.Perception, null, Ability.Intelligence, 200), Implant.GetImplant(ImplantSlot.Eye, null, Skill.Treatment, null, 1), Implant.GetImplant(ImplantSlot.Feet, null, Ability.Agility, null, 1) }; _character.SetImplants(alreadyEquippedImplants); var finalImplantTemplates = new[] { ImplantTemplate.GetImplantTemplate(ImplantSlot.Chest, Ability.Sense, Ability.Psychic, Ability.Strength), // 1 ImplantTemplate.GetImplantTemplate(ImplantSlot.RightArm, Skill.Burst, null, null), // 2 ImplantTemplate.GetImplantTemplate(ImplantSlot.Head, Skill.Treatment, null, null), // 3 ImplantTemplate.GetImplantTemplate(ImplantSlot.Eye, null, Skill.Treatment, Skill.Bow), // 1 ImplantTemplate.GetImplantTemplate(ImplantSlot.RightHand, null, null, Skill.Grenade), // 2 ImplantTemplate.GetImplantTemplate(ImplantSlot.LeftArm, Skill.Brawling, null, null), // 2 ImplantTemplate.GetImplantTemplate(ImplantSlot.Feet, null, Ability.Agility, null), // 1 ImplantTemplate.GetImplantTemplate(ImplantSlot.Ear, null, null, Skill.PsychoModi) // 3 }; var ladderProcess = new DegenerateLadderProcess(_character, finalImplantTemplates); var orderedFinalImplantSlots = ladderProcess.OrderedFinalImplants .Select(i => i.ImplantSlot) .ToArray(); Assert.IsTrue(Array.IndexOf(orderedFinalImplantSlots, ImplantSlot.Head) > Array.IndexOf(orderedFinalImplantSlots, ImplantSlot.Eye)); Assert.IsTrue(Array.IndexOf(orderedFinalImplantSlots, ImplantSlot.Head) > Array.IndexOf(orderedFinalImplantSlots, ImplantSlot.Feet)); Assert.IsTrue(Array.IndexOf(orderedFinalImplantSlots, ImplantSlot.Ear) > Array.IndexOf(orderedFinalImplantSlots, ImplantSlot.Eye)); Assert.IsTrue(Array.IndexOf(orderedFinalImplantSlots, ImplantSlot.Ear) > Array.IndexOf(orderedFinalImplantSlots, ImplantSlot.Feet)); }
public void DegenerateLadderProcessLeavesAlreadyEquippedImplantsAlone() { var alreadyEquippedImplants = new[] { Implant.GetImplant(ImplantSlot.Head, Skill.Treatment, null, Ability.Sense, 200), Implant.GetImplant(ImplantSlot.Leg, Ability.Agility, Ability.Stamina, null, 200) }; _character.SetImplants(alreadyEquippedImplants); Assert.AreEqual(146, _character.GetAbilityValue(Ability.Agility)); Assert.AreEqual(124, _character.GetAbilityValue(Ability.Stamina)); Assert.AreEqual(116, _character.GetAbilityValue(Ability.Sense)); Assert.AreEqual(391.625, _character.TreatmentValue); var finalImplantTemplates = new[] { ImplantTemplate.GetImplantTemplate(ImplantSlot.Chest, Ability.Sense, Ability.Psychic, Ability.Strength), // Psychic ImplantTemplate.GetImplantTemplate(ImplantSlot.RightArm, Ability.Strength, null, null), // Sense ImplantTemplate.GetImplantTemplate(ImplantSlot.Waist, null, Ability.Sense, Ability.Stamina), // Psychic ImplantTemplate.GetImplantTemplate(ImplantSlot.Eye, null, Skill.Treatment, null), // Agility ImplantTemplate.GetImplantTemplate(ImplantSlot.RightHand, null, null, Skill.Treatment), // Intelligence ImplantTemplate.GetImplantTemplate(ImplantSlot.Feet, null, Ability.Agility, null), // Agility ImplantTemplate.GetImplantTemplate(ImplantSlot.Ear, null, null, Ability.Intelligence) // Psychic }; var finalImplantSlots = finalImplantTemplates.Select(t => t.ImplantSlot).ToArray(); var ladderProcess = new DegenerateLadderProcess(_character, finalImplantTemplates); Assert.AreEqual(146, _character.GetAbilityValue(Ability.Agility)); Assert.AreEqual(124, _character.GetAbilityValue(Ability.Stamina)); Assert.AreEqual(116, _character.GetAbilityValue(Ability.Sense)); Assert.AreEqual(391.625, _character.TreatmentValue); Assert.AreEqual(_character.GetImplant(ImplantSlot.Head), alreadyEquippedImplants[0]); Assert.AreEqual(_character.GetImplant(ImplantSlot.Leg), alreadyEquippedImplants[1]); Assert.AreEqual(400, _character.GetTotalImplantQL()); // The final QL should be greater than what we get by w/o any laddered equips. int unladderedTotalFinalImplantQL = 0; foreach (var implantTemplate in finalImplantTemplates) { unladderedTotalFinalImplantQL += _character.GetMaxImplant(implantTemplate).QL; } Assert.IsTrue(unladderedTotalFinalImplantQL < ladderProcess.TotalFinalImplantQL); // The final QL should be greater than what we get by laddering in the arbitrary order declared above. foreach (var implantTemplate in finalImplantTemplates) { _character.EquipMaxImplant(implantTemplate); } Assert.IsTrue(unladderedTotalFinalImplantQL < _character.GetTotalImplantQL(finalImplantSlots)); Assert.IsTrue(_character.GetTotalImplantQL(finalImplantSlots) < ladderProcess.TotalFinalImplantQL); Assert.AreEqual(0, ladderProcess.OrderedLadderImplants.Count); // Some regression tests, I don't know for sure that 423 is what to expect, hopefully won't ever drop below this. Assert.AreEqual(388, unladderedTotalFinalImplantQL); Assert.AreEqual(406, _character.GetTotalImplantQL(finalImplantSlots)); Assert.AreEqual(406 / (double)7, _character.GetAverageImplantQL(finalImplantSlots)); Assert.AreEqual(423, ladderProcess.TotalFinalImplantQL); Assert.AreEqual(423 / (double)7, ladderProcess.AverageFinalImplantQL); }
protected override void Run() { var workingCharacter = new Character(_character); while (true) { Implant nextLadderImplant = null; foreach (var emptyLadderImplantSlot in _availableLadderImplantSlots .Where(workingCharacter.IsImplantSlotEmpty)) { foreach (var relevantLadderImplantGroup in emptyLadderImplantSlot.LadderImplantGroups .Where(g => !g.IsSupersededByOtherLadderImplantGroups(workingCharacter))) { var trialLadderImplantTemplate = relevantLadderImplantGroup.GetBestImplantTemplate(workingCharacter); var trialLadderImplant = workingCharacter .EquipMaxImplant(trialLadderImplantTemplate, isSlotKnownToBeEmpty: true); var trialDegenerateLadderProcess = new DegenerateLadderProcess(workingCharacter, _finalImplantTemplates); int trialTotalFinalImplantQL = trialDegenerateLadderProcess.TotalFinalImplantQL; var trialOrderedFinalImplants = trialDegenerateLadderProcess.OrderedFinalImplants; if (trialTotalFinalImplantQL > TotalFinalImplantQL // The old application used this heuristic: if we've found an implant useful for laddering, and // we've found another 'just as good' that adds more treatment, prefer the one adding more treatment. || (nextLadderImplant != null && trialTotalFinalImplantQL == TotalFinalImplantQL && trialLadderImplant.TotalTreatmentIncrease > nextLadderImplant.TotalTreatmentIncrease)) { TotalFinalImplantQL = trialTotalFinalImplantQL; _orderedFinalImplants = trialOrderedFinalImplants; nextLadderImplant = trialLadderImplant; } workingCharacter.UnequipImplant(trialLadderImplant.ImplantSlot); } } if (nextLadderImplant != null) { workingCharacter.SetImplant(nextLadderImplant, isSlotKnownToBeEmpty: true); _orderedLadderImplants.Add(nextLadderImplant); } else { break; } } // Avoid unnecessary ladder implants if the degenerate ladder process is just as good. It's convenient // for this check to come after the above, because the above implicitly guarantees we'll try at least 2 // ladder implants deep (as long as 2+ slots are available) by virtue of TotalFinalImplantQL being // initialized to 0. This is important to handle the case where treatment and ability reqs are in perfect // balance w / each other s.t. only 1 ladder implant doesn't help at all. Doing this is only relevant // if we found < 2 ladder implants. If we found >= 2, it's because the 2nd ladder implant actually does help. if (_orderedLadderImplants.Count < 2) { workingCharacter = new Character(_character); var baseDegenerateLadderProcess = new DegenerateLadderProcess(workingCharacter, _finalImplantTemplates); int baseTotalFinalImplantQL = baseDegenerateLadderProcess.TotalFinalImplantQL; var baseOrderedFinalImplants = baseDegenerateLadderProcess.OrderedFinalImplants; if (baseTotalFinalImplantQL >= TotalFinalImplantQL) { TotalFinalImplantQL = baseTotalFinalImplantQL; _orderedLadderImplants.Clear(); _orderedFinalImplants = baseOrderedFinalImplants; } } }
/// <summary> /// When the combo box's dropdown is closed, we hide the implant. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void combo_DropDownClosed(object sender, EventArgs e) { m_fakeToolTip.Hide(); m_lastImplant = null; }
/// <summary> /// Sets the implant name for the given slot and the provided set. /// </summary> /// <param name="set"></param> /// <param name="slot"></param> /// <param name="implant"></param> /// <returns></returns> private static void SetImplant(SerializableSettingsImplantSet set, ImplantSlots slot, Implant implant) { // Set may be null when the user is editing the phantom line if (set == null) { return; } // Invoke the property setter with the matching name through reflection typeof(SerializableSettingsImplantSet).GetProperty(slot.ToString()).SetValue(set, implant.Name, null); }