wrap up some "token" => "gem" conversions, code-style

This commit is contained in:
Tyler Renelle 2013-05-11 19:19:09 +01:00
parent 35342e8b71
commit 0ca67bef95
9 changed files with 31 additions and 31 deletions

View file

@ -38,7 +38,7 @@ module.exports.app = (appExports, model) ->
taskTypes = ['habit', 'daily', 'todo', 'reward']
batch.set 'tasks', {}
_.each taskTypes, (type) -> batch.set "#{type}Ids", []
batch.set 'balance', 1 if user.get('balance') < 1 #only if they haven't manually bought tokens
batch.set 'balance', 1 if user.get('balance') < 1 #only if they haven't manually bought gems
# Reset stats
batch.set 'stats.hp', 50

View file

@ -58,7 +58,7 @@ viewHelpers = (view) ->
view.fn "truarr", (num) -> num-1
view.fn 'count', (arr) -> arr?.length or 0
view.fn "tokens", (gp) -> return gp/0.25
view.fn "gems", (gp) -> return gp/0.25
view.fn "encodeiCalLink", (uid, apiToken) ->
loc = window?.location.host or process.env.BASE_URL

View file

@ -54,21 +54,21 @@ module.exports.app = (appExports, model) ->
appExports.buyHatchingPotion = (e, el) ->
name = $(el).attr 'data-hatchingPotion'
newHatchingPotion = _.findWhere hatchingPotions, name: name
tokens = user.get('balance') * 4
if tokens >= newHatchingPotion.value
if confirm "Buy this hatching potion with #{newHatchingPotion.value} of your #{tokens} Gems?"
gems = user.get('balance') * 4
if gems >= newHatchingPotion.value
if confirm "Buy this hatching potion with #{newHatchingPotion.value} of your #{gems} Gems?"
user.push 'items.hatchingPotions', newHatchingPotion.name
user.set 'balance', (tokens - newHatchingPotion.value) / 4
user.set 'balance', (gems - newHatchingPotion.value) / 4
else
$('#more-tokens-modal').modal 'show'
$('#more-gems-modal').modal 'show'
appExports.buyEgg = (e, el) ->
name = $(el).attr 'data-egg'
newEgg = _.findWhere pets, name: name
tokens = user.get('balance') * 4
if tokens >= newEgg.value
if confirm "Buy this egg with #{newEgg.value} of your #{tokens} Gems?"
gems = user.get('balance') * 4
if gems >= newEgg.value
if confirm "Buy this egg with #{newEgg.value} of your #{gems} Gems?"
user.push 'items.eggs', newEgg
user.set 'balance', (tokens - newEgg.value) / 4
user.set 'balance', (gems - newEgg.value) / 4
else
$('#more-tokens-modal').modal 'show'
$('#more-gems-modal').modal 'show'

View file

@ -82,11 +82,11 @@ hr
}
}
/* Tokens
/* Gems
-------------------------------------------------- */
/* Adaptation of GH's social-count for Tokens */
.token-cost
.gem-cost
border: 1px solid #D4D4D4;
font-size: 11px;
font-weight: bold;
@ -98,7 +98,7 @@ hr
background-color: #FAFAFA;
position: relative;
.token-cost::before
.gem-cost::before
content: "";
display: block;
width: 0;
@ -111,7 +111,7 @@ hr
top: 50%;
margin-top: -6px;
.token-cost::after
.gem-cost::after
content: "";
display: block;
width: 0;

View file

@ -1,11 +1,11 @@
.token-wallet
.gem-wallet
cursor: pointer
.tile
background-color: darken($neutral, 10%)
.add-token-btn
.add-gems-btn
opacity: 0
&:hover, &:focus
.add-token-btn
.add-gems-btn
opacity: 1
background-color: $good
.tile

View file

@ -2,7 +2,7 @@
<div class="module full-width">
<span class='option-box pull-right wallet'>
<app:rewards:userTokens />
<app:rewards:userGems />
</span>
<ul class="nav nav-tabs game-tabs">

View file

@ -34,23 +34,23 @@
<!-- Re-Roll modal -->
<app:modals:modal modalId='reroll-modal' header="Reset Your Tasks">
<app:rewards:userTokens/>
<app:rewards:userGems />
<p>Highly discouraged because red tasks provide good incentive to improve (<a target="_blank" href="https://github.com/lefnire/habitrpg#all-my-tasks-are-red-im-dying-too-fast">read more</a>). However, this becomes necessary after long bouts of bad habits.</p>
<@footer>
{#if lt(_user.balance,1)}
<a data-dismiss="modal" x-bind="click:showStripe" class="btn btn-success btn-large">Buy More Gems</a><span class='token-cost'>Not enough Gems</span>
<a data-dismiss="modal" x-bind="click:showStripe" class="btn btn-success btn-large">Buy More Gems</a><span class='gem-cost'>Not enough Gems</span>
{else}
<a data-dismiss="modal" x-bind=click:buyReroll class="btn btn-danger btn-large">Re-Roll</a><span class='token-cost'>4 Gems</span>
<a data-dismiss="modal" x-bind=click:buyReroll class="btn btn-danger btn-large">Re-Roll</a><span class='gem-cost'>4 Gems</span>
{/}
</@footer>
</app:modals:modal>
<!-- Buy more Gems modal -->
<app:modals:modal modalId='more-tokens-modal' header="Out Of Gems">
<app:rewards:userTokens/>
<app:modals:modal modalId='more-gems-modal' header="Out Of Gems">
<app:rewards:userGems />
<p>Oops, out of Gems, which are used to buy special items! Habit is an open source project, and can use all the help it can get - buy more Gems to receive this pet, and consider it a donation to the contributors</p>
<@footer>
<a data-dismiss="modal" x-bind="click:showStripe" class="btn btn-success btn-large">Buy More Gems</a><span class='token-cost'>Not enough Gems</span>
<a data-dismiss="modal" x-bind="click:showStripe" class="btn btn-success btn-large">Buy More Gems</a><span class='gem-cost'>Not enough Gems</span>
</@footer>
</app:modals:modal>

View file

@ -27,7 +27,7 @@
<pet:>
<td class="{#if _user.items.pets[.name]}active-pet{/}">
<img rel=tooltip title="{.text} - {.value} Tokens" x-bind="click:selectPet" data-pet='{.name}' src='img/sprites/{.icon}'/>
<img rel=tooltip title="{.text} - {.value} Gems" x-bind="click:selectPet" data-pet='{.name}' src='img/sprites/{.icon}'/>
</td>
<hatchingPotion:>

View file

@ -52,10 +52,10 @@
<userTokens:>
<a class="pull-right token-wallet" rel='popover' data-trigger='hover' data-title='Gems' data-content="Used for buying special items (reroll, eggs, hatching potions, etc). You'll need to unlock those features before being able to use Gems." data-placement='bottom'>
<span class="task-action-btn tile flush bright add-token-btn" x-bind="click:showStripe"></span>
<span class="task-action-btn tile flush neutral"><div class="Gems"></div> {tokens(_user.balance)} Gems
<userGems:>
<a class="pull-right gem-wallet" rel='popover' data-trigger='hover' data-title='Gems' data-content="Used for buying special items (reroll, eggs, hatching potions, etc). You'll need to unlock those features before being able to use Gems." data-placement='bottom'>
<span class="task-action-btn tile flush bright add-gems-btn" x-bind="click:showStripe"></span>
<span class="task-action-btn tile flush neutral"><div class="Gems"></div> {gems(_user.balance)} Gems
</a>