Continued work on point buy UI
This commit is contained in:
@@ -248,14 +248,18 @@ function linkPointBuy(dependencyGraph, prop){
|
||||
dependOnCalc({ dependencyGraph, prop, key: 'max' });
|
||||
dependOnCalc({ dependencyGraph, prop, key: 'cost' });
|
||||
prop.values?.forEach(row => {
|
||||
row.type = 'pointBuyRow';
|
||||
row.tableName = prop.name;
|
||||
row.tableId = prop._id;
|
||||
dependencyGraph.addNode(row._id, row);
|
||||
linkVariableName(dependencyGraph, row);
|
||||
dependOnCalc({ dependencyGraph, row, key: 'min' });
|
||||
dependOnCalc({ dependencyGraph, row, key: 'max' });
|
||||
dependOnCalc({ dependencyGraph, row, key: 'cost' });
|
||||
// Wrap the document in a new object so we don't bash it unintentionally
|
||||
const pointBuyRow = {
|
||||
...row,
|
||||
type: 'pointBuyRow',
|
||||
tableName: prop.name,
|
||||
tableId: prop._id,
|
||||
}
|
||||
dependencyGraph.addNode(row._id, pointBuyRow);
|
||||
linkVariableName(dependencyGraph, pointBuyRow);
|
||||
dependOnCalc({ dependencyGraph, pointBuyRow, key: 'row.min' });
|
||||
dependOnCalc({ dependencyGraph, pointBuyRow, key: 'row.max' });
|
||||
dependOnCalc({ dependencyGraph, pointBuyRow, key: 'row.cost' });
|
||||
});
|
||||
if (prop.inactive) return;
|
||||
}
|
||||
|
||||
@@ -8,9 +8,9 @@ export default function computePointBuy(computation, node) {
|
||||
prop.spent = 0;
|
||||
prop.values?.forEach(row => {
|
||||
// Clean up added properties
|
||||
delete row.tableId;
|
||||
delete row.tableName;
|
||||
delete row.type;
|
||||
// delete row.tableId;
|
||||
// delete row.tableName;
|
||||
// delete row.type;
|
||||
|
||||
row.spent = 0;
|
||||
if (row.value === undefined) return;
|
||||
@@ -21,18 +21,10 @@ export default function computePointBuy(computation, node) {
|
||||
|
||||
// Check min and max
|
||||
if (min !== null && row.value < min) {
|
||||
row.errors = row.errors || [];
|
||||
row.errors.push({
|
||||
type: 'pointBuyError',
|
||||
message: 'Value smaller than min value'
|
||||
});
|
||||
row.value = min;
|
||||
}
|
||||
if (max !== null && row.value > max) {
|
||||
row.errors = row.errors || [];
|
||||
row.errors.push({
|
||||
type: 'pointBuyError',
|
||||
message: 'Value larger than max value'
|
||||
});
|
||||
row.value = max;
|
||||
}
|
||||
// Evaluate the cost function
|
||||
if (!costFunction) return;
|
||||
|
||||
Reference in New Issue
Block a user