Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed shop ordering

  • Loading branch information...
commit 297ccf3442f36b767efdd745f1532f0eaec759d3 1 parent 193cd97
Horia Dragomir hdragomir authored
Showing with 65 additions and 60 deletions.
  1. +59 −51 config/shop.json
  2. +6 −9 js/Shop.js
110 config/shop.json
View
@@ -1,54 +1,62 @@
-{
+[
- "houses" : [
- "buildings/poor_house",
- "buildings/villager_house",
- "buildings/knights_house",
- "buildings/fairy_house",
- "buildings/ladys_house",
- "buildings/jokers_house",
- "buildings/wizards_house",
- "buildings/crazy_hogs_pub",
- "buildings/wedding_chapel",
- "buildings/straight_a_schoolhouse",
- "buildings/horse_stable",
- "buildings/shoe_house",
- "buildings/theatre",
- "buildings/dwarf_house",
- "buildings/bakery",
- "buildings/unicorn_stable",
- "buildings/gingerbread_house",
- "buildings/silver_mine",
- "buildings/royal_summer_house",
- "buildings/artist_studio",
- "buildings/medieval_university",
- "buildings/tailor_shop",
- "buildings/gold_mine",
- "buildings/bath_house",
- "buildings/observatory"
- ],
+ {
+ "name": "houses",
+ "items" : [
+ "buildings/poor_house",
+ "buildings/villager_house",
+ "buildings/knights_house",
+ "buildings/fairy_house",
+ "buildings/ladys_house",
+ "buildings/jokers_house",
+ "buildings/wizards_house",
+ "buildings/crazy_hogs_pub",
+ "buildings/wedding_chapel",
+ "buildings/straight_a_schoolhouse",
+ "buildings/horse_stable",
+ "buildings/shoe_house",
+ "buildings/theatre",
+ "buildings/dwarf_house",
+ "buildings/bakery",
+ "buildings/unicorn_stable",
+ "buildings/gingerbread_house",
+ "buildings/silver_mine",
+ "buildings/royal_summer_house",
+ "buildings/artist_studio",
+ "buildings/medieval_university",
+ "buildings/tailor_shop",
+ "buildings/gold_mine",
+ "buildings/bath_house",
+ "buildings/observatory"
+ ]
+ },
- "farming": [
- "farming/basic_plot",
- "farming/seed-melon",
- "farming/seed-beans",
- "farming/seed-grapes",
- "farming/seed-pumpkin",
- "farming/seed-strawberry",
- "farming/seed-wheat"
- ],
-
- "decoration": [
- "decorations/flower_rose",
- "decorations/flower_sunflower",
- "decorations/flower_daisy",
- "decorations/pond",
- "decorations/haybale",
- "decorations/flower_dalia",
- "decorations/windmill",
- "decorations/scarecrow",
- "decorations/well",
- "decorations/fountain_rock"
- ]
+ {
+ "name": "farming",
+ "items" : [
+ "farming/basic_plot",
+ "farming/seed-melon",
+ "farming/seed-beans",
+ "farming/seed-grapes",
+ "farming/seed-pumpkin",
+ "farming/seed-strawberry",
+ "farming/seed-wheat"
+ ]
+ },
-}
+ {
+ "name": "decoration",
+ "items" : [
+ "decorations/flower_rose",
+ "decorations/flower_sunflower",
+ "decorations/flower_daisy",
+ "decorations/pond",
+ "decorations/haybale",
+ "decorations/flower_dalia",
+ "decorations/windmill",
+ "decorations/scarecrow",
+ "decorations/well",
+ "decorations/fountain_rock"
+ ]
+ }
+]
15 js/Shop.js
View
@@ -75,7 +75,7 @@
nav = document.querySelector('nav');
hud_goals = document.getElementById('hud-goals');
- var defaultDepartmentId, ddi = 0;
+ var defaultDepartmentId;
var shopItems = {}, i;
@@ -147,17 +147,14 @@
};
- for (i in this.shopItems) {
- if (this.shopItems.hasOwnProperty(i)) {
+ this.shopItems.forEach(function (item, ddi) {
if (ddi++ === Shop.DEFAULT_DEPARTMENT_INDEX) {
- defaultDepartmentId = i;
+ defaultDepartmentId = item.name;
}
+ shopItems[item.name] = item.items.map(setItemProperties, this);
+ shopItems[item.name].sort(this.sortShopItems);
- shopItems[i] = this.shopItems[i].map(setItemProperties, this);
-
- shopItems[i].sort(this.sortShopItems);
- }
- }
+ }, this);
var shopWrapper = document.createElement("div");
shopWrapper.id = "shop";
Please sign in to comment.
Something went wrong with that request. Please try again.