|
|
@ -50,115 +50,6 @@ function getBidCapReasonForScenario(scenario) { |
|
|
|
return getBidCapReason(scenario[0], scenario[1], scenario[2], scenario[3], scenario[4], scenario[5], scenario[6], scenario[7], scenario[8]); |
|
|
|
} |
|
|
|
|
|
|
|
//The function from our main codebase
|
|
|
|
function getBidCapReason(generalCapIsEnabled, generalCap, capPresidence, applyPresidenceTo, oversightAction, rowCapIsEnabled, rowCap, tieBid, myBid) { |
|
|
|
let tieBidNum = Number(tieBid); |
|
|
|
let winBidNum = Number(tieBid) + 25; |
|
|
|
let generalCapNum = Number(generalCap); |
|
|
|
let rowCapNum = Number(rowCap); |
|
|
|
let myBidNum = Number(myBid); |
|
|
|
|
|
|
|
//Build our response object
|
|
|
|
let results = newResult(false, 0, null, null, myBidNum); |
|
|
|
|
|
|
|
//WIP - LOTS of rules here - these are just the beginning.
|
|
|
|
if(generalCapIsEnabled) { |
|
|
|
if(capPresidence == Presidence.General) { |
|
|
|
if(applyPresidenceTo == AppliesTo.All) { |
|
|
|
|
|
|
|
switch(oversightAction) { |
|
|
|
case Oversight.Win: |
|
|
|
if(winBidNum > generalCapNum) { |
|
|
|
results = newResult(true, 1, generalCapNum, Capsource.General, generalCapNum); |
|
|
|
return results; |
|
|
|
} |
|
|
|
//winBidNum <= generalCapNum
|
|
|
|
results = newResult(false, 2, generalCapNum, Capsource.General, myBidNum); |
|
|
|
break; |
|
|
|
|
|
|
|
case Oversight.Tie: |
|
|
|
if(tieBidNum > generalCapNum) { |
|
|
|
results = newResult(true, 3, generalCapNum, Capsource.General, generalCapNum); |
|
|
|
return results; |
|
|
|
} |
|
|
|
//tieBidNum <= generalCapNum
|
|
|
|
results = newResult(false, 4, generalCapNum, Capsource.General, myBidNum); |
|
|
|
break; |
|
|
|
|
|
|
|
case Oversight.Watch: |
|
|
|
results = newResult(false, 5, generalCapNum, Capsource.General, myBidNum); |
|
|
|
break; |
|
|
|
|
|
|
|
case Oversight.Ignore: |
|
|
|
results = newResult(false, 6, generalCapNum, Capsource.General, myBidNum); |
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
//We should never get here because all oversight actions have been covered.
|
|
|
|
} |
|
|
|
return results; |
|
|
|
} |
|
|
|
else if(applyPresidenceTo == AppliesTo.None){ |
|
|
|
|
|
|
|
} |
|
|
|
else if(applyPresidenceTo == AppliesTo.Capped){ |
|
|
|
|
|
|
|
} |
|
|
|
else if(applyPresidenceTo == AppliesTo.Uncapped){ |
|
|
|
|
|
|
|
} |
|
|
|
return results; |
|
|
|
} |
|
|
|
else if(capPresidence == Presidence.Row) { |
|
|
|
return results; |
|
|
|
} |
|
|
|
else if(capPresidence == Presidence.Highest){ |
|
|
|
return results; |
|
|
|
} |
|
|
|
else if(capPresidence == Presidence.Lowest){ |
|
|
|
return results; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//If we made it here, generalCapIsEnabled is FALSE so no conflicts should exist
|
|
|
|
//This means rowCaps are the winners if they are enabled.
|
|
|
|
if(rowCapIsEnabled) { |
|
|
|
switch(oversightAction) { |
|
|
|
case Oversight.Win: |
|
|
|
if(winBidNum > rowCapNum) { |
|
|
|
results = newResult(true, 101, rowCapNum, Capsource.Row, rowCapNum); |
|
|
|
return results; |
|
|
|
} |
|
|
|
//winBidNum <= rowCapNum
|
|
|
|
results = newResult(false, 102, rowCapNum, Capsource.Row, myBidNum); |
|
|
|
break; |
|
|
|
|
|
|
|
case Oversight.Tie: |
|
|
|
if(tieBidNum > rowCapNum) { |
|
|
|
results = newResult(true, 103, rowCapNum, Capsource.Row, rowCapNum); |
|
|
|
return results; |
|
|
|
} |
|
|
|
//tieBidNum <= generalCapNum
|
|
|
|
results = newResult(false, 104, rowCapNum, Capsource.Row, myBidNum); |
|
|
|
break; |
|
|
|
|
|
|
|
case Oversight.Watch: |
|
|
|
results = newResult(false, 105, null, Capsource.Row, myBidNum); |
|
|
|
break; |
|
|
|
|
|
|
|
case Oversight.Ignore: |
|
|
|
results = newResult(false, 106, null, Capsource.Row, myBidNum); |
|
|
|
break; |
|
|
|
default: |
|
|
|
//We should never get here because all oversight actions have been covered.
|
|
|
|
} |
|
|
|
return results; |
|
|
|
} |
|
|
|
//Caps are not enabled for this row.
|
|
|
|
|
|
|
|
return results; |
|
|
|
} |
|
|
|
|
|
|
|
//Stuff to Testing the actual functionality
|
|
|
|
function Assert(testName, thingsToCheck) { |
|
|
|
let allChecksPassed = true; |
|
|
@ -268,6 +159,115 @@ function getTest(testId) { |
|
|
|
return test; |
|
|
|
} |
|
|
|
|
|
|
|
//The function from our main codebase
|
|
|
|
function getBidCapReason(generalCapIsEnabled, generalCap, capPresidence, applyPresidenceTo, oversightAction, rowCapIsEnabled, rowCap, tieBid, myBid) { |
|
|
|
let tieBidNum = Number(tieBid); |
|
|
|
let winBidNum = Number(tieBid) + 25; |
|
|
|
let generalCapNum = Number(generalCap); |
|
|
|
let rowCapNum = Number(rowCap); |
|
|
|
let myBidNum = Number(myBid); |
|
|
|
|
|
|
|
//Build our response object
|
|
|
|
let results = newResult(false, 0, null, null, myBidNum); |
|
|
|
|
|
|
|
//WIP - LOTS of rules here - these are just the beginning.
|
|
|
|
if(generalCapIsEnabled) { |
|
|
|
if(capPresidence == Presidence.General) { |
|
|
|
if(applyPresidenceTo == AppliesTo.All) { |
|
|
|
|
|
|
|
switch(oversightAction) { |
|
|
|
case Oversight.Win: |
|
|
|
if(winBidNum > generalCapNum) { |
|
|
|
results = newResult(true, 1, generalCapNum, Capsource.General, generalCapNum); |
|
|
|
return results; |
|
|
|
} |
|
|
|
//winBidNum <= generalCapNum
|
|
|
|
results = newResult(false, 2, generalCapNum, Capsource.General, myBidNum); |
|
|
|
break; |
|
|
|
|
|
|
|
case Oversight.Tie: |
|
|
|
if(tieBidNum > generalCapNum) { |
|
|
|
results = newResult(true, 3, generalCapNum, Capsource.General, generalCapNum); |
|
|
|
return results; |
|
|
|
} |
|
|
|
//tieBidNum <= generalCapNum
|
|
|
|
results = newResult(false, 4, generalCapNum, Capsource.General, myBidNum); |
|
|
|
break; |
|
|
|
|
|
|
|
case Oversight.Watch: |
|
|
|
results = newResult(false, 5, generalCapNum, Capsource.General, myBidNum); |
|
|
|
break; |
|
|
|
|
|
|
|
case Oversight.Ignore: |
|
|
|
results = newResult(false, 6, generalCapNum, Capsource.General, myBidNum); |
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
//We should never get here because all oversight actions have been covered.
|
|
|
|
} |
|
|
|
return results; |
|
|
|
} |
|
|
|
else if(applyPresidenceTo == AppliesTo.None){ |
|
|
|
|
|
|
|
} |
|
|
|
else if(applyPresidenceTo == AppliesTo.Capped){ |
|
|
|
|
|
|
|
} |
|
|
|
else if(applyPresidenceTo == AppliesTo.Uncapped){ |
|
|
|
|
|
|
|
} |
|
|
|
return results; |
|
|
|
} |
|
|
|
else if(capPresidence == Presidence.Row) { |
|
|
|
return results; |
|
|
|
} |
|
|
|
else if(capPresidence == Presidence.Highest){ |
|
|
|
return results; |
|
|
|
} |
|
|
|
else if(capPresidence == Presidence.Lowest){ |
|
|
|
return results; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//If we made it here, generalCapIsEnabled is FALSE so no conflicts should exist
|
|
|
|
//This means rowCaps are the winners if they are enabled.
|
|
|
|
if(rowCapIsEnabled) { |
|
|
|
switch(oversightAction) { |
|
|
|
case Oversight.Win: |
|
|
|
if(winBidNum > rowCapNum) { |
|
|
|
results = newResult(true, 101, rowCapNum, Capsource.Row, rowCapNum); |
|
|
|
return results; |
|
|
|
} |
|
|
|
//winBidNum <= rowCapNum
|
|
|
|
results = newResult(false, 102, rowCapNum, Capsource.Row, myBidNum); |
|
|
|
break; |
|
|
|
|
|
|
|
case Oversight.Tie: |
|
|
|
if(tieBidNum > rowCapNum) { |
|
|
|
results = newResult(true, 103, rowCapNum, Capsource.Row, rowCapNum); |
|
|
|
return results; |
|
|
|
} |
|
|
|
//tieBidNum <= generalCapNum
|
|
|
|
results = newResult(false, 104, rowCapNum, Capsource.Row, myBidNum); |
|
|
|
break; |
|
|
|
|
|
|
|
case Oversight.Watch: |
|
|
|
results = newResult(false, 105, null, Capsource.Row, myBidNum); |
|
|
|
break; |
|
|
|
|
|
|
|
case Oversight.Ignore: |
|
|
|
results = newResult(false, 106, null, Capsource.Row, myBidNum); |
|
|
|
break; |
|
|
|
default: |
|
|
|
//We should never get here because all oversight actions have been covered.
|
|
|
|
} |
|
|
|
return results; |
|
|
|
} |
|
|
|
//Caps are not enabled for this row.
|
|
|
|
|
|
|
|
return results; |
|
|
|
} |
|
|
|
|
|
|
|
//All the scenarios we could run into
|
|
|
|
function getUseCases(){ |
|
|
|
let useCases = []; //[generalCapIsEnabled, generalCap, capPresidence, applyPresidenceTo, oversightAction, rowCapIsEnabled, rowCap, tieBid, myBid];
|
|
|
|