Browse Source

Moved area and mass to lookup tables. Even better!

tags/v0.7.0
Fen Dweller 7 years ago
parent
commit
ec89e06552
1 changed files with 58 additions and 27 deletions
  1. +58
    -27
      recursive-macro.js

+ 58
- 27
recursive-macro.js View File

@@ -1,3 +1,28 @@

var areas =
{
"Person": 1,
"Car": 4,
"Bus": 12,
"Motorcycle": 2,
"House": 1000,
"Train": 10000,
"Parking Garage": 20000,
"Overpass": 10000
};

var masses =
{
"Person": 80,
"Car": 1000,
"Bus": 5000,
"Motorcycle": 200,
"House": 10000,
"Train": 50000,
"Parking Garage": 100000,
"Overpass": 100000
};

// describes everything in the container // describes everything in the container


function describe_all(contents) { function describe_all(contents) {
@@ -88,11 +113,11 @@ function defaultAnalVore(thing) {
} }


function defaultArea(thing) { function defaultArea(thing) {
return 1;
return areas[thing.name];
} }


function defaultMass(thing) { function defaultMass(thing) {
return 80;
return masses[thing.name];
} }




@@ -140,6 +165,7 @@ function DefaultEntity() {
this.kick = defaultKick; this.kick = defaultKick;
this.anal_vore = defaultAnalVore; this.anal_vore = defaultAnalVore;
this.sum = defaultSum; this.sum = defaultSum;
this.area = defaultArea;
this.mass = defaultMass; this.mass = defaultMass;
this.sum_property = defaultSumProperty; this.sum_property = defaultSumProperty;
return this; return this;
@@ -156,9 +182,10 @@ function copy_defaults(self,proto) {
} }


function Person(count = 1) { function Person(count = 1) {
this.name = "Person";

copy_defaults(this,new DefaultEntity()); copy_defaults(this,new DefaultEntity());


this.name = "Person";
this.count = count; this.count = count;
this.contents = {}; this.contents = {};


@@ -186,13 +213,14 @@ function Person(count = 1) {
} }


function EmptyCar(count = 1) { function EmptyCar(count = 1) {
copy_defaults(this,new DefaultEntity());
this.name = "Car"; this.name = "Car";

copy_defaults(this,new DefaultEntity());
this.count = count; this.count = count;
this.contents = {}; this.contents = {};


this.area = 4;
this.mass = 1000;


this.describeOne = function() { this.describeOne = function() {
color = random_desc(["black","black","gray","gray","blue","red","tan","white","white"]); color = random_desc(["black","black","gray","gray","blue","red","tan","white","white"]);
@@ -215,13 +243,14 @@ function EmptyCar(count = 1) {
} }


function Car(count = 1) { function Car(count = 1) {
copy_defaults(this,new DefaultEntity());
this.name = "Car"; this.name = "Car";

copy_defaults(this,new DefaultEntity());
this.count = count; this.count = count;
this.contents = {}; this.contents = {};


this.area = 4;
this.mass = 1000;


var amount = distribution(2,5,count); var amount = distribution(2,5,count);
this.contents.person = new Person(amount); this.contents.person = new Person(amount);
@@ -247,13 +276,14 @@ function Car(count = 1) {
} }


function Bus(count = 1) { function Bus(count = 1) {
copy_defaults(this,new DefaultEntity());
this.name = "Bus"; this.name = "Bus";

copy_defaults(this,new DefaultEntity());
this.count = count; this.count = count;
this.contents = {}; this.contents = {};


this.area = 12;
this.mass = 3000;


var amount = distribution(10,35,count); var amount = distribution(10,35,count);
this.contents.person = new Person(amount); this.contents.person = new Person(amount);
@@ -278,39 +308,40 @@ function Bus(count = 1) {
} }


function Motorcycle(count = 1) { function Motorcycle(count = 1) {
copy_defaults(this,new DefaultEntity());
this.name = "Motorcycle"; this.name = "Motorcycle";

copy_defaults(this,new DefaultEntity());
this.count = count; this.count = count;
this.contents = {}; this.contents = {};


this.area = 2;
this.mass = 200;


var amount = distribution(1,2,count); var amount = distribution(1,2,count);
this.contents.person = new Person(amount); this.contents.person = new Person(amount);
} }


function Train(count = 1) { function Train(count = 1) {
copy_defaults(this,new DefaultEntity());
this.name = "Train"; this.name = "Train";
copy_defaults(this,new DefaultEntity());
this.count = count; this.count = count;
this.contents = {}; this.contents = {};


this.area = 200;
this.mass = 10000;


var amount = distribution(20,60,count); var amount = distribution(20,60,count);
this.contents.person = new Person(amount); this.contents.person = new Person(amount);
} }


function House(count = 1) { function House(count = 1) {
copy_defaults(this,new DefaultEntity());
this.name = "House"; this.name = "House";
copy_defaults(this,new DefaultEntity());
this.count = count; this.count = count;
this.contents = {}; this.contents = {};


this.area = 400;
this.mass = 20000;


var amount = distribution(0,8,count); var amount = distribution(0,8,count);
this.contents.person = new Person(amount); this.contents.person = new Person(amount);
@@ -338,13 +369,13 @@ function House(count = 1) {
} }


function ParkingGarage(count = 1) { function ParkingGarage(count = 1) {
copy_defaults(this,new DefaultEntity());
this.name = "Parking Garage"; this.name = "Parking Garage";
copy_defaults(this,new DefaultEntity());
this.count = count; this.count = count;
this.contents = {}; this.contents = {};


this.area = 20000;
this.mass = 2000000;


var amount = distribution(10,200,count); var amount = distribution(10,200,count);
this.contents.person = new Person(amount); this.contents.person = new Person(amount);
@@ -371,13 +402,13 @@ function ParkingGarage(count = 1) {
} }


function Overpass(count = 1) { function Overpass(count = 1) {
copy_defaults(this,new DefaultEntity());
this.name = "Overpass"; this.name = "Overpass";
copy_defaults(this,new DefaultEntity());
this.count = count; this.count = count;
this.contents = {}; this.contents = {};


this.area = 20000;
this.mass = 1000000;


var amount = distribution(0,20,count); var amount = distribution(0,20,count);
this.contents.person = new Person(amount); this.contents.person = new Person(amount);


Loading…
Cancel
Save