pets: rename everything "food" to "hatcing potions" (since we may be adding food in the near future)

This commit is contained in:
Tyler Renelle 2013-03-27 11:24:06 -07:00
parent 6520bfb789
commit 4edbb8bf3d
6 changed files with 55 additions and 55 deletions

View file

@ -50,7 +50,7 @@ items = module.exports.items =
{text: 'Bear Cub', name: 'BearCub', value: 2}
]
food: [
hatchingPotions: [
{text: 'Common', name: 'Base', notes: "Hatches your pet in it's base form.", value: 1}
{text: 'White', name: 'White', notes: 'Turns your animal into a White pet.', value: 2}
{text: 'Desert', name: 'Desert', notes: 'Turns your animal into a Desert pet.', value: 2}
@ -68,7 +68,7 @@ _.each ['weapon', 'armor', 'head', 'shield'], (key) ->
_.each items[key], (item) -> item.type = key
_.each items.pets, (pet) -> pet.notes = 'Find some Hatching Potion to sprinkle on this egg, and one day it will hatch into a loyal pet.'
_.each items.food, (food) -> food.notes = "Sprinkle this on an egg, and it will hatch as a #{food.text} pet."
_.each items.hatchingPotions, (hatchingPotion) -> hatchingPotion.notes = "Sprinkle this on an egg, and it will hatch as a #{hatchingPotion.text} pet."
###
view exports
@ -204,7 +204,7 @@ module.exports.updateStore = updateStore = (model) ->
model.set '_view.items.potion', items.potion
model.set '_view.items.reroll', items.reroll
model.set '_view.items.pets', items.pets
model.set '_view.items.food', items.food
model.set '_view.items.hatchingPotions', items.hatchingPotions

View file

@ -1,6 +1,6 @@
_ = require 'underscore'
{ randomVal } = require './helpers'
{ pets, food } = require('./items').items
{ pets, hatchingPotions } = require('./items').items
###
app exports
@ -22,33 +22,33 @@ module.exports.app = (appExports, model) ->
$('#drops-enabled-modal').modal 'show'
appExports.chooseEgg = (e, el) ->
model.ref '_feedEgg', e.at()
model.ref '_hatchEgg', e.at()
appExports.feedEgg = (e, el) ->
foodName = $(el).children('select').val()
myFood = user.get 'items.food'
egg = model.get '_feedEgg'
appExports.hatchEgg = (e, el) ->
hatchingPotionName = $(el).children('select').val()
myHatchingPotion = user.get 'items.hatchingPotions'
egg = model.get '_hatchEgg'
eggs = user.get 'items.eggs'
myPets = user.get 'items.pets'
foodIdx = myFood.indexOf foodName
hatchingPotionIdx = myHatchingPotion.indexOf hatchingPotionName
eggIdx = eggs.indexOf egg
return alert "You don't own that food :\\" if foodIdx is -1
return alert "You don't own that egg :\\" if eggIdx is -1
return alert "You already have that pet." if myPets and myPets.indexOf("#{egg.name}-#{foodName}") != -1
return alert "You don't own that hatching potion yet, complete more tasks!" if hatchingPotionIdx is -1
return alert "You don't own that egg yet, complete more tasks!" if eggIdx is -1
return alert "You already have that pet, hatch a different combo." if myPets and myPets.indexOf("#{egg.name}-#{hatchingPotionName}") != -1
user.push 'items.pets', egg.name + '-' + foodName
user.push 'items.pets', egg.name + '-' + hatchingPotionName
eggs.splice eggIdx, 1
myFood.splice foodIdx, 1
myHatchingPotion.splice hatchingPotionIdx, 1
user.set 'items.eggs', eggs
user.set 'items.food', myFood
user.set 'items.hatchingPotions', myHatching Potion
alert 'Your egg hatched! Visit your stable to equip your pet.'
#FIXME Bug: this removes from the array properly in the browser, but on refresh is has removed all items from the arrays
# user.remove 'items.food', foodIdx, 1
# user.remove 'items.hatchingPotions', hatchingPotionIdx, 1
# user.remove 'items.eggs', eggIdx, 1
appExports.choosePet = (e, el) ->
@ -63,14 +63,14 @@ module.exports.app = (appExports, model) ->
pet = {} if user.get('items.currentPet.str') is petStr
user.set 'items.currentPet', pet
appExports.buyFood = (e, el) ->
name = $(el).attr 'data-food'
newFood = _.findWhere food, name: name
appExports.buyHatchingPotion = (e, el) ->
name = $(el).attr 'data-hatchingPotion'
newHatchingPotion = _.findWhere hatchingPotion, name: name
tokens = user.get('balance') * 4
if tokens > newFood.value
if confirm "Buy this food with #{newFood.value} of your #{tokens} tokens?"
user.push 'items.food', newFood.name
user.set 'balance', (tokens - newFood.value) / 4
if tokens > newHatching Potion.value
if confirm "Buy this hatching potion with #{newHatchingPotion.value} of your #{tokens} tokens?"
user.push 'items.hatchingPotions', newHatchingPotion.name
user.set 'balance', (tokens - newHatchingPotion.value) / 4
else
$('#more-tokens-modal').modal 'show'

View file

@ -5,7 +5,7 @@ _ = require 'underscore'
browser = require './browser'
character = require './character'
items = require './items'
{ pets, food } = items.items
{ pets, hatchingPotions } = items.items
algos = require './algos'
MODIFIER = algos.MODIFIER # each new level, armor, weapon add 2% modifier (this mechanism will change)
@ -29,7 +29,7 @@ randomDrop = (model, delta) ->
chanceMultiplier *= Math.abs(delta) # multiply chance by reddness
if user.get('flags.dropsEnabled') and Math.random() < (.01 * chanceMultiplier)
# current breakdown - 3% (adjustable) chance on drop
# If they got a drop: 50% chance of egg, 50% Food. If food, broken down further even further
# If they got a drop: 50% chance of egg, 50% Hatching Potion. If hatchingPotion, broken down further even further
rarity = Math.random()
# Egg, 40% chance
@ -39,7 +39,7 @@ randomDrop = (model, delta) ->
drop.type = 'Egg'
drop.dialog = "You've found a #{drop.text} Egg! #{drop.notes}"
# Food, 60% chance - break down by rarity even more. FIXME this may not be the best method, so revisit
# Hatching Potion, 60% chance - break down by rarity even more. FIXME this may not be the best method, so revisit
else
acceptableDrops = []
@ -62,9 +62,9 @@ randomDrop = (model, delta) ->
else
acceptableDrops = ['Base']
acceptableDrops = _.filter(food, (foodItem) -> foodItem.name in acceptableDrops)
acceptableDrops = _.filter(hatchingPotions, (hatchingPotion) -> hatchingPotion.name in acceptableDrops)
drop = randomVal acceptableDrops
user.push 'items.food', drop.name
user.push 'items.hatchingPotions', drop.name
drop.type = 'HatchingPotion'
drop.dialog = "You've found a #{drop.text} Hatching Potion! #{drop.notes}"

View file

@ -46,5 +46,5 @@
clear:both
.pets-menu > div
float:left
.food-menu > div
.hatchingPotions-menu > div
float:left

View file

@ -250,23 +250,23 @@
</table>
{/}
<h4>Hatching Potions</h4>
{#with _view.items.food as :food}
{#with _view.items.hatchingPotions as :hatchingPotion}
<table>
<tr>
{#with :food[0]}<app:pets:food />{/}
{#with :food[1]}<app:pets:food />{/}
{#with :food[2]}<app:pets:food />{/}
{#with :food[3]}<app:pets:food />{/}
{#with :hatchingPotion[0]}<app:pets:hatchingPotion />{/}
{#with :hatchingPotion[1]}<app:pets:hatchingPotion />{/}
{#with :hatchingPotion[2]}<app:pets:hatchingPotion />{/}
{#with :hatchingPotion[3]}<app:pets:hatchingPotion />{/}
</tr>
<tr>
{#with :food[4]}<app:pets:food />{/}
{#with :food[5]}<app:pets:food />{/}
{#with :food[6]}<app:pets:food />{/}
{#with :food[7]}<app:pets:food />{/}
{#with :hatchingPotion[4]}<app:pets:hatchingPotion />{/}
{#with :hatchingPotion[5]}<app:pets:hatchingPotion />{/}
{#with :hatchingPotion[6]}<app:pets:hatchingPotion />{/}
{#with :hatchingPotion[7]}<app:pets:hatchingPotion />{/}
</tr>
<tr>
{#with :food[8]}<app:pets:food />{/}
{#with :food[9]}<app:pets:food />{/}
{#with :hatchingPotion[8]}<app:pets:hatchingPotion />{/}
{#with :hatchingPotion[9]}<app:pets:hatchingPotion />{/}
</tr>
</table>
{/}

View file

@ -21,9 +21,9 @@
<img rel=tooltip title="{.text} - {.value} Tokens" x-bind="click:selectPet" data-pet='{.name}' src='img/sprites/{.icon}'/>
</td>
<food:>
<td class="active-food">
<div rel=tooltip class="Pet_HatchingPotion_{.name}" title="{.text} - {.value} Tokens" x-bind="click:buyFood" data-food='{.name}'></div>
<hatchingPotion:>
<td class="active-hatchingPotion">
<div rel=tooltip class="Pet_HatchingPotion_{.name}" title="{.text} - {.value} Tokens" x-bind="click:buyHatchingPotion" data-hatchingPotion='{.name}'></div>
{.text}
</td>
@ -51,31 +51,31 @@
</menu>
</li>
<li class="customize-menu">
{#if not(_user.items.food)}
{#if not(_user.items.hatchingPotions)}
<p>You don't have any hatching potions yet.</p>
{/if}
<menu label="Hatching Potion" class='food-menu'>
{#each _user.items.food as :food}
<menu label="Hatching Potion" class='hatchingPotion-menu'>
{#each _user.items.hatchingPotions as :hatchingPotion}
<div>
<button rel=tooltip title="{:food}" class="customize-option Pet_HatchingPotion_{{:food}}" x-bind="click: chooseFood"></button>
<p>{:food}</p>
<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 _feedEgg}
{#if _hatchEgg}
<div class='span6 well'>
<h3>Hatch Your Egg</h3>
{#if not(_user.items.food)}
{#if not(_user.items.hatchingPotions)}
<p>You don't have any hatching potions yet.</p>
{else}
<p>What would you like to sprinkle on your {_feedEgg.text} egg?</p>
<form x-bind="submit:feedEgg">
<p>What would you like to sprinkle on your {_hatchEgg.text} egg?</p>
<form x-bind="submit:hatchEgg">
<select>
{#each _user.items.food as :food}
<option>{:food}</option>
{#each _user.items.hatchingPotions as :hatchingPotion}
<option>{:hatchingPotion}</option>
{/each}
</select>
<button type=submit>Sprinkle</button>