rewrite: add read-only inventory. fix empty pet issue, it was the wrong

casting type UserSchema.items.eggs.type
This commit is contained in:
Tyler Renelle
2013-09-02 14:26:59 -04:00
parent 8482439617
commit 687da68d52
4 changed files with 34 additions and 76 deletions

View File

@@ -123,29 +123,15 @@ var UserSchema = new Schema({
},
eggs: [
{
/*"Wolf",*/
text: String,
/*"Wolf",*/
name: String,
/*3*/
value: Number,
/*"Find a hatching potion to pour on this egg, and one day it will hatch into a loyal pet.",*/
notes: String,
/*"Egg",*/
type: String,
/*"You've found a Wolf Egg! Find a hatching potion to pour on this egg, and one day it will hatch into a loyal pet." },*/
dialog: String
text: String, // Wolf
name: String, // Wolf
value: Number, //3
notes: String, //Find a hatching potion to pour on this egg, and one day it will hatch into a loyal pet.
//type: String, //Egg // FIXME this is forcing mongoose to return object as "[object Object]", but I don't think this is needed anyway?
dialog: String //You've found a Wolf Egg! Find a hatching potion to pour on this egg, and one day it will hatch into a loyal pet
}
],
/* ["Base", "Skeleton",...]*/
hatchingPotions: Array,
hatchingPotions: Array, //["Base", "Skeleton",...]
lastDrop: {
date: Date,
count: Number

View File

@@ -45,7 +45,7 @@
.row-fluid
.span6.border-right
h2 Inventory
app:avatar:inventory
include ./inventory
.span6
h2 Market
app:game-pane:market

View File

@@ -0,0 +1,24 @@
.row-fluid
div(ng-class='{span6: _hatchEgg}')
menu.inventory-list(type='list')
li.customize-menu
menu.pets-menu(label='Eggs')
p(ng-show='!user.items.eggs') You don't have any eggs yet.
div(ng-repeat='egg in user.items.eggs track by $index')
button.customize-option(tooltip='{{egg.text}}', x-bind='click: chooseEgg', class='Pet_Egg_{{egg.name}}')
p {{egg.text}}
li.customize-menu
menu.hatchingPotion-menu(label='Hatching Potions')
p(ng-show='!user.items.hatchingPotions') You don't have any hatching potions yet.
div(ng-repeat='hatchingPotion in user.items.hatchingPotions track by $index')
button.customize-option(tooltip='{{hatchingPotion}}', x-bind='click: chooseHatching Potion', class='Pet_HatchingPotion_{{hatchingPotion}}')
p {{hatchingPotion}}
.span6(ng-show='_hatchEgg')
h3 Hatch Your Egg
p(ng-show='!user.items.hatchingPotions') You don't have any hatching potions yet.
div(ng-show='user.items.hatchingPotions')
p Which hatching potion will you pour on your {{_hatchEgg.text}} egg?
form(x-bind='submit:hatchEgg')
select
option(ng-repeat='hatchingPotion in user.items.hatchingPotions track by $index') {{hatchingPotion}}
button(type='submit') Pour

View File

@@ -7,67 +7,15 @@
<hatchingPotion:>
<td class="active-hatchingPotion" x-bind="click:buyHatchingPotion" data-hatchingPotion='{.name}'>
<div class="Pet_HatchingPotion_{.name}"></div>
<p>{.text}<br/><small>{.value} Gems<small></p>
<p>{.text}<br/><small>{.value} Gems</small></p>
</td>
<egg:>
<td class="active-egg" x-bind="click:buyEgg" data-egg='{.name}'>
<div rel=tooltip class="Pet_Egg_{.name}"></div>
<p>{.text}<br/><small>{.value} Gems<small></p>
<p>{.text}<br/><small>{.value} Gems</small></p>
</td>
<inventory:>
<div class='row-fluid'>
<div class='{#if _hatchEgg}span6{/}'>
<menu type="list" class="inventory-list">
<li class="customize-menu">
<menu label="Eggs" class='pets-menu'>
{#if not(_user.items.eggs)}
<p>You don't have any eggs yet.</p>
{/if}
{#each _user.items.eggs as :egg}
<div>
<button rel=tooltip title="{:egg.text}" class="customize-option Pet_Egg_{{:egg.name}}" x-bind="click: chooseEgg"></button>
<p>{:egg.text}</p>
</div>
{/each}
</menu>
</li>
<li class="customize-menu">
<menu label="Hatching Potions" class='hatchingPotion-menu'>
{#if not(_user.items.hatchingPotions)}
<p>You don't have any hatching potions yet.</p>
{/if}
{#each _user.items.hatchingPotions as :hatchingPotion}
<div>
<button rel=tooltip title="{:hatchingPotion}" class="customize-option Pet_HatchingPotion_{{:hatchingPotion}}" x-bind="click: chooseHatching Potion"></button>
<p>{:hatchingPotion}</p>
</div>
{/each}
</menu>
</li>
</menu>
</div>
{#if _hatchEgg}
<div class='span6'>
<h3>Hatch Your Egg</h3>
{#if not(_user.items.hatchingPotions)}
<p>You don't have any hatching potions yet.</p>
{else}
<p>Which hatching potion will you pour on your {_hatchEgg.text} egg?</p>
<form x-bind="submit:hatchEgg">
<select>
{#each _user.items.hatchingPotions as :hatchingPotion}
<option>{:hatchingPotion}</option>
{/each}
</select>
<button type=submit>Pour</button>
</form>
{/if}
</div>
{/if}
</div>
<stable:>
<!-- tables, I know - I spent a good 1h here with divs & row-fluid and can't get it working, so screw it -->
<table><tr>