I want to know if this can be trimmed down further. I am repeating myself with this.title
and this.position
. Also this.position
is the corresponding array index, not sure if that is a good idea, if player throws 3 then perhaps I can just denote that as player is currently at positions[3]
. I use this.price
instead of this.rent
because otherwise I would have 2 different object properties, purchaseprice
and rentprice
, I felt I could merge the 2 into 1 property and use an array.
Looking forward to suggestions.
Positions
positions = [
new Position("Go", 0),
new Cities("Cairo", "brown", [60, 2, 10, 30, 90, 160, 250], 1),
new CardPosition("Chest", "chest", 2),
new Cities("Vienna", "brown", [60, 4, 20, 60, 180, 320, 450], 3),
new Tax("Income Tax", 200, 4),
new Airport("Schiphol", [200, 25, 50, 100, 200], 5),
new Cities("Brussels", "blue", [100, 6, 30, 90, 270, 400, 550], 6),
new CardPosition("Chance", "chance", 7),
new Cities("Stockholm", "blue", [100, 6, 30, 90, 270, 400, 550], 8),
new Cities("Geneva", "blue", [120, 8, 40, 100, 300, 450, 600], 9),
new Position("Jailhouse", 10),
new Cities("Amsterdam", "pink", [140, 10, 50, 150, 450, 625, 750], 11),
new Position("Electric", 12),
new Cities("Bangkok", "pink", [140, 10, 50, 150, 450, 625, 750], 13),
new Cities("Istanbul", "pink", [160, 12, 60, 180, 500, 700, 900], 14),
new Airport("DBX", [200, 25, 50, 100, 200], 15),
new Cities("Hong Kong", "orange", [180, 14, 70, 200, 550, 750, 950], 16),
new CardPosition("Chest", "chest", 17),
new Cities("Madrid", "orange", [180, 14, 70, 200, 550, 750, 950], 18),
new Cities("Sydney", "orange", [200, 14, 70, 200, 550, 750, 950], 19),
new Position("Free Parking", 20),
new Cities("Toronto", "red", [220, 18, 90, 250, 700, 875, 1050], 21),
new CardPosition("Chance", "chance", 22),
new Cities("Mumbai", "red", [220, 18, 90, 250, 700, 875, 1050], 23),
new Cities("Rome", "red", [240, 20, 100, 300, 750, 925, 1100], 24),
new Airport("BCN", [200, 25, 50, 100, 200], 25),
new Cities("Rio", "yellow", [260, 22, 110, 330, 800, 975, 1150], 26),
new Cities("Tokyo", "yellow", [260, 22, 110, 330, 800, 975, 1150], 27),
new Position("Water Works", 28),
new Cities("Paris", "yellow", [280, 24, 120, 360, 850, 1025, 1200], 29),
new Position("Go to Jail", 30),
new Cities("Berlin", "green", [300, 26, 130, 390, 900, 1100, 1275], 31),
new Cities("Bejing", "green", [300, 26, 130, 390, 900, 1100, 1275], 32),
new CardPosition("Chest", "chest", 33),
new Cities("Moscow", "green", [320, 28, 150, 450, 1000, 1200, 1400], 34),
new Airport("LAX", [200, 25, 50, 100, 200], 35),
new CardPosition("Chance", "chance", 36),
new Cities("New York", "navy", [350, 35, 175, 500, 1100, 1300, 1500], 37),
new Tax("Super Tax", 100, 38),
new Cities("London", "navy", [400, 50, 200, 600, 1400, 1700, 2000], 39)
];
function Position (title,position){
this.title = title;
this.position = position;
this.forsale = false;
}
function CardPosition (title,type,position){
this.title = title;
this.type = type;
this.position = position;
this.forsale = false;
}
function Tax (title,tax,position){
this.title = title;
this.tax = tax;
this.position = position;
this.forsale = false;
this.type = "tax";
}
function Airport(title,prices,position){
this.title = title;
this.rating = 0;
this.price = prices[this.rating];
this.position = position;
this.forsale = true;
this.type = "airport";
}
function Cities (title,set,prices,position){
this.title = title;
this.set = set;
this.rating = 0;
this.prices = prices;
this.price = prices[this.rating];
this.position = position;
this.owner = "unowned";
this.forsale = true;
this.type = "city";
}