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.
 
 
 

1213 lines
30 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,"engine"],["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. // remove all instances of thing
  167. function contents_remove(thing) {
  168. for (let key in contents) {
  169. if (contents.hasOwnProperty(key)) {
  170. let type = contents[key];
  171. for (let i=0; i<type.length; i++) {
  172. if (type[i][0] == thing) {
  173. type.splice(i,1);
  174. --i;
  175. }
  176. }
  177. }
  178. }
  179. }
  180. // adds thing to parent
  181. function contents_insert(parent,thing,min,max,label) {
  182. let owner = contents[parent];
  183. if (label == undefined)
  184. owner.push([thing,min,max]);
  185. else
  186. owner.push([thing,min,max,label]);
  187. }
  188. function initContents(name,count) {
  189. let result = {};
  190. let type = contents[name];
  191. for (let i=0; i<type.length; i++) {
  192. let amount = distribution(type[i][1],type[i][2],count);
  193. if (amount > 0) {
  194. // if a custom label is supplied, use it!
  195. if (type[i].length == 4)
  196. result[type[i][3]] = new things[type[i][0]](amount);
  197. else
  198. result[type[i][0]] = new things[type[i][0]](amount);
  199. }
  200. }
  201. return result;
  202. }
  203. // general logic: each step fills in a fraction of the remaining space
  204. function fill_area(area, weights, variance=0.15)
  205. {
  206. area = area + Math.random() * variance * 2 - variance;
  207. var result = [];
  208. var candidates = [];
  209. for (var key in weights) {
  210. if (weights.hasOwnProperty(key)) {
  211. candidates.push({"name": key, "area": areas[key], "weight": weights[key]});
  212. }
  213. }
  214. candidates = candidates.sort(function (x,y) {
  215. return x.area - y.area;
  216. });
  217. while(candidates.length > 0) {
  218. var candidate = candidates.pop();
  219. if (candidate.area > area)
  220. continue;
  221. var max = Math.floor(area / candidate.area);
  222. var limit = Math.min(max, 100);
  223. var count = 0;
  224. var loopvar = limit;
  225. // for small amounts, actually do the randomness
  226. // the first few ones get a much better shot
  227. while (loopvar > 0) {
  228. if (loopvar <= clusters[candidate.name] && loopvar == 1)
  229. count += 1;
  230. else if (loopvar <= clusters[candidate.name]) {
  231. if (Math.random() < candidate.weight ? 1 : 0 || Math.random() < 0.75) {
  232. count += 1;
  233. }
  234. }
  235. else
  236. count += Math.random() < candidate.weight ? 1 : 0;
  237. --loopvar;
  238. }
  239. if (limit < max) {
  240. count += Math.round((max-limit) * candidate.weight);
  241. }
  242. area -= count * candidate.area;
  243. if (count > 0)
  244. result.push(new things[candidate.name](count));
  245. }
  246. return new Container(result);
  247. }
  248. // describes everything in the container
  249. function describe_all(contents,verbose=true,except=[]) {
  250. var things = [];
  251. for (var key in contents) {
  252. if (contents.hasOwnProperty(key) && !except.includes(key)) {
  253. things.push(contents[key].describe(verbose));
  254. }
  255. }
  256. return merge_things(things);
  257. }
  258. function random_desc(list, odds=1) {
  259. if (Math.random() < odds)
  260. return list[Math.floor(Math.random() * list.length)];
  261. else
  262. return "";
  263. }
  264. // combine strings into a list with proper grammar
  265. function merge_things(list,semicolons=false) {
  266. if (list.length == 0) {
  267. return "";
  268. } else if (list.length == 1) {
  269. return list[0];
  270. } else if (list.length == 2) {
  271. return list[0] + " and " + list[1];
  272. } else {
  273. var result = "";
  274. list.slice(0,list.length-1).forEach(function(term) {
  275. result += term + ", ";
  276. });
  277. result += "and " + list[list.length-1];
  278. return result;
  279. }
  280. }
  281. // combine the adjectives for something into a single string
  282. function merge_desc(list) {
  283. var result = "";
  284. list.forEach(function(term) {
  285. if (term != "")
  286. result += term + " ";
  287. });
  288. // knock off the last space
  289. if (result.length > 0) {
  290. result = result.substring(0, result.length - 1);
  291. }
  292. return result;
  293. }
  294. // maybe make this something that approximates a
  295. // normal distribution; doing this 15,000,000 times is bad...
  296. // solution: only a few are random lul
  297. // improvement: take up to 100 samples, then use that to scale the final result
  298. function distribution(min, max, samples) {
  299. var result = 0;
  300. var limit = Math.min(100,samples);
  301. if (limit < samples) {
  302. let dist = 0;
  303. for (let i = 0; i < limit; i++) {
  304. dist += Math.random();
  305. }
  306. dist /= 100;
  307. return Math.floor(dist * samples * (max - min + 1) + samples * min);
  308. } else {
  309. for (let i = 0; i < limit; i++) {
  310. result += Math.floor(Math.random() * (max - min + 1) + min);
  311. }
  312. }
  313. return result;
  314. }
  315. function defaultArea(thing) {
  316. return areas[thing.name];
  317. }
  318. function defaultMass(thing) {
  319. return masses[thing.name];
  320. }
  321. function defaultMerge(thing) {
  322. return function(container) {
  323. var newCount = this.count + container.count;
  324. var newThing = new things[thing.name](newCount);
  325. newThing.contents = {};
  326. for (var key in this.contents) {
  327. if (this.contents.hasOwnProperty(key)) {
  328. newThing.contents[key] = this.contents[key];
  329. }
  330. }
  331. for (key in container.contents) {
  332. if (container.contents.hasOwnProperty(key)) {
  333. if (this.contents.hasOwnProperty(key)) {
  334. newThing.contents[key] = this.contents[key].merge(container.contents[key]);
  335. } else {
  336. newThing.contents[key] = container.contents[key];
  337. }
  338. }
  339. }
  340. return newThing;
  341. };
  342. }
  343. function defaultSum(thing) {
  344. return function() {
  345. var counts = {};
  346. if (thing.name != "Container")
  347. counts[thing.name] = thing.count;
  348. for (var key in thing.contents) {
  349. if (thing.contents.hasOwnProperty(key)) {
  350. var subcount = thing.contents[key].sum();
  351. for (var subkey in subcount) {
  352. if (!counts.hasOwnProperty(subkey)) {
  353. counts[subkey] = 0;
  354. }
  355. counts[subkey] += subcount[subkey];
  356. }
  357. }
  358. }
  359. return counts;
  360. };
  361. }
  362. function defaultSumProperty(thing) {
  363. return function(prop) {
  364. var total = 0;
  365. total += thing[prop] * thing.count;
  366. for (var key in thing.contents) {
  367. if (thing.contents.hasOwnProperty(key)) {
  368. total += thing.contents[key].sum_property(prop);
  369. }
  370. }
  371. return total;
  372. };
  373. }
  374. function defaultAddContent(thing) {
  375. return function(name, min, max, count) {
  376. if (min == max) {
  377. let object = new things[name](min*count);
  378. thing.contents[object.name] = object;
  379. } else {
  380. let object = new things[name](distribution(min, max, count));
  381. thing.contents[object.name] = object;
  382. }
  383. };
  384. }
  385. function DefaultEntity() {
  386. this.sum = defaultSum;
  387. this.area = defaultArea;
  388. this.mass = defaultMass;
  389. this.sum_property = defaultSumProperty;
  390. this.merge = defaultMerge;
  391. return this;
  392. }
  393. // god I love reinventing the wheel
  394. function copy_defaults(self,proto) {
  395. for (var key in proto) {
  396. if (proto.hasOwnProperty(key)) {
  397. self[key] = proto[key](self);
  398. }
  399. }
  400. }
  401. function Container(contents = []) {
  402. this.name = "Container";
  403. copy_defaults(this,new DefaultEntity());
  404. if (Number.isInteger(contents))
  405. this.count = contents;
  406. else
  407. this.count = 0;
  408. this.contents = {};
  409. for (var i=0; i < contents.length; i++) {
  410. this.contents[contents[i].name] = contents[i];
  411. }
  412. for (var key in this.contents) {
  413. if (this.contents.hasOwnProperty(key)) {
  414. this.count += this.contents[key].count;
  415. }
  416. }
  417. this.describe = function(verbose = true) {
  418. return describe_all(this.contents,verbose);
  419. };
  420. return this;
  421. }
  422. function Person(count = 1) {
  423. this.name = "Person";
  424. copy_defaults(this,new DefaultEntity());
  425. this.count = count;
  426. this.contents = initContents(this.name,this.count);
  427. this.describeOne = function (verbose=true) {
  428. var body = random_desc(["skinny","fat","tall","short","stocky","spindly"], (verbose ? 0.6 : 0));
  429. var sex = random_desc(["male", "female"], (verbose ? 1 : 0));
  430. var species = "";
  431. species = random_desc(["wolf","cat","dog","squirrel","horse","hyena","fox","jackal","crux","sergal"]);
  432. return "a " + merge_desc([body,sex,species]);
  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 Human(count = 1) {
  452. this.name = "Person";
  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(["man", "woman"], 1);
  459. return "a " + merge_desc([body,sex]);
  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 + " people";
  471. }
  472. } else {
  473. return (this.count > 1 ? this.count + " people" : "a person");
  474. }
  475. };
  476. return this;
  477. }
  478. function Cow(count = 1) {
  479. this.name = "Cow";
  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 body = random_desc(["skinny","fat","tall","short","stocky","spindly"], (verbose ? 0.6 : 0));
  485. var sex = random_desc(["male", "female"], (verbose ? 1 : 0));
  486. return "a " + merge_desc([body,sex,"cow"]);
  487. };
  488. this.describe = function(verbose=true) {
  489. if (verbose) {
  490. if (count <= 3) {
  491. var list = [];
  492. for (var i = 0; i < count; i++) {
  493. list.push(this.describeOne(this.count <= 2));
  494. }
  495. return merge_things(list);
  496. } else {
  497. return this.count + " cattle";
  498. }
  499. } else {
  500. return (this.count > 1 ? this.count + " cattle" : "a cow");
  501. }
  502. };
  503. return this;
  504. }
  505. function EmptyCar(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"]);
  512. var adjective = random_desc(["rusty","brand-new"],0.3);
  513. var type = random_desc(["SUV","coupe","sedan","truck","van","convertible"]);
  514. return "a parked " + 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());
  522. }
  523. return merge_things(list);
  524. } else {
  525. return this.count + " parked cars";
  526. }
  527. } else {
  528. return (this.count > 1 ? this.count + " parked cars" : "a parked car");
  529. }
  530. };
  531. }
  532. function Car(count = 1) {
  533. this.name = "Car";
  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 color = random_desc(["black","black","gray","gray","blue","red","tan","white","white"], (verbose ? 1 : 0));
  539. var adjective = random_desc(["rusty","brand-new"], (verbose ? 0.3 : 0));
  540. var type = random_desc(["SUV","coupe","sedan","truck","van","convertible"]);
  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 + " cars with " + describe_all(this.contents,verbose) + " inside";
  553. }
  554. } else {
  555. return (this.count > 1 ? this.count + " cars" : "a car");
  556. }
  557. };
  558. }
  559. function Bus(count = 1) {
  560. this.name = "Bus";
  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","brand-new"], (verbose ? 0.3 : 0));
  566. var color = random_desc(["black","tan","gray"], (verbose ? 1 : 0));
  567. var type = random_desc(["bus","double-decker bus","articulating bus"]);
  568. return "a " + merge_desc([adjective,color,type]);
  569. };
  570. this.describe = function(verbose = true) {
  571. if (verbose) {
  572. if (this.count <= 3) {
  573. var list = [];
  574. for (var i = 0; i < this.count; i++) {
  575. list.push(this.describeOne(this.count < 2));
  576. }
  577. return merge_things(list) + " with " + describe_all(this.contents,verbose) + " inside";
  578. } else {
  579. return this.count + " buses with " + describe_all(this.contents,verbose) + " inside";
  580. }
  581. } else {
  582. return (this.count > 1 ? this.count + " buses" : "a bus");
  583. }
  584. };
  585. }
  586. function Tram(count = 1) {
  587. this.name = "Tram";
  588. copy_defaults(this,new DefaultEntity());
  589. this.count = count;
  590. this.contents = initContents(this.name,this.count);
  591. this.describeOne = function(verbose=true) {
  592. var adjective = random_desc(["rusty","weathered"], (verbose ? 0.3 : 0));
  593. var color = random_desc(["blue","brown","gray"], (verbose ? 1 : 0));
  594. var type = random_desc(["tram"]);
  595. return "a " + merge_desc([adjective,color,type]);
  596. };
  597. this.describe = function(verbose = true) {
  598. if (verbose) {
  599. if (this.count == 1) {
  600. var list = [];
  601. for (var i = 0; i < this.count; i++) {
  602. list.push(this.describeOne(verbose));
  603. }
  604. return merge_things(list) + " with " + describe_all(this.contents,verbose) + " inside";
  605. } else {
  606. return this.count + " trams with " + describe_all(this.contents,verbose) + " inside";
  607. }
  608. } else {
  609. return (this.count > 1 ? this.count + " trams" : "a tram");
  610. }
  611. };
  612. this.anal_vore = function() {
  613. return "You slide " + this.describe() + " up your tight ass";
  614. };
  615. }
  616. function Train(count = 1) {
  617. this.name = "Train";
  618. copy_defaults(this,new DefaultEntity());
  619. this.count = count;
  620. this.contents = initContents(this.name,this.count);
  621. this.describeOne = function(verbose=true) {
  622. var adjective = random_desc(["rusty","brand-new"], (verbose ? 0.3 : 0));
  623. var color = random_desc(["black","tan","gray"], (verbose ? 1 : 0));
  624. var type = random_desc(["train","passenger train","freight train"]);
  625. return "a " + merge_desc([adjective,color,type]);
  626. };
  627. this.describe = function(verbose = true) {
  628. if (verbose) {
  629. if (this.count == 1) {
  630. var list = [];
  631. for (var i = 0; i < this.count; i++) {
  632. list.push(this.describeOne(verbose));
  633. }
  634. return merge_things(list) + " with " + this.contents["engine"].describe(false) + " in the engine and " + this.contents["Train Car"].describe() + " attached";
  635. } else {
  636. return this.count + " trains with " + this.contents["engine"].describe(false) + " in the engine and " + this.contents["Train Car"].describe() + " attached";
  637. }
  638. } else {
  639. return (this.count > 1 ? this.count + " trains" : "a train");
  640. }
  641. };
  642. this.anal_vore = function() {
  643. 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");
  644. return "You snatch up " + this.describeOne() + " and stuff it into your pucker, moaning as " + cars;
  645. };
  646. }
  647. function TrainCar(count = 1) {
  648. this.name = "Train Car";
  649. copy_defaults(this,new DefaultEntity());
  650. this.count = count;
  651. this.contents = initContents(this.name,this.count);
  652. this.describeOne = function(verbose=true) {
  653. var adjective = random_desc(["rusty","brand-new"], (verbose ? 0.3 : 0));
  654. var color = random_desc(["black","tan","gray"], (verbose ? 1 : 0));
  655. var type = random_desc(["train car","passenger train car","freight train car"]);
  656. return "a " + merge_desc([adjective,color,type]);
  657. };
  658. this.describe = function(verbose = true) {
  659. if (verbose) {
  660. return (this.count > 1 ? this.count + " train cars" : "a train car") + " with " + describe_all(this.contents) + " inside";
  661. } else {
  662. return (this.count > 1 ? this.count + " train cars" : "a train car");
  663. }
  664. };
  665. }
  666. function House(count = 1) {
  667. this.name = "House";
  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","two-story","large"], (verbose ? 0.5 : 0));
  673. var color = random_desc(["blue","white","gray","tan","green"], (verbose ? 0.5 : 0));
  674. var name = random_desc(["house","house","house","house","house","trailer"], 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 + " homes with " + describe_all(this.contents,verbose) + " inside";
  687. }
  688. } else {
  689. return (this.count > 1 ? this.count + " houses" : "a house");
  690. }
  691. };
  692. }
  693. function Barn(count = 1) {
  694. this.name = "Barn";
  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 size = random_desc(["little","big","large"], (verbose ? 0.5 : 0));
  700. var color = random_desc(["blue","white","gray","tan","green"], (verbose ? 0.5 : 0));
  701. var name = random_desc(["barn","barn","barn","barn","barn","farmhouse"], 1);
  702. return "a " + merge_desc([size,color,name]);
  703. };
  704. this.describe = function(verbose = true) {
  705. if (verbose) {
  706. if (this.count <= 3) {
  707. var list = [];
  708. for (var i = 0; i < this.count; i++) {
  709. list.push(this.describeOne(this.count < 2));
  710. }
  711. return merge_things(list) + " with " + describe_all(this.contents,verbose) + " inside";
  712. } else {
  713. return this.count + " barns with " + describe_all(this.contents,verbose) + " inside";
  714. }
  715. } else {
  716. return (this.count > 1 ? this.count + " barns" : "a barn");
  717. }
  718. };
  719. }
  720. function SmallSkyscraper(count = 1) {
  721. this.name = "Small Skyscraper";
  722. copy_defaults(this,new DefaultEntity());
  723. this.count = count;
  724. this.contents = initContents(this.name,this.count);
  725. this.describeOne = function(verbose=true) {
  726. var color = random_desc(["blue","white","gray","tan","green"], (verbose ? 0.5 : 0));
  727. var name = random_desc(["skyscraper","office tower","office building"], 1);
  728. return "a " + merge_desc([color,name]);
  729. };
  730. this.describe = function(verbose = true) {
  731. if (verbose) {
  732. if (this.count <= 3) {
  733. var list = [];
  734. for (var i = 0; i < this.count; i++) {
  735. list.push(this.describeOne(this.count < 2));
  736. }
  737. return merge_things(list) + " with " + describe_all(this.contents,verbose) + " inside";
  738. } else {
  739. return this.count + " small skyscrapers with " + describe_all(this.contents,verbose) + " inside";
  740. }
  741. } else {
  742. return (this.count > 1 ? this.count + " small skyscrapers" : "a small skyscraper");
  743. }
  744. };
  745. }
  746. function LargeSkyscraper(count = 1) {
  747. this.name = "Large Skyscraper";
  748. copy_defaults(this,new DefaultEntity());
  749. this.count = count;
  750. this.contents = initContents(this.name,this.count);
  751. this.describeOne = function(verbose=true) {
  752. var color = random_desc(["blue","white","gray","tan","green"], (verbose ? 0.5 : 0));
  753. var name = random_desc(["skyscraper","office tower","office building"], 1);
  754. return "a " + merge_desc(["towering",color,name]);
  755. };
  756. this.describe = function(verbose = true) {
  757. if (verbose) {
  758. if (this.count <= 3) {
  759. var list = [];
  760. for (var i = 0; i < this.count; i++) {
  761. list.push(this.describeOne(this.count < 2));
  762. }
  763. return merge_things(list) + " with " + describe_all(this.contents,verbose) + " inside";
  764. } else {
  765. return this.count + " large skyscrapers with " + describe_all(this.contents,verbose) + " inside";
  766. }
  767. } else {
  768. return (this.count > 1 ? this.count + " large skyscrapers" : "a large skyscraper");
  769. }
  770. };
  771. }
  772. function ParkingGarage(count = 1) {
  773. this.name = "Parking Garage";
  774. copy_defaults(this,new DefaultEntity());
  775. this.count = count;
  776. this.contents = initContents(this.name,this.count);
  777. this.describeOne = function(verbose=true) {
  778. return "a parking garage";
  779. };
  780. this.describe = function(verbose = true) {
  781. if (verbose) {
  782. return (this.count == 1 ? "a parking garage" : this.count + " parking garages") + " with " + describe_all(this.contents, verbose) + " inside";
  783. } else {
  784. return (this.count == 1 ? "a parking garage" : this.count + " parking garages");
  785. }
  786. };
  787. }
  788. function Town(count = 1) {
  789. this.name = "Town";
  790. copy_defaults(this,new DefaultEntity());
  791. this.count = count;
  792. this.contents = initContents(this.name,this.count);
  793. this.describe = function(verbose = true) {
  794. if (verbose) {
  795. return (this.count == 1 ? "a town" : this.count + " towns") + " with " + describe_all(this.contents, verbose) + " in " + (this.count == 1 ? "it" : "them");
  796. } else {
  797. return (this.count == 1 ? "a town" : this.count + " towns");
  798. }
  799. };
  800. }
  801. function City(count = 1) {
  802. this.name = "City";
  803. copy_defaults(this,new DefaultEntity());
  804. this.count = count;
  805. this.contents = initContents(this.name,this.count);
  806. this.describe = function(verbose = true) {
  807. if (verbose) {
  808. return (this.count == 1 ? "a city" : this.count + " cities") + " with " + describe_all(this.contents, verbose) + " in " + (this.count == 1 ? "it" : "them");
  809. } else {
  810. return (this.count == 1 ? "a city" : this.count + " cities");
  811. }
  812. };
  813. }
  814. function Continent(count = 1) {
  815. this.name = "Continent";
  816. copy_defaults(this,new DefaultEntity());
  817. this.count = count;
  818. this.contents = initContents(this.name,this.count);
  819. this.describe = function(verbose = true) {
  820. if (verbose) {
  821. return (this.count == 1 ? "a continent" : this.count + " continents") + " with " + describe_all(this.contents, verbose) + " on " + (this.count == 1 ? "it" : "them");
  822. } else {
  823. return (this.count == 1 ? "a continent" : this.count + " continents");
  824. }
  825. };
  826. }
  827. function Planet(count = 1) {
  828. this.name = "Planet";
  829. copy_defaults(this,new DefaultEntity());
  830. this.count = count;
  831. this.contents = initContents(this.name,this.count);
  832. this.describe = function(verbose = true) {
  833. if (verbose) {
  834. return (this.count == 1 ? "a planet" : this.count + " planets") + " with " + describe_all(this.contents, verbose) + " on " + (this.count == 1 ? "it" : "them");
  835. } else {
  836. return (this.count == 1 ? "a planet" : this.count + " planets");
  837. }
  838. };
  839. }
  840. function Star(count = 1) {
  841. this.name = "Star";
  842. copy_defaults(this,new DefaultEntity());
  843. this.count = count;
  844. this.contents = initContents(this.name,this.count);
  845. this.describe = function(verbose = true) {
  846. return (this.count == 1 ? "a star" : this.count + " stars");
  847. };
  848. }
  849. function SolarSystem(count = 1) {
  850. this.name = "Solar System";
  851. copy_defaults(this,new DefaultEntity());
  852. this.count = count;
  853. this.contents = initContents(this.name,this.count);
  854. this.describe = function(verbose = true) {
  855. if (verbose) {
  856. return (this.count == 1 ? "a solar system" : this.count + " solar systems") + " made up of " + describe_all(this.contents, verbose);
  857. } else {
  858. return (this.count == 1 ? "a solar system" : this.count + " solar systems");
  859. }
  860. };
  861. }
  862. function Galaxy(count = 1) {
  863. this.name = "Galaxy";
  864. copy_defaults(this,new DefaultEntity());
  865. this.count = count;
  866. this.contents = initContents(this.name,this.count);
  867. this.describe = function(verbose = true) {
  868. if (verbose) {
  869. return (this.count == 1 ? "a galaxy" : this.count + " galaxies") + " made up of " + describe_all(this.contents, verbose);
  870. } else {
  871. return (this.count == 1 ? "a galaxy" : this.count + " galaxies");
  872. }
  873. };
  874. }
  875. function Soldier(count = 1) {
  876. this.name = "Soldier";
  877. copy_defaults(this,new DefaultEntity());
  878. this.count = count;
  879. this.contents = initContents(this.name,this.count);
  880. this.describe = function(verbose = true) {
  881. return (this.count == 1 ? "a soldier" : this.count + " soldiers");
  882. };
  883. }
  884. function Tank(count = 1) {
  885. this.name = "Tank";
  886. copy_defaults(this,new DefaultEntity());
  887. this.count = count;
  888. this.contents = initContents(this.name,this.count);
  889. this.describe = function(verbose = true) {
  890. if (verbose) {
  891. return (this.count == 1 ? "a tank" : this.count + " tanks") + " with " + describe_all(this.contents, verbose) + " trapped inside.";
  892. } else {
  893. return (this.count == 1 ? "a tank" : this.count + " tanks");
  894. }
  895. };
  896. }
  897. function Artillery(count = 1) {
  898. this.name = "Artillery";
  899. copy_defaults(this,new DefaultEntity());
  900. this.count = count;
  901. this.contents = initContents(this.name,this.count);
  902. this.describe = function(verbose = true) {
  903. if (verbose) {
  904. return (this.count == 1 ? "an artillery unit" : this.count + " artillery units") + " with " + describe_all(this.contents, verbose) + " trapped inside.";
  905. } else {
  906. return (this.count == 1 ? "an artillery unit" : this.count + " artillery units");
  907. }
  908. };
  909. }
  910. function Helicopter(count = 1) {
  911. this.name = "Helicopter";
  912. copy_defaults(this,new DefaultEntity());
  913. this.count = count;
  914. this.contents = initContents(this.name,this.count);
  915. this.describe = function(verbose = true) {
  916. if (verbose) {
  917. return (this.count == 1 ? "a helicopter" : this.count + " helicopters") + " with " + describe_all(this.contents, verbose) + " riding inside.";
  918. } else {
  919. return (this.count == 1 ? "a helicopter" : this.count + " helicopters");
  920. }
  921. };
  922. }
  923. function Micro(count = 1) {
  924. this.name = "Micro";
  925. copy_defaults(this,new DefaultEntity());
  926. this.count = count;
  927. this.contents = initContents(this.name,this.count);
  928. this.describe = function(verbose = true) {
  929. return (this.count == 1 ? "a micro" : this.count + " micros");
  930. };
  931. }
  932. function Macro(count = 1) {
  933. this.name = "Macro";
  934. copy_defaults(this,new DefaultEntity());
  935. this.count = count;
  936. this.contents = initContents(this.name,this.count);
  937. this.describe = function(verbose = true) {
  938. return (this.count == 1 ? "a smaller macro" : this.count + " smaller macros");
  939. };
  940. }