classes: armory WIP

This commit is contained in:
Tyler Renelle
2013-11-30 14:55:39 -07:00
parent 83e3a6aff2
commit 91c141140d
9 changed files with 65 additions and 52 deletions

View File

@@ -73,24 +73,24 @@ habitrpg.controller('SettingsCtrl',
$rootScope.$watch('modals.restore', function(value){
if(value === true){
$scope.restoreValues.stats = angular.copy(User.user.stats);
$scope.restoreValues.items = angular.copy(User.user.items);
// $scope.restoreValues.items = angular.copy(User.user.items);
$scope.restoreValues.achievements = {streak: User.user.achievements.streak || 0};
}
})
$scope.restore = function(){
var stats = $scope.restoreValues.stats,
items = $scope.restoreValues.items,
// items = $scope.restoreValues.items,
achievements = $scope.restoreValues.achievements;
User.setMultiple({
"stats.hp": stats.hp,
"stats.exp": stats.exp,
"stats.gp": stats.gp,
"stats.lvl": stats.lvl,
"items.weapon": items.weapon,
"items.armor": items.armor,
"items.head": items.head,
"items.shield": items.shield,
// "items.weapon": items.weapon,
// "items.armor": items.armor,
// "items.head": items.head,
// "items.shield": items.shield,
"achievements.streak": achievements.streak
});
$rootScope.modals.restore = false;

View File

@@ -105,12 +105,9 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User', '
*/
var updateStore = function(){
var sorted, updated;
updated = window.habitrpgShared.items.updateStore(User.user);
/* Figure out whether we wanna put this in habitrpg-shared
*/
sorted = [updated.weapon, updated.armor, updated.head, updated.shield, updated.potion, updated.reroll];
var updated = window.habitrpgShared.items.updateStore(User.user);
// Figure out whether we wanna put this in habitrpg-shared
var sorted = [updated.weapon, updated.armor, updated.head, updated.shield, updated.potion, updated.reroll];
$scope.itemStore = sorted;
}

View File

@@ -203,13 +203,12 @@ api.clearCompleted = function(req, res, next) {
------------------------------------------------------------------------
*/
api.buy = function(req, res, next) {
var hasEnough, type, user;
user = res.locals.user;
type = req.params.type;
if (type !== 'weapon' && type !== 'armor' && type !== 'head' && type !== 'shield' && type !== 'potion') {
return res.json(400, {err: ":type must be in one of: 'weapon', 'armor', 'head', 'shield', 'potion'"});
var user = res.locals.user;
var item = req.params.item;
if (item !== 'potion' && !items.items.gear.flat[item]) {
return res.json(400, {err: ":item must be a supported key, see https://github.com/HabitRPG/habitrpg-shared/blob/master/script/items.coffee"});
}
hasEnough = items.buyItem(user, type);
var hasEnough = items.buyItem(user, type);
if (hasEnough) {
return user.save(function(err, saved) {
if (err) return res.json(500, {err: err});

View File

@@ -105,10 +105,20 @@ var UserSchema = new Schema({
party: Schema.Types.Mixed
},
items: {
armor: Number,
weapon: Number,
head: Number,
shield: Number,
gear: {
owned: _.transform(items.items.gear.flat, function(m,v,k){
m[v.key] = {type: Boolean};
if (v.key.match(/[weapon|armor|head|shield]_warrior_0/))
m[v.key]['default'] = true;
}),
current: {
weapon: {type: String, 'default': 'weapon_warrior_0'},
armor: {type: String, 'default': 'armor_warrior_0'},
head: {type: String, 'default': 'head_warrior_0'},
shield: {type: String, 'default': 'shield_warrior_0'}
}
},
// -------------- Animals -------------------
@@ -213,7 +223,8 @@ var UserSchema = new Schema({
lvl: Number,
// Class System
'class': String,
// 'class': {type: String, enum: ['warrior','rogue','wizard','rogue'], 'default': 'warrior'},
'class': {type: String, 'default': 'warrior'},
points: {type: Number, 'default': 0},
str: {type: Number, 'default': 0},
def: {type: Number, 'default': 0},

View File

@@ -48,7 +48,7 @@ if (nconf.get('NODE_ENV') == 'development') {
}
/* Items*/
router.post('/user/buy/:type', auth.auth, cron, user.buy);
router.post('/user/buy/:item', auth.auth, cron, user.buy);
/* User*/
router.get('/user', auth.auth, cron, user.getUser);

View File

@@ -5,6 +5,11 @@ script(type='text/ng-template', id='partials/options.inventory.inventory.html')
p.well Click an egg to see usable potions highlighted in green and then click one of the highlighted potions to hatch your pet. If no potions are highlighted, click that egg again to deselect it, and instead click a potion first to have the usable eggs highlighted. You can also sell unwanted drops to Alexander the Merchant.
menu.inventory-list(type='list')
li.customize-menu
menu.pets-menu(label='Gear')
div(ng-repeat='(k,v) in user.items.gear.owned')
button.customize-option(popover='{{Items.gear.flat[k].notes}}', popover-title='{{Items.gear.flat[k].text}}', popover-trigger='mouseenter', popover-placement='right', ng-click='equip(v)', class='shop_{{v.key}}')
li.customize-menu
menu.pets-menu(label='Eggs ({{eggCount}})')
p(ng-show='eggCount < 1') You don't have any eggs yet.

View File

@@ -8,24 +8,24 @@ figure.herobox(ng-click='spell ? castEnd(profile, "user", $event) : clickMember(
// Mount Body
span(ng-if='profile.items.currentMount', class='Mount_Body_{{profile.items.currentMount}}')
// Avatar
//span(class='{{profile.preferences.gender}}_skin_{{profile.preferences.skin}}')
//span(class='{{profile.preferences.gender}}_head_0')
//span(class='{{profile.preferences.gender}}_hair_base_{{profile.preferences.hair.base}}_{{profile.preferences.hair.color}}')
//span(class='{{profile.preferences.gender}}_hair_bangs_{{profile.preferences.hair.bangs}}_{{profile.preferences.hair.color}}')
//span(class='{{equipped("armor", profile.items.armor, profile.preferences, profile.backer, profile.contributor)}}-{{profile.stats.class}}')
//span(class='{{equipped("head", profile.items.head, profile.preferences, profile.backer, profile.contributor)}}-{{profile.stats.class}}', ng-show='profile.preferences.showHelm')
//span(class='{{equipped("shield",profile.items.shield,profile.preferences, profile.backer, profile.contributor)}}-{{profile.stats.class}}')
//span(class='{{equipped("weapon",profile.items.weapon,profile.preferences, profile.backer, profile.contributor)}}-{{profile.stats.class}}')
//- Avatar
//-span(class='{{profile.preferences.gender}}_skin_{{profile.preferences.skin}}')
//-span(class='{{profile.preferences.gender}}_head_0')
//-span(class='{{profile.preferences.gender}}_hair_base_{{profile.preferences.hair.base}}_{{profile.preferences.hair.color}}')
//-span(class='{{profile.preferences.gender}}_hair_bangs_{{profile.preferences.hair.bangs}}_{{profile.preferences.hair.color}}')
//-span(class='{{equipped("armor", profile.items.armor, profile.preferences, profile.backer, profile.contributor)}}-{{profile.stats.class}}')
//-span(class='{{equipped("head", profile.items.head, profile.preferences, profile.backer, profile.contributor)}}-{{profile.stats.class}}', ng-show='profile.preferences.showHelm')
//-span(class='{{equipped("shield",profile.items.shield,profile.preferences, profile.backer, profile.contributor)}}-{{profile.stats.class}}')
//-span(class='{{equipped("weapon",profile.items.weapon,profile.preferences, profile.backer, profile.contributor)}}-{{profile.stats.class}}')
span(class='m_skin_{{profile.preferences.skin}}')
span(class='m_head_0')
span(class='m_hair_base_{{profile.preferences.hair.base}}_{{profile.preferences.hair.color}}')
span(class='m_hair_bangs_{{profile.preferences.hair.bangs}}_{{profile.preferences.hair.color}}')
span(class='m_armor_{{profile.items.armor}}-{{profile.stats.class}}')
span(class='m_head_{{profile.items.head}}-{{profile.stats.class}}', ng-show='profile.preferences.showHelm')
span(class='m_shield_{{profile.items.shield}}-{{profile.stats.class}}')
span(class='m_weapon_{{profile.items.weapon}}-{{profile.stats.class}}')
span(class='m_{{profile.items.gear.current.armor}}')
span(class='m_{{profile.items.gear.current.head}}', ng-show='profile.preferences.showHelm')
span(class='m_{{profile.items.gear.current.shield}}')
span(class='m_{{profile.items.gear.current.weapon}}')
// Mount Head
span(ng-if='profile.items.currentMount', class='Mount_Head_{{profile.items.currentMount}}')

View File

@@ -29,19 +29,20 @@ div(ng-controller='SettingsCtrl')
.option-group.option-medium
input.option-content(type='number', data-for='stats.lvl', ng-model='restoreValues.stats.lvl')
span.input-suffix Level
h3 Items
.option-group.option-medium
input.option-content(type='number', data-for='items.weapon', ng-model='restoreValues.items.weapon')
span.input-suffix Weapon
.option-group.option-medium
input.option-content(type='number', data-for='items.armor', ng-model='restoreValues.items.armor')
span.input-suffix Armor
.option-group.option-medium
input.option-content(type='number', data-for='items.head', ng-model='restoreValues.items.head')
span.input-suffix Helm
.option-group.option-medium
input.option-content(type='number', data-for='items.shield', ng-model='restoreValues.items.shield')
span.input-suffix Shield
//-
h3 Items
.option-group.option-medium
input.option-content(type='number', data-for='items.weapon', ng-model='restoreValues.items.weapon')
span.input-suffix Weapon
.option-group.option-medium
input.option-content(type='number', data-for='items.armor', ng-model='restoreValues.items.armor')
span.input-suffix Armor
.option-group.option-medium
input.option-content(type='number', data-for='items.head', ng-model='restoreValues.items.head')
span.input-suffix Helm
.option-group.option-medium
input.option-content(type='number', data-for='items.shield', ng-model='restoreValues.items.shield')
span.input-suffix Shield
h3 Streak Achievements
.option-group.option-medium
input.option-content(type='number', data-for='achievements.streak', ng-model='restoreValues.achievements.streak')

View File

@@ -59,7 +59,7 @@ script(id='templates/habitrpg-tasks.html', type="text/ng-template")
span.reward-cost {{item.value}}
span.shop_gold
// main content
span(ng-class='{"shop_{{item.classes}} shop-sprite item-img": true}')
span(ng-class='{"shop_{{item.key}} shop-sprite item-img": true}')
p.task-text {{item.text}}
// Spells
@@ -75,7 +75,7 @@ script(id='templates/habitrpg-tasks.html', type="text/ng-template")
strong {{spell.mana}}
| &nbsp;MP
// main content
span(ng-class='{"shop_{{spell.classes}} shop-sprite item-img": true}')
span(ng-class='{"shop_{{spell.key}} shop-sprite item-img": true}')
p.task-text {{spell.text}}
br