Преглед на файлове

Format the codebase with Prettier

master
Fen Dweller преди 3 години
родител
ревизия
c6f2037ca6
променени са 9 файла, в които са добавени 13905 реда и са изтрити 9046 реда
  1. +4
    -0
      .prettierrc
  2. +1913
    -1936
      features.js
  3. +3001
    -1997
      game.js
  4. +31
    -46
      migrations.js
  5. +951
    -707
      presets.js
  6. +6788
    -3814
      recursive-desc.js
  7. +895
    -403
      recursive-macro.js
  8. +93
    -24
      sounds.js
  9. +229
    -119
      units.js

+ 4
- 0
.prettierrc Целия файл

@@ -0,0 +1,4 @@
{
"tabWidth": 2,
"useTabs": false
}

+ 1913
- 1936
features.js
Файловите разлики са ограничени, защото са твърде много
Целия файл


+ 3001
- 1997
game.js
Файловите разлики са ограничени, защото са твърде много
Целия файл


+ 31
- 46
migrations.js Целия файл

@@ -2,40 +2,27 @@

migrations = [
// 0 -> 1
// does nothing
save => {
},
(save) => {},

// 1 -> 2

// automatic digestion is now a subcategory, so anyone with
// a digest time of 0 should have that unset
save => {
if (save.oralDigestTime == 0)
save.oralDigestAuto = false;
if (save.analDigestTime == 0)
save.analDigestAuto = false;
if (save.tailDigestTime == 0)
save.tailDigestAuto = false;
if (save.cockDigestTime == 0)
save.cockDigestAuto = false;
if (save.unbirthDigestTime == 0)
save.unbirthDigestAuto = false;
if (save.breastDigestTime == 0)
save.breastDigestAuto = false;
if (save.soulDigestTime == 0)
save.soulDigestAuto = false;
if (save.bladderDigestTime == 0)
save.bladderDigestAuto = false;
if (save.gooDigestTime == 0)
save.gooDigestAuto = false;
if (save.pawDigestTime == 0)
save.pawDigestAuto = false;
if (save.cropTransferTime == 0)
save.cropTransferAuto = false;
if (save.wingDigestTime == 0)
save.wingDigestAuto = false;
(save) => {
if (save.oralDigestTime == 0) save.oralDigestAuto = false;
if (save.analDigestTime == 0) save.analDigestAuto = false;
if (save.tailDigestTime == 0) save.tailDigestAuto = false;
if (save.cockDigestTime == 0) save.cockDigestAuto = false;
if (save.unbirthDigestTime == 0) save.unbirthDigestAuto = false;
if (save.breastDigestTime == 0) save.breastDigestAuto = false;
if (save.soulDigestTime == 0) save.soulDigestAuto = false;
if (save.bladderDigestTime == 0) save.bladderDigestAuto = false;
if (save.gooDigestTime == 0) save.gooDigestAuto = false;
if (save.pawDigestTime == 0) save.pawDigestAuto = false;
if (save.cropTransferTime == 0) save.cropTransferAuto = false;
if (save.wingDigestTime == 0) save.wingDigestAuto = false;
},

// 2 -> 3
@@ -43,23 +30,17 @@ migrations = [
// passive production is now written as percentage points;
// old values won't make sense anymore, so we'll just
// erase them
save => {
if (save.baseCumProduction)
delete save.baseCumProduction;
if (save.baseFemcumProduction)
delete save.baseFemcumProduction;
if (save.baseLactationProduction)
delete save.baseLactationProduction;
if (save.baseGasProduction)
delete save.baseGasProduction;
if (save.basePissProduction)
delete save.basePissProduction;
if (save.baseScatProduction)
delete save.baseScatProduction;
}
(save) => {
if (save.baseCumProduction) delete save.baseCumProduction;
if (save.baseFemcumProduction) delete save.baseFemcumProduction;
if (save.baseLactationProduction) delete save.baseLactationProduction;
if (save.baseGasProduction) delete save.baseGasProduction;
if (save.basePissProduction) delete save.basePissProduction;
if (save.baseScatProduction) delete save.baseScatProduction;
},
];

function migrate(save, target=null) {
function migrate(save, target = null) {
if (target == null) {
target = migrations.length;
}
@@ -67,13 +48,17 @@ function migrate(save, target=null) {
let version = save.version;

if (version == undefined) {
alert("This save is from before versioning was added. It can't be automatically updated, and it might lose some settings. Double check that everything's there! Any subsequent saves will work correctly.");
alert(
"This save is from before versioning was added. It can't be automatically updated, and it might lose some settings. Double check that everything's there! Any subsequent saves will work correctly."
);
save["version"] = migrations.length;
return false;
}

if (version == 0 ) {
alert("This save is from before v1.0. It can't be automatically migrated, so it may lose some settings. Double check the resulting character. Subsequent saves will function correctly.");
if (version == 0) {
alert(
"This save is from before v1.0. It can't be automatically migrated, so it may lose some settings. Double check the resulting character. Subsequent saves will function correctly."
);
save["version"] = migrations.length;
return false;
}


+ 951
- 707
presets.js
Файловите разлики са ограничени, защото са твърде много
Целия файл


+ 6788
- 3814
recursive-desc.js
Файловите разлики са ограничени, защото са твърде много
Целия файл


+ 895
- 403
recursive-macro.js
Файловите разлики са ограничени, защото са твърде много
Целия файл


+ 93
- 24
sounds.js Целия файл

@@ -1,30 +1,99 @@
let last_used = {};

let sounds = {
"crush": [["Thump.", "Thoomp."], ["Crunch."], ["Crrruunch."], ["CRUNCH!"], ["CRRRUNNCH!"], ["SKRRRRUNCH!"], ["SKRRRRRRRSMASH!"]],
"swallow": [["Ulp.", "Glp.", "Slurp."], ["Glrph.", "Glurk."], ["Gluuuurrkph!", "Glurp - GLK."], ["GLRP!", "GULP!", "GLUK!"], ["GLRRRRPKH!", "GLUUUURK!"], ["GLUUUUURRPKH!", "GLOOOORPH-GLK!"]],
"drip":
[["Drip."], ["Dribble"], ["Drip-sploosh"], ["Dribble-SPLOOSH!"], ["SPLOOOOOSH!!"]],
"liquid": [["Sploosh."], ["Gush!"], ["SPLOOSH!"], ["SPLOOSH!"], ["SPLOOOOOOSH!"]],
"insert": [["Slp.", "Shlk."], ["Shlp.", "Shlrp."], ["Shlllp."], ["SHLP!", "SQUELCH!"], ["SHLLLLRP!"]],
"drop": [["Thump."], ["Thump!"], ["Splat."], ["Splat!"], ["SPLAT!"]],
"belch": [["Burp.", "Urp."], ["Urph.", "Burph."], ["Urrrrrph."], ["UuuuuuuRRRRRPPHHHhhhh."], ["UUUURRRRPHH!"], ["BUUUURRRRRRRRPPPHHH!"]],
"fart":
[["Pft."], ["Pffft."], ["Pfffffbt."], ["Frrrrrrrt."], ["FRRRRRRRRPBBT!"]],
"scat":
[["Clench."], ["Squeeeeeze."], ["Squeeeeeeeeeeeze."], ["Sqlllllch."], ["SQLLLLLLCH!"]],
"digest":
[["Grrgle."], ["Grrrrgle"], ["Grrrrlglorp."], ["GrrrrGLRRRLPH!"], ["GRRRRRLGPRLHK!"]],
"goo":
[["Splat."], ["Squish."], ["Squish!"], ["SQLCH!"], ["SQLLLLRCH!"], ["SQQQQUEEEEELLCH!"]],
"vomit":
[["Hurk."], ["Hurrk."], ["Bleugh."], ["Bleugh!"], ["Bleeeugh!"], ["BLEEEUGHK!"]],
"breath":
[["Woosh."], ["Fwoosh."], ["FWOOSH."], ["FWOOSH!"], ["FWOOOOOOSH!"]],
"chew":
[["Snap.", "Crack."], ["Crunch."], ["Crack!"], ["CRUNCH!"], ["CRRRUNCH!"]],
"magic":
[["Zap."], ["Zap!"], ["Fwoosh!"]]
crush: [
["Thump.", "Thoomp."],
["Crunch."],
["Crrruunch."],
["CRUNCH!"],
["CRRRUNNCH!"],
["SKRRRRUNCH!"],
["SKRRRRRRRSMASH!"],
],
swallow: [
["Ulp.", "Glp.", "Slurp."],
["Glrph.", "Glurk."],
["Gluuuurrkph!", "Glurp - GLK."],
["GLRP!", "GULP!", "GLUK!"],
["GLRRRRPKH!", "GLUUUURK!"],
["GLUUUUURRPKH!", "GLOOOORPH-GLK!"],
],
drip: [
["Drip."],
["Dribble"],
["Drip-sploosh"],
["Dribble-SPLOOSH!"],
["SPLOOOOOSH!!"],
],
liquid: [
["Sploosh."],
["Gush!"],
["SPLOOSH!"],
["SPLOOSH!"],
["SPLOOOOOOSH!"],
],
insert: [
["Slp.", "Shlk."],
["Shlp.", "Shlrp."],
["Shlllp."],
["SHLP!", "SQUELCH!"],
["SHLLLLRP!"],
],
drop: [["Thump."], ["Thump!"], ["Splat."], ["Splat!"], ["SPLAT!"]],
belch: [
["Burp.", "Urp."],
["Urph.", "Burph."],
["Urrrrrph."],
["UuuuuuuRRRRRPPHHHhhhh."],
["UUUURRRRPHH!"],
["BUUUURRRRRRRRPPPHHH!"],
],
fart: [
["Pft."],
["Pffft."],
["Pfffffbt."],
["Frrrrrrrt."],
["FRRRRRRRRPBBT!"],
],
scat: [
["Clench."],
["Squeeeeeze."],
["Squeeeeeeeeeeeze."],
["Sqlllllch."],
["SQLLLLLLCH!"],
],
digest: [
["Grrgle."],
["Grrrrgle"],
["Grrrrlglorp."],
["GrrrrGLRRRLPH!"],
["GRRRRRLGPRLHK!"],
],
goo: [
["Splat."],
["Squish."],
["Squish!"],
["SQLCH!"],
["SQLLLLRCH!"],
["SQQQQUEEEEELLCH!"],
],
vomit: [
["Hurk."],
["Hurrk."],
["Bleugh."],
["Bleugh!"],
["Bleeeugh!"],
["BLEEEUGHK!"],
],
breath: [["Woosh."], ["Fwoosh."], ["FWOOSH."], ["FWOOSH!"], ["FWOOOOOOSH!"]],
chew: [
["Snap.", "Crack."],
["Crunch."],
["Crack!"],
["CRUNCH!"],
["CRRRUNCH!"],
],
magic: [["Zap."], ["Zap!"], ["Fwoosh!"]],
};

function pickByMass(name, mass) {


+ 229
- 119
units.js Целия файл

@@ -1,4 +1,4 @@
'use strict';
"use strict";

function round(number, precision = 3) {
return Math.round(number * Math.pow(10, precision)) / Math.pow(10, precision);
@@ -16,34 +16,40 @@ function numberRough(value, suffix = "") {
} else {
var scale = Math.floor(Math.log10(value));
switch (scale) {
case 1: return "dozens " + suffix;
case 2: return "hundreds " + suffix;
case 1:
return "dozens " + suffix;
case 2:
return "hundreds " + suffix;
default:
let prefix = "";

if (scale % 3 == 1)
prefix = "tens of ";
else if (scale % 3 == 2)
prefix = "hundreds of ";
if (scale % 3 == 1) prefix = "tens of ";
else if (scale % 3 == 2) prefix = "hundreds of ";

let order = Math.floor(scale / 3);

switch (order) {
case 1: return prefix + "thousands " + suffix;
case 2: return prefix + "millions " + suffix;
case 3: return prefix + "billions " + suffix;
case 4: return prefix + "trillions " + suffix;
case 5: return prefix + "quadrillions " + suffix;
case 6: return prefix + "quintillions " + suffix;
default: return "uncountably many";
case 1:
return prefix + "thousands " + suffix;
case 2:
return prefix + "millions " + suffix;
case 3:
return prefix + "billions " + suffix;
case 4:
return prefix + "trillions " + suffix;
case 5:
return prefix + "quadrillions " + suffix;
case 6:
return prefix + "quintillions " + suffix;
default:
return "uncountably many";
}
}
}
}

function fixedIfDecimal(num, fixed) {
if (fixed === undefined)
return num.toString();
if (fixed === undefined) return num.toString();
else;
return num.toFixed(fixed);
}
@@ -56,9 +62,12 @@ function number(value, type = "full", fixed) {
return fixedIfDecimal(val, fixed);
}

case "scientific": return val.toExponential(3, fixed).toString();
case "words": return number_words_repeated(val, fixed);
case "prefix": return number_prefix(val, fixed);
case "scientific":
return val.toExponential(3, fixed).toString();
case "words":
return number_words_repeated(val, fixed);
case "prefix":
return number_prefix(val, fixed);
}
}

@@ -68,108 +77,169 @@ function number_words(value) {
return fixedIfDecimal(value, fixed);
}
switch (scale) {
case 0: return value.toString();
case 1: return Math.round(value / 1e3).toString() + " thousand";
case 2: return Math.round(value / 1e6).toString() + " million";
case 3: return Math.round(value / 1e9).toString() + " billion";
case 4: return Math.round(value / 1e12).toString() + " trillion";
case 5: return Math.round(value / 1e15).toString() + " quadrillion";
case 6: return Math.round(value / 1e18).toString() + " quintillion";
case 7: return Math.round(value / 1e21).toString() + " sextillion";
case 8: return Math.round(value / 1e24).toString() + " septillion";
case 9: return Math.round(value / 1e27).toString() + " octillion";
case 10: return Math.round(value / 1e30).toString() + " nonillion";
case 11: return Math.round(value / 1e33).toString() + " decillion";
case 12: return Math.round(value / 1e36).toString() + " undecillion";
case 13: return Math.round(value / 1e39).toString() + " duodecillion";
case 14: return Math.round(value / 1e42).toString() + " tredecillion";
case 15: return Math.round(value / 1e45).toString() + " quattuordecillion";
case 16: return Math.round(value / 1e48).toString() + " quindecillion";
case 17: return Math.round(value / 1e51).toString() + " sexdecillion";
case 18: return Math.round(value / 1e54).toString() + " septendecillion";
case 19: return Math.round(value / 1e57).toString() + " octodecillion";
case 20: return Math.round(value / 1e60).toString() + " novemdecillion";
default: return Math.round(value / 1e63).toString() + " vigintillion";
case 0:
return value.toString();
case 1:
return Math.round(value / 1e3).toString() + " thousand";
case 2:
return Math.round(value / 1e6).toString() + " million";
case 3:
return Math.round(value / 1e9).toString() + " billion";
case 4:
return Math.round(value / 1e12).toString() + " trillion";
case 5:
return Math.round(value / 1e15).toString() + " quadrillion";
case 6:
return Math.round(value / 1e18).toString() + " quintillion";
case 7:
return Math.round(value / 1e21).toString() + " sextillion";
case 8:
return Math.round(value / 1e24).toString() + " septillion";
case 9:
return Math.round(value / 1e27).toString() + " octillion";
case 10:
return Math.round(value / 1e30).toString() + " nonillion";
case 11:
return Math.round(value / 1e33).toString() + " decillion";
case 12:
return Math.round(value / 1e36).toString() + " undecillion";
case 13:
return Math.round(value / 1e39).toString() + " duodecillion";
case 14:
return Math.round(value / 1e42).toString() + " tredecillion";
case 15:
return Math.round(value / 1e45).toString() + " quattuordecillion";
case 16:
return Math.round(value / 1e48).toString() + " quindecillion";
case 17:
return Math.round(value / 1e51).toString() + " sexdecillion";
case 18:
return Math.round(value / 1e54).toString() + " septendecillion";
case 19:
return Math.round(value / 1e57).toString() + " octodecillion";
case 20:
return Math.round(value / 1e60).toString() + " novemdecillion";
default:
return Math.round(value / 1e63).toString() + " vigintillion";
}
}

function number_words_repeated(value, fixed) {
if (value == Infinity)
return "a lot of";
if (value == Infinity) return "a lot of";
var scale = Math.floor(Math.log(value) / Math.log(1000));
if (scale < 0)
return fixedIfDecimal(value, fixed);
if (scale < 0) return fixedIfDecimal(value, fixed);
switch (scale) {
case 0: return fixedIfDecimal(value, fixed);
case 1: return Math.round(value / 1e3).toString() + " thousand";
case 2: return Math.round(value / 1e6).toString() + " million";
case 3: return Math.round(value / 1e9).toString() + " billion";
case 4: return Math.round(value / 1e12).toString() + " trillion";
case 5: return Math.round(value / 1e15).toString() + " quadrillion";
case 6: return Math.round(value / 1e18).toString() + " quintillion";
case 7: return Math.round(value / 1e21).toString() + " sextillion";
case 8: return Math.round(value / 1e24).toString() + " septillion";
case 9: return Math.round(value / 1e27).toString() + " octillion";
case 10: return Math.round(value / 1e30).toString() + " nonillion";
case 11: return Math.round(value / 1e33).toString() + " decillion";
default: return number_words_repeated(value / 1e33) + " decillion";
case 0:
return fixedIfDecimal(value, fixed);
case 1:
return Math.round(value / 1e3).toString() + " thousand";
case 2:
return Math.round(value / 1e6).toString() + " million";
case 3:
return Math.round(value / 1e9).toString() + " billion";
case 4:
return Math.round(value / 1e12).toString() + " trillion";
case 5:
return Math.round(value / 1e15).toString() + " quadrillion";
case 6:
return Math.round(value / 1e18).toString() + " quintillion";
case 7:
return Math.round(value / 1e21).toString() + " sextillion";
case 8:
return Math.round(value / 1e24).toString() + " septillion";
case 9:
return Math.round(value / 1e27).toString() + " octillion";
case 10:
return Math.round(value / 1e30).toString() + " nonillion";
case 11:
return Math.round(value / 1e33).toString() + " decillion";
default:
return number_words_repeated(value / 1e33) + " decillion";
}
}

function number_prefix(value, fixed) {
var scale = Math.floor(Math.log(value) / Math.log(1000));
if (scale < 0)
return fixedIfDecimal(value, fixed);
if (scale < 0) return fixedIfDecimal(value, fixed);
switch (scale) {
case 0: return fixedIfDecimal(value, fixed);
case 1: return Math.round(value / 1e3).toString() + "K";
case 2: return Math.round(value / 1e6).toString() + "M";
case 3: return Math.round(value / 1e9).toString() + "G";
case 4: return Math.round(value / 1e12).toString() + "T";
case 5: return Math.round(value / 1e15).toString() + "P";
case 6: return Math.round(value / 1e18).toString() + "E";
case 7: return Math.round(value / 1e21).toString() + "Z";
default: return Math.round(value / 1e24).toString() + "Y";
case 0:
return fixedIfDecimal(value, fixed);
case 1:
return Math.round(value / 1e3).toString() + "K";
case 2:
return Math.round(value / 1e6).toString() + "M";
case 3:
return Math.round(value / 1e9).toString() + "G";
case 4:
return Math.round(value / 1e12).toString() + "T";
case 5:
return Math.round(value / 1e15).toString() + "P";
case 6:
return Math.round(value / 1e18).toString() + "E";
case 7:
return Math.round(value / 1e21).toString() + "Z";
default:
return Math.round(value / 1e24).toString() + "Y";
}
}

function mass(kg, type = "metric", singular = false) {
switch (type) {
case "metric": return metricMass(kg, singular);
case "SI": return metricSymMass(kg, singular);
case "customary": return customaryMass(kg, singular);
case "US": return customarySymMass(kg, singular);
case "approx": return approxMass(kg, singular);
case "metric":
return metricMass(kg, singular);
case "SI":
return metricSymMass(kg, singular);
case "customary":
return customaryMass(kg, singular);
case "US":
return customarySymMass(kg, singular);
case "approx":
return approxMass(kg, singular);
}
}

function length(m, type = "metric", singular = false) {
switch (type) {
case "metric": return metricLength(m, singular);
case "SI": return metricSymLength(m, singular);
case "customary": return customaryLength(m, singular);
case "US": return customarySymLength(m, singular);
case "approx": return approxLength(m, singular);
case "metric":
return metricLength(m, singular);
case "SI":
return metricSymLength(m, singular);
case "customary":
return customaryLength(m, singular);
case "US":
return customarySymLength(m, singular);
case "approx":
return approxLength(m, singular);
}
}

function area(m2, type = "metric", singular = false) {
switch (type) {
case "metric": return metricArea(m2, singular);
case "SI": return metricSymArea(m2, singular);
case "customary": return customaryArea(m2, singular);
case "US": return customarySymArea(m2, singular);
case "approx": return approxArea(m2, singular);
case "metric":
return metricArea(m2, singular);
case "SI":
return metricSymArea(m2, singular);
case "customary":
return customaryArea(m2, singular);
case "US":
return customarySymArea(m2, singular);
case "approx":
return approxArea(m2, singular);
}
}

function volume(m3, type = "metric", singular = false) {
switch (type) {
case "metric": return metricVolume(m3, singular);
case "SI": return metricSymVolume(m3, singular);
case "customary": return customaryVolume(m3, singular);
case "US": return customarySymVolume(m3, singular);
case "approx": return approxVolume(m3, singular);
case "metric":
return metricVolume(m3, singular);
case "SI":
return metricSymVolume(m3, singular);
case "customary":
return customaryVolume(m3, singular);
case "US":
return customarySymVolume(m3, singular);
case "approx":
return approxVolume(m3, singular);
}
}

@@ -266,13 +336,21 @@ function approxMass(kg, singular = false) {
return mass + (singular || mass == 1 ? " tank" : " tanks");
} else if (kg < 5.2e10) {
let mass = round(kg / 9.7e7, 2);
return mass + (singular || mass == 1 ? " aircraft carrier" : " aircraft carriers");
return (
mass +
(singular || mass == 1 ? " aircraft carrier" : " aircraft carriers")
);
} else if (kg < 1.5e13) {
let mass = round(kg / 5.2e10, 2);
return mass + (singular || mass == 1 ? " Great Wall of China" : " Great Wall Of Chinas");
return (
mass +
(singular || mass == 1 ? " Great Wall of China" : " Great Wall Of Chinas")
);
} else if (kg < 5e21) {
let mass = round(kg / 1.5e15, 2);
return mass + (singular || mass == 1 ? " New York City" : " New York Cities");
return (
mass + (singular || mass == 1 ? " New York City" : " New York Cities")
);
//this figure includes a lot of underlying bedrock, just the city itself is 1.13587210581190e11 but I needed a good figure to fit in this spot
} else if (kg < 6e23) {
let mass = round(kg / 4.6e20, 2);
@@ -352,7 +430,7 @@ function customarySymLength(m, singular = false) {

if (ft < 1) {
let length = round(ft * 12, 0);
return length + "\"";
return length + '"';
} else if (ft < 5280) {
let end = customarySymLength((ft - Math.floor(ft)) / 3.28084, singular);
let length = Math.floor(ft);
@@ -369,13 +447,23 @@ function approxLength(m, singular = false) {
return length + (singular || length == 1 ? " person" : " people");
} else if (m < 350) {
let length = round(m / 49, 1);
return length + (singular || length == 1 ? " football field" : " football fields");
return (
length +
(singular || length == 1 ? " football field" : " football fields")
);
} else if (m < 20000) {
let length = round(m / 449, 1);
return length + (singular || length == 1 ? " Empire State Building" : " Empire State Buildings");
return (
length +
(singular || length == 1
? " Empire State Building"
: " Empire State Buildings")
);
} else if (m < 2000000) {
let length = round(m / 80467.2, 1);
return length + (singular || length == 1 ? " Panama Canal" : " Panama Canals");
return (
length + (singular || length == 1 ? " Panama Canal" : " Panama Canals")
);
} else if (m < 3474574 * 2) {
let length = round(m / 3474574, 1);
return length + (singular || length == 1 ? " Moon" : " moons");
@@ -409,7 +497,10 @@ function approxLength(m, singular = false) {
function metricArea(m2, singular = false) {
if (m2 < 1 / 10) {
let area = round(m2 * 10000, 2);
return area + (singular || area == 1 ? " square centimeter" : " square centimeters");
return (
area +
(singular || area == 1 ? " square centimeter" : " square centimeters")
);
} else if (m2 < 100000) {
let area = round(m2, 2);
return area + (singular || area == 1 ? " square meter" : " square meters");
@@ -438,7 +529,7 @@ function customaryArea(m2, singular = false) {
if (ft2 < 1) {
let area = round(ft2 * 144, 0);
return area + (singular || area == 1 ? " square inch" : " square inches");
} else if (ft2 < 5280 * 5280 / 10) {
} else if (ft2 < (5280 * 5280) / 10) {
let area = round(ft2, 1);
return area + (singular || area == 1 ? " square foot" : " square feet");
} else {
@@ -463,21 +554,23 @@ function customarySymArea(m2, singular = false) {
function approxArea(m2, singular = false) {
if (m2 < 20000) {
let area = round(m2 / 5341.85, 1);
return area + (singular || area == 1 ? " football field" : " football fields");
} else if (m2 < 9.36e+15) {
return (
area + (singular || area == 1 ? " football field" : " football fields")
);
} else if (m2 < 9.36e15) {
let area = round(m2 / 10117.1, 1);
return area + (singular || area == 1 ? " block" : " blocks");
} else if (m2 < 3.7920361e+13) {
let area = round(m2 / 9.36e+8, 1);
} else if (m2 < 3.7920361e13) {
let area = round(m2 / 9.36e8, 1);
return area + (singular || area == 1 ? " city" : " cities");
} else if (m2 < 9.4800902e+18) {
let area = round(m2 / 9.4800902e+12, 1);
} else if (m2 < 9.4800902e18) {
let area = round(m2 / 9.4800902e12, 1);
return area + (singular || area == 1 ? " moon" : " moons");
} else if (m2 < 2.8118957330513e+42) {
let area = round(m2 / 6.4900004e+28, 1);
} else if (m2 < 2.8118957330513e42) {
let area = round(m2 / 6.4900004e28, 1);
return area + (singular || area == 1 ? " solar system" : " solar systems");
} else {
let area = round(m2 / 2.8118957330513e+42, 1);
let area = round(m2 / 2.8118957330513e42, 1);
return area + (singular || area == 1 ? " milky way" : " milky ways");
}
}
@@ -491,13 +584,21 @@ function metricVolume(m3, singular = false) {
return volume + (singular || volume == 1 ? " liter" : " liters");
} else if (m3 < 1000000) {
let volume = round(m3, 0);
return volume + (singular || volume == 1 ? " cubic meter" : " cubic meters");
return (
volume + (singular || volume == 1 ? " cubic meter" : " cubic meters")
);
} else if (m3 < 1e12) {
let volume = round(m3 / 1e9, 3);
return volume + (singular || volume == 1 ? " cubic kilometer" : " cubic kilometers");
return (
volume +
(singular || volume == 1 ? " cubic kilometer" : " cubic kilometers")
);
} else {
let volume = round(m3 / 1e9, 0);
return volume + (singular || volume == 1 ? " cubic kilometer" : " cubic kilometers");
return (
volume +
(singular || volume == 1 ? " cubic kilometer" : " cubic kilometers")
);
}
}

@@ -524,7 +625,9 @@ function customaryVolume(m3, singular = false) {
let gallons = m3 * 264.172;
if (gallons < 1 / 16) {
let volume = round(gallons * 128, 0);
return volume + (singular || volume == 1 ? " fluid ounce" : " fluid ounces");
return (
volume + (singular || volume == 1 ? " fluid ounce" : " fluid ounces")
);
} else if (gallons < 1 / 4) {
let volume = round(gallons * 16, 1);
return volume + (singular || volume == 1 ? " cup" : " cups");
@@ -570,7 +673,7 @@ function approxVolume(m3, singular = false) {
if (m3 < 2 / 10000) {
let volume = round(m3 * 4e5, 0);
return volume + (singular || volume == 1 ? " shot" : " shots");
} else if (m3 < .1) {
} else if (m3 < 0.1) {
let volume = round(m3 * 2254, 1);
return volume + (singular || volume == 1 ? " glass" : " glasses");
} else if (m3 < 100) {
@@ -578,13 +681,21 @@ function approxVolume(m3, singular = false) {
return volume + (singular || volume == 1 ? " bathtub" : " bathtubs");
} else if (m3 < 1e5) {
let volume = round(m3 / 1000, 2);
return volume + (singular || volume == 1 ? " Olympic swimming pool" : " Olympic swimming pools");
return (
volume +
(singular || volume == 1
? " Olympic swimming pool"
: " Olympic swimming pools")
);
} else if (m3 < 1e9) {
let volume = round(m3 / 3.2e5, 2);
return volume + (singular || volume == 1 ? " oil tanker" : " oil tankers");
} else if (m3 < 1e15) {
let volume = round(m3 / 1.8919e10, 3);
return volume + (singular || volume == 1 ? " Great Salt Lake" : " Great Salt Lakes");
return (
volume +
(singular || volume == 1 ? " Great Salt Lake" : " Great Salt Lakes")
);
} else if (m3 < 1e20) {
let volume = round(m3 / 3.547e17, 3);
return volume + (singular || volume == 1 ? " ocean" : " oceans");
@@ -597,17 +708,16 @@ function approxVolume(m3, singular = false) {
}
}


function makeSphere(input = 0, diameter = false) {
if (diameter = true) {
if ((diameter = true)) {
input = input / 2;
}
return (4 / 3) * Math.PI * (Math.pow(input, 3));
return (4 / 3) * Math.PI * Math.pow(input, 3);
}

function breakSphere(input = 0, diameter = false) {
let output = math.pow((3 * input) / (4 * Math.PI), 1 / 3)
if (diameter = true) {
let output = math.pow((3 * input) / (4 * Math.PI), 1 / 3);
if ((diameter = true)) {
output = output * 2;
}
return output;


Loading…
Отказ
Запис