mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-11 08:43:02 +00:00
reused random functionality as it worked better on percentage rolls between min/max
This commit is contained in:
@@ -253,34 +253,15 @@ export function getBlueprint(name, module) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provide 'worst' primary modifications
|
* Provide 'percent' primary modifications
|
||||||
* @param {Object} ship The ship for which to perform the modifications
|
* @param {Object} ship The ship for which to perform the modifications
|
||||||
* @param {Object} m The module for which to perform the modifications
|
* @param {Object} m The module for which to perform the modifications
|
||||||
* @param {Number} percent The percent to set values to of full.
|
* @param {Number} percent The percent to set values to of full.
|
||||||
*/
|
*/
|
||||||
export function setPercent(ship, m, percent) {
|
export function setPercent(ship, m, percent) {
|
||||||
ship.clearModifications(m);
|
ship.clearModifications(m);
|
||||||
const features = m.blueprint.grades[m.blueprint.grade].features;
|
// Pick given value as multiplier
|
||||||
for (const featureName in features) {
|
const mult = percent / 100;
|
||||||
const value = features[featureName][1];
|
|
||||||
const featureIsBeneficial = isBeneficial(featureName, features[featureName]);
|
|
||||||
if (featureIsBeneficial === true) {
|
|
||||||
_setValue(ship, m, featureName, (percent / 100) * value);
|
|
||||||
} else {
|
|
||||||
_setValue(ship, m, featureName, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Provide 'random' primary modifications
|
|
||||||
* @param {Object} ship The ship for which to perform the modifications
|
|
||||||
* @param {Object} m The module for which to perform the modifications
|
|
||||||
*/
|
|
||||||
export function setRandom(ship, m) {
|
|
||||||
ship.clearModifications(m);
|
|
||||||
// Pick a single value for our randomness
|
|
||||||
const mult = Math.random();
|
|
||||||
const features = m.blueprint.grades[m.blueprint.grade].features;
|
const features = m.blueprint.grades[m.blueprint.grade].features;
|
||||||
for (const featureName in features) {
|
for (const featureName in features) {
|
||||||
let value;
|
let value;
|
||||||
@@ -304,6 +285,16 @@ export function setRandom(ship, m) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provide 'random' primary modifications
|
||||||
|
* @param {Object} ship The ship for which to perform the modifications
|
||||||
|
* @param {Object} m The module for which to perform the modifications
|
||||||
|
*/
|
||||||
|
export function setRandom(ship, m) {
|
||||||
|
// Pick a single value for our randomness
|
||||||
|
setPercent(ship, m, Math.random() * 100);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a modification feature value
|
* Set a modification feature value
|
||||||
* @param {Object} ship The ship for which to perform the modifications
|
* @param {Object} ship The ship for which to perform the modifications
|
||||||
|
|||||||
Reference in New Issue
Block a user