Skip to content

Commit

Permalink
#1941 SimulationCraft pulls are now updated upon modal opening and no…
Browse files Browse the repository at this point in the history
…t on load.

This allows the modal to have up-to-date info about pulls if you've edited them in your current session
  • Loading branch information
Wotuu committed Aug 11, 2023
1 parent 5017737 commit 323e793
Showing 1 changed file with 37 additions and 28 deletions.
65 changes: 37 additions & 28 deletions resources/assets/js/custom/inline/common/dungeonroute/simulate.js
Expand Up @@ -21,8 +21,6 @@ class CommonDungeonrouteSimulate extends InlineCode {
$(`#simulate_${key}`).on('change', this._saveSettings.bind(this));
}
this._loadSettings();

//
}

/**
Expand Down Expand Up @@ -74,43 +72,52 @@ class CommonDungeonrouteSimulate extends InlineCode {
}
}
}
}

/**
*
* @private
*/
_refreshBloodlustPerPullsPullList() {

// If not filled yet, fill the bloodlust per pull selector
let $bloodlustPerPullSelect = $('#simulate_bloodlust_per_pull');
// Either didn't have any options yet, or none selected. Either is a candidate for re-building the select
if ($bloodlustPerPullSelect.val() === null || $bloodlustPerPullSelect.val().length === 0) {
// Remove existing options
$bloodlustPerPullSelect.find('option').remove();
let selectedPulls = [];

let killZoneMapObjectGroup = getState().getDungeonMap().mapObjectGroupManager.getByName(MAP_OBJECT_GROUP_KILLZONE);
let sortedKillZones = _.sortBy(_.values(killZoneMapObjectGroup.objects), 'index');
let bloodlustKeys = [SPELL_BLOODLUST, SPELL_HEROISM, SPELL_FURY_OF_THE_ASPECTS, SPELL_TIME_WARP, SPELL_ANCIENT_HYSTERIA];

for (let i = 0; i < sortedKillZones.length; i++) {
let killZone = sortedKillZones[i];

let $option = jQuery('<option>', {
value: killZone.id,
text: lang.get(`messages.simulate_pull`, {'index': killZone.index})
});
let previouslySelectedPulls = $bloodlustPerPullSelect.val();

$bloodlustPerPullSelect.append($option);
// Remove existing options
$bloodlustPerPullSelect.find('option').remove();
let selectedPulls = [];

// Determine if this pull activated Bloodlust~ spells
for (let index in killZone.spellIds) {
let spellId = killZone.spellIds[index];
let killZoneMapObjectGroup = getState().getDungeonMap().mapObjectGroupManager.getByName(MAP_OBJECT_GROUP_KILLZONE);
let sortedKillZones = _.sortBy(_.values(killZoneMapObjectGroup.objects), 'index');
let bloodlustKeys = [SPELL_BLOODLUST, SPELL_HEROISM, SPELL_FURY_OF_THE_ASPECTS, SPELL_TIME_WARP, SPELL_ANCIENT_HYSTERIA];

if (bloodlustKeys.includes(spellId)) {
selectedPulls.push(killZone.id);
break;
}
for (let i = 0; i < sortedKillZones.length; i++) {
let killZone = sortedKillZones[i];

let $option = jQuery('<option>', {
value: killZone.id,
text: lang.get(`messages.simulate_pull`, {'index': killZone.index})
});

$bloodlustPerPullSelect.append($option);

// Determine if this pull activated Bloodlust~ spells
for (let index in killZone.spellIds) {
let spellId = killZone.spellIds[index];

if (bloodlustKeys.includes(spellId)) {
selectedPulls.push(killZone.id);
break;
}
}
}


if (previouslySelectedPulls.length === 0) {
$bloodlustPerPullSelect.val(selectedPulls);
}

refreshSelectPickers();
}

/**
Expand All @@ -126,6 +133,8 @@ class CommonDungeonrouteSimulate extends InlineCode {
* @private
*/
_simulateModalOpened() {
this._refreshBloodlustPerPullsPullList();

if (this._initialized) {
return;
}
Expand Down

0 comments on commit 323e793

Please sign in to comment.