42 lines
2.0 KiB
JavaScript
42 lines
2.0 KiB
JavaScript
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
});
|
|
};
|
|
import { orderBy } from 'lodash';
|
|
import { rulesEngineSelectors } from "../selectors";
|
|
import { getAbilityManager } from './AbilityManager';
|
|
import { BaseManager } from './BaseManager';
|
|
export class AttributesManager extends BaseManager {
|
|
constructor(params) {
|
|
super(params);
|
|
this.getHighestAbilityScore = (abilities) => {
|
|
let orderedAbilities = orderBy(abilities, [(ability) => ability.getTotalScore(), (ability) => ability.getLabel()], ['desc', 'asc']);
|
|
return orderedAbilities[0];
|
|
};
|
|
this.params = params;
|
|
}
|
|
getAbilities() {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
const abilities = rulesEngineSelectors.getAbilities(this.state);
|
|
return abilities.map((ability) => {
|
|
return getAbilityManager(Object.assign(Object.assign({}, this.params), { ability }));
|
|
});
|
|
});
|
|
}
|
|
getAbilitiesWithoutBlessings() {
|
|
const abilities = rulesEngineSelectors.getAbilities(this.state);
|
|
return abilities.map((ability) => {
|
|
return getAbilityManager(Object.assign(Object.assign({}, this.params), { ability }));
|
|
});
|
|
}
|
|
getValidGlobalModifiers() {
|
|
const validGlobalModifiers = rulesEngineSelectors.getValidGlobalModifiers(this.state);
|
|
return validGlobalModifiers;
|
|
}
|
|
}
|