mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
Merge branch 'locks-auto-equip' into develop
This commit is contained in:
@@ -52,6 +52,7 @@
|
|||||||
"classEquipBonus": "Class Bonus",
|
"classEquipBonus": "Class Bonus",
|
||||||
"battleGear": "Battle Gear",
|
"battleGear": "Battle Gear",
|
||||||
"battleGearText": "This is the gear you wear into battle; it affects numbers when interacting with your tasks.",
|
"battleGearText": "This is the gear you wear into battle; it affects numbers when interacting with your tasks.",
|
||||||
|
"autoEquipBattleGear": "Auto-equip new gear",
|
||||||
"costume": "Costume",
|
"costume": "Costume",
|
||||||
"costumeText": "If you prefer the look of other gear to what you have equipped, check the \"Use Costume\" box to visually don a costume while wearing your battle gear underneath.",
|
"costumeText": "If you prefer the look of other gear to what you have equipped, check the \"Use Costume\" box to visually don a costume while wearing your battle gear underneath.",
|
||||||
"useCostume": "Use Costume",
|
"useCostume": "Use Costume",
|
||||||
|
|||||||
@@ -978,7 +978,7 @@ api.wrap = (user, main=true) ->
|
|||||||
message = i18n.t('armoireExp', req.language)
|
message = i18n.t('armoireExp', req.language)
|
||||||
armoireResp = {"type": "experience", "value": armoireExp}
|
armoireResp = {"type": "experience", "value": armoireExp}
|
||||||
else
|
else
|
||||||
user.items.gear.equipped[item.type] = item.key
|
if user.preferences.autoEquip then user.items.gear.equipped[item.type] = item.key
|
||||||
user.items.gear.owned[item.key] = true
|
user.items.gear.owned[item.key] = true
|
||||||
message = user.fns.handleTwoHanded(item, null, req)
|
message = user.fns.handleTwoHanded(item, null, req)
|
||||||
message ?= i18n.t('messageBought', {itemText: item.text(req.language)}, req.language)
|
message ?= i18n.t('messageBought', {itemText: item.text(req.language)}, req.language)
|
||||||
|
|||||||
@@ -30,7 +30,9 @@ newUser = (addTasks=true)->
|
|||||||
quest:
|
quest:
|
||||||
progress:
|
progress:
|
||||||
down: 0
|
down: 0
|
||||||
preferences: {}
|
preferences: {
|
||||||
|
autoEquip: true
|
||||||
|
}
|
||||||
dailys: []
|
dailys: []
|
||||||
todos: []
|
todos: []
|
||||||
rewards: []
|
rewards: []
|
||||||
@@ -145,7 +147,7 @@ describe 'User', ->
|
|||||||
buffs = {per:0, int:0, con:0, str:0, stealth: 0, streaks: false}
|
buffs = {per:0, int:0, con:0, str:0, stealth: 0, streaks: false}
|
||||||
expect(user.stats).to.eql { str: 1, con: 1, per: 1, int: 1, hp: 50, mp: 32, lvl: 1, exp: 0, gp: 0, class: 'warrior', buffs: buffs }
|
expect(user.stats).to.eql { str: 1, con: 1, per: 1, int: 1, hp: 50, mp: 32, lvl: 1, exp: 0, gp: 0, class: 'warrior', buffs: buffs }
|
||||||
expect(user.items.gear).to.eql { equipped: base_gear, costume: base_gear, owned: {weapon_warrior_0: true} }
|
expect(user.items.gear).to.eql { equipped: base_gear, costume: base_gear, owned: {weapon_warrior_0: true} }
|
||||||
expect(user.preferences).to.eql { costume: false }
|
expect(user.preferences).to.eql { autoEquip: true, costume: false }
|
||||||
|
|
||||||
it 'calculates max MP', ->
|
it 'calculates max MP', ->
|
||||||
user = newUser()
|
user = newUser()
|
||||||
@@ -392,33 +394,6 @@ describe 'User', ->
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe 'store', ->
|
describe 'store', ->
|
||||||
it 'recovers hp buying potions', ->
|
|
||||||
user = newUser()
|
|
||||||
user.stats.hp = 30
|
|
||||||
user.stats.gp = 50
|
|
||||||
user.ops.buy {params: {key: 'potion'}}
|
|
||||||
expect(user).toHaveHP 45
|
|
||||||
expect(user).toHaveGP 25
|
|
||||||
|
|
||||||
user.ops.buy {params: {key: 'potion'}}
|
|
||||||
expect(user).toHaveHP 50 # don't exceed max hp
|
|
||||||
expect(user).toHaveGP 0
|
|
||||||
|
|
||||||
it 'buys equipment', ->
|
|
||||||
user = newUser()
|
|
||||||
user.stats.gp = 31
|
|
||||||
user.ops.buy {params: {key: 'armor_warrior_1'}}
|
|
||||||
expect(user.items.gear.owned).to.eql { weapon_warrior_0: true, armor_warrior_1: true }
|
|
||||||
expect(user.items.gear.equipped).to.eql { armor: 'armor_warrior_1', weapon: 'weapon_base_0', head: 'head_base_0', shield: 'shield_base_0' }
|
|
||||||
expect(user).toHaveGP 1
|
|
||||||
|
|
||||||
it 'does not buy equipment without enough Gold', ->
|
|
||||||
user = newUser()
|
|
||||||
user.stats.gp = 1
|
|
||||||
user.ops.buy {params: {key: 'armor_warrior_1'}}
|
|
||||||
expect(user.items.gear.equipped).to.eql { armor: 'armor_base_0', weapon: 'weapon_base_0', head: 'head_base_0', shield: 'shield_base_0' }
|
|
||||||
expect(user).toHaveGP 1
|
|
||||||
|
|
||||||
it 'buys a Quest scroll', ->
|
it 'buys a Quest scroll', ->
|
||||||
user = newUser()
|
user = newUser()
|
||||||
user.stats.gp = 205
|
user.stats.gp = 205
|
||||||
|
|||||||
@@ -16,9 +16,13 @@ describe('user.fns.buy', function() {
|
|||||||
gear: {
|
gear: {
|
||||||
owned: {
|
owned: {
|
||||||
weapon_warrior_0: true
|
weapon_warrior_0: true
|
||||||
|
},
|
||||||
|
equipped: {
|
||||||
|
weapon_warrior_0: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
preferences: {},
|
||||||
stats: { gp: 200 },
|
stats: { gp: 200 },
|
||||||
achievements: { },
|
achievements: { },
|
||||||
flags: { }
|
flags: { }
|
||||||
@@ -36,13 +40,77 @@ describe('user.fns.buy', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
context('Potion', function() {
|
context('Potion', function() {
|
||||||
it('recovers hp');
|
it('recovers 15 hp', function() {
|
||||||
|
user.stats.hp = 30;
|
||||||
|
user.ops.buy({params: {key: 'potion'}});
|
||||||
|
expect(user.stats.hp).to.eql(45);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does not increase hp above 50', function() {
|
||||||
|
user.stats.hp = 45;
|
||||||
|
user.ops.buy({params: {key: 'potion'}});
|
||||||
|
expect(user.stats.hp).to.eql(50);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('deducts 25 gp', function() {
|
||||||
|
user.stats.hp = 45;
|
||||||
|
user.ops.buy({params: {key: 'potion'}});
|
||||||
|
|
||||||
|
expect(user.stats.gp).to.eql(175);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does not purchase if not enough gp', function() {
|
||||||
|
user.stats.hp = 45;
|
||||||
|
user.stats.gp = 5;
|
||||||
|
user.ops.buy({params: {key: 'potion'}});
|
||||||
|
|
||||||
|
expect(user.stats.hp).to.eql(45);
|
||||||
|
expect(user.stats.gp).to.eql(5);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
context('Gear', function() {
|
context('Gear', function() {
|
||||||
it('buys equipment');
|
it('adds equipment to inventory', function() {
|
||||||
|
user.stats.gp = 31;
|
||||||
|
|
||||||
it('does not buy equipment without enough Gold');
|
user.ops.buy({params: {key: 'armor_warrior_1'}});
|
||||||
|
|
||||||
|
expect(user.items.gear.owned).to.eql({ weapon_warrior_0: true, armor_warrior_1: true });
|
||||||
|
});
|
||||||
|
|
||||||
|
it('deducts gold from user', function() {
|
||||||
|
user.stats.gp = 31;
|
||||||
|
|
||||||
|
user.ops.buy({params: {key: 'armor_warrior_1'}});
|
||||||
|
|
||||||
|
expect(user.stats.gp).to.eql(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('auto equips equipment if user has auto-equip preference turned on', function() {
|
||||||
|
user.stats.gp = 31;
|
||||||
|
user.preferences.autoEquip = true;
|
||||||
|
|
||||||
|
user.ops.buy({params: {key: 'armor_warrior_1'}});
|
||||||
|
|
||||||
|
expect(user.items.gear.equipped).to.have.property('armor', 'armor_warrior_1');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('buys equipment but does not auto-equip', function() {
|
||||||
|
user.stats.gp = 31;
|
||||||
|
user.preferences.autoEquip = false;
|
||||||
|
|
||||||
|
user.ops.buy({params: {key: 'armor_warrior_1'}});
|
||||||
|
|
||||||
|
expect(user.items.gear.equipped).to.not.have.property('armor');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does not buy equipment without enough Gold', function() {
|
||||||
|
user.stats.gp = 20;
|
||||||
|
|
||||||
|
user.ops.buy({params: {key: 'armor_warrior_1'}});
|
||||||
|
|
||||||
|
expect(user.items.gear.owned).to.not.have.property('armor_warrior_1');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
context('Quests', function() {
|
context('Quests', function() {
|
||||||
|
|||||||
@@ -347,6 +347,7 @@ var UserSchema = new Schema({
|
|||||||
language: String,
|
language: String,
|
||||||
automaticAllocation: Boolean,
|
automaticAllocation: Boolean,
|
||||||
allocationMode: {type:String, enum: ['flat','classbased','taskbased'], 'default': 'flat'},
|
allocationMode: {type:String, enum: ['flat','classbased','taskbased'], 'default': 'flat'},
|
||||||
|
autoEquip: {type: Boolean, 'default': true},
|
||||||
costume: Boolean,
|
costume: Boolean,
|
||||||
dateFormat: {type: String, enum:['MM/dd/yyyy', 'dd/MM/yyyy', 'yyyy/MM/dd'], 'default': 'MM/dd/yyyy'},
|
dateFormat: {type: String, enum:['MM/dd/yyyy', 'dd/MM/yyyy', 'yyyy/MM/dd'], 'default': 'MM/dd/yyyy'},
|
||||||
sleep: {type: Boolean, 'default': false},
|
sleep: {type: Boolean, 'default': false},
|
||||||
|
|||||||
@@ -5,6 +5,13 @@
|
|||||||
popover-placement='right', popover-append-to-body='true',
|
popover-placement='right', popover-append-to-body='true',
|
||||||
popover=env.t('battleGearText'))=env.t('battleGear')
|
popover=env.t('battleGearText'))=env.t('battleGear')
|
||||||
|
|
||||||
|
.checkbox.equipment-title
|
||||||
|
label
|
||||||
|
input(type="checkbox", ng-model="user.preferences.autoEquip",
|
||||||
|
ng-change='set({"preferences.autoEquip":user.preferences.autoEquip ? true : false})')
|
||||||
|
|
|
||||||
|
=env.t('autoEquipBattleGear')
|
||||||
|
|
||||||
div
|
div
|
||||||
button.btn.btn-default(type="button", ng-click='dequip("battleGear");') {{env.t("unequipBattleGear")}}
|
button.btn.btn-default(type="button", ng-click='dequip("battleGear");') {{env.t("unequipBattleGear")}}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user