big steppy
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 

1806 lignes
50 KiB

  1. 'use strict';
  2. var things =
  3. {
  4. "Container": {
  5. "Container": Container,
  6. mass: 0,
  7. area: 0,
  8. clusters: 0,
  9. cluster_chances: 0,
  10. contents: [],
  11. descriptor: ["", ""]
  12. },
  13. //Creatures
  14. "Person": {
  15. "Person": Person,
  16. mass: 80,
  17. area: .33,
  18. clusters: 5,
  19. cluster_chances: .8,
  20. contents: [],
  21. descriptor: ["a person", "people"]
  22. },
  23. "Human": {
  24. "Human": Human,
  25. mass: 80,
  26. area: .33,
  27. clusters: 5,
  28. cluster_chances: .8,
  29. contents: [],
  30. descriptor: ["a person", "people"]
  31. },
  32. "Cow": {
  33. "Cow": Cow,
  34. mass: 300,
  35. area: 2,
  36. clusters: 15,
  37. cluster_chances: .5,
  38. contents: [],
  39. descriptor: ["a cow", "cattle"]
  40. },
  41. "Micro": {
  42. "Micro": Micro,
  43. mass: .01,
  44. area: .05,
  45. clusters: 50,
  46. cluster_chances: 1,
  47. contents: [],
  48. descriptor: ["a micro", "micros"]
  49. },
  50. "Macro": {
  51. "Macro": Macro,
  52. mass: 8e4,
  53. area: 100,
  54. clusters: 0,
  55. cluster_chances: 0,
  56. contents: [],
  57. descriptor: ["a smaller macro", "smaller macros"]
  58. },
  59. //Vehicles
  60. "Empty Car": {
  61. "Empty Car": EmptyCar,
  62. mass: 1000,
  63. area: 4,
  64. clusters: 2,
  65. cluster_chances: .3,
  66. contents: [],
  67. descriptor: ["a parked car", "parked cars"]
  68. },
  69. "Car": {
  70. "Car": Car,
  71. mass: 1000,
  72. area: 4,
  73. clusters: 4,
  74. cluster_chances: .5,
  75. contents: [["Person", 1, 4]],
  76. descriptor: ["a car", "cars"]
  77. },
  78. "Bus": {
  79. "Bus": Bus,
  80. mass: 5000,
  81. area: 12,
  82. clusters: 1,
  83. cluster_chances: .25,
  84. contents: [["Person", 2, 30]],
  85. descriptor: ["a bus", "busses"]
  86. },
  87. "Tram": {
  88. "Tram": Tram,
  89. mass: 1e4,
  90. area: 20,
  91. clusters: 1,
  92. cluster_chances: .2,
  93. contents: [["Person", 10, 50]],
  94. descriptor: ["a tram", "trams"]
  95. },
  96. "Train": {
  97. "Train": Train,
  98. mass: 5e4,
  99. area: 40,
  100. clusters: 2,
  101. cluster_chances: .1,
  102. contents: [["Person", 1, 4, "engine"], ["Train Car", 2, 10]],
  103. descriptor: ["a train", "trains"]
  104. },
  105. "Train Car": {
  106. "Train Car": TrainCar,
  107. mass: 7500,
  108. area: 20,
  109. clusters: 1,
  110. cluster_chances: .05,
  111. contents: [["Person", 10, 40]],
  112. descriptor: ["a train car", "train cars"]
  113. },
  114. "Helicopter": {
  115. "Helicopter": Helicopter,
  116. mass: 1500,
  117. area: 12,
  118. clusters: 0,
  119. cluster_chances: 0,
  120. contents: [["Person", 4, 16]],
  121. descriptor: ["a helicopter", "helicopters"]
  122. },
  123. "Empty Helicopter": {
  124. "Empty Helicopter": EmptyHelicopter,
  125. mass: 1500,
  126. area: 12,
  127. clusters: 3,
  128. cluster_chances: 0.05,
  129. contents: [],
  130. descriptor: ["a parked helicopter", "parked helicopters"]
  131. },
  132. "Plane": {
  133. "Plane": Plane,
  134. mass: 6500,
  135. area: 50,
  136. clusters: 1,
  137. cluster_chances: .05,
  138. contents: [],
  139. descriptor: ["a small plane", "small planes"]
  140. },
  141. "Empty Plane": {
  142. "Empty Plane": EmptyPlane,
  143. mass: 6500,
  144. area: 50,
  145. clusters: 1,
  146. cluster_chances: .05,
  147. contents: [["Person", 2, 9]],
  148. descriptor: ["a parked plane", "parked aircraft"]
  149. },
  150. "Airliner": {
  151. "Airliner": Airliner,
  152. mass: 6500,
  153. area: 1250,
  154. clusters: 1,
  155. cluster_chances: .05,
  156. contents: [["Person", 5, 300]],
  157. descriptor: ["an airliner", "airliners"]
  158. },
  159. "Empty Airliner": {
  160. "Empty Airliner": EmptyAirliner,
  161. mass: 6500,
  162. area: 1250,
  163. clusters: 1,
  164. cluster_chances: .05,
  165. contents: [],
  166. descriptor: ["a parked airliner", "parked airliners"]
  167. },
  168. //Buildings
  169. "House": {
  170. "House": House,
  171. mass: 1e4,
  172. area: 150,
  173. clusters: 5,
  174. cluster_chances: .5,
  175. contents: [["Person", 0, 8], ["Empty Car", 0, 2]],
  176. descriptor: ["house", "houses"]
  177. },
  178. "Business": {
  179. "Business": Business,
  180. mass: 5e4,
  181. area: 400,
  182. clusters: 5,
  183. cluster_chances: .25,
  184. contents: [["Person", 0, 30], ["Car", 0, 5], ["Empty Car", 0, 20]],
  185. descriptor: ["a local business", "buildings"]
  186. },
  187. "Barn": {
  188. "Barn": Barn,
  189. mass: 5e3,
  190. area: 300,
  191. clusters: 1,
  192. cluster_chances: .1,
  193. contents: [["Person", 0, 2], ["Cow", 30, 70]],
  194. descriptor: ["a barn", "barns"]
  195. },
  196. "Small Hangar": {
  197. "Small Hangar": SmallHangar,
  198. mass: 5e5,
  199. area: 2500,
  200. clusters: 1,
  201. cluster_chances: .1,
  202. contents: [["Person", 0, 3], ["Plane", 0, 1], ["Empty Plane", 2, 6]],
  203. descriptor: ["a small hangar", "small hangars"]
  204. },
  205. "Helicopter Hangar": {
  206. "Helicopter Hangar": HelicopterHangar,
  207. mass: 5e5,
  208. area: 2000,
  209. clusters: 1,
  210. cluster_chances: .1,
  211. contents: [["Person", 0, 3], ["Helicopter", 0, 1], ["Helicopter", 2, 6]],
  212. descriptor: ["a helicopter hangar", "helicopter hangar"]
  213. },
  214. "Large Hangar": {
  215. "Large Hangar": LargeHangar,
  216. mass: 5e6,
  217. area: 8000,
  218. clusters: 1,
  219. cluster_chances: .1,
  220. contents: [["Person", 0, 5], ["Airliner", 0, 1], ["Empty Airliner", 1, 2]],
  221. descriptor: ["an aircraft hangar", "hangars"]
  222. },
  223. "Small Skyscraper": {
  224. "Small Skyscraper": SmallSkyscraper,
  225. mass: 1e7,
  226. area: 1000,
  227. clusters: 2,
  228. cluster_chances: .25,
  229. contents: [["Person", 150, 750], ["Empty Car", 10, 50]],
  230. descriptor: ["a small skyscraper", "small skyscrapers"]
  231. },
  232. "Large Skyscraper": {
  233. "Large Skyscraper": LargeSkyscraper,
  234. mass: 8e7,
  235. area: 2000,
  236. clusters: 1,
  237. cluster_chances: .25,
  238. contents: [["Person", 500, 1500], ["Empty Car", 20, 100]],
  239. descriptor: ["a large skyscraper", "large skyscrapers"]
  240. },
  241. "Parking Garage": {
  242. "Parking Garage": ParkingGarage,
  243. mass: 1e7,
  244. area: 750,
  245. clusters: 1,
  246. cluster_chances: .1,
  247. contents: [["Person", 10, 200], ["Empty Car", 100, 300], ["Car", 5, 30]],
  248. descriptor: ["a parking garage", "parking garages"]
  249. },
  250. //Places
  251. "Ranch": {
  252. "Ranch": Ranch,
  253. mass: 2e7,
  254. area: 4e4,
  255. clusters: 0,
  256. cluster_chances: 0,
  257. contents: [["Person", 10, 50], ["House", 1, 3], ["Barn", 1, 2]],
  258. descriptor: ["a ranch", "ranchs"]
  259. },
  260. "Airstrip": {
  261. "Airstrip": Airstrip,
  262. mass: 2e7,
  263. area: 9e5,
  264. clusters: 0,
  265. cluster_chances: 0,
  266. contents: [["Person", 10, 50], ["Small Hangar", 1, 3], ["Plane", 0, 2], ["Helicopter", 0, 1], ["Helicopter Hangar", 0, 1], ["Car", 0, 5], ["Empty Car", 0, 20]],
  267. descriptor: ["an airstrip", "airstrips"]
  268. },
  269. "Airport": {
  270. "Airport": Airport,
  271. mass: 1.5e8,
  272. area: 6e6,
  273. clusters: 0,
  274. cluster_chances: 0,
  275. contents: [["Person", 1500, 4000], ["Small Hangar", 4, 12], ["Plane", 2, 5], ["Helicopter", 1, 3], ["Helicopter Hangar", 2, 6], ["Airliner", 1, 3], ["Large Hangar", 2, 6], ["Car", 20, 75], ["Empty Car", 400, 1000]],
  276. descriptor: ["an airport", "airports"]
  277. },
  278. "Town": {
  279. "Town": Town,
  280. mass: 1,
  281. area: 1e7,
  282. clusters: 5,
  283. cluster_chances: .1,
  284. contents: [["Person", 10000, 100000], ["House", 5000, 50000], ["Empty Car", 200, 800], ["Car", 500, 80000], ["Bus", 5, 25], ["Train", 5, 25], ["Business", 500, 5000]],
  285. descriptor: ["a town", "towns"]
  286. },
  287. "City": {
  288. "City": City,
  289. mass: 1,
  290. area: 1e9,
  291. clusters: 0,
  292. cluster_chances: .2,
  293. contents: [["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], ["Business", 2000, 10000]],
  294. descriptor: ["a city", "cities"]
  295. },
  296. "Continent": {
  297. "Continent": Continent,
  298. mass: 1e21,
  299. area: 1.5e13,
  300. clusters: 5,
  301. cluster_chances: .5,
  302. contents: [["Person", 1000000, 15000000], ["House", 2500, 10000], ["Car", 25000, 375000], ["Train", 50, 500], ["Town", 500, 1000], ["City", 50, 250], ["Business", 250, 1000]],
  303. descriptor: ["a continent", "continents"]
  304. },
  305. //Celestial Bodies
  306. "Planet": {
  307. "Planet": Planet,
  308. mass: 5.972e24,
  309. area: 2.5e14,
  310. clusters: 0,
  311. cluster_chances: 1,
  312. contents: [["Continent", 4, 9]],
  313. descriptor: ["a planet", "planets"]
  314. },
  315. "Star": {
  316. "Star": Star,
  317. mass: 1e40,
  318. area: 3e18,
  319. clusters: 1,
  320. cluster_chances: 1,
  321. contents: [],
  322. descriptor: ["a star", "stars"]
  323. },
  324. "Solar System": {
  325. "Solar System": SolarSystem,
  326. mass: 1,
  327. area: 3e21,
  328. clusters: 1,
  329. cluster_chances: 1,
  330. contents: [["Star", 1, 1], ["Planet", 5, 15]],
  331. descriptor: ["a solar system", "solar systems"]
  332. },
  333. "Galaxy": {
  334. "Galaxy": Galaxy,
  335. mass: 1,
  336. area: 2e45,
  337. clusters: 1,
  338. cluster_chances: 1,
  339. contents: [["Star", 1e9, 500e9], ["Solar System", 1e8, 500e8]],
  340. descriptor: ["a galaxy", "galaxies"]
  341. },
  342. "Cluster": {
  343. "Cluster": Cluster,
  344. mass: 1,
  345. area: 2e49,
  346. clusters: 1,
  347. cluster_chances: 1,
  348. contents: [["Galaxy", 200, 5000]],
  349. descriptor: ["a cluster", "clusters"]
  350. },
  351. "Universe": {
  352. "Universe": Universe,
  353. mass: 1,
  354. area: 7e53,
  355. clusters: 1,
  356. cluster_chances: 1,
  357. contents: [["Cluster", 1.5e9, 2.5e9]],
  358. descriptor: ["a universe", "universes"]
  359. },
  360. "Multiverse": {
  361. "Multiverse": Multiverse,
  362. mass: 1,
  363. area: 5e56,
  364. clusters: 1,
  365. cluster_chances: 1,
  366. contents: [["Universe", 100, 1000]],
  367. descriptor: ["a multiverse", "multiverses"]
  368. },
  369. //Military
  370. "Soldier": {
  371. "Soldier": Soldier,
  372. mass: 80,
  373. area: 1,
  374. clusters: 2,
  375. cluster_chances: .2,
  376. contents: [],
  377. descriptor: ["a soldier", "soldiers"]
  378. },
  379. "Tank": {
  380. "Tank": Tank,
  381. mass: 5000,
  382. area: 20,
  383. clusters: 2,
  384. cluster_chances: .25,
  385. contents: [["Soldier", 3, 5]],
  386. descriptor: ["a tank", "tanks"]
  387. },
  388. "Artillery": {
  389. "Artillery": Artillery,
  390. mass: 7000,
  391. area: 25,
  392. clusters: 3,
  393. cluster_chances: .5,
  394. contents: [["Soldier", 4, 6]],
  395. descriptor: ["an artillery tank", "artillery tanks"]
  396. },
  397. "Military Helicopter": {
  398. "Military Helicopter": MilitaryHelicopter,
  399. mass: 1500,
  400. area: 12,
  401. clusters: 0,
  402. cluster_chances: 0,
  403. contents: [["Soldier", 4, 16]],
  404. descriptor: ["a helicopter", "helicopters"]
  405. },
  406. "Squad": {
  407. "Squad": Squad,
  408. mass: 1,
  409. area: 30,
  410. clusters: 20,
  411. cluster_chances: .05,
  412. contents: [["Soldier", 6, 9]],
  413. descriptor: ["a squad", "squads"]
  414. },
  415. "Platoon": {
  416. "Platoon": Platoon,
  417. mass: 100,
  418. area: 150,
  419. clusters: 2,
  420. cluster_chances: .1,
  421. contents: [["Soldier", 16, 44]],
  422. descriptor: ["a military platoon", "platoons"]
  423. },
  424. "Company": {
  425. "Company": Company,
  426. mass: 500,
  427. area: 600,
  428. clusters: 2,
  429. cluster_chances: .1,
  430. contents: [["Soldier", 60, 200]],
  431. descriptor: ["a company of soldiers", "companies"]
  432. },
  433. "Battalion": {
  434. "Battalion": Battalion,
  435. mass: 1000,
  436. area: 3500,
  437. clusters: 2,
  438. cluster_chances: .1,
  439. contents: [["Soldier", 300, 1000]],
  440. descriptor: ["a battalion", "battalions"]
  441. },
  442. "Brigade": {
  443. "Brigade": Brigade,
  444. mass: 1500,
  445. area: 2e4,
  446. clusters: 2,
  447. cluster_chances: .1,
  448. contents: [["Soldier", 1500, 3200]],
  449. descriptor: ["a brigade", "brigades"]
  450. },
  451. "Division": {
  452. "Division": Division,
  453. mass: 2000,
  454. area: 8e4,
  455. clusters: 3,
  456. cluster_chances: .1,
  457. contents: [["Soldier", 10000, 16000]],
  458. descriptor: ["a division", "divisions"]
  459. },
  460. "Tank Division": {
  461. "Tank Division": TankDivision,
  462. mass: 3000,
  463. area: 1e5,
  464. clusters: 1,
  465. cluster_chances: .15,
  466. contents: [["Soldier", 8000, 1200], ["Tank", 250, 500]],
  467. descriptor: ["a tank division", "tank divisions"]
  468. },
  469. "Army": {
  470. "Army": Army,
  471. mass: 5000,
  472. area: 1e6,
  473. clusters: 2,
  474. cluster_chances: .1,
  475. contents: [["Soldier", 40000, 75000]],
  476. descriptor: ["an army", "armies"]
  477. },
  478. };
  479. //Alterante Army Structuring, may be used later
  480. //"Squad": [["Soldier",6,9]],
  481. // "Platoon": [["Squad",3,4]],
  482. //"Company": [["Platoon",3,5],["Squad",0,2]],
  483. //"Battalion": [["Company",4,6]],
  484. //"Brigade": [["Battalion",2,5],["Company",0,3]],
  485. //"Division": [["Brigade",2,4]],
  486. //"Tank Division": [["Brigade",2,4],["Tank",250,500]],
  487. //"Army": [["Division",3,8],["Tank Division",1,5]],
  488. // replace all instances of from with to
  489. function contents_substitute(from, to) {
  490. for (let key in contents) {
  491. if (contents.hasOwnProperty(key)) {
  492. let type = contents[key];
  493. for (let i = 0; i < type.length; i++) {
  494. if (type[i][0] == from) {
  495. type[i][0] = to;
  496. }
  497. }
  498. }
  499. }
  500. }
  501. // remove all instances of thing
  502. function contents_remove(thing) {
  503. for (let key in contents) {
  504. if (contents.hasOwnProperty(key)) {
  505. let type = contents[key];
  506. for (let i = 0; i < type.length; i++) {
  507. if (type[i][0] == thing) {
  508. type.splice(i, 1);
  509. --i;
  510. }
  511. }
  512. }
  513. }
  514. }
  515. // adds thing to parent
  516. function contents_insert(parent, thing, min, max, label) {
  517. let owner = things[parent].contents;
  518. if (label == undefined)
  519. owner.push([thing, min, max]);
  520. else
  521. owner.push([thing, min, max, label]);
  522. }
  523. function initContents(name, count) { //builds the contents for each destrucable(thing) when called
  524. let result = {};
  525. let type = things[name].contents;
  526. for (let i = 0; i < type.length; i++) {
  527. let amount = distribution(type[i][1], type[i][2], count); //arrays of contents look like ["thing name",min,max,"optional name"] so those values have to pulled out
  528. if (amount > 0) {
  529. // if a custom label is supplied, use it!
  530. if (type[i].length == 4) //if has optional name
  531. result[type[i][3]] = new things[type[i][0]][type[i][0]](amount); //creates a "thing name" under the key of "optional name"
  532. else
  533. result[type[i][0]] = new things[type[i][0]][type[i][0]](amount);
  534. }
  535. }
  536. return result;
  537. }
  538. function get_living_prey(sum) {
  539. let total = 0;
  540. for (let key in sum) {
  541. if (sum.hasOwnProperty(key)) {
  542. if (key == "Micro" || key == "Macro" || key == "Person" || key == "Cow" || key == 'Soldier')
  543. total += sum[key];
  544. }
  545. }
  546. return total;
  547. }
  548. // general logic: each step fills in a fraction of the remaining space
  549. function fill_area(area, weights, variance = 0.15) {
  550. area = area + Math.random() * variance * 2 * area - variance * area;
  551. var result = [];
  552. var candidates = [];
  553. for (var key in weights) {
  554. if (weights.hasOwnProperty(key)) {
  555. candidates.push({ "name": key, "area": things[key].area, "weight": weights[key] });
  556. }
  557. }
  558. candidates = candidates.sort(function (x, y) {
  559. return x.area - y.area;
  560. });
  561. while (candidates.length > 0) {
  562. var candidate = candidates.pop();
  563. if (candidate.area > area)
  564. continue;
  565. var max = Math.floor(area / candidate.area);
  566. var limit = Math.min(max, 1000);
  567. var count = 0;
  568. var loopvar = 0;
  569. // for small amounts, actually do the randomness
  570. // the first few ones get a much better shot
  571. // if we have nothing at all, it's even better!
  572. while (loopvar < limit) {
  573. if (loopvar == 0 && result.length == 0) {
  574. ++count;
  575. }
  576. else if (loopvar <= things[candidate.name].clusters) {
  577. if (Math.random() < candidate.weight ? 1 : Math.random() < things[candidate.name].cluster_chances) {
  578. ++count;
  579. }
  580. }
  581. else {
  582. count += Math.random() < candidate.weight ? 1 : 0;
  583. }
  584. ++loopvar;
  585. }
  586. // if we're doing more than the limit, then we just add on the rest, with some variance
  587. if (limit < max) {
  588. const base = (max - limit) * candidate.weight;
  589. count += Math.round(base - base / 10 + base * Math.random() / 5);
  590. }
  591. area -= count * candidate.area;
  592. if (count > 0)
  593. result.push(new things[candidate.name][candidate.name](count));
  594. }
  595. return new Container(result);
  596. }
  597. // maybe make this something that approximates a
  598. // normal distribution; doing this 15,000,000 times is bad...
  599. // solution: only a few are random lul
  600. // improvement: take up to 100 samples, then use that to scale the final result
  601. function distribution(min, max, samples) {
  602. var result = 0;
  603. var limit = Math.min(100, samples);
  604. if (limit < samples) {
  605. let dist = 0;
  606. for (let i = 0; i < limit; i++) {
  607. dist += Math.random();
  608. }
  609. dist /= 100;
  610. return Math.floor(dist * samples * (max - min + 1) + samples * min);
  611. } else {
  612. for (let i = 0; i < limit; i++) {
  613. result += Math.floor(Math.random() * (max - min + 1) + min);
  614. }
  615. }
  616. return result;
  617. }
  618. function defaultMultiply(thing) {
  619. return function (amount) {
  620. thing.count *= amount;
  621. for (var key in thing.contents) {
  622. if (thing.contents.hasOwnProperty(key)) {
  623. thing.contents[key].multiply(amount);
  624. }
  625. }
  626. };
  627. }
  628. function defaultArea(thing) {
  629. return things[thing.name].area;
  630. }
  631. function defaultMass(thing) {
  632. return things[thing.name].mass;
  633. }
  634. function defaultDescribeOne(thing) {
  635. return function (verbose) { //verbose doesn't matter for this case, becasue it handles things with no extra text to use when being verbose
  636. return things[thing.name].descriptor[0];
  637. }
  638. }
  639. function defaultMerge(thing) { //this merges all objects into one containers
  640. return function (container) {
  641. var newCount = this.count + container.count;
  642. var newThing = new things[thing.name][thing.name](newCount);
  643. newThing.contents = {};
  644. for (var key in this.contents) {
  645. if (this.contents.hasOwnProperty(key)) {
  646. newThing.contents[key] = this.contents[key];
  647. }
  648. }
  649. for (key in container.contents) {
  650. if (container.contents.hasOwnProperty(key)) {
  651. if (this.contents.hasOwnProperty(key)) {
  652. newThing.contents[key] = this.contents[key].merge(container.contents[key]);
  653. } else {
  654. newThing.contents[key] = container.contents[key];
  655. }
  656. }
  657. }
  658. return newThing;
  659. };
  660. }
  661. function listSum(sum) {
  662. let result = [];
  663. for (let key in sum) {
  664. if (sum.hasOwnProperty(key)) {
  665. result.push(new things[key][key](sum[key]).describe(false));
  666. }
  667. }
  668. return merge_things(result);
  669. }
  670. // turn a nested object into a container with everything on one level
  671. function flatten(thing) {
  672. let dict = defaultSum(thing)();
  673. let list = [];
  674. Object.entries(dict).forEach(function ([key, val]) {
  675. let obj = new things[key][key](val);
  676. obj.contents = [];
  677. list.push(obj);
  678. });
  679. list.sort(function (x, y) {
  680. if (y.area != x.area) {
  681. return y.area - x.area;
  682. } else {
  683. return x.name.localeCompare(y.name);
  684. }
  685. });
  686. return new Container(list);
  687. }
  688. function defaultSum(thing) {
  689. return function () {
  690. var counts = {};
  691. if (thing.name != "Container")
  692. counts[thing.name] = thing.count;
  693. for (var key in thing.contents) {
  694. if (thing.contents.hasOwnProperty(key)) {
  695. var subcount = thing.contents[key].sum();
  696. for (var subkey in subcount) {
  697. if (!counts.hasOwnProperty(subkey)) {
  698. counts[subkey] = 0;
  699. }
  700. counts[subkey] += subcount[subkey];
  701. }
  702. }
  703. }
  704. return counts;
  705. };
  706. }
  707. function defaultSumProperty(thing) {
  708. return function (prop) {
  709. var total = 0;
  710. total += thing[prop] * thing.count;
  711. for (var key in thing.contents) {
  712. if (thing.contents.hasOwnProperty(key)) {
  713. total += thing.contents[key].sum_property(prop);
  714. }
  715. }
  716. return total;
  717. };
  718. }
  719. function defaultModProperty(thing) {
  720. return function(prop, func) {
  721. thing[prop] = func(thing[prop]);
  722. for (var key in thing.contents) {
  723. if (thing.contents.hasOwnProperty(key)) {
  724. thing.contents[key].mod_property(prop, func);
  725. }
  726. }
  727. };
  728. }
  729. function defaultAddContent(thing) {
  730. return function (name, min, max, count) {
  731. if (min == max) {
  732. let object = new things[name](min * count);
  733. thing.contents[object.name] = object;
  734. } else {
  735. let object = new things[name](distribution(min, max, count));
  736. thing.contents[object.name] = object;
  737. }
  738. };
  739. }
  740. function DefaultEntity() {
  741. this.sum = defaultSum;
  742. this.area = defaultArea;
  743. this.mass = defaultMass;
  744. this.sum_property = defaultSumProperty;
  745. this.mod_property = defaultModProperty;
  746. this.merge = defaultMerge;
  747. this.multiply = defaultMultiply;
  748. this.describeSimple = defaultDescribeSimple;
  749. this.describeOne = defaultDescribeOne;
  750. return this;
  751. }
  752. // god I love reinventing the wheel
  753. function copy_defaults(self, proto) { //loads the values defined in things into the fuction that calls it
  754. for (var key in proto) { //proto will always be a new DefaultEntity, self is the parent function
  755. if (proto.hasOwnProperty(key)) {
  756. self[key] = proto[key](self);
  757. }
  758. }
  759. }
  760. // combine strings into a list with proper grammar
  761. function merge_things(list, semicolons = false) {
  762. if (list.length == 0) {
  763. return "";
  764. } else if (list.length == 1) {
  765. return list[0];
  766. } else if (list.length == 2) {
  767. return list[0] + " and " + list[1];
  768. } else {
  769. var result = "";
  770. list.slice(0, list.length - 1).forEach(function (term) {
  771. result += term + ", ";
  772. });
  773. result += "and " + list[list.length - 1];
  774. return result;
  775. }
  776. }
  777. // combine the adjectives for something into a single string
  778. function merge_desc(list) {
  779. var result = "";
  780. list.forEach(function (term) {
  781. if (term != "")
  782. result += term + " ";
  783. });
  784. // knock off the last space
  785. if (result.length > 0) {
  786. result = result.substring(0, result.length - 1);
  787. }
  788. let article = "a "
  789. //a/an overwriting terms
  790. let forcedTerms = ["honor", "heir"]; //words that need to start with an but don't start with a,e,i,o,u
  791. let force = false;
  792. for (let i of forcedTerms) {
  793. if (i === result.substring(0, i.length)) { force = true; }
  794. }
  795. let exceptionTerms = ["uniform", "unique"]; //words that need to start with a and start with a,e,i,o,u
  796. let exception = false;
  797. for (let i of exceptionTerms) {
  798. if (i === result.substring(0, i.length)) { exception = true; }
  799. }
  800. //check if the string should start with an
  801. if ((force == true) || (exception == false && ((result.charAt(0) == "a") || (result.charAt(0) == "e") || (result.charAt(0) == "i") || (result.charAt(0) == "o") || (result.charAt(0) == "u")))) {
  802. article = "an ";
  803. }
  804. result = article + result;
  805. return result;
  806. }
  807. // describes everything in the container
  808. function describe_all(contents, verbose = true, except = []) {
  809. var things = [];
  810. for (var key in contents) {
  811. if (contents.hasOwnProperty(key) && !except.includes(key)) {
  812. things.push(contents[key].describe(verbose));
  813. }
  814. }
  815. return merge_things(things);
  816. }
  817. function random_desc(list, odds = 1) { //strings together an array into a series of words
  818. if (Math.random() < odds)
  819. return list[Math.floor(Math.random() * list.length)];
  820. else
  821. return "";
  822. }
  823. function defaultDescribeSimple(thing) {
  824. return function (flat) {
  825. if (flat) {
  826. return flatten(thing).describe(false)
  827. } else {
  828. return thing.describe(false);
  829. }
  830. }
  831. }
  832. function defaultDescribe(verbose = true, parent, descAs) {
  833. let descriptorEnd = " inside";
  834. let descriptorConjunction = " with ";
  835. let groupLessThan3 = false;
  836. switch (descAs) {
  837. case "vehicle":
  838. descriptorEnd = pickString(" inside", " inside", " inside", " inside", " riding inside", " trapped inside", " sitting inside");
  839. break;
  840. case "community":
  841. groupLessThan3 = true;
  842. descriptorEnd = " in " + (parent.count == 1 ? "it" : "them");
  843. break;
  844. case "celestial":
  845. groupLessThan3 = true;
  846. descriptorConjunction = pickString(" made up of ", " consisting of ", " containing ");
  847. descriptorEnd = "";
  848. break;
  849. case "military":
  850. groupLessThan3 = true;
  851. descriptorConjunction = pickString(" of ", " of ", " made up of ", " comprised of ", " containing ");
  852. descriptorEnd = "";
  853. break;
  854. case "generic vehicle":
  855. groupLessThan3 = true;
  856. descriptorEnd = pickString(" inside", " inside", " inside", " inside", " riding inside", " trapped inside", " sitting inside");
  857. break;
  858. } if (verbose) {
  859. if (parent.count == 1) { //singular parent (specifying single to catch cases where groupLessThan3 = true, otherwise it would output "1 towns" instead of "a town"
  860. if (things[parent.name].contents.length > 0) {
  861. return (things[parent.name].descriptor[0] + descriptorConjunction + describe_all(parent.contents, false) + descriptorEnd);
  862. } else {
  863. return parent.describeOne(verbose);
  864. }
  865. }
  866. else if (parent.count <= 3 && groupLessThan3 == false) { // less than 3 parents and an ojbect that has varety when described
  867. var list = [];
  868. for (var i = 0; i < parent.count; i++) {
  869. list.push(parent.describeOne(parent.count <= 2));
  870. }
  871. if (things[parent.name].contents.length > 0) {
  872. return (merge_things(list) + descriptorConjunction + describe_all(parent.contents, false) + descriptorEnd);
  873. } else {
  874. return merge_things(list);
  875. }
  876. } else {//if there are more than 3 of the object
  877. if (things[parent.name].contents.length > 0) {
  878. return (parent.count + " " + things[parent.name].descriptor[1] + descriptorConjunction + describe_all(parent.contents, false) + descriptorEnd);
  879. } else {
  880. return (parent.count + " " + things[parent.name].descriptor[1]);
  881. }
  882. }
  883. } else {//not verbose
  884. return (parent.count > 1 ? (parent.count + " " + things[parent.name].descriptor[1]) : things[parent.name].descriptor[0]);
  885. }
  886. }
  887. function Container(contents = []) {
  888. this.name = "Container";
  889. copy_defaults(this, new DefaultEntity());
  890. if (Number.isInteger(contents))
  891. this.count = contents;
  892. else
  893. this.count = 0;
  894. this.contents = {};
  895. for (var i = 0; i < contents.length; i++) {
  896. this.contents[contents[i].name] = contents[i];
  897. }
  898. for (var key in this.contents) {
  899. if (this.contents.hasOwnProperty(key)) {
  900. this.count += this.contents[key].count;
  901. }
  902. }
  903. this.describe = function (verbose = true) {
  904. return describe_all(this.contents, verbose);
  905. };
  906. return this;
  907. }
  908. function Person(count = 1) {
  909. this.name = "Person";
  910. copy_defaults(this, new DefaultEntity());
  911. this.mass = ((Math.random() - .5) * 20) + this.mass;
  912. this.count = count;
  913. this.contents = initContents(this.name, this.count);
  914. this.describeOne = function (verbose = true) {
  915. var body = random_desc(["skinny", "fat", "tall", "short", "stocky", "spindly", "muscular", "fit", "multi-colored"], (verbose ? 0.6 : 0));
  916. var sex = random_desc(["male", "female"], (verbose ? 0.75 : 0));
  917. var species = "";
  918. species = random_desc(["wolf", "cat", "dog", "squirrel", "horse", "hyena", "fox", "jackal", "crux", "sergal", "coyote", "rabbit", "lizard", "avian"]);
  919. return merge_desc([body, sex, species]);
  920. };
  921. this.describe = function (verbose = true) {
  922. return defaultDescribe(verbose, this);
  923. }
  924. return this;
  925. }
  926. function Human(count = 1) {
  927. this.name = "Person";
  928. copy_defaults(this, new DefaultEntity());
  929. this.mass = ((Math.random() - .5) * 20) + this.mass;
  930. this.count = count;
  931. this.contents = initContents(this.name, this.count);
  932. this.describeOne = function (verbose = true) {
  933. var body = random_desc(["skinny", "fat", "tall", "short", "stocky", "spindly", "muscular", "fit", "tanned"], (verbose ? 0.6 : 0));
  934. var sex = random_desc(["man", "woman"], 1);
  935. return merge_desc([body, sex]);
  936. };
  937. this.describe = function (verbose = true) {
  938. return defaultDescribe(verbose, this);
  939. }
  940. return this;
  941. }
  942. function Cow(count = 1) {
  943. this.name = "Cow";
  944. copy_defaults(this, new DefaultEntity());
  945. this.count = count;
  946. this.contents = initContents(this.name, this.count);
  947. this.describeOne = function (verbose = true) {
  948. var body = random_desc(["skinny", "fat", "tall", "short", "stocky", "spindly", "brown"], (verbose ? 0.6 : 0));
  949. var sex = random_desc(["bull", "steer", "cow", "cow", "cow", "heifer"], (verbose ? 1 : 0));
  950. return merge_desc([body, sex]);
  951. };
  952. this.describe = function (verbose = true) {
  953. return defaultDescribe(verbose, this);
  954. }
  955. return this;
  956. }
  957. function EmptyCar(count = 1) {
  958. this.name = "Empty Car";
  959. copy_defaults(this, new DefaultEntity());
  960. this.count = count;
  961. this.contents = initContents(this.name, this.count);
  962. this.describeOne = function (verbose = true) {
  963. var color = random_desc(["black", "black", "gray", "gray", "blue", "red", "tan", "white", "white"]);
  964. var adjective = random_desc(["rusty", "brand-new", "luxury", "beat-up", "dented", "restored", "classic"], 0.3);
  965. var type = random_desc(["SUV", "coupe", "sedan", "truck", "van", "convertible"]);
  966. return merge_desc(["parked", adjective, color, type]);
  967. };
  968. this.describe = function (verbose = true) {
  969. return defaultDescribe(verbose, this, "vehicle");
  970. }
  971. }
  972. function Car(count = 1) {
  973. this.name = "Car";
  974. copy_defaults(this, new DefaultEntity());
  975. this.count = count;
  976. this.contents = initContents(this.name, this.count);
  977. this.describeOne = function (verbose = true) {
  978. var color = random_desc(["black", "black", "gray", "gray", "blue", "red", "tan", "white", "white"], (verbose ? 1 : 0));
  979. var adjective = random_desc(["rusty", "brand-new", "luxury", "beat-up", "dented", "restored", "classic"], (verbose ? 0.3 : 0));
  980. var type = random_desc(["SUV", "coupe", "sedan", "truck", "van", "convertible"]);
  981. return merge_desc([adjective, color, type]);
  982. };
  983. this.describe = function (verbose = true) {
  984. return defaultDescribe(verbose, this, "vehicle");
  985. }
  986. }
  987. function Bus(count = 1) {
  988. this.name = "Bus";
  989. copy_defaults(this, new DefaultEntity());
  990. this.count = count;
  991. this.contents = initContents(this.name, this.count);
  992. this.describeOne = function (verbose = true) {
  993. var adjective = random_desc(["rusty", "brand-new", "aging", "modern"], (verbose ? 0.3 : 0));
  994. var color = random_desc(["black", "tan", "gray"], (verbose ? 1 : 0));
  995. var type = random_desc(["bus", "double-decker bus", "articulating bus", "open-top bus", "sleeper bus", "intercity bus"]);
  996. return merge_desc([adjective, color, type]);
  997. };
  998. this.describe = function (verbose = true) {
  999. return defaultDescribe(verbose, this, "vehicle");
  1000. }
  1001. }
  1002. function Tram(count = 1) {
  1003. this.name = "Tram";
  1004. copy_defaults(this, new DefaultEntity());
  1005. this.count = count;
  1006. this.contents = initContents(this.name, this.count);
  1007. this.describeOne = function (verbose = true) {
  1008. var adjective = random_desc(["rusty", "weathered", "well-maintained",], (verbose ? 0.3 : 0));
  1009. var color = random_desc(["blue", "brown", "gray"], (verbose ? 1 : 0));
  1010. var type = random_desc(["tram"]);
  1011. return merge_desc([adjective, color, type]);
  1012. };
  1013. this.describe = function (verbose = true) {
  1014. return defaultDescribe(verbose, this, "vehicle");
  1015. }
  1016. this.anal_vore = function () {
  1017. return "You slide " + this.describe() + " up your tight ass";
  1018. };
  1019. }
  1020. function EmptyHelicopter(count = 1) {
  1021. this.name = "Empty Helicopter";
  1022. copy_defaults(this, new DefaultEntity());
  1023. this.count = count;
  1024. this.contents = initContents(this.name, this.count);
  1025. this.describeOne = function (verbose = true) {
  1026. var color = random_desc(["blue", "white", "white", "red", "black", "gold", "yellow"], (verbose ? 0.6 : 0));
  1027. var type = random_desc(["bubble coptor", "helicopter", "helicopter", "news chopper", "police helicopter", "chopper"]);
  1028. return merge_desc([adjective, color, type]);
  1029. };
  1030. this.describe = function (verbose = true) {
  1031. return defaultDescribe(verbose, this, "vehicle");
  1032. }
  1033. }
  1034. function Helicopter(count = 1) {
  1035. this.name = "Helicopter";
  1036. copy_defaults(this, new DefaultEntity());
  1037. this.count = count;
  1038. this.contents = initContents(this.name, this.count);
  1039. this.describeOne = function (verbose = true) {
  1040. var color = random_desc(["blue", "white", "white", "red", "black", "gold", "yellow"], (verbose ? 0.6 : 0));
  1041. var type = random_desc(["bubble coptor", "helicopter", "helicopter", "news chopper", "police helicopter", "chopper"]);
  1042. return merge_desc([adjective, color, type]);
  1043. };
  1044. this.describe = function (verbose = true) {
  1045. return defaultDescribe(verbose, this, "vehicle");
  1046. }
  1047. }
  1048. function EmptyPlane(count = 1) {
  1049. this.name = "Empty Plane";
  1050. copy_defaults(this, new DefaultEntity());
  1051. this.count = count;
  1052. this.contents = initContents(this.name, this.count);
  1053. this.describeOne = function (verbose = true) {
  1054. var adjective = random_desc(["brand-new", "aging", "modern"], (verbose ? 0.2 : 0));
  1055. var color = random_desc(["blue", "white", "white", "blue and white", "red and white", "black", "gold"], (verbose ? 0.9 : 0));
  1056. var type = random_desc(["luxury jet", "business jet", "single-engine plane", "light aircraft"]);
  1057. return merge_desc([adjective, color, type]);
  1058. };
  1059. this.describe = function (verbose = true) {
  1060. return defaultDescribe(verbose, this, "vehicle");
  1061. }
  1062. }
  1063. function Plane(count = 1) {
  1064. this.name = "Plane";
  1065. copy_defaults(this, new DefaultEntity());
  1066. this.count = count;
  1067. this.contents = initContents(this.name, this.count);
  1068. this.describeOne = function (verbose = true) {
  1069. var adjective = random_desc(["brand-new", "aging", "modern"], (verbose ? 0.2 : 0));
  1070. var color = random_desc(["blue", "white", "white", "blue and white", "red and white", "black", "gold"], (verbose ? 0.9 : 0));
  1071. var type = random_desc(["luxury jet", "business jet", "single-engine plane", "light aircraft"]);
  1072. return merge_desc([adjective, color, type]);
  1073. };
  1074. this.describe = function (verbose = true) {
  1075. return defaultDescribe(verbose, this, "vehicle");
  1076. }
  1077. }
  1078. function EmptyAirliner(count = 1) {
  1079. this.name = "Empty Airliner";
  1080. copy_defaults(this, new DefaultEntity());
  1081. this.count = count;
  1082. this.contents = initContents(this.name, this.count);
  1083. this.describeOne = function (verbose = true) {
  1084. var adjective = random_desc(["brand-new", "aging", "modern"], (verbose ? 0.2 : 0));
  1085. var color = random_desc(["blue", "white", "white", "blue and white"], (verbose ? 0.9 : 0));
  1086. var type = random_desc(["airliner", "twin-engine jet", "trijet", "four engine jet", "double-decker airliner", "widebody airliner", "passenger jet", "airliner"]);
  1087. return merge_desc([adjective, color, type]);
  1088. };
  1089. this.describe = function (verbose = true) {
  1090. return defaultDescribe(verbose, this, "vehicle");
  1091. }
  1092. }
  1093. function Airliner(count = 1) {
  1094. this.name = "Airliner";
  1095. copy_defaults(this, new DefaultEntity());
  1096. this.count = count;
  1097. this.contents = initContents(this.name, this.count);
  1098. this.describeOne = function (verbose = true) {
  1099. var adjective = random_desc(["brand-new", "aging", "modern"], (verbose ? 0.2 : 0));
  1100. var color = random_desc(["blue", "white", "white", "blue and white"], (verbose ? 0.9 : 0));
  1101. var type = random_desc(["airliner", "twin-engine jet", "trijet", "four engine jet", "double-decker airliner", "widebody airliner", "passenger jet", "airliner"]);
  1102. return merge_desc([adjective, color, type]);
  1103. };
  1104. this.describe = function (verbose = true) {
  1105. return defaultDescribe(verbose, this, "vehicle");
  1106. }
  1107. }
  1108. function Train(count = 1) {
  1109. this.name = "Train";
  1110. copy_defaults(this, new DefaultEntity());
  1111. this.count = count;
  1112. this.contents = initContents(this.name, this.count);
  1113. this.describeOne = function (verbose = true) {
  1114. var adjective = random_desc(["rusty", "brand-new", "steam", "freshly-painted"], (verbose ? 0.3 : 0));
  1115. var color = random_desc(["black", "tan", "gray"], (verbose ? 1 : 0));
  1116. var type = random_desc(["train", "passenger train", "freight train"]);
  1117. return merge_desc([adjective, color, type]);
  1118. };
  1119. this.describe = function (verbose = true) {
  1120. if (verbose) {
  1121. if (this.count == 1) {
  1122. var list = [];
  1123. for (var i = 0; i < this.count; i++) {
  1124. list.push(this.describeOne(verbose));
  1125. }
  1126. return merge_things(list) + " with " + this.contents["engine"].describe(false) + " in the engine and " + this.contents["Train Car"].describe() + " attached";
  1127. } else {
  1128. return this.count + " trains with " + this.contents["engine"].describe(false) + " in the engine and " + this.contents["Train Car"].describe() + " attached";
  1129. }
  1130. } else {
  1131. return (this.count > 1 ? this.count + " trains" : "a train");
  1132. }
  1133. };
  1134. this.anal_vore = function () {
  1135. 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");
  1136. return "You snatch up " + this.describeOne() + " and stuff it into your pucker, moaning as " + cars;
  1137. };
  1138. }
  1139. function TrainCar(count = 1) {
  1140. this.name = "Train Car";
  1141. copy_defaults(this, new DefaultEntity());
  1142. this.count = count;
  1143. this.contents = initContents(this.name, this.count);
  1144. this.describeOne = function (verbose = true) {
  1145. var adjective = random_desc(["rusty", "brand-new", "vintage", "graffitied", "well-maintained"], (verbose ? 0.3 : 0));
  1146. var color = random_desc(["black", "tan", "gray", "yellow", "steel", "wooden"], (verbose ? 1 : 0));
  1147. var type = random_desc(["train car", "passenger train car", "freight train car"]);
  1148. return merge_desc([adjective, color, type]);
  1149. };
  1150. this.describe = function (verbose = true) {
  1151. return defaultDescribe(verbose, this, "vehicle");
  1152. }
  1153. }
  1154. function House(count = 1) {
  1155. this.name = "House";
  1156. copy_defaults(this, new DefaultEntity());
  1157. this.count = count;
  1158. this.contents = initContents(this.name, this.count);
  1159. this.describeOne = function (verbose = true) {
  1160. var size = random_desc(["little", "two-story", "large", "well-built", "run-down", "cheap",], (verbose ? 0.5 : 0));
  1161. var color = random_desc(["blue", "white", "gray", "tan", "green", "wooden", "brick"], (verbose ? 0.5 : 0));
  1162. var name = random_desc(["house", "home", "duplex", "house", "house", "trailer"], 1);
  1163. return merge_desc([size, color, name]);
  1164. };
  1165. this.describe = function (verbose = true) {
  1166. return defaultDescribe(verbose, this);
  1167. }
  1168. }
  1169. //might split this into a general business and resutrant categories
  1170. function Business(count = 1) {
  1171. this.name = "Business";
  1172. copy_defaults(this, new DefaultEntity());
  1173. this.count = count;
  1174. this.contents = initContents(this.name, this.count);
  1175. this.describeOne = function (verbose = true) {
  1176. var size = random_desc(["little", "two-story", "large", "well-built", "run-down", "cheap", "aging", "corner"], (verbose ? 0.5 : 0));
  1177. var color = random_desc(["blue", "white", "gray", "tan", "green", "brick", "concrete"], (verbose ? 0.5 : 0));
  1178. var name = random_desc(["mall", "resturant", "bank", "clinic", "shop", "post office", "tire shop", "chain resturant", "grocery store", "barber shop", "pizza resturant", "hardware store", "movie theather", "gas station"], 1);
  1179. return merge_desc([size, color, name]);
  1180. };
  1181. this.describe = function (verbose = true) {
  1182. return defaultDescribe(verbose, this);
  1183. }
  1184. }
  1185. function Barn(count = 1) {
  1186. this.name = "Barn";
  1187. copy_defaults(this, new DefaultEntity());
  1188. this.count = count;
  1189. this.contents = initContents(this.name, this.count);
  1190. this.describeOne = function (verbose = true) {
  1191. var size = random_desc(["little", "big", "large", "weathered", "rotted", "new"], (verbose ? 0.5 : 0));
  1192. var color = random_desc(["blue", "white", "gray", "tan", "green", "red"], (verbose ? 0.5 : 0));
  1193. var name = random_desc(["barn", "barn", "barn", "barn", "barn", "farmhouse"], 1);
  1194. return merge_desc([size, color, name]);
  1195. };
  1196. this.describe = function (verbose = true) {
  1197. return defaultDescribe(verbose, this);
  1198. }
  1199. }
  1200. function SmallHangar(count = 1) {
  1201. this.name = "Small Hangar";
  1202. copy_defaults(this, new DefaultEntity());
  1203. this.count = count;
  1204. this.contents = initContents(this.name, this.count);
  1205. this.describeOne = function (verbose = true) {
  1206. var size = random_desc(["weathered", "aging", "new"], (verbose ? 0.5 : 0));
  1207. var color = random_desc(["blue", "white", "gray", "tan", "green"], (verbose ? 0.5 : 0));
  1208. var name = random_desc(["hangar", "hangar", "hangar", "aircraft hangar"], 1);
  1209. return merge_desc([size, color, name]);
  1210. };
  1211. this.describe = function (verbose = true) {
  1212. return defaultDescribe(verbose, this);
  1213. }
  1214. }
  1215. function HelicopterHangar(count = 1) {
  1216. this.name = "Helicopter Hangar";
  1217. copy_defaults(this, new DefaultEntity());
  1218. this.count = count;
  1219. this.contents = initContents(this.name, this.count);
  1220. this.describeOne = function (verbose = true) {
  1221. var size = random_desc(["weathered", "aging", "new"], (verbose ? 0.5 : 0));
  1222. var color = random_desc(["blue", "white", "gray", "tan", "green"], (verbose ? 0.5 : 0));
  1223. var name = random_desc(["hangar", "hangar", "hangar", "helicopter hangar"], 1);
  1224. return merge_desc([size, color, name]);
  1225. };
  1226. this.describe = function (verbose = true) {
  1227. return defaultDescribe(verbose, this);
  1228. }
  1229. }
  1230. function LargeHangar(count = 1) {
  1231. this.name = "Large Hangar";
  1232. copy_defaults(this, new DefaultEntity());
  1233. this.count = count;
  1234. this.contents = initContents(this.name, this.count);
  1235. this.describeOne = function (verbose = true) {
  1236. var size = random_desc(["weathered", "aging", "new"], (verbose ? 0.5 : 0));
  1237. var color = random_desc(["blue", "white", "gray", "tan", "green"], (verbose ? 0.5 : 0));
  1238. var name = random_desc(["hangar", "hangar", "hangar", "large hangar", "spacious hangar"], 1);
  1239. return merge_desc([size, color, name]);
  1240. };
  1241. this.describe = function (verbose = true) {
  1242. return defaultDescribe(verbose, this);
  1243. }
  1244. }
  1245. function SmallSkyscraper(count = 1) {
  1246. this.name = "Small Skyscraper";
  1247. copy_defaults(this, new DefaultEntity());
  1248. this.count = count;
  1249. this.contents = initContents(this.name, this.count);
  1250. this.describeOne = function (verbose = true) {
  1251. var color = random_desc(["blue", "white", "gray", "tan", "green"], (verbose ? 0.5 : 0));
  1252. var name = random_desc(["skyscraper", "office tower", "office building", "high rise"], 1);
  1253. return merge_desc([color, name]);
  1254. };
  1255. this.describe = function (verbose = true) {
  1256. return defaultDescribe(verbose, this);
  1257. }
  1258. }
  1259. function LargeSkyscraper(count = 1) {
  1260. this.name = "Large Skyscraper";
  1261. copy_defaults(this, new DefaultEntity());
  1262. this.count = count;
  1263. this.contents = initContents(this.name, this.count);
  1264. this.describeOne = function (verbose = true) {
  1265. var color = random_desc(["blue", "white", "gray", "tan", "green", "glass"], (verbose ? 0.5 : 0));
  1266. var name = random_desc(["skyscraper", "office tower", "office building"], 1);
  1267. return merge_desc(["towering", color, name]);
  1268. };
  1269. this.describe = function (verbose = true) {
  1270. return defaultDescribe(verbose, this);
  1271. }
  1272. }
  1273. function ParkingGarage(count = 1) {
  1274. this.name = "Parking Garage";
  1275. copy_defaults(this, new DefaultEntity());
  1276. this.count = count;
  1277. this.contents = initContents(this.name, this.count);
  1278. this.describe = function (verbose = true) {
  1279. return defaultDescribe(verbose, this);
  1280. }
  1281. }
  1282. function Ranch(count = 1) {
  1283. this.name = "Ranch";
  1284. copy_defaults(this, new DefaultEntity());
  1285. this.count = count;
  1286. this.contents = initContents(this.name, this.count);
  1287. this.describeOne = function (verbose = true) {
  1288. var size = random_desc(["little", "large", "prosperous", "run-down"], (verbose ? 0.5 : 0));
  1289. var name = random_desc(["ranch", "farm", "ranch", "dairy farm", "cattle farm", "ranch", "farm"], 1);
  1290. return merge_desc([size, name]);
  1291. };
  1292. this.describe = function (verbose = true) {
  1293. return defaultDescribe(verbose, this);
  1294. }
  1295. }
  1296. function Airstrip(count = 1) {
  1297. this.name = "Airstrip";
  1298. copy_defaults(this, new DefaultEntity());
  1299. this.count = count;
  1300. this.contents = initContents(this.name, this.count);
  1301. this.describe = function (verbose = true) {
  1302. return defaultDescribe(verbose, this, "community");
  1303. }
  1304. }
  1305. function Airport(count = 1) {
  1306. this.name = "Airport";
  1307. copy_defaults(this, new DefaultEntity());
  1308. this.count = count;
  1309. this.contents = initContents(this.name, this.count);
  1310. this.describe = function (verbose = true) {
  1311. return defaultDescribe(verbose, this, "community");
  1312. }
  1313. }
  1314. function Town(count = 1) {
  1315. this.name = "Town";
  1316. copy_defaults(this, new DefaultEntity());
  1317. this.count = count;
  1318. this.contents = initContents(this.name, this.count);
  1319. this.describe = function (verbose = true) {
  1320. return defaultDescribe(verbose, this, "community");
  1321. }
  1322. }
  1323. function City(count = 1) {
  1324. this.name = "City";
  1325. copy_defaults(this, new DefaultEntity());
  1326. this.count = count;
  1327. this.contents = initContents(this.name, this.count);
  1328. this.describe = function (verbose = true) {
  1329. return defaultDescribe(verbose, this, "community");
  1330. }
  1331. }
  1332. function Continent(count = 1) {
  1333. this.name = "Continent";
  1334. copy_defaults(this, new DefaultEntity());
  1335. this.count = count;
  1336. this.contents = initContents(this.name, this.count);
  1337. this.describe = function (verbose = true) {
  1338. return defaultDescribe(verbose, this, "community");
  1339. }
  1340. }
  1341. function Planet(count = 1) {
  1342. this.name = "Planet";
  1343. copy_defaults(this, new DefaultEntity());
  1344. this.count = count;
  1345. this.contents = initContents(this.name, this.count);
  1346. this.describe = function (verbose = true) {
  1347. return defaultDescribe(verbose, this, "community");
  1348. }
  1349. }
  1350. function Star(count = 1) {
  1351. this.name = "Star";
  1352. copy_defaults(this, new DefaultEntity());
  1353. this.count = count;
  1354. this.contents = initContents(this.name, this.count);
  1355. this.describe = function (verbose = true) {
  1356. return (this.count == 1 ? "a star" : this.count + " stars");
  1357. };
  1358. }
  1359. function SolarSystem(count = 1) {
  1360. this.name = "Solar System";
  1361. copy_defaults(this, new DefaultEntity());
  1362. this.count = count;
  1363. this.contents = initContents(this.name, this.count);
  1364. this.describe = function (verbose = true) {
  1365. return defaultDescribe(verbose, this, "celestial");
  1366. }
  1367. }
  1368. function Galaxy(count = 1) {
  1369. this.name = "Galaxy";
  1370. copy_defaults(this, new DefaultEntity());
  1371. this.count = count;
  1372. this.contents = initContents(this.name, this.count);
  1373. this.describe = function (verbose = true) {
  1374. return defaultDescribe(verbose, this, "celestial");
  1375. }
  1376. }
  1377. function Cluster(count = 1) {
  1378. this.name = "Cluster";
  1379. copy_defaults(this, new DefaultEntity());
  1380. this.count = count;
  1381. this.contents = initContents(this.name, this.count);
  1382. this.describe = function (verbose = true) {
  1383. return defaultDescribe(verbose, this, "celestial");
  1384. }
  1385. }
  1386. function Universe(count = 1) {
  1387. this.name = "Universe";
  1388. copy_defaults(this, new DefaultEntity());
  1389. this.count = count;
  1390. this.contents = initContents(this.name, this.count);
  1391. this.describe = function (verbose = true) {
  1392. return defaultDescribe(verbose, this, "celestial");
  1393. }
  1394. }
  1395. function Multiverse(count = 1) {
  1396. this.name = "Multiverse";
  1397. copy_defaults(this, new DefaultEntity());
  1398. this.count = count;
  1399. this.contents = initContents(this.name, this.count);
  1400. this.describe = function (verbose = true) {
  1401. return defaultDescribe(verbose, this, "celestial");
  1402. }
  1403. }
  1404. function Soldier(count = 1) {
  1405. this.name = "Soldier";
  1406. copy_defaults(this, new DefaultEntity());
  1407. this.count = count;
  1408. this.contents = initContents(this.name, this.count);
  1409. this.describe = function (verbose = true) {
  1410. return defaultDescribe(verbose, this, "military");
  1411. }
  1412. }
  1413. function Tank(count = 1) {
  1414. this.name = "Tank";
  1415. copy_defaults(this, new DefaultEntity());
  1416. this.count = count;
  1417. this.contents = initContents(this.name, this.count);
  1418. this.describe = function (verbose = true) {
  1419. return defaultDescribe(verbose, this, "generic vehicle");
  1420. }
  1421. }
  1422. function Artillery(count = 1) {
  1423. this.name = "Artillery";
  1424. copy_defaults(this, new DefaultEntity());
  1425. this.count = count;
  1426. this.contents = initContents(this.name, this.count);
  1427. this.describe = function (verbose = true) {
  1428. return defaultDescribe(verbose, this, "generic vehicle");
  1429. }
  1430. }
  1431. function MilitaryHelicopter(count = 1) {
  1432. this.name = "Military Helicopter";
  1433. copy_defaults(this, new DefaultEntity());
  1434. this.count = count;
  1435. this.contents = initContents(this.name, this.count);
  1436. this.describe = function (verbose = true) {
  1437. return defaultDescribe(verbose, this, "generic vehicle");
  1438. }
  1439. }
  1440. function Micro(count = 1) {
  1441. this.name = "Micro";
  1442. copy_defaults(this, new DefaultEntity());
  1443. this.count = count;
  1444. this.contents = initContents(this.name, this.count);
  1445. this.describe = function (verbose = true) {
  1446. return defaultDescribe(verbose, this);
  1447. }
  1448. }
  1449. function Macro(count = 1) {
  1450. this.name = "Macro";
  1451. copy_defaults(this, new DefaultEntity());
  1452. this.count = count;
  1453. this.contents = initContents(this.name, this.count);
  1454. this.describe = function (verbose = true) {
  1455. return defaultDescribe(verbose, this);
  1456. }
  1457. }
  1458. function Squad(count = 1) {
  1459. this.name = "Squad";
  1460. copy_defaults(this, new DefaultEntity());
  1461. this.count = count;
  1462. this.contents = initContents(this.name, this.count);
  1463. this.describe = function (verbose = true) {
  1464. return defaultDescribe(verbose, this, "military");
  1465. }
  1466. }
  1467. function Platoon(count = 1) {
  1468. this.name = "Platoon";
  1469. copy_defaults(this, new DefaultEntity());
  1470. this.count = count;
  1471. this.contents = initContents(this.name, this.count);
  1472. this.describe = function (verbose = true) {
  1473. return defaultDescribe(verbose, this, "military");
  1474. }
  1475. }
  1476. function Company(count = 1) {
  1477. this.name = "Company";
  1478. copy_defaults(this, new DefaultEntity());
  1479. this.count = count;
  1480. this.contents = initContents(this.name, this.count);
  1481. this.describe = function (verbose = true) {
  1482. return defaultDescribe(verbose, this, "military");
  1483. }
  1484. }
  1485. function Battalion(count = 1) {
  1486. this.name = "Battalion";
  1487. copy_defaults(this, new DefaultEntity());
  1488. this.count = count;
  1489. this.contents = initContents(this.name, this.count);
  1490. this.describe = function (verbose = true) {
  1491. return defaultDescribe(verbose, this, "military");
  1492. }
  1493. }
  1494. function Brigade(count = 1) {
  1495. this.name = "Brigade";
  1496. copy_defaults(this, new DefaultEntity());
  1497. this.count = count;
  1498. this.contents = initContents(this.name, this.count);
  1499. this.describe = function (verbose = true) {
  1500. return defaultDescribe(verbose, this, "military");
  1501. }
  1502. }
  1503. function Division(count = 1) {
  1504. this.name = "Division";
  1505. copy_defaults(this, new DefaultEntity());
  1506. this.count = count;
  1507. this.contents = initContents(this.name, this.count);
  1508. this.describe = function (verbose = true) {
  1509. return defaultDescribe(verbose, this, "military");
  1510. }
  1511. }
  1512. function TankDivision(count = 1) {
  1513. this.name = "Tank Division";
  1514. copy_defaults(this, new DefaultEntity());
  1515. this.count = count;
  1516. this.contents = initContents(this.name, this.count);
  1517. this.describe = function (verbose = true) {
  1518. return defaultDescribe(verbose, this, "military");
  1519. }
  1520. }
  1521. function Army(count = 1) {
  1522. this.name = "Army";
  1523. copy_defaults(this, new DefaultEntity());
  1524. this.count = count;
  1525. this.contents = initContents(this.name, this.count);
  1526. this.describe = function (verbose = true) {
  1527. return defaultDescribe(verbose, this, "military");
  1528. }
  1529. }
  1530. //todo
  1531. //farms
  1532. //factories
  1533. //racetracks
  1534. //more building types
  1535. //cranes and other construction equipment
  1536. //nebula
  1537. //biome magic also set it so that you can't roll your existing biome
  1538. //chemical factory
  1539. //grand army
  1540. //armada