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.
 
 
 

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