big steppy
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

1223 行
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 listSum(sum) {
  344. let result = [];
  345. for (let key in sum) {
  346. if (sum.hasOwnProperty(key)) {
  347. result.push(new things[key](sum[key]).describe(false));
  348. }
  349. }
  350. return merge_things(result);
  351. }
  352. function defaultSum(thing) {
  353. return function() {
  354. var counts = {};
  355. if (thing.name != "Container")
  356. counts[thing.name] = thing.count;
  357. for (var key in thing.contents) {
  358. if (thing.contents.hasOwnProperty(key)) {
  359. var subcount = thing.contents[key].sum();
  360. for (var subkey in subcount) {
  361. if (!counts.hasOwnProperty(subkey)) {
  362. counts[subkey] = 0;
  363. }
  364. counts[subkey] += subcount[subkey];
  365. }
  366. }
  367. }
  368. return counts;
  369. };
  370. }
  371. function defaultSumProperty(thing) {
  372. return function(prop) {
  373. var total = 0;
  374. total += thing[prop] * thing.count;
  375. for (var key in thing.contents) {
  376. if (thing.contents.hasOwnProperty(key)) {
  377. total += thing.contents[key].sum_property(prop);
  378. }
  379. }
  380. return total;
  381. };
  382. }
  383. function defaultAddContent(thing) {
  384. return function(name, min, max, count) {
  385. if (min == max) {
  386. let object = new things[name](min*count);
  387. thing.contents[object.name] = object;
  388. } else {
  389. let object = new things[name](distribution(min, max, count));
  390. thing.contents[object.name] = object;
  391. }
  392. };
  393. }
  394. function DefaultEntity() {
  395. this.sum = defaultSum;
  396. this.area = defaultArea;
  397. this.mass = defaultMass;
  398. this.sum_property = defaultSumProperty;
  399. this.merge = defaultMerge;
  400. return this;
  401. }
  402. // god I love reinventing the wheel
  403. function copy_defaults(self,proto) {
  404. for (var key in proto) {
  405. if (proto.hasOwnProperty(key)) {
  406. self[key] = proto[key](self);
  407. }
  408. }
  409. }
  410. function Container(contents = []) {
  411. this.name = "Container";
  412. copy_defaults(this,new DefaultEntity());
  413. if (Number.isInteger(contents))
  414. this.count = contents;
  415. else
  416. this.count = 0;
  417. this.contents = {};
  418. for (var i=0; i < contents.length; i++) {
  419. this.contents[contents[i].name] = contents[i];
  420. }
  421. for (var key in this.contents) {
  422. if (this.contents.hasOwnProperty(key)) {
  423. this.count += this.contents[key].count;
  424. }
  425. }
  426. this.describe = function(verbose = true) {
  427. return describe_all(this.contents,verbose);
  428. };
  429. return this;
  430. }
  431. function Person(count = 1) {
  432. this.name = "Person";
  433. copy_defaults(this,new DefaultEntity());
  434. this.count = count;
  435. this.contents = initContents(this.name,this.count);
  436. this.describeOne = function (verbose=true) {
  437. var body = random_desc(["skinny","fat","tall","short","stocky","spindly"], (verbose ? 0.6 : 0));
  438. var sex = random_desc(["male", "female"], (verbose ? 1 : 0));
  439. var species = "";
  440. species = random_desc(["wolf","cat","dog","squirrel","horse","hyena","fox","jackal","crux","sergal"]);
  441. return "a " + merge_desc([body,sex,species]);
  442. };
  443. this.describe = function(verbose=true) {
  444. if (verbose) {
  445. if (count <= 3) {
  446. var list = [];
  447. for (var i = 0; i < count; i++) {
  448. list.push(this.describeOne(this.count <= 2));
  449. }
  450. return merge_things(list);
  451. } else {
  452. return this.count + " people";
  453. }
  454. } else {
  455. return (this.count > 1 ? this.count + " people" : "a person");
  456. }
  457. };
  458. return this;
  459. }
  460. function Human(count = 1) {
  461. this.name = "Person";
  462. copy_defaults(this,new DefaultEntity());
  463. this.count = count;
  464. this.contents = initContents(this.name,this.count);
  465. this.describeOne = function (verbose=true) {
  466. var body = random_desc(["skinny","fat","tall","short","stocky","spindly"], (verbose ? 0.6 : 0));
  467. var sex = random_desc(["man", "woman"], 1);
  468. return "a " + merge_desc([body,sex]);
  469. };
  470. this.describe = function(verbose=true) {
  471. if (verbose) {
  472. if (count <= 3) {
  473. var list = [];
  474. for (var i = 0; i < count; i++) {
  475. list.push(this.describeOne(this.count <= 2));
  476. }
  477. return merge_things(list);
  478. } else {
  479. return this.count + " people";
  480. }
  481. } else {
  482. return (this.count > 1 ? this.count + " people" : "a person");
  483. }
  484. };
  485. return this;
  486. }
  487. function Cow(count = 1) {
  488. this.name = "Cow";
  489. copy_defaults(this,new DefaultEntity());
  490. this.count = count;
  491. this.contents = initContents(this.name,this.count);
  492. this.describeOne = function (verbose=true) {
  493. var body = random_desc(["skinny","fat","tall","short","stocky","spindly"], (verbose ? 0.6 : 0));
  494. var sex = random_desc(["male", "female"], (verbose ? 1 : 0));
  495. return "a " + merge_desc([body,sex,"cow"]);
  496. };
  497. this.describe = function(verbose=true) {
  498. if (verbose) {
  499. if (count <= 3) {
  500. var list = [];
  501. for (var i = 0; i < count; i++) {
  502. list.push(this.describeOne(this.count <= 2));
  503. }
  504. return merge_things(list);
  505. } else {
  506. return this.count + " cattle";
  507. }
  508. } else {
  509. return (this.count > 1 ? this.count + " cattle" : "a cow");
  510. }
  511. };
  512. return this;
  513. }
  514. function EmptyCar(count = 1) {
  515. this.name = "Car";
  516. copy_defaults(this,new DefaultEntity());
  517. this.count = count;
  518. this.contents = initContents(this.name,this.count);
  519. this.describeOne = function(verbose=true) {
  520. var color = random_desc(["black","black","gray","gray","blue","red","tan","white","white"]);
  521. var adjective = random_desc(["rusty","brand-new"],0.3);
  522. var type = random_desc(["SUV","coupe","sedan","truck","van","convertible"]);
  523. return "a parked " + merge_desc([adjective,color,type]);
  524. };
  525. this.describe = function(verbose = true) {
  526. if (verbose) {
  527. if (this.count <= 3) {
  528. var list = [];
  529. for (var i = 0; i < this.count; i++) {
  530. list.push(this.describeOne());
  531. }
  532. return merge_things(list);
  533. } else {
  534. return this.count + " parked cars";
  535. }
  536. } else {
  537. return (this.count > 1 ? this.count + " parked cars" : "a parked car");
  538. }
  539. };
  540. }
  541. function Car(count = 1) {
  542. this.name = "Car";
  543. copy_defaults(this,new DefaultEntity());
  544. this.count = count;
  545. this.contents = initContents(this.name,this.count);
  546. this.describeOne = function(verbose=true) {
  547. var color = random_desc(["black","black","gray","gray","blue","red","tan","white","white"], (verbose ? 1 : 0));
  548. var adjective = random_desc(["rusty","brand-new"], (verbose ? 0.3 : 0));
  549. var type = random_desc(["SUV","coupe","sedan","truck","van","convertible"]);
  550. return "a " + merge_desc([adjective,color,type]);
  551. };
  552. this.describe = function(verbose = true) {
  553. if (verbose) {
  554. if (this.count <= 3) {
  555. var list = [];
  556. for (var i = 0; i < this.count; i++) {
  557. list.push(this.describeOne(this.count < 2));
  558. }
  559. return merge_things(list) + " with " + describe_all(this.contents,verbose) + " inside";
  560. } else {
  561. return this.count + " cars with " + describe_all(this.contents,verbose) + " inside";
  562. }
  563. } else {
  564. return (this.count > 1 ? this.count + " cars" : "a car");
  565. }
  566. };
  567. }
  568. function Bus(count = 1) {
  569. this.name = "Bus";
  570. copy_defaults(this,new DefaultEntity());
  571. this.count = count;
  572. this.contents = initContents(this.name,this.count);
  573. this.describeOne = function(verbose=true) {
  574. var adjective = random_desc(["rusty","brand-new"], (verbose ? 0.3 : 0));
  575. var color = random_desc(["black","tan","gray"], (verbose ? 1 : 0));
  576. var type = random_desc(["bus","double-decker bus","articulating bus"]);
  577. return "a " + merge_desc([adjective,color,type]);
  578. };
  579. this.describe = function(verbose = true) {
  580. if (verbose) {
  581. if (this.count <= 3) {
  582. var list = [];
  583. for (var i = 0; i < this.count; i++) {
  584. list.push(this.describeOne(this.count < 2));
  585. }
  586. return merge_things(list) + " with " + describe_all(this.contents,verbose) + " inside";
  587. } else {
  588. return this.count + " buses with " + describe_all(this.contents,verbose) + " inside";
  589. }
  590. } else {
  591. return (this.count > 1 ? this.count + " buses" : "a bus");
  592. }
  593. };
  594. }
  595. function Tram(count = 1) {
  596. this.name = "Tram";
  597. copy_defaults(this,new DefaultEntity());
  598. this.count = count;
  599. this.contents = initContents(this.name,this.count);
  600. this.describeOne = function(verbose=true) {
  601. var adjective = random_desc(["rusty","weathered"], (verbose ? 0.3 : 0));
  602. var color = random_desc(["blue","brown","gray"], (verbose ? 1 : 0));
  603. var type = random_desc(["tram"]);
  604. return "a " + merge_desc([adjective,color,type]);
  605. };
  606. this.describe = function(verbose = true) {
  607. if (verbose) {
  608. if (this.count == 1) {
  609. var list = [];
  610. for (var i = 0; i < this.count; i++) {
  611. list.push(this.describeOne(verbose));
  612. }
  613. return merge_things(list) + " with " + describe_all(this.contents,verbose) + " inside";
  614. } else {
  615. return this.count + " trams with " + describe_all(this.contents,verbose) + " inside";
  616. }
  617. } else {
  618. return (this.count > 1 ? this.count + " trams" : "a tram");
  619. }
  620. };
  621. this.anal_vore = function() {
  622. return "You slide " + this.describe() + " up your tight ass";
  623. };
  624. }
  625. function Train(count = 1) {
  626. this.name = "Train";
  627. copy_defaults(this,new DefaultEntity());
  628. this.count = count;
  629. this.contents = initContents(this.name,this.count);
  630. this.describeOne = function(verbose=true) {
  631. var adjective = random_desc(["rusty","brand-new"], (verbose ? 0.3 : 0));
  632. var color = random_desc(["black","tan","gray"], (verbose ? 1 : 0));
  633. var type = random_desc(["train","passenger train","freight train"]);
  634. return "a " + merge_desc([adjective,color,type]);
  635. };
  636. this.describe = function(verbose = true) {
  637. if (verbose) {
  638. if (this.count == 1) {
  639. var list = [];
  640. for (var i = 0; i < this.count; i++) {
  641. list.push(this.describeOne(verbose));
  642. }
  643. return merge_things(list) + " with " + this.contents["engine"].describe(false) + " in the engine and " + this.contents["Train Car"].describe() + " attached";
  644. } else {
  645. return this.count + " trains with " + this.contents["engine"].describe(false) + " in the engine and " + this.contents["Train Car"].describe() + " attached";
  646. }
  647. } else {
  648. return (this.count > 1 ? this.count + " trains" : "a train");
  649. }
  650. };
  651. this.anal_vore = function() {
  652. 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");
  653. return "You snatch up " + this.describeOne() + " and stuff it into your pucker, moaning as " + cars;
  654. };
  655. }
  656. function TrainCar(count = 1) {
  657. this.name = "Train Car";
  658. copy_defaults(this,new DefaultEntity());
  659. this.count = count;
  660. this.contents = initContents(this.name,this.count);
  661. this.describeOne = function(verbose=true) {
  662. var adjective = random_desc(["rusty","brand-new"], (verbose ? 0.3 : 0));
  663. var color = random_desc(["black","tan","gray"], (verbose ? 1 : 0));
  664. var type = random_desc(["train car","passenger train car","freight train car"]);
  665. return "a " + merge_desc([adjective,color,type]);
  666. };
  667. this.describe = function(verbose = true) {
  668. if (verbose) {
  669. return (this.count > 1 ? this.count + " train cars" : "a train car") + " with " + describe_all(this.contents) + " inside";
  670. } else {
  671. return (this.count > 1 ? this.count + " train cars" : "a train car");
  672. }
  673. };
  674. }
  675. function House(count = 1) {
  676. this.name = "House";
  677. copy_defaults(this,new DefaultEntity());
  678. this.count = count;
  679. this.contents = initContents(this.name,this.count);
  680. this.describeOne = function(verbose=true) {
  681. var size = random_desc(["little","two-story","large"], (verbose ? 0.5 : 0));
  682. var color = random_desc(["blue","white","gray","tan","green"], (verbose ? 0.5 : 0));
  683. var name = random_desc(["house","house","house","house","house","trailer"], 1);
  684. return "a " + merge_desc([size,color,name]);
  685. };
  686. this.describe = function(verbose = true) {
  687. if (verbose) {
  688. if (this.count <= 3) {
  689. var list = [];
  690. for (var i = 0; i < this.count; i++) {
  691. list.push(this.describeOne(this.count < 2));
  692. }
  693. return merge_things(list) + " with " + describe_all(this.contents,verbose) + " inside";
  694. } else {
  695. return this.count + " homes with " + describe_all(this.contents,verbose) + " inside";
  696. }
  697. } else {
  698. return (this.count > 1 ? this.count + " houses" : "a house");
  699. }
  700. };
  701. }
  702. function Barn(count = 1) {
  703. this.name = "Barn";
  704. copy_defaults(this,new DefaultEntity());
  705. this.count = count;
  706. this.contents = initContents(this.name,this.count);
  707. this.describeOne = function(verbose=true) {
  708. var size = random_desc(["little","big","large"], (verbose ? 0.5 : 0));
  709. var color = random_desc(["blue","white","gray","tan","green"], (verbose ? 0.5 : 0));
  710. var name = random_desc(["barn","barn","barn","barn","barn","farmhouse"], 1);
  711. return "a " + merge_desc([size,color,name]);
  712. };
  713. this.describe = function(verbose = true) {
  714. if (verbose) {
  715. if (this.count <= 3) {
  716. var list = [];
  717. for (var i = 0; i < this.count; i++) {
  718. list.push(this.describeOne(this.count < 2));
  719. }
  720. return merge_things(list) + " with " + describe_all(this.contents,verbose) + " inside";
  721. } else {
  722. return this.count + " barns with " + describe_all(this.contents,verbose) + " inside";
  723. }
  724. } else {
  725. return (this.count > 1 ? this.count + " barns" : "a barn");
  726. }
  727. };
  728. }
  729. function SmallSkyscraper(count = 1) {
  730. this.name = "Small Skyscraper";
  731. copy_defaults(this,new DefaultEntity());
  732. this.count = count;
  733. this.contents = initContents(this.name,this.count);
  734. this.describeOne = function(verbose=true) {
  735. var color = random_desc(["blue","white","gray","tan","green"], (verbose ? 0.5 : 0));
  736. var name = random_desc(["skyscraper","office tower","office building"], 1);
  737. return "a " + merge_desc([color,name]);
  738. };
  739. this.describe = function(verbose = true) {
  740. if (verbose) {
  741. if (this.count <= 3) {
  742. var list = [];
  743. for (var i = 0; i < this.count; i++) {
  744. list.push(this.describeOne(this.count < 2));
  745. }
  746. return merge_things(list) + " with " + describe_all(this.contents,verbose) + " inside";
  747. } else {
  748. return this.count + " small skyscrapers with " + describe_all(this.contents,verbose) + " inside";
  749. }
  750. } else {
  751. return (this.count > 1 ? this.count + " small skyscrapers" : "a small skyscraper");
  752. }
  753. };
  754. }
  755. function LargeSkyscraper(count = 1) {
  756. this.name = "Large Skyscraper";
  757. copy_defaults(this,new DefaultEntity());
  758. this.count = count;
  759. this.contents = initContents(this.name,this.count);
  760. this.describeOne = function(verbose=true) {
  761. var color = random_desc(["blue","white","gray","tan","green"], (verbose ? 0.5 : 0));
  762. var name = random_desc(["skyscraper","office tower","office building"], 1);
  763. return "a " + merge_desc(["towering",color,name]);
  764. };
  765. this.describe = function(verbose = true) {
  766. if (verbose) {
  767. if (this.count <= 3) {
  768. var list = [];
  769. for (var i = 0; i < this.count; i++) {
  770. list.push(this.describeOne(this.count < 2));
  771. }
  772. return merge_things(list) + " with " + describe_all(this.contents,verbose) + " inside";
  773. } else {
  774. return this.count + " large skyscrapers with " + describe_all(this.contents,verbose) + " inside";
  775. }
  776. } else {
  777. return (this.count > 1 ? this.count + " large skyscrapers" : "a large skyscraper");
  778. }
  779. };
  780. }
  781. function ParkingGarage(count = 1) {
  782. this.name = "Parking Garage";
  783. copy_defaults(this,new DefaultEntity());
  784. this.count = count;
  785. this.contents = initContents(this.name,this.count);
  786. this.describeOne = function(verbose=true) {
  787. return "a parking garage";
  788. };
  789. this.describe = function(verbose = true) {
  790. if (verbose) {
  791. return (this.count == 1 ? "a parking garage" : this.count + " parking garages") + " with " + describe_all(this.contents, verbose) + " inside";
  792. } else {
  793. return (this.count == 1 ? "a parking garage" : this.count + " parking garages");
  794. }
  795. };
  796. }
  797. function Town(count = 1) {
  798. this.name = "Town";
  799. copy_defaults(this,new DefaultEntity());
  800. this.count = count;
  801. this.contents = initContents(this.name,this.count);
  802. this.describe = function(verbose = true) {
  803. if (verbose) {
  804. return (this.count == 1 ? "a town" : this.count + " towns") + " with " + describe_all(this.contents, verbose) + " in " + (this.count == 1 ? "it" : "them");
  805. } else {
  806. return (this.count == 1 ? "a town" : this.count + " towns");
  807. }
  808. };
  809. }
  810. function City(count = 1) {
  811. this.name = "City";
  812. copy_defaults(this,new DefaultEntity());
  813. this.count = count;
  814. this.contents = initContents(this.name,this.count);
  815. this.describe = function(verbose = true) {
  816. if (verbose) {
  817. return (this.count == 1 ? "a city" : this.count + " cities") + " with " + describe_all(this.contents, verbose) + " in " + (this.count == 1 ? "it" : "them");
  818. } else {
  819. return (this.count == 1 ? "a city" : this.count + " cities");
  820. }
  821. };
  822. }
  823. function Continent(count = 1) {
  824. this.name = "Continent";
  825. copy_defaults(this,new DefaultEntity());
  826. this.count = count;
  827. this.contents = initContents(this.name,this.count);
  828. this.describe = function(verbose = true) {
  829. if (verbose) {
  830. return (this.count == 1 ? "a continent" : this.count + " continents") + " with " + describe_all(this.contents, verbose) + " on " + (this.count == 1 ? "it" : "them");
  831. } else {
  832. return (this.count == 1 ? "a continent" : this.count + " continents");
  833. }
  834. };
  835. }
  836. function Planet(count = 1) {
  837. this.name = "Planet";
  838. copy_defaults(this,new DefaultEntity());
  839. this.count = count;
  840. this.contents = initContents(this.name,this.count);
  841. this.describe = function(verbose = true) {
  842. if (verbose) {
  843. return (this.count == 1 ? "a planet" : this.count + " planets") + " with " + describe_all(this.contents, verbose) + " on " + (this.count == 1 ? "it" : "them");
  844. } else {
  845. return (this.count == 1 ? "a planet" : this.count + " planets");
  846. }
  847. };
  848. }
  849. function Star(count = 1) {
  850. this.name = "Star";
  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. return (this.count == 1 ? "a star" : this.count + " stars");
  856. };
  857. }
  858. function SolarSystem(count = 1) {
  859. this.name = "Solar System";
  860. copy_defaults(this,new DefaultEntity());
  861. this.count = count;
  862. this.contents = initContents(this.name,this.count);
  863. this.describe = function(verbose = true) {
  864. if (verbose) {
  865. return (this.count == 1 ? "a solar system" : this.count + " solar systems") + " made up of " + describe_all(this.contents, verbose);
  866. } else {
  867. return (this.count == 1 ? "a solar system" : this.count + " solar systems");
  868. }
  869. };
  870. }
  871. function Galaxy(count = 1) {
  872. this.name = "Galaxy";
  873. copy_defaults(this,new DefaultEntity());
  874. this.count = count;
  875. this.contents = initContents(this.name,this.count);
  876. this.describe = function(verbose = true) {
  877. if (verbose) {
  878. return (this.count == 1 ? "a galaxy" : this.count + " galaxies") + " made up of " + describe_all(this.contents, verbose);
  879. } else {
  880. return (this.count == 1 ? "a galaxy" : this.count + " galaxies");
  881. }
  882. };
  883. }
  884. function Soldier(count = 1) {
  885. this.name = "Soldier";
  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. return (this.count == 1 ? "a soldier" : this.count + " soldiers");
  891. };
  892. }
  893. function Tank(count = 1) {
  894. this.name = "Tank";
  895. copy_defaults(this,new DefaultEntity());
  896. this.count = count;
  897. this.contents = initContents(this.name,this.count);
  898. this.describe = function(verbose = true) {
  899. if (verbose) {
  900. return (this.count == 1 ? "a tank" : this.count + " tanks") + " with " + describe_all(this.contents, verbose) + " trapped inside.";
  901. } else {
  902. return (this.count == 1 ? "a tank" : this.count + " tanks");
  903. }
  904. };
  905. }
  906. function Artillery(count = 1) {
  907. this.name = "Artillery";
  908. copy_defaults(this,new DefaultEntity());
  909. this.count = count;
  910. this.contents = initContents(this.name,this.count);
  911. this.describe = function(verbose = true) {
  912. if (verbose) {
  913. return (this.count == 1 ? "an artillery unit" : this.count + " artillery units") + " with " + describe_all(this.contents, verbose) + " trapped inside.";
  914. } else {
  915. return (this.count == 1 ? "an artillery unit" : this.count + " artillery units");
  916. }
  917. };
  918. }
  919. function Helicopter(count = 1) {
  920. this.name = "Helicopter";
  921. copy_defaults(this,new DefaultEntity());
  922. this.count = count;
  923. this.contents = initContents(this.name,this.count);
  924. this.describe = function(verbose = true) {
  925. if (verbose) {
  926. return (this.count == 1 ? "a helicopter" : this.count + " helicopters") + " with " + describe_all(this.contents, verbose) + " riding inside.";
  927. } else {
  928. return (this.count == 1 ? "a helicopter" : this.count + " helicopters");
  929. }
  930. };
  931. }
  932. function Micro(count = 1) {
  933. this.name = "Micro";
  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 micro" : this.count + " micros");
  939. };
  940. }
  941. function Macro(count = 1) {
  942. this.name = "Macro";
  943. copy_defaults(this,new DefaultEntity());
  944. this.count = count;
  945. this.contents = initContents(this.name,this.count);
  946. this.describe = function(verbose = true) {
  947. return (this.count == 1 ? "a smaller macro" : this.count + " smaller macros");
  948. };
  949. }