big steppy
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

1187 lines
29 KiB

  1. 'use strict';
  2. var things =
  3. {
  4. "Container": Container,
  5. "Person": Person,
  6. "Human": Human,
  7. "Cow": Cow,
  8. "Empty Car": EmptyCar,
  9. "Car": Car,
  10. "Bus": Bus,
  11. "Tram": Tram,
  12. "House": House,
  13. "Barn": Barn,
  14. "Small Skyscraper": SmallSkyscraper,
  15. "Large Skyscraper": LargeSkyscraper,
  16. "Train": Train,
  17. "Train Car": TrainCar,
  18. "Parking Garage": ParkingGarage,
  19. "Town": Town,
  20. "City": City,
  21. "Continent": Continent,
  22. "Planet": Planet,
  23. "Star": Star,
  24. "Solar System": SolarSystem,
  25. "Galaxy": Galaxy,
  26. "Soldier": Soldier,
  27. "Tank": Tank,
  28. "Artillery": Artillery,
  29. "Helicopter": Helicopter,
  30. "Micro": Micro,
  31. "Macro": Macro,
  32. };
  33. var areas =
  34. {
  35. "Container": 0,
  36. "Person": 0.33,
  37. "Human": 0.33,
  38. "Cow": 2,
  39. "Car": 4,
  40. "Bus": 12,
  41. "Tram": 20,
  42. "House": 150,
  43. "Barn": 300,
  44. "Small Skyscraper": 1000,
  45. "Large Skyscraper": 2000,
  46. "Train": 40,
  47. "TrainCar": 20,
  48. "Parking Garage": 750,
  49. "Town": 1e7,
  50. "City": 1e9,
  51. "Continent": 1.5e13,
  52. "Planet": 2.5e14,
  53. "Star": 3e18,
  54. "Solar System": 3e21,
  55. "Galaxy": 2e42,
  56. "Soldier": 1,
  57. "Tank": 10,
  58. "Artillery": 12,
  59. "Helicopter": 8,
  60. "Micro": 0.05,
  61. "Macro": 100,
  62. };
  63. var masses =
  64. {
  65. "Container": 0,
  66. "Person": 80,
  67. "Human": 80,
  68. "Cow": 300,
  69. "Car": 1000,
  70. "Bus": 5000,
  71. "Tram": 10000,
  72. "House": 10000,
  73. "Barn": 5000,
  74. "Small Skyscraper": 10000000,
  75. "Large Skyscraper": 80000000,
  76. "Train": 50000,
  77. "Train Car": 7500,
  78. "Parking Garage": 10000000,
  79. "Town": 1,
  80. "City": 1,
  81. "Continent": 1e21,
  82. "Planet": 5.972e24,
  83. "Star": 1e40,
  84. "Solar System": 1,
  85. "Galaxy": 1,
  86. "Soldier": 80,
  87. "Tank": 5000,
  88. "Artillery": 7000,
  89. "Helicopter": 1500,
  90. "Micro": 0.01,
  91. "Macro": 80000,
  92. };
  93. var clusters =
  94. {
  95. "Container": 0,
  96. "Person": 5,
  97. "Human": 5,
  98. "Cow": 15,
  99. "Car": 3,
  100. "Bus": 1,
  101. "Tram": 1,
  102. "House": 5,
  103. "Barn": 1,
  104. "Small Skyscraper": 2,
  105. "Large Skyscraper": 1,
  106. "Train": 2,
  107. "Train Car": 1,
  108. "Parking Garage": 1,
  109. "Town": 5,
  110. "City": 1,
  111. "Continent": 5,
  112. "Planet": 1,
  113. "Star": 1,
  114. "Solar System": 1,
  115. "Galaxy": 1,
  116. "Soldier": 0,
  117. "Tank": 0,
  118. "Artillery": 0,
  119. "Helicopter": 0,
  120. "Micro": 10,
  121. "Macro": 0,
  122. };
  123. var contents =
  124. {
  125. "Container": [],
  126. "Person": [],
  127. "Human": [],
  128. "Cow": [],
  129. "Car": [["Person",1,4]],
  130. "Bus": [["Person",2,30]],
  131. "Tram": [["Person",10,50]],
  132. "Train": [["Person",1,4],["Train Car",2,10]],
  133. "Train Car": [["Person",10,40]],
  134. "House": [["Person",0,8],["Empty Car",0,2]],
  135. "Barn": [["Person",0,2],["Cow",30,70]],
  136. "Small Skyscraper": [["Person",150,750],["Empty Car",10,50]],
  137. "Large Skyscraper": [["Person",500,1500],["Empty Car",20,100]],
  138. "Parking Garage": [["Person",10,200],["Empty Car",100,300],["Car",5,30]],
  139. "Town": [["Person",10000,100000],["House",5000,50000],["Empty Car",200,800],["Car",500,80000],["Bus",5,25],["Train",5,25]],
  140. "City": [["Person",100000,1500000],["House",20000,200000],["Empty Car",10000,100000],["Car",7500,125000],["Bus",200,400],["Train",10,50],["Tram",25,100],["Small Skyscraper",50,300],["Large Skyscraper",10,75],["Parking Garage",5,10]],
  141. "Continent": [["Person",1000000,15000000],["House",2500,10000],["Car",25000,375000],["Train",50,500],["Town",500,1000],["City",50,250]],
  142. "Planet": [["Continent",4,9]],
  143. "Star": [],
  144. "Solar System": [["Star",1,1],["Planet",5,15]],
  145. "Galaxy": [["Star",1e9,500e9],["Solar System",1e8,500e8]],
  146. "Soldier": [],
  147. "Tank": [["Soldier",3,5]],
  148. "Artillery": [["Soldier",4,6]],
  149. "Helicopter": [["Soldier",4,16]],
  150. "Micro": [[]],
  151. "Macro": [[]]
  152. };
  153. // replace all instances of from with to
  154. function contents_substitute(from,to) {
  155. for (let key in contents) {
  156. if (contents.hasOwnProperty(key)) {
  157. let type = contents[key];
  158. for (let i=0; i<type.length; i++) {
  159. if (type[i][0] == from) {
  160. type[i][0] = to;
  161. }
  162. }
  163. }
  164. }
  165. }
  166. function initContents(name,count) {
  167. let result = {};
  168. let type = contents[name];
  169. for (let i=0; i<type.length; i++) {
  170. let amount = distribution(type[i][1],type[i][2],count);
  171. if (amount > 0)
  172. result[type[i][0]] = new things[type[i][0]](amount);
  173. }
  174. return result;
  175. }
  176. // general logic: each step fills in a fraction of the remaining space
  177. function fill_area(area, weights, variance=0.15)
  178. {
  179. area = area + Math.random() * variance * 2 - variance;
  180. var result = [];
  181. var candidates = [];
  182. for (var key in weights) {
  183. if (weights.hasOwnProperty(key)) {
  184. candidates.push({"name": key, "area": areas[key], "weight": weights[key]});
  185. }
  186. }
  187. candidates = candidates.sort(function (x,y) {
  188. return x.area - y.area;
  189. });
  190. while(candidates.length > 0) {
  191. var candidate = candidates.pop();
  192. if (candidate.area > area)
  193. continue;
  194. var max = Math.floor(area / candidate.area);
  195. var limit = Math.min(max, 100);
  196. var count = 0;
  197. var loopvar = limit;
  198. // for small amounts, actually do the randomness
  199. // the first few ones get a much better shot
  200. while (loopvar > 0) {
  201. if (loopvar <= clusters[candidate.name] && loopvar == 1)
  202. count += 1;
  203. else if (loopvar <= clusters[candidate.name]) {
  204. if (Math.random() < candidate.weight ? 1 : 0 || Math.random() < 0.75) {
  205. count += 1;
  206. }
  207. }
  208. else
  209. count += Math.random() < candidate.weight ? 1 : 0;
  210. --loopvar;
  211. }
  212. if (limit < max) {
  213. count += Math.round((max-limit) * candidate.weight);
  214. }
  215. area -= count * candidate.area;
  216. if (count > 0)
  217. result.push(new things[candidate.name](count));
  218. }
  219. return new Container(result);
  220. }
  221. // describes everything in the container
  222. function describe_all(contents,verbose=true,except=[]) {
  223. var things = [];
  224. for (var key in contents) {
  225. if (contents.hasOwnProperty(key) && !except.includes(key)) {
  226. things.push(contents[key].describe(verbose));
  227. }
  228. }
  229. return merge_things(things);
  230. }
  231. function random_desc(list, odds=1) {
  232. if (Math.random() < odds)
  233. return list[Math.floor(Math.random() * list.length)];
  234. else
  235. return "";
  236. }
  237. // combine strings into a list with proper grammar
  238. function merge_things(list,semicolons=false) {
  239. if (list.length == 0) {
  240. return "";
  241. } else if (list.length == 1) {
  242. return list[0];
  243. } else if (list.length == 2) {
  244. return list[0] + " and " + list[1];
  245. } else {
  246. var result = "";
  247. list.slice(0,list.length-1).forEach(function(term) {
  248. result += term + ", ";
  249. });
  250. result += "and " + list[list.length-1];
  251. return result;
  252. }
  253. }
  254. // combine the adjectives for something into a single string
  255. function merge_desc(list) {
  256. var result = "";
  257. list.forEach(function(term) {
  258. if (term != "")
  259. result += term + " ";
  260. });
  261. // knock off the last space
  262. if (result.length > 0) {
  263. result = result.substring(0, result.length - 1);
  264. }
  265. return result;
  266. }
  267. // maybe make this something that approximates a
  268. // normal distribution; doing this 15,000,000 times is bad...
  269. // solution: only a few are random lul
  270. // improvement: take up to 100 samples, then use that to scale the final result
  271. function distribution(min, max, samples) {
  272. var result = 0;
  273. var limit = Math.min(100,samples);
  274. if (limit < samples) {
  275. let dist = 0;
  276. for (let i = 0; i < limit; i++) {
  277. dist += Math.random();
  278. }
  279. dist /= 100;
  280. return Math.floor(dist * samples * (max - min + 1) + samples * min);
  281. } else {
  282. for (let i = 0; i < limit; i++) {
  283. result += Math.floor(Math.random() * (max - min + 1) + min);
  284. }
  285. }
  286. return result;
  287. }
  288. function defaultArea(thing) {
  289. return areas[thing.name];
  290. }
  291. function defaultMass(thing) {
  292. return masses[thing.name];
  293. }
  294. function defaultMerge(thing) {
  295. return function(container) {
  296. var newCount = this.count + container.count;
  297. var newThing = new things[thing.name](newCount);
  298. newThing.contents = {};
  299. for (var key in this.contents) {
  300. if (this.contents.hasOwnProperty(key)) {
  301. newThing.contents[key] = this.contents[key];
  302. }
  303. }
  304. for (key in container.contents) {
  305. if (container.contents.hasOwnProperty(key)) {
  306. if (this.contents.hasOwnProperty(key)) {
  307. newThing.contents[key] = this.contents[key].merge(container.contents[key]);
  308. } else {
  309. newThing.contents[key] = container.contents[key];
  310. }
  311. }
  312. }
  313. return newThing;
  314. };
  315. }
  316. function defaultSum(thing) {
  317. return function() {
  318. var counts = {};
  319. if (thing.name != "Container")
  320. counts[thing.name] = thing.count;
  321. for (var key in thing.contents) {
  322. if (thing.contents.hasOwnProperty(key)) {
  323. var subcount = thing.contents[key].sum();
  324. for (var subkey in subcount) {
  325. if (!counts.hasOwnProperty(subkey)) {
  326. counts[subkey] = 0;
  327. }
  328. counts[subkey] += subcount[subkey];
  329. }
  330. }
  331. }
  332. return counts;
  333. };
  334. }
  335. function defaultSumProperty(thing) {
  336. return function(prop) {
  337. var total = 0;
  338. total += thing[prop] * thing.count;
  339. for (var key in thing.contents) {
  340. if (thing.contents.hasOwnProperty(key)) {
  341. total += thing.contents[key].sum_property(prop);
  342. }
  343. }
  344. return total;
  345. };
  346. }
  347. function defaultAddContent(thing) {
  348. return function(name, min, max, count) {
  349. if (min == max) {
  350. let object = new things[name](min*count);
  351. thing.contents[object.name] = object;
  352. } else {
  353. let object = new things[name](distribution(min, max, count));
  354. thing.contents[object.name] = object;
  355. }
  356. };
  357. }
  358. function DefaultEntity() {
  359. this.sum = defaultSum;
  360. this.area = defaultArea;
  361. this.mass = defaultMass;
  362. this.sum_property = defaultSumProperty;
  363. this.merge = defaultMerge;
  364. return this;
  365. }
  366. // god I love reinventing the wheel
  367. function copy_defaults(self,proto) {
  368. for (var key in proto) {
  369. if (proto.hasOwnProperty(key)) {
  370. self[key] = proto[key](self);
  371. }
  372. }
  373. }
  374. function Container(contents = []) {
  375. this.name = "Container";
  376. copy_defaults(this,new DefaultEntity());
  377. if (Number.isInteger(contents))
  378. this.count = contents;
  379. else
  380. this.count = 0;
  381. this.contents = {};
  382. for (var i=0; i < contents.length; i++) {
  383. this.contents[contents[i].name] = contents[i];
  384. }
  385. for (var key in this.contents) {
  386. if (this.contents.hasOwnProperty(key)) {
  387. this.count += this.contents[key].count;
  388. }
  389. }
  390. this.describe = function(verbose = true) {
  391. return describe_all(this.contents,verbose);
  392. };
  393. return this;
  394. }
  395. function Person(count = 1) {
  396. this.name = "Person";
  397. copy_defaults(this,new DefaultEntity());
  398. this.count = count;
  399. this.contents = initContents(this.name,this.count);
  400. this.describeOne = function (verbose=true) {
  401. var body = random_desc(["skinny","fat","tall","short","stocky","spindly"], (verbose ? 0.6 : 0));
  402. var sex = random_desc(["male", "female"], (verbose ? 1 : 0));
  403. var species = "";
  404. species = random_desc(["wolf","cat","dog","squirrel","horse","hyena","fox","jackal","crux","sergal"]);
  405. return "a " + merge_desc([body,sex,species]);
  406. };
  407. this.describe = function(verbose=true) {
  408. if (verbose) {
  409. if (count <= 3) {
  410. var list = [];
  411. for (var i = 0; i < count; i++) {
  412. list.push(this.describeOne(this.count <= 2));
  413. }
  414. return merge_things(list);
  415. } else {
  416. return this.count + " people";
  417. }
  418. } else {
  419. return (this.count > 1 ? this.count + " people" : "a person");
  420. }
  421. };
  422. return this;
  423. }
  424. function Human(count = 1) {
  425. this.name = "Human";
  426. copy_defaults(this,new DefaultEntity());
  427. this.count = count;
  428. this.contents = initContents(this.name,this.count);
  429. this.describeOne = function (verbose=true) {
  430. var body = random_desc(["skinny","fat","tall","short","stocky","spindly"], (verbose ? 0.6 : 0));
  431. var sex = random_desc(["man", "woman"], (verbose ? 1 : 0));
  432. return "a " + merge_desc([body,sex]);
  433. };
  434. this.describe = function(verbose=true) {
  435. if (verbose) {
  436. if (count <= 3) {
  437. var list = [];
  438. for (var i = 0; i < count; i++) {
  439. list.push(this.describeOne(this.count <= 2));
  440. }
  441. return merge_things(list);
  442. } else {
  443. return this.count + " people";
  444. }
  445. } else {
  446. return (this.count > 1 ? this.count + " people" : "a person");
  447. }
  448. };
  449. return this;
  450. }
  451. function Cow(count = 1) {
  452. this.name = "Cow";
  453. copy_defaults(this,new DefaultEntity());
  454. this.count = count;
  455. this.contents = initContents(this.name,this.count);
  456. this.describeOne = function (verbose=true) {
  457. var body = random_desc(["skinny","fat","tall","short","stocky","spindly"], (verbose ? 0.6 : 0));
  458. var sex = random_desc(["male", "female"], (verbose ? 1 : 0));
  459. return "a " + merge_desc([body,sex,"cow"]);
  460. };
  461. this.describe = function(verbose=true) {
  462. if (verbose) {
  463. if (count <= 3) {
  464. var list = [];
  465. for (var i = 0; i < count; i++) {
  466. list.push(this.describeOne(this.count <= 2));
  467. }
  468. return merge_things(list);
  469. } else {
  470. return this.count + " cattle";
  471. }
  472. } else {
  473. return (this.count > 1 ? this.count + " cattle" : "a cow");
  474. }
  475. };
  476. return this;
  477. }
  478. function EmptyCar(count = 1) {
  479. this.name = "Car";
  480. copy_defaults(this,new DefaultEntity());
  481. this.count = count;
  482. this.contents = initContents(this.name,this.count);
  483. this.describeOne = function(verbose=true) {
  484. var color = random_desc(["black","black","gray","gray","blue","red","tan","white","white"]);
  485. var adjective = random_desc(["rusty","brand-new"],0.3);
  486. var type = random_desc(["SUV","coupe","sedan","truck","van","convertible"]);
  487. return "a parked " + merge_desc([adjective,color,type]);
  488. };
  489. this.describe = function(verbose = true) {
  490. if (verbose) {
  491. if (this.count <= 3) {
  492. var list = [];
  493. for (var i = 0; i < this.count; i++) {
  494. list.push(this.describeOne());
  495. }
  496. return merge_things(list);
  497. } else {
  498. return this.count + " parked cars";
  499. }
  500. } else {
  501. return (this.count > 1 ? this.count + " parked cars" : "a parked car");
  502. }
  503. };
  504. }
  505. function Car(count = 1) {
  506. this.name = "Car";
  507. copy_defaults(this,new DefaultEntity());
  508. this.count = count;
  509. this.contents = initContents(this.name,this.count);
  510. this.describeOne = function(verbose=true) {
  511. var color = random_desc(["black","black","gray","gray","blue","red","tan","white","white"], (verbose ? 1 : 0));
  512. var adjective = random_desc(["rusty","brand-new"], (verbose ? 0.3 : 0));
  513. var type = random_desc(["SUV","coupe","sedan","truck","van","convertible"]);
  514. return "a " + merge_desc([adjective,color,type]);
  515. };
  516. this.describe = function(verbose = true) {
  517. if (verbose) {
  518. if (this.count <= 3) {
  519. var list = [];
  520. for (var i = 0; i < this.count; i++) {
  521. list.push(this.describeOne(this.count < 2));
  522. }
  523. return merge_things(list) + " with " + describe_all(this.contents,verbose) + " inside";
  524. } else {
  525. return this.count + " cars with " + describe_all(this.contents,verbose) + " inside";
  526. }
  527. } else {
  528. return (this.count > 1 ? this.count + " cars" : "a car");
  529. }
  530. };
  531. }
  532. function Bus(count = 1) {
  533. this.name = "Bus";
  534. copy_defaults(this,new DefaultEntity());
  535. this.count = count;
  536. this.contents = initContents(this.name,this.count);
  537. this.describeOne = function(verbose=true) {
  538. var adjective = random_desc(["rusty","brand-new"], (verbose ? 0.3 : 0));
  539. var color = random_desc(["black","tan","gray"], (verbose ? 1 : 0));
  540. var type = random_desc(["bus","double-decker bus","articulating bus"]);
  541. return "a " + merge_desc([adjective,color,type]);
  542. };
  543. this.describe = function(verbose = true) {
  544. if (verbose) {
  545. if (this.count <= 3) {
  546. var list = [];
  547. for (var i = 0; i < this.count; i++) {
  548. list.push(this.describeOne(this.count < 2));
  549. }
  550. return merge_things(list) + " with " + describe_all(this.contents,verbose) + " inside";
  551. } else {
  552. return this.count + " buses with " + describe_all(this.contents,verbose) + " inside";
  553. }
  554. } else {
  555. return (this.count > 1 ? this.count + " buses" : "a bus");
  556. }
  557. };
  558. }
  559. function Tram(count = 1) {
  560. this.name = "Tram";
  561. copy_defaults(this,new DefaultEntity());
  562. this.count = count;
  563. this.contents = initContents(this.name,this.count);
  564. this.describeOne = function(verbose=true) {
  565. var adjective = random_desc(["rusty","weathered"], (verbose ? 0.3 : 0));
  566. var color = random_desc(["blue","brown","gray"], (verbose ? 1 : 0));
  567. var type = random_desc(["tram"]);
  568. return "a " + merge_desc([adjective,color,type]);
  569. };
  570. this.describe = function(verbose = true) {
  571. if (verbose) {
  572. if (this.count == 1) {
  573. var list = [];
  574. for (var i = 0; i < this.count; i++) {
  575. list.push(this.describeOne(verbose));
  576. }
  577. return merge_things(list) + " with " + describe_all(this.contents,verbose) + " inside";
  578. } else {
  579. return this.count + " trams with " + describe_all(this.contents,verbose) + " inside";
  580. }
  581. } else {
  582. return (this.count > 1 ? this.count + " trams" : "a tram");
  583. }
  584. };
  585. this.anal_vore = function() {
  586. return "You slide " + this.describe() + " up your tight ass";
  587. };
  588. }
  589. function Train(count = 1) {
  590. this.name = "Train";
  591. copy_defaults(this,new DefaultEntity());
  592. this.count = count;
  593. this.contents = initContents(this.name,this.count);
  594. this.describeOne = function(verbose=true) {
  595. var adjective = random_desc(["rusty","brand-new"], (verbose ? 0.3 : 0));
  596. var color = random_desc(["black","tan","gray"], (verbose ? 1 : 0));
  597. var type = random_desc(["train","passenger train","freight train"]);
  598. return "a " + merge_desc([adjective,color,type]);
  599. };
  600. this.describe = function(verbose = true) {
  601. if (verbose) {
  602. if (this.count == 1) {
  603. var list = [];
  604. for (var i = 0; i < this.count; i++) {
  605. list.push(this.describeOne(verbose));
  606. }
  607. return merge_things(list) + " with " + this.contents["Person"].describe(false) + " in the engine and " + this.contents["Train Car"].describe() + " attached";
  608. } else {
  609. return this.count + " trains with " + this.contents["Person"].describe(false) + " in the engine and " + this.contents["Train Car"].describe() + " attached";
  610. }
  611. } else {
  612. return (this.count > 1 ? this.count + " trains" : "a train");
  613. }
  614. };
  615. this.anal_vore = function() {
  616. var cars = (this.contents["Train Car"].count == 1 ? this.contents["Train Car"].describe() + " follows it inside" : this.contents["Train Car"].describe() + " are pulled slowly inside");
  617. return "You snatch up " + this.describeOne() + " and stuff it into your pucker, moaning as " + cars;
  618. };
  619. }
  620. function TrainCar(count = 1) {
  621. this.name = "Train Car";
  622. copy_defaults(this,new DefaultEntity());
  623. this.count = count;
  624. this.contents = initContents(this.name,this.count);
  625. this.describeOne = function(verbose=true) {
  626. var adjective = random_desc(["rusty","brand-new"], (verbose ? 0.3 : 0));
  627. var color = random_desc(["black","tan","gray"], (verbose ? 1 : 0));
  628. var type = random_desc(["train car","passenger train car","freight train car"]);
  629. return "a " + merge_desc([adjective,color,type]);
  630. };
  631. this.describe = function(verbose = true) {
  632. if (verbose) {
  633. return (this.count > 1 ? this.count + " train cars" : "a train car") + " with " + describe_all(this.contents) + " inside";
  634. } else {
  635. return (this.count > 1 ? this.count + " train cars" : "a train car");
  636. }
  637. };
  638. }
  639. function House(count = 1) {
  640. this.name = "House";
  641. copy_defaults(this,new DefaultEntity());
  642. this.count = count;
  643. this.contents = initContents(this.name,this.count);
  644. this.describeOne = function(verbose=true) {
  645. var size = random_desc(["little","two-story","large"], (verbose ? 0.5 : 0));
  646. var color = random_desc(["blue","white","gray","tan","green"], (verbose ? 0.5 : 0));
  647. var name = random_desc(["house","house","house","house","house","trailer"], 1);
  648. return "a " + merge_desc([size,color,name]);
  649. };
  650. this.describe = function(verbose = true) {
  651. if (verbose) {
  652. if (this.count <= 3) {
  653. var list = [];
  654. for (var i = 0; i < this.count; i++) {
  655. list.push(this.describeOne(this.count < 2));
  656. }
  657. return merge_things(list) + " with " + describe_all(this.contents,verbose) + " inside";
  658. } else {
  659. return this.count + " homes with " + describe_all(this.contents,verbose) + " inside";
  660. }
  661. } else {
  662. return (this.count > 1 ? this.count + " houses" : "a house");
  663. }
  664. };
  665. }
  666. function Barn(count = 1) {
  667. this.name = "Barn";
  668. copy_defaults(this,new DefaultEntity());
  669. this.count = count;
  670. this.contents = initContents(this.name,this.count);
  671. this.describeOne = function(verbose=true) {
  672. var size = random_desc(["little","big","large"], (verbose ? 0.5 : 0));
  673. var color = random_desc(["blue","white","gray","tan","green"], (verbose ? 0.5 : 0));
  674. var name = random_desc(["barn","barn","barn","barn","barn","farmhouse"], 1);
  675. return "a " + merge_desc([size,color,name]);
  676. };
  677. this.describe = function(verbose = true) {
  678. if (verbose) {
  679. if (this.count <= 3) {
  680. var list = [];
  681. for (var i = 0; i < this.count; i++) {
  682. list.push(this.describeOne(this.count < 2));
  683. }
  684. return merge_things(list) + " with " + describe_all(this.contents,verbose) + " inside";
  685. } else {
  686. return this.count + " barns with " + describe_all(this.contents,verbose) + " inside";
  687. }
  688. } else {
  689. return (this.count > 1 ? this.count + " barns" : "a barn");
  690. }
  691. };
  692. }
  693. function SmallSkyscraper(count = 1) {
  694. this.name = "Small Skyscraper";
  695. copy_defaults(this,new DefaultEntity());
  696. this.count = count;
  697. this.contents = initContents(this.name,this.count);
  698. this.describeOne = function(verbose=true) {
  699. var color = random_desc(["blue","white","gray","tan","green"], (verbose ? 0.5 : 0));
  700. var name = random_desc(["skyscraper","office tower","office building"], 1);
  701. return "a " + merge_desc([color,name]);
  702. };
  703. this.describe = function(verbose = true) {
  704. if (verbose) {
  705. if (this.count <= 3) {
  706. var list = [];
  707. for (var i = 0; i < this.count; i++) {
  708. list.push(this.describeOne(this.count < 2));
  709. }
  710. return merge_things(list) + " with " + describe_all(this.contents,verbose) + " inside";
  711. } else {
  712. return this.count + " small skyscrapers with " + describe_all(this.contents,verbose) + " inside";
  713. }
  714. } else {
  715. return (this.count > 1 ? this.count + " small skyscrapers" : "a small skyscraper");
  716. }
  717. };
  718. }
  719. function LargeSkyscraper(count = 1) {
  720. this.name = "Large Skyscraper";
  721. copy_defaults(this,new DefaultEntity());
  722. this.count = count;
  723. this.contents = initContents(this.name,this.count);
  724. this.describeOne = function(verbose=true) {
  725. var color = random_desc(["blue","white","gray","tan","green"], (verbose ? 0.5 : 0));
  726. var name = random_desc(["skyscraper","office tower","office building"], 1);
  727. return "a " + merge_desc(["towering",color,name]);
  728. };
  729. this.describe = function(verbose = true) {
  730. if (verbose) {
  731. if (this.count <= 3) {
  732. var list = [];
  733. for (var i = 0; i < this.count; i++) {
  734. list.push(this.describeOne(this.count < 2));
  735. }
  736. return merge_things(list) + " with " + describe_all(this.contents,verbose) + " inside";
  737. } else {
  738. return this.count + " large skyscrapers with " + describe_all(this.contents,verbose) + " inside";
  739. }
  740. } else {
  741. return (this.count > 1 ? this.count + " large skyscrapers" : "a large skyscraper");
  742. }
  743. };
  744. }
  745. function ParkingGarage(count = 1) {
  746. this.name = "Parking Garage";
  747. copy_defaults(this,new DefaultEntity());
  748. this.count = count;
  749. this.contents = initContents(this.name,this.count);
  750. this.describeOne = function(verbose=true) {
  751. return "a parking garage";
  752. };
  753. this.describe = function(verbose = true) {
  754. if (verbose) {
  755. return (this.count == 1 ? "a parking garage" : this.count + " parking garages") + " with " + describe_all(this.contents, verbose) + " inside";
  756. } else {
  757. return (this.count == 1 ? "a parking garage" : this.count + " parking garages");
  758. }
  759. };
  760. }
  761. function Town(count = 1) {
  762. this.name = "Town";
  763. copy_defaults(this,new DefaultEntity());
  764. this.count = count;
  765. this.contents = initContents(this.name,this.count);
  766. this.describe = function(verbose = true) {
  767. if (verbose) {
  768. return (this.count == 1 ? "a town" : this.count + " towns") + " with " + describe_all(this.contents, verbose) + " in " + (this.count == 1 ? "it" : "them");
  769. } else {
  770. return (this.count == 1 ? "a town" : this.count + " towns");
  771. }
  772. };
  773. }
  774. function City(count = 1) {
  775. this.name = "City";
  776. copy_defaults(this,new DefaultEntity());
  777. this.count = count;
  778. this.contents = initContents(this.name,this.count);
  779. this.describe = function(verbose = true) {
  780. if (verbose) {
  781. return (this.count == 1 ? "a city" : this.count + " cities") + " with " + describe_all(this.contents, verbose) + " in " + (this.count == 1 ? "it" : "them");
  782. } else {
  783. return (this.count == 1 ? "a city" : this.count + " cities");
  784. }
  785. };
  786. }
  787. function Continent(count = 1) {
  788. this.name = "Continent";
  789. copy_defaults(this,new DefaultEntity());
  790. this.count = count;
  791. this.contents = initContents(this.name,this.count);
  792. this.describe = function(verbose = true) {
  793. if (verbose) {
  794. return (this.count == 1 ? "a continent" : this.count + " continents") + " with " + describe_all(this.contents, verbose) + " on " + (this.count == 1 ? "it" : "them");
  795. } else {
  796. return (this.count == 1 ? "a continent" : this.count + " continents");
  797. }
  798. };
  799. }
  800. function Planet(count = 1) {
  801. this.name = "Planet";
  802. copy_defaults(this,new DefaultEntity());
  803. this.count = count;
  804. this.contents = initContents(this.name,this.count);
  805. this.describe = function(verbose = true) {
  806. if (verbose) {
  807. return (this.count == 1 ? "a planet" : this.count + " planets") + " with " + describe_all(this.contents, verbose) + " on " + (this.count == 1 ? "it" : "them");
  808. } else {
  809. return (this.count == 1 ? "a planet" : this.count + " planets");
  810. }
  811. };
  812. }
  813. function Star(count = 1) {
  814. this.name = "Star";
  815. copy_defaults(this,new DefaultEntity());
  816. this.count = count;
  817. this.contents = initContents(this.name,this.count);
  818. this.describe = function(verbose = true) {
  819. return (this.count == 1 ? "a star" : this.count + " stars");
  820. };
  821. }
  822. function SolarSystem(count = 1) {
  823. this.name = "Solar System";
  824. copy_defaults(this,new DefaultEntity());
  825. this.count = count;
  826. this.contents = initContents(this.name,this.count);
  827. this.describe = function(verbose = true) {
  828. if (verbose) {
  829. return (this.count == 1 ? "a solar system" : this.count + " solar systems") + " made up of " + describe_all(this.contents, verbose);
  830. } else {
  831. return (this.count == 1 ? "a solar system" : this.count + " solar systems");
  832. }
  833. };
  834. }
  835. function Galaxy(count = 1) {
  836. this.name = "Galaxy";
  837. copy_defaults(this,new DefaultEntity());
  838. this.count = count;
  839. this.contents = initContents(this.name,this.count);
  840. this.describe = function(verbose = true) {
  841. if (verbose) {
  842. return (this.count == 1 ? "a galaxy" : this.count + " galaxies") + " made up of " + describe_all(this.contents, verbose);
  843. } else {
  844. return (this.count == 1 ? "a galaxy" : this.count + " galaxies");
  845. }
  846. };
  847. }
  848. function Soldier(count = 1) {
  849. this.name = "Soldier";
  850. copy_defaults(this,new DefaultEntity());
  851. this.count = count;
  852. this.contents = initContents(this.name,this.count);
  853. this.describe = function(verbose = true) {
  854. return (this.count == 1 ? "a soldier" : this.count + " soldiers");
  855. };
  856. }
  857. function Tank(count = 1) {
  858. this.name = "Tank";
  859. copy_defaults(this,new DefaultEntity());
  860. this.count = count;
  861. this.contents = initContents(this.name,this.count);
  862. this.describe = function(verbose = true) {
  863. if (verbose) {
  864. return (this.count == 1 ? "a tank" : this.count + " tanks") + " with " + describe_all(this.contents, verbose) + " trapped inside.";
  865. } else {
  866. return (this.count == 1 ? "a tank" : this.count + " tanks");
  867. }
  868. };
  869. }
  870. function Artillery(count = 1) {
  871. this.name = "Artillery";
  872. copy_defaults(this,new DefaultEntity());
  873. this.count = count;
  874. this.contents = initContents(this.name,this.count);
  875. this.describe = function(verbose = true) {
  876. if (verbose) {
  877. return (this.count == 1 ? "an artillery unit" : this.count + " artillery units") + " with " + describe_all(this.contents, verbose) + " trapped inside.";
  878. } else {
  879. return (this.count == 1 ? "an artillery unit" : this.count + " artillery units");
  880. }
  881. };
  882. }
  883. function Helicopter(count = 1) {
  884. this.name = "Helicopter";
  885. copy_defaults(this,new DefaultEntity());
  886. this.count = count;
  887. this.contents = initContents(this.name,this.count);
  888. this.describe = function(verbose = true) {
  889. if (verbose) {
  890. return (this.count == 1 ? "a helicopter" : this.count + " helicopters") + " with " + describe_all(this.contents, verbose) + " riding inside.";
  891. } else {
  892. return (this.count == 1 ? "a helicopter" : this.count + " helicopters");
  893. }
  894. };
  895. }
  896. function Micro(count = 1) {
  897. this.name = "Micro";
  898. copy_defaults(this,new DefaultEntity());
  899. this.count = count;
  900. this.contents = initContents(this.name,this.count);
  901. this.describe = function(verbose = true) {
  902. return (this.count == 1 ? "a micro" : this.count + " micros");
  903. };
  904. }
  905. function Macro(count = 1) {
  906. this.name = "Macro";
  907. copy_defaults(this,new DefaultEntity());
  908. this.count = count;
  909. this.contents = initContents(this.name,this.count);
  910. this.describe = function(verbose = true) {
  911. return (this.count == 1 ? "a smaller macro" : this.count + " smaller macros");
  912. };
  913. }