// enumerate.js
(function () {
/* global AdventureJS A */
var p = AdventureJS.Dictionary.prototype;
/**
* Enumerate is used to present a number in several styles.
* Primarily used for presenting a count of stacked assets,
* such as "10 pistachios".
* @method AdventureJS.Dictionary#enumerate
* @memberOf AdventureJS
* @param {String} text
* @returns {String}
*/
p.enumerate = function Dictionary_enumerate(style, count) {
this.game.log(
"L1545",
"log",
"high",
`Dictionary.enumerate ${(style, count)}`,
"dictionary"
);
if (!["numeric", "spelled", "grouped"].includes(style)) style = "spelled";
switch (style) {
case "numeric":
return `${count}`;
case "spelled":
return this.numberToWords(count);
case "grouped":
switch (count) {
case -1:
return "plenty of";
case 0:
return "no";
case 1:
return "a";
case 2:
return "a couple of";
case 3:
return "several";
case 4:
case 5:
return "a few";
case 6:
return "a half dozen";
case 7:
case 8:
case 9:
case 10:
case 11:
return "a handful of";
case 12:
return "a dozen";
case 13:
return "a baker's dozen of";
case 20:
return "a score of";
case 40:
return "two score";
case 42:
return "forty two";
case 60:
return "three score";
case 80:
return "four score";
case 87:
return "four score and seven";
case 100:
return "a hundred";
case 144:
return "a gross of";
default:
// return "numerous";
}
// if none of the above...
if (count > 24 && count < 100) {
return "dozens of";
}
if (count > 200) {
return "hundreds of";
}
if (count > 1000) {
return "thousands of";
}
return "some";
}
};
})();