Merge branch 'master' into production

This commit is contained in:
Nick Winter 2014-11-25 10:58:40 -08:00
commit 8cd77a084c
7 changed files with 79 additions and 4 deletions

View file

@ -64,3 +64,7 @@ module.exports =
'store:item-purchased': c.object {required: ['item', 'itemSlug']}, 'store:item-purchased': c.object {required: ['item', 'itemSlug']},
item: {type: 'object'} item: {type: 'object'}
itemSlug: {type: 'string'} itemSlug: {type: 'string'}
'store:hero-purchased': c.object {required: ['hero', 'heroSlug']},
hero: {type: 'object'}
heroSlug: {type: 'string'}

View file

@ -66,8 +66,11 @@
left: 150px left: 150px
color: rgb(42,38,28) color: rgb(42,38,28)
.item-description
margin: 15px 15px 0 25px
#skills #skills
margin: 25px margin: 15px 15px 0 25px
h3 h3
color: rgb(41,35,25) color: rgb(41,35,25)

View file

@ -18,6 +18,9 @@
div.stat= stat.display div.stat= stat.display
img.hr(src="/images/pages/play/modal/hr.png", class=stat.isLast ? "" : "faded", draggable="false") img.hr(src="/images/pages/play/modal/hr.png", class=stat.isLast ? "" : "faded", draggable="false")
if item.description
.item-description= item.description
if props.length if props.length
#skills #skills
h3.big-font(data-i18n="play.skills_granted") h3.big-font(data-i18n="play.skills_granted")

View file

@ -28,7 +28,7 @@
.hero-stat-row .hero-stat-row
.stat-label(data-i18n='choose_hero.status') .stat-label(data-i18n='choose_hero.status')
.stat-value(data-i18n=hero.purchasable ? 'play.purchasable' : (hero.locked ? 'play.locked' : 'play.available')) .stat-value.hero-status-value(data-i18n=hero.purchasable ? 'play.purchasable' : (hero.locked ? 'play.locked' : 'play.available'))
.hero-stat-row .hero-stat-row
.stat-label(data-i18n='choose_hero.weapons') .stat-label(data-i18n='choose_hero.weapons')
@ -62,7 +62,6 @@
span.gem.gem-20 span.gem.gem-20
else if visibleHero.locked else if visibleHero.locked
//#locked-hero-explanation= lockedExplanation
#locked-hero-explanation #locked-hero-explanation
h2 h2
span= visibleHero.name span= visibleHero.name
@ -74,7 +73,6 @@
.form .form
.form-group.select-group .form-group.select-group
span.help-block(data-i18n="choose_hero.programming_language_description") Which programming language do you want to use? span.help-block(data-i18n="choose_hero.programming_language_description") Which programming language do you want to use?
//label.control-label(for="option-code-language", data-i18n="choose_hero.programming_language") Programming Language
select#option-code-language(name="code-language") select#option-code-language(name="code-language")
for option in codeLanguages for option in codeLanguages
option(value=option.id, selected=codeLanguage === option.id)= option.name option(value=option.id, selected=codeLanguage === option.id)= option.name

View file

@ -19,6 +19,7 @@ module.exports = class ItemDetailsView extends CocoView
if @item if @item
@spellDocs = {} @spellDocs = {}
@item.name = utils.i18n @item.attributes, 'name' @item.name = utils.i18n @item.attributes, 'name'
@item.description = utils.i18n @item.attributes, 'description'
@item.affordable = me.gems() >= @item.get('gems') @item.affordable = me.gems() >= @item.get('gems')
@item.owned = me.ownsItem @item.get('original') @item.owned = me.ownsItem @item.get('original')
@item.comingSoon = not @item.getFrontFacingStats().props.length and not _.size @item.getFrontFacingStats().stats # Temp: while there are placeholder items @item.comingSoon = not @item.getFrontFacingStats().props.length and not _.size @item.getFrontFacingStats().stats # Temp: while there are placeholder items

View file

@ -1,10 +1,13 @@
ModalView = require 'views/kinds/ModalView' ModalView = require 'views/kinds/ModalView'
template = require 'templates/play/modal/play-heroes-modal' template = require 'templates/play/modal/play-heroes-modal'
buyGemsPromptTemplate = require 'templates/play/modal/buy-gems-prompt'
CocoCollection = require 'collections/CocoCollection' CocoCollection = require 'collections/CocoCollection'
ThangType = require 'models/ThangType' ThangType = require 'models/ThangType'
SpriteBuilder = require 'lib/sprites/SpriteBuilder' SpriteBuilder = require 'lib/sprites/SpriteBuilder'
AudioPlayer = require 'lib/AudioPlayer' AudioPlayer = require 'lib/AudioPlayer'
utils = require 'lib/utils' utils = require 'lib/utils'
BuyGemsModal = require 'views/play/modal/BuyGemsModal'
Purchase = require 'models/Purchase'
module.exports = class PlayHeroesModal extends ModalView module.exports = class PlayHeroesModal extends ModalView
className: 'modal fade play-modal' className: 'modal fade play-modal'
@ -16,6 +19,9 @@ module.exports = class PlayHeroesModal extends ModalView
'change #option-code-language': 'onCodeLanguageChanged' 'change #option-code-language': 'onCodeLanguageChanged'
'click #close-modal': 'hide' 'click #close-modal': 'hide'
'click #confirm-button': 'saveAndHide' 'click #confirm-button': 'saveAndHide'
'click .unlock-button': 'onUnlockButtonClicked'
'click .buy-gems-prompt-button': 'onBuyGemsPromptButtonClicked'
'click': 'onClickedSomewhere'
shortcuts: shortcuts:
'left': -> @$el.find('#hero-carousel').carousel('prev') if @heroes.models.length and not @$el.hasClass 'secret' 'left': -> @$el.find('#hero-carousel').carousel('prev') if @heroes.models.length and not @$el.hasClass 'secret'
@ -211,6 +217,65 @@ module.exports = class PlayHeroesModal extends ModalView
@codeLanguage = @$el.find('#option-code-language').val() @codeLanguage = @$el.find('#option-code-language').val()
@codeLanguageChanged = true @codeLanguageChanged = true
#- Purchasing the hero
onUnlockButtonClicked: (e) ->
e.stopPropagation()
button = $(e.target).closest('button')
affordable = @visibleHero.get('gems') <= me.gems()
if not affordable
@askToBuyGems button
else if button.hasClass('confirm')
purchase = Purchase.makeFor(@visibleHero)
purchase.save()
#- set local changes to mimic what should happen on the server...
purchased = me.get('purchased') ? {}
purchased.heroes ?= []
purchased.heroes.push(@visibleHero.get('original'))
me.set('purchased', purchased)
me.set('spent', (me.get('spent') ? 0) + @visibleHero.get('gems'))
#- ...then rerender visible hero
heroEntry = @$el.find(".hero-item[data-hero-id='#{@visibleHero.get('original')}']")
heroEntry.find('.hero-status-value').attr('data-i18n', 'play.available').i18n()
heroEntry.removeClass 'locked purchasable'
@rerenderFooter()
Backbone.Mediator.publish 'store:hero-purchased', hero: @visibleHero, heroSlug: @visibleHero.get('slug')
else
button.addClass('confirm').text($.i18n.t('play.confirm'))
@$el.one 'click', (e) ->
button.removeClass('confirm').text($.i18n.t('play.unlock')) if e.target isnt button[0]
askToBuyGems: (unlockButton) ->
if me.getGemPromptGroup() is 'no-prompt'
return @openModalView new BuyGemsModal()
@$el.find('.unlock-button').popover 'destroy'
popoverTemplate = buyGemsPromptTemplate {}
unlockButton.popover(
animation: true
trigger: 'manual'
placement: 'left'
content: ' ' # template has it
container: @$el
template: popoverTemplate
).popover 'show'
popover = unlockButton.data('bs.popover')
popover?.$tip?.i18n()
onBuyGemsPromptButtonClicked: (e) ->
@openModalView new BuyGemsModal()
onClickedSomewhere: (e) ->
return if @destroyed
@$el.find('.unlock-button').popover 'destroy'
#- Exiting
saveAndHide: -> saveAndHide: ->
hero = @selectedHero.get('original') hero = @selectedHero.get('original')

View file

@ -67,6 +67,7 @@ module.exports = class PlayItemsModal extends ModalView
'rasterIcon' 'rasterIcon'
'gems' 'gems'
'tier' 'tier'
'description'
'i18n' 'i18n'
'heroClass' 'heroClass'
] ]