From 1bcd4a3fbd5ac5870ac8baa25ca7a29f985beeb6 Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Fri, 8 Feb 2013 01:04:38 -0500 Subject: [PATCH] some more half-backed changes for the new customization engine --- src/app/content.coffee | 52 +++++++++++++++++++++--------------------- src/app/helpers.coffee | 28 ++++++++++++----------- src/app/index.coffee | 10 +++++++- styles/sprites.styl | 27 +++++++++++----------- views/app/index.html | 15 ++++++++---- 5 files changed, 75 insertions(+), 57 deletions(-) diff --git a/src/app/content.coffee b/src/app/content.coffee index e2a9645d7c..d33684b73c 100644 --- a/src/app/content.coffee +++ b/src/app/content.coffee @@ -57,41 +57,41 @@ module.exports = items: #TODO: figure out how to calculate index & type without having to store it in the JSON weapon: [ - {type: 'weapon', index: 0, text: "Sword 1", icon: "item-sword1", notes:'Training weapon.', value:0} - {type: 'weapon', index: 1, text: "Sword 2", icon:'item-sword2', notes:'Increases experience gain by 3%.', value:20} - {type: 'weapon', index: 2, text: "Axe", icon:'item-axe', notes:'Increases experience gain by 6%.', value:30} - {type: 'weapon', index: 3, text: "Morningstar", icon:'item-morningstar', notes:'Increases experience gain by 9%.', value:45} - {type: 'weapon', index: 4, text: "Blue Sword", icon:'item-bluesword', notes:'Increases experience gain by 12%.', value:65} - {type: 'weapon', index: 5, text: "Red Sword", icon:'item-redsword', notes:'Increases experience gain by 15%.', value:90} - {type: 'weapon', index: 6, text: "Golden Sword", icon:'item-goldensword', notes:'Increases experience gain by 18%.', value:120} + {type: 'weapon', index: 0, text: "Sword 1", classes: "weapon_0", notes:'Training weapon.', value:0} + {type: 'weapon', index: 1, text: "Sword 2", classes:'weapon_1', notes:'Increases experience gain by 3%.', value:20} + {type: 'weapon', index: 2, text: "Axe", classes:'weapon_2', notes:'Increases experience gain by 6%.', value:30} + {type: 'weapon', index: 3, text: "Morningstar", classes:'weapon_3', notes:'Increases experience gain by 9%.', value:45} + {type: 'weapon', index: 4, text: "Blue Sword", classes:'weapon_4', notes:'Increases experience gain by 12%.', value:65} + {type: 'weapon', index: 5, text: "Red Sword", classes:'weapon_5', notes:'Increases experience gain by 15%.', value:90} + {type: 'weapon', index: 6, text: "Golden Sword", classes:'weapon_6', notes:'Increases experience gain by 18%.', value:120} ] armor: [ - {type: 'armor', index: 0, text: "Cloth Armor", icon: 'item-clotharmor', notes:'Training armor.', value:0} - {type: 'armor', index: 1, text: "Leather Armor", icon: 'item-leatherarmor', notes:'Decreases HP loss by 3%.', value:30} - {type: 'armor', index: 2, text: "Chain Mail", icon: 'item-mailarmor', notes:'Decreases HP loss by 6%.', value:45} - {type: 'armor', index: 3, text: "Plate Mail", icon: 'item-platearmor', notes:'Decreases HP loss by 9%.', value:65} - {type: 'armor', index: 4, text: "Red Armor", icon: 'item-redarmor', notes:'Decreases HP loss by 12%.', value:90} - {type: 'armor', index: 5, text: "Golden Armor", icon: 'item-goldenarmor', notes:'Decreases HP loss by 15%.', value:120} + {type: 'armor', index: 0, text: "Cloth Armor", classes: 'armor_0', notes:'Training armor.', value:0} + {type: 'armor', index: 1, text: "Leather Armor", classes: 'armor_1', notes:'Decreases HP loss by 3%.', value:30} + {type: 'armor', index: 2, text: "Chain Mail", classes: 'armor_2', notes:'Decreases HP loss by 6%.', value:45} + {type: 'armor', index: 3, text: "Plate Mail", classes: 'armor_3', notes:'Decreases HP loss by 9%.', value:65} + {type: 'armor', index: 4, text: "Red Armor", classes: 'armor_4', notes:'Decreases HP loss by 12%.', value:90} + {type: 'armor', index: 5, text: "Golden Armor", classes: 'armor_5', notes:'Decreases HP loss by 15%.', value:120} ] head: [ - {type: 'armor', index: 0, text: "No Helm", icon: 'item-nohelm', notes:'Training armor.', value:0} - {type: 'armor', index: 1, text: "Leather Helm", icon: 'item-leatherhelm', notes:'Decreases HP loss by 3%.', value:30} - {type: 'armor', index: 2, text: "Chain Coif", icon: 'item-mailhelm', notes:'Decreases HP loss by 6%.', value:45} - {type: 'armor', index: 3, text: "Plate Helm", icon: 'item-platehelm', notes:'Decreases HP loss by 9%.', value:65} - {type: 'armor', index: 4, text: "Red Helm", icon: 'item-redhelm', notes:'Decreases HP loss by 12%.', value:90} - {type: 'armor', index: 5, text: "Golden Helm", icon: 'item-goldenhelm', notes:'Decreases HP loss by 15%.', value:120} + {type: 'armor', index: 0, text: "No Helm", classes: 'head_0', notes:'Training armor.', value:0} + {type: 'armor', index: 1, text: "Leather Helm", classes: 'head_1', notes:'Decreases HP loss by 3%.', value:30} + {type: 'armor', index: 2, text: "Chain Coif", classes: 'head_2', notes:'Decreases HP loss by 6%.', value:45} + {type: 'armor', index: 3, text: "Plate Helm", classes: 'head_3', notes:'Decreases HP loss by 9%.', value:65} + {type: 'armor', index: 4, text: "Red Helm", classes: 'head_4', notes:'Decreases HP loss by 12%.', value:90} + {type: 'armor', index: 5, text: "Golden Helm", classes: 'head_5', notes:'Decreases HP loss by 15%.', value:120} ] shield: [ - {type: 'armor', index: 0, text: "Shield 1", icon: 'item-clotharmor', notes:'Training armor.', value:0} - {type: 'armor', index: 1, text: "Shield 2", icon: 'item-leatherarmor', notes:'Decreases HP loss by 3%.', value:30} - {type: 'armor', index: 2, text: "Shield 3", icon: 'item-mailarmor', notes:'Decreases HP loss by 6%.', value:45} - {type: 'armor', index: 3, text: "Shield 4", icon: 'item-platearmor', notes:'Decreases HP loss by 9%.', value:65} - {type: 'armor', index: 4, text: "Shielf 5", icon: 'item-redarmor', notes:'Decreases HP loss by 12%.', value:90} + {type: 'armor', index: 0, text: "Shield 1", classes: 'shield_0', notes:'Training armor.', value:0} + {type: 'armor', index: 1, text: "Shield 2", classes: 'shield_1', notes:'Decreases HP loss by 3%.', value:30} + {type: 'armor', index: 2, text: "Shield 3", classes: 'shield_2', notes:'Decreases HP loss by 6%.', value:45} + {type: 'armor', index: 3, text: "Shield 4", classes: 'shield_3', notes:'Decreases HP loss by 9%.', value:65} + {type: 'armor', index: 4, text: "Shielf 5", classes: 'shield_4', notes:'Decreases HP loss by 12%.', value:90} ] - potion: {type: 'potion', text: "Potion", notes: "Recover 15 HP", value: 25, icon: 'item-flask'} + potion: {type: 'potion', text: "Potion", notes: "Recover 15 HP", value: 25, icon: 'item-flask.png'} reroll: type: 'reroll' text: "Re-Roll" - icon: 'favicon' + icon: 'favicon.png' notes: "Resets your tasks. When you're struggling and everything's red, use for a clean slate." value:0 diff --git a/src/app/helpers.coffee b/src/app/helpers.coffee index ad3b66de29..36cb48ee67 100644 --- a/src/app/helpers.coffee +++ b/src/app/helpers.coffee @@ -57,21 +57,23 @@ module.exports.viewHelpers = (view) -> view.fn "tokens", (gp) -> return gp/0.25 - view.fn 'armor', (user) -> - armor = user?.items?.armor || 0 + view.fn 'equipped', (user, type) -> {gender, armorSet} = user?.preferences || {'m', 'v1'} - if gender == 'f' - return if (parseInt(armor) == 0) then "f_armor_#{armor}_#{armorSet}" else "f_armor_#{armor}" - else - return "m_armor_#{armor}" - view.fn 'head', (user) -> - head = user?.items?.head || 0 - {gender, armorSet} = user?.preferences || {'m', 'v1'} - if gender == 'f' - return if (parseInt(head) > 1) then "f_head_#{head}_#{armorSet}" else "f_head_#{head}" - else - return "m_head_#{head}" + if type=='armor' + armor = user?.items?.armor || 0 + if gender == 'f' + return if (parseInt(armor) == 0) then "f_armor_#{armor}_#{armorSet}" else "f_armor_#{armor}" + else + return "m_armor_#{armor}" + + else if type=='head' + head = user?.items?.head || 0 + if gender == 'f' + return if (parseInt(head) > 1) then "f_head_#{head}_#{armorSet}" else "f_head_#{head}" + else + return "m_head_#{head}" + view.fn "username", (auth) -> if auth?.facebook?.displayName? diff --git a/src/app/index.coffee b/src/app/index.coffee index 3797d06334..21282dfbaf 100644 --- a/src/app/index.coffee +++ b/src/app/index.coffee @@ -47,8 +47,10 @@ get '/', (page, model, next) -> # Setup Item Store _view.items = - armor: content.items.armor[parseInt(obj?.items?.armor || 0) + 1] weapon: content.items.weapon[parseInt(obj?.items?.weapon || 0) + 1] + armor: content.items.armor[parseInt(obj?.items?.armor || 0) + 1] + head: content.items.head[parseInt(obj?.items?.head || 0) + 1] + shield: content.items.shield[parseInt(obj?.items?.shield || 0) + 1] potion: content.items.potion reroll: content.items.reroll @@ -230,6 +232,12 @@ ready (model) -> else if type == 'weapon' user.set 'items.weapon', index model.set '_view.items.weapon', content.items.weapon[parseInt(index) + 1] + else if type == 'head' + user.set 'items.head', index + model.set '_view.items.head', content.items.head[parseInt(index) + 1] + else if type == 'shield' + user.set 'items.shield', index + model.set '_view.items.shield', content.items.shield[parseInt(index) + 1] else if type == 'potion' hp = user.get 'stats.hp' hp += 15 diff --git a/styles/sprites.styl b/styles/sprites.styl index eaa4bccab9..f9ae5cfe66 100644 --- a/styles/sprites.styl +++ b/styles/sprites.styl @@ -1,25 +1,26 @@ .avatar - position: relative; - margin-top: -12px; - width: 90px; - height: 90px; + position: relative + margin-top: -12px + width: 90px + height: 90px .character-sprites - position: absolute; - top: -15px; + position: absolute + top: -15px .lvl - position: absolute; - bottom: 0px; - right: 10px; + position: absolute + bottom: 0px + right: 10px -table.customize td div - position: relative - display: block +.character-sprites span + position: absolute + +.itemstore-icons + background-size: 50% .weapon_6, .weapon_5, .weapon_4, .weapon_3, .weapon_2, .weapon_1, .weapon_0, .f_shield_5, .f_shield_4, .f_shield_3, .f_shield_2, .f_shield_1, .m_shield_5, .m_shield_4, .m_shield_3, .m_shield_2, .m_shield_1, .m_head_5, .m_head_4, .m_head_3, .m_head_2, .m_head_1, .m_head_0, .f_head_5_v2, .f_head_5_v1, .f_head_4_v2, .f_head_4_v1, .f_head_3_v2, .f_head_3_v1, .f_head_2_v2, .f_head_2_v1, .f_head_1, .f_head_0, .f_hair_white, .f_hair_brown, .f_hair_black, .f_hair_blond, .m_hair_blond, .m_hair_black, .m_hair_brown, .m_hair_white, .f_armor_5, .f_armor_4, .f_armor_3, .f_armor_2, .f_armor_1, .f_armor_0_v2, .f_armor_0_v1, .m_armor_5, .m_armor_4, .m_armor_3, .m_armor_2, .m_armor_1, .m_armor_0, .f_skin_dead, .f_skin_orc, .f_skin_asian, .f_skin_black, .f_skin_white, .m_skin_dead, .m_skin_orc, .m_skin_asian, .m_skin_black, .m_skin_white { background: url("img/BrowserQuest/habitrpg_mods/css_sprite.png") no-repeat; - position: absolute; } .weapon_6 {background-position: 0 0; width: 90px; height: 90px} .weapon_5 {background-position: -90px 0; width: 90px; height: 90px} diff --git a/views/app/index.html b/views/app/index.html index 7b2c49911c..c87f856acf 100644 --- a/views/app/index.html +++ b/views/app/index.html @@ -222,9 +222,9 @@ {#with _user.preferences as :p} - + - + {/} @@ -351,8 +351,8 @@ {#if _user.flags.itemsEnabled}