mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-01 07:21:15 +00:00
pets: basic framework for selecting both eggs & potions. now it shows which is hatchable with green background, setting up for selling eggs
This commit is contained in:
parent
c52bbc8f0d
commit
be624a03b0
4 changed files with 41 additions and 23 deletions
|
|
@ -103,3 +103,6 @@ menu.pets div
|
|||
-moz-filter: brightness(0%)
|
||||
-o-filter: brightness(0%)
|
||||
-ms-filter: brightness(0%)*/
|
||||
|
||||
.selectableInventory
|
||||
background-color: lightgreen !important
|
||||
|
|
|
|||
|
|
@ -1,27 +1,42 @@
|
|||
habitrpg.controller("InventoryCtrl", ['$scope', 'User',
|
||||
function($scope, User) {
|
||||
|
||||
$scope.hatching = false;
|
||||
// convenience vars since these are accessed frequently
|
||||
$scope.userEggs = User.user.items.eggs;
|
||||
$scope.userHatchingPotions = User.user.items.hatchingPotions;
|
||||
|
||||
$scope.chooseEgg = function(egg){
|
||||
if($scope.userHatchingPotions && $scope.userHatchingPotions.length < 1) {
|
||||
return alert("You have no hatching potion!");
|
||||
if (!$scope.selectedPotion) {
|
||||
$scope.selectedEgg = egg.name;
|
||||
} else {
|
||||
$scope.hatch(egg, $scope.selectedPotion);
|
||||
}
|
||||
|
||||
$scope.selectedEgg = egg;
|
||||
$scope.selectedPotion = $scope.userHatchingPotions[0];
|
||||
$scope.hatching = true;
|
||||
}
|
||||
|
||||
$scope.pour = function(){
|
||||
var pet = $scope.selectedEgg.name + '-' + $scope.selectedPotion;
|
||||
$scope.choosePotion = function(potion){
|
||||
if (!$scope.selectedEgg) {
|
||||
$scope.selectedPotion = potion;
|
||||
} else {
|
||||
$scope.hatch($scope.selectedEgg, potion);
|
||||
}
|
||||
}
|
||||
|
||||
if(User.user.items.pets && ~User.user.items.pets.indexOf(pet)) {
|
||||
$scope.ownsPet = function(egg, potion){
|
||||
if (!egg || !potion) return;
|
||||
var pet = egg + '-' + potion;
|
||||
return User.user.items.pets && ~User.user.items.pets.indexOf(pet)
|
||||
}
|
||||
|
||||
$scope.selectableInventory = function(egg, potion) {
|
||||
if (!egg || !potion) return;
|
||||
if (!$scope.ownsPet(egg, potion)) return 'selectableInventory';
|
||||
}
|
||||
|
||||
$scope.hatch = function(egg, potion){
|
||||
var pet = $scope.selectedEgg + '-' + $scope.selectedPotion;
|
||||
if ($scope.ownsPet(egg, potion)){
|
||||
return alert("You already have that pet, hatch a different combo.")
|
||||
}
|
||||
|
||||
var i = _.indexOf($scope.userEggs, $scope.selectedEgg);
|
||||
$scope.userEggs.splice(i, 1);
|
||||
|
||||
|
|
@ -40,7 +55,7 @@ habitrpg.controller("InventoryCtrl", ['$scope', 'User',
|
|||
alert("Your egg hatched! Visit your stable to equip your pet.");
|
||||
|
||||
$scope.selectedEgg = null;
|
||||
$scope.hatching = false;
|
||||
$scope.selectedPotion = null;
|
||||
}
|
||||
|
||||
}]);
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
angular.module('habitrpg')
|
||||
.filter('gold', function () {
|
||||
return function (gp) {
|
||||
return Math.floor(gp);
|
||||
}
|
||||
}).filter('silver', function () {
|
||||
return function (gp) {
|
||||
return Math.floor((gp - Math.floor(gp))*100);
|
||||
}
|
||||
});
|
||||
.filter('gold', function () {
|
||||
return function (gp) {
|
||||
return Math.floor(gp);
|
||||
}
|
||||
}).filter('silver', function () {
|
||||
return function (gp) {
|
||||
return Math.floor((gp - Math.floor(gp))*100);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -5,13 +5,13 @@
|
|||
menu.pets-menu(label='Eggs ({{userEggs.length}})')
|
||||
p(ng-show='userEggs.length < 1') You don't have any eggs yet.
|
||||
div(ng-repeat='egg in userEggs track by $index')
|
||||
button.customize-option(tooltip='{{egg.text}}', ng-click='chooseEgg(egg)', class='Pet_Egg_{{egg.name}}')
|
||||
button.customize-option(tooltip='{{egg.text}}', ng-click='chooseEgg(egg)', class='Pet_Egg_{{egg.name}}', ng-class='selectableInventory(egg.name, selectedPotion)')
|
||||
p {{egg.text}}
|
||||
li.customize-menu
|
||||
menu.hatchingPotion-menu(label='Hatching Potions ({{userHatchingPotions.length}})')
|
||||
p(ng-show='userHatchingPotions.length < 1') You don't have any hatching potions yet.
|
||||
div(ng-repeat='hatchingPotion in userHatchingPotions track by $index')
|
||||
button.customize-option(tooltip='{{hatchingPotion}}', class='Pet_HatchingPotion_{{hatchingPotion}}')
|
||||
button.customize-option(tooltip='{{hatchingPotion}}', ng-click='choosePotion(hatchingPotion)', class='Pet_HatchingPotion_{{hatchingPotion}}', ng-class='selectableInventory(selectedEgg, hatchingPotion)')
|
||||
p {{hatchingPotion}}
|
||||
.span6(ng-show='hatching')
|
||||
h3 Hatch Your Egg
|
||||
|
|
|
|||
Loading…
Reference in a new issue