Fixes #7958 - do not remove Battle Gear equipment when changing class (#8064)

* Changed files to fix Bug 7958:
 - website/client-old/.../userCtrl.js#38: removed to keep inventory constant
 - website/common/.../changeClass.js#33:  removed to stop 'classes' introduction

* Adjustments following Bug Review
 - Removed remaining 'foundKey' logic
 - Adjusted test logic to reflect feature change

* Reverting userCtrl.js to development version
 - Reintroduces "classes" Guide tour

* New version of Fixes #7958
 - Changed logic to only notify user the first time they choose a class
 - Changed message to represent this change in logic
 - #LINT: Cleaned interface for changing class
    - New method: enableClasses() -- because, really, should we be calling User.changeClass({}) from the UX?
    - New method: payForNewClass() -- handles prompting the user to confirm that they want to change class

* Remove new User Flag, use flags.tour.classes

* Whoopsie. Fix PR conflict.

* Changed files to fix Bug 7958:
 - website/client-old/.../userCtrl.js#38: removed to keep inventory constant
 - website/common/.../changeClass.js#33:  removed to stop 'classes' introduction

* Adjustments following Bug Review
 - Removed remaining 'foundKey' logic
 - Adjusted test logic to reflect feature change

* Reverting userCtrl.js to development version
 - Reintroduces "classes" Guide tour

* New version of Fixes #7958
 - Changed logic to only notify user the first time they choose a class
 - Changed message to represent this change in logic
 - #LINT: Cleaned interface for changing class
    - New method: enableClasses() -- because, really, should we be calling User.changeClass({}) from the UX?
    - New method: payForNewClass() -- handles prompting the user to confirm that they want to change class

* Remove new User Flag, use flags.tour.classes

* Whoopsie. Fix PR conflict.

* Removed Extraneous Flag

* Removed Extraneous Flag

* Changed files to fix Bug 7958:
 - website/client-old/.../userCtrl.js#38: removed to keep inventory constant
 - website/common/.../changeClass.js#33:  removed to stop 'classes' introduction

* New version of Fixes #7958
 - Changed logic to only notify user the first time they choose a class
 - Changed message to represent this change in logic
 - #LINT: Cleaned interface for changing class
    - New method: enableClasses() -- because, really, should we be calling User.changeClass({}) from the UX?
    - New method: payForNewClass() -- handles prompting the user to confirm that they want to change class

Remove new User Flag, use flags.tour.classes

Whoopsie. Fix PR conflict.

Removed Extraneous Flag

* Fixes handling architecture change

* Updates following Review 20170418-0602

* Remove cause of mocha/no-exclusive-tests lint failure
This commit is contained in:
CJ
2017-07-20 13:28:53 -04:00
committed by Sabe Jones
parent ca90d88289
commit 605391e4e7
7 changed files with 29 additions and 47 deletions

View File

@@ -1,7 +1,5 @@
import i18n from '../i18n';
import get from 'lodash/get';
import each from 'lodash/each';
import findLast from 'lodash/findLast';
import pick from 'lodash/pick';
import splitWhitespace from '../libs/splitWhitespace';
import { capByLevel } from '../statHelpers';
@@ -43,31 +41,8 @@ module.exports = function changeClass (user, req = {}, analytics) {
user.stats.class = klass;
user.flags.classSelected = true;
each(['weapon', 'armor', 'shield', 'head'], (type) => {
let foundKey = false;
findLast(user.items.gear.owned, (val, key) => {
if (key.indexOf(`${type}_${klass}`) !== -1 && val === true) {
foundKey = key;
return true;
}
});
if (!foundKey) {
if (type === 'weapon') {
foundKey = `weapon_${klass}_0`;
} else if (type === 'shield' && klass === 'rogue') {
foundKey = 'shield_rogue_0';
} else {
foundKey = `${type}_base_0`;
}
}
user.items.gear.equipped[type] = foundKey;
if (type === 'weapon' || (type === 'shield' && klass === 'rogue')) { // eslint-disable-line no-extra-parens
user.items.gear.owned[`${type}_${klass}_0`] = true;
}
});
user.items.gear.owned[`weapon_${klass}_0`] = true;
if (klass === 'rogue') user.items.gear.owned[`shield_${klass}_0`] = true;
if (analytics) {
analytics.track('change class', {