Merge branch 'master' into production

This commit is contained in:
Nick Winter 2014-10-10 19:20:10 -07:00
commit fb39081380
12 changed files with 163 additions and 95 deletions

View file

@ -29,7 +29,7 @@ module.exports = class LevelBus extends Bus
constructor: ->
super(arguments...)
@changedSessionProperties = {}
@saveSession = _.debounce(@saveSession, 1000, {maxWait: 5000})
@saveSession = _.debounce(@reallySaveSession, 1000, {maxWait: 5000})
@playerIsIdle = false
init: ->
@ -190,7 +190,7 @@ module.exports = class LevelBus extends Bus
state.complete = true
@session.set('state', state)
@changedSessionProperties.state = true
@saveSession()
@reallySaveSession() # Make sure it saves right away; don't debounce it.
onNewGoalStates: ({goalStates})->
state = @session.get 'state'
@ -232,7 +232,8 @@ module.exports = class LevelBus extends Bus
@changedSessionProperties.permissions = true
@saveSession()
saveSession: ->
# Debounced as saveSession
reallySaveSession: ->
return if _.isEmpty @changedSessionProperties
# don't let peeking admins mess with the session accidentally
return unless @session.get('multiplayer') or @session.get('creator') is me.id

View file

@ -8,7 +8,7 @@ module.exports.createAetherOptions = (options) ->
aetherOptions =
functionName: options.functionName
protectAPI: not options.skipProtectAPI
includeFlow: options.includeFlow
includeFlow: Boolean options.includeFlow
yieldConditionally: options.functionName is 'plan'
simpleLoops: true
globals: ['Vector', '_']
@ -47,3 +47,4 @@ functionParameters =
chooseAction: []
plan: []
initializeCentroids: []
update: []

View file

@ -81,6 +81,7 @@ module.exports = LayerAdapter = class LayerAdapter extends CocoClass
#- Layer ordering
updateLayerOrder: ->
return if @destroyed
@container.sortChildren @layerOrderComparator
layerOrderComparator: (a, b) ->

View file

@ -58,14 +58,14 @@ module.exports = nativeDescription: "español (ES)", englishDescription: "Spanis
hours_played: "horas jugadas" # Hover over a level on /play
# items: "Items" # Tooltip on item shop button from /play
# heroes: "Heroes" # Tooltip on hero shop button from /play
# achievements: "Achievements" # Tooltip on achievement list button from /play
# account: "Account" # Tooltip on account button from /play
achievements: "Logros" # Tooltip on achievement list button from /play
account: "Cuenta" # Tooltip on account button from /play
# settings: "Settings" # Tooltip on settings button from /play
# next: "Next" # Go from choose hero to choose inventory before playing a level
# change_hero: "Change Hero" # Go back from choose inventory to choose hero
next: "Siguiente Heroe" # Go from choose hero to choose inventory before playing a level
change_hero: "Seleccionar Heroe" # Go back from choose inventory to choose hero
# choose_inventory: "Equip Items"
# older_campaigns: "Older Campaigns"
# anonymous: "Anonymous Player"
older_campaigns: "Campañas Anteriores"
anonymous: "Jugador Anonimo"
level_difficulty: "Dificultad: "
campaign_beginner: "Campaña de Principiante"
choose_your_level: "Elige tu nivel" # The rest of this section is the old play view at /play-old and isn't very important.
@ -182,12 +182,12 @@ module.exports = nativeDescription: "español (ES)", englishDescription: "Spanis
play_level:
done: "Hecho"
home: "Inicio"
# skip: "Skip"
skip: "Saltar"
game_menu: "Menu del Juego"
guide: "Guía"
restart: "Reiniciar"
goals: "Objetivos"
# goal: "Goal"
goal: "Objetivo Principal"
success: "Exito!"
incomplete: "Incompleto"
timed_out: "Te has quedado sin tiempo"
@ -204,7 +204,7 @@ module.exports = nativeDescription: "español (ES)", englishDescription: "Spanis
victory_rate_the_level: "Puntúa este nivel: " # Only in old-style levels.
victory_return_to_ladder: "Volver a Clasificación"
victory_play_next_level: "Jugar el siguiente nivel" # Only in old-style levels.
# victory_play_continue: "Continue"
victory_play_continue: "Continuar"
victory_go_home: "Ir a Inicio" # Only in old-style levels.
victory_review: "¡Cuéntanos más!" # Only in old-style levels.
victory_hour_of_code_done: "¿Ya terminaste?"
@ -220,18 +220,18 @@ module.exports = nativeDescription: "español (ES)", englishDescription: "Spanis
# tome_cast_button_running: "Running"
# tome_cast_button_ran: "Ran"
# tome_submit_button: "Submit"
# tome_reload_method: "Reload original code for this method" # Title text for individual method reload button.
# tome_select_method: "Select a Method"
# tome_see_all_methods: "See all methods you can edit" # Title text for method list selector (shown when there are multiple programmable methdos).
tome_reload_method: "Recargcar código original para este método" # Title text for individual method reload button.
tome_select_method: "Seleccionar método"
tome_see_all_methods: "Métodos que pueden ser editados" # Title text for method list selector (shown when there are multiple programmable methdos).
tome_select_a_thang: "Selecciona a alguien para "
tome_available_spells: "Hechizos disponibles"
# tome_your_skills: "Your Skills"
tome_your_skills: "Tus Habilidades"
hud_continue: "Continuar (pulsa Shift+Space)"
spell_saved: "Hechizo guardado"
skip_tutorial: "Saltar (esc)"
keyboard_shortcuts: "Atajos de teclado"
loading_ready: "¡Listo!"
# loading_start: "Start Level"
loading_start: "Iniciar Nivel"
time_current: "Ahora:"
time_total: "Máx:"
time_goto: "Ir a:"
@ -266,7 +266,7 @@ module.exports = nativeDescription: "español (ES)", englishDescription: "Spanis
tip_hardware_problem: "P: Cuantos programadores hacen falta para cambiar una bombilla? R: Ninguno, es un problema de hardware."
# tip_hofstadters_law: "Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law."
# tip_premature_optimization: "Premature optimization is the root of all evil. - Donald Knuth"
# tip_brute_force: "When in doubt, use brute force. - Ken Thompson"
tip_brute_force: "Cuando haya dudas, usa la fuerza bruta. - Ken Thompson"
customize_wizard: "Personalizar Mago"
game_menu:
@ -286,14 +286,14 @@ module.exports = nativeDescription: "español (ES)", englishDescription: "Spanis
# inventory:
# choose_inventory: "Equip Items"
# choose_hero:
# choose_hero: "Choose Your Hero"
# programming_language: "Programming Language"
# programming_language_description: "Which programming language do you want to use?"
# status: "Status"
# weapons: "Weapons"
# health: "Health"
# speed: "Speed"
choose_hero:
choose_hero: "Selecciona tu Heroe"
programming_language: "Lenguaje de Programación"
programming_language_description: "¿Qué lenguaje de programación deseas usar?"
status: "Estado"
weapons: "Armas"
health: "Salud"
speed: "Velocidad"
save_load:
granularity_saved_games: "Salvado"

View file

@ -28,3 +28,5 @@ module.exports =
'world:attacked-when-out-of-range': c.object {required: ['thang']},
replacedNoteChain: {type: 'array'}
thang: {type: 'object'}
'world:custom-script-trigger': {type: 'object'}

View file

@ -68,6 +68,10 @@ $stashWidth: $totalWidth - $equippedWidth - $stashMargin
border-color: #28f
@include box-shadow(0 0 10px #28f)
&.should-equip
background-color: #8fa
outline: 2px solid #8af
&.droppable
outline: 2px solid blue
@ -189,6 +193,14 @@ $stashWidth: $totalWidth - $equippedWidth - $stashMargin
.item-info:after
content: ' (available)'
&.should-equip
background-color: #8fa
outline: 2px solid #8af
.item-info:after
content: ' (drag to equip)'
font-weight: bold
&.equipped
background-color: #ff5

View file

@ -14,9 +14,9 @@ block modal-footer-content
if readyToRank
.ladder-submission-view
else if level.get('type') === 'ladder'
a.btn.btn-primary(href="/play/ladder/#{level.get('slug')}#my-matches", data-dismiss="modal", data-i18n="play_level.victory_go_ladder") Return to Ladder
a.btn.btn-primary(href="/play/ladder/#{level.get('slug')}#my-matches", data-dismiss="modal", data-i18n="play_level.victory_return_to_ladder") Return to Ladder
else if level.get('type', true) === 'hero'
a.btn.btn-success.world-map-button(href="/play-hero", data-dismiss="modal", data-i18n="play_level.victory_continue") Continue
a.btn.btn-success.world-map-button(href="/play-hero", data-dismiss="modal", data-i18n="play_level.victory_play_continue") Continue
else if hasNextLevel
button.btn.btn-success.next-level-button(data-dismiss="modal", data-i18n="play_level.victory_play_next_level") Play Next Level
else

View file

@ -29,7 +29,7 @@ module.exports = class InventoryView extends CocoView
@items = new CocoCollection([], {model: ThangType})
@equipment = options.equipment or @options.session?.get('heroConfig')?.inventory or me.get('heroConfig')?.inventory or {}
@equipment = $.extend true, {}, @equipment
@assignLevelEquipment()
@requireLevelEquipment()
@items.url = '/db/thang.type?view=items&project=name,components,original,rasterIcon'
@supermodel.loadCollection(@items, 'items')
@ -103,25 +103,44 @@ module.exports = class InventoryView extends CocoView
for itemSlot in @$el.find '.item-slot'
slot = $(itemSlot).data 'slot'
#$(itemSlot).find('.placeholder').css('background-image', "url(/images/pages/game-menu/slot-#{slot}.png)")
do (slot) =>
do (slot, itemSlot) =>
$(itemSlot).droppable
drop: (e, ui) => @onAvailableItemDoubleClick()
accept: (el) -> $(el).parent().hasClass slot
activeClass: 'droppable'
hoverClass: 'droppable-hover'
tolerance: 'touch'
@makeEquippedSlotDraggable $(itemSlot)
@$el.find('#selected-items').hide() # Hide until one is selected
@delegateEvents()
if @selectedHero and not @startedLoadingFirstHero
@loadHero()
@requireLevelEquipment()
afterInsert: ->
super()
@canvasWidth = @$el.find('canvas').innerWidth()
@canvasHeight = @$el.find('canvas').innerHeight()
@inserted = true
makeEquippedSlotDraggable: (slot) ->
unequip = => @unequipItemFromSlot slot
shouldStayEquippedWhenDropped = (isValidDrop) ->
pos = $(@).position()
revert = Math.abs(pos.left) < $(@).outerWidth() and Math.abs(pos.top) < $(@).outerHeight()
unequip() if not revert
revert
# TODO: figure out how to make this actually above the available items list (the .ui-draggable-helper img is still inside .item-view and so underlaps...)
$(slot).find('img').draggable
revert: shouldStayEquippedWhenDropped
appendTo: @$el
cursorAt: {left: 35.5, top: 35.5}
revertDuration: 200
distance: 10
scroll: false
zIndex: 100
clearSelection: ->
@$el.find('.item-slot.selected').removeClass 'selected'
@ -197,7 +216,10 @@ module.exports = class InventoryView extends CocoView
for el in @$el.find('#available-equipment .list-group-item')
itemID = $(el).find('.item-view').data('item-id')
if itemID is itemIDToUnequip
return $(el).removeClass('equipped')
unequipped = $(el).removeClass('equipped')
break
@requireLevelEquipment() if unequipped
return unequipped
equipSelectedItemToSlot: (slot) ->
selectedItemContainer = @getSelectedAvailableItemContainer()
@ -207,6 +229,8 @@ module.exports = class InventoryView extends CocoView
slotContainer.html(newItemHTML)
slotContainer.find('.item-view').data('item-id', selectedItemContainer.find('.item-view').data('item-id'))
@$el.find('.list-group-item').removeClass('active')
@makeEquippedSlotDraggable slot
@requireLevelEquipment()
onSelectionChanged: ->
@$el.find('.item-slot').show()
@ -290,7 +314,7 @@ module.exports = class InventoryView extends CocoView
config[slotName] = item.get('original')
config
assignLevelEquipment: ->
requireLevelEquipment: ->
# This is temporary, until we have a more general way of awarding items and configuring needed/locked items per level.
gear =
'simple-boots': '53e237bf53457600003e3f05'
@ -306,17 +330,37 @@ module.exports = class InventoryView extends CocoView
'shadow-guard': {feet: 'simple-boots'}
'true-names': {feet: 'simple-boots', 'right-hand': 'longsword'}
'the-raised-sword': {feet: 'simple-boots', 'right-hand': 'longsword', torso: 'leather-tunic'}
'the-first-kithmaze': {feet: 'simple-boots', 'right-hand': 'longsword', torso: 'leather-tunic', 'programming-book': 'programmaticon-i'}
'the-second-kithmaze': {feet: 'simple-boots', 'right-hand': 'longsword', torso: 'leather-tunic', 'programming-book': 'programmaticon-i'}
'new-sight': {feet: 'simple-boots', 'right-hand': 'longsword', torso: 'leather-tunic', 'programming-book': 'programmaticon-i'}
'lowly-kithmen': {feet: 'simple-boots', 'right-hand': 'longsword', torso: 'leather-tunic', 'programming-book': 'programmaticon-i', eyes: 'crude-glasses'}
'a-bolt-in-the-dark': {feet: 'simple-boots', 'right-hand': 'longsword', torso: 'leather-tunic', 'programming-book': 'programmaticon-i', eyes: 'crude-glasses'}
'the-first-kithmaze': {feet: 'simple-boots', 'programming-book': 'programmaticon-i'}
'the-second-kithmaze': {feet: 'simple-boots', 'programming-book': 'programmaticon-i'}
'new-sight': {'right-hand': 'longsword', 'programming-book': 'programmaticon-i'}
'lowly-kithmen': {feet: 'simple-boots', 'right-hand': 'longsword', 'programming-book': 'programmaticon-i', eyes: 'crude-glasses'}
'a-bolt-in-the-dark': {feet: 'simple-boots', 'right-hand': 'longsword', torso: 'leather-tunic', eyes: 'crude-glasses'}
'the-final-kithmaze': {feet: 'simple-boots', 'right-hand': 'longsword', torso: 'leather-tunic', 'programming-book': 'programmaticon-i', eyes: 'crude-glasses'}
'kithgard-gates': {feet: 'simple-boots', 'right-hand': 'builders-hammer', torso: 'leather-tunic', 'programming-book': 'programmaticon-i', eyes: 'crude-glasses'}
'defence-of-plainswood': {feet: 'simple-boots', 'right-hand': 'builders-hammer', torso: 'leather-tunic', 'programming-book': 'programmaticon-i', eyes: 'crude-glasses'}
'kithgard-gates': {feet: 'simple-boots', 'right-hand': 'builders-hammer'}
'defence-of-plainswood': {feet: 'simple-boots', 'right-hand': 'builders-hammer'}
# TODO: figure out leather boots for plainswood (or next one?)
return unless necessaryGear = gearByLevel[@options.levelID]
for slot, item of necessaryGear ? {}
@equipment[slot] ?= gear[item]
if @inserted
if @supermodel.finished()
equipment = @getCurrentEquipmentConfig() # Make sure @equipment is updated
else
equipment = @equipment
hadRequired = @remainingRequiredEquipment?.length
@remainingRequiredEquipment = []
@$el.find('.should-equip').removeClass('should-equip')
inWorldMap = $('#world-map-view').length
for slot, item of necessaryGear
continue if item is 'leather-tunic' and inWorldMap # Don't tell them they need it until they need it in the level
continue if equipment[slot] and not (item is 'builders-hammer' and @equipment[slot] is gear.longsword)
availableSlotSelector = "#available-equipment li[data-item-id='#{gear[item]}']"
@highlightElement availableSlotSelector, delay: 500, sides: ['right'], rotation: Math.PI / 2
@$el.find(availableSlotSelector).addClass 'should-equip'
@$el.find("#equipped div[data-slot='#{slot}']").addClass 'should-equip'
@remainingRequiredEquipment.push slot: slot, item: gear[item]
if hadRequired and not @remainingRequiredEquipment.length
@endHighlight()
@highlightElement (if inWorldMap then '#play-level-button' else '.overlaid-close-button'), duration: 5000
$('#play-level-button').prop('disabled', @remainingRequiredEquipment.length > 0)
# Restrict available items to those that would be available by this item.
@allowedItems = []
@ -370,7 +414,9 @@ module.exports = class InventoryView extends CocoView
onShown: ->
# Called when we switch tabs to this within the modal
@requireLevelEquipment()
@loadHero()
onHidden: ->
# Called when the modal itself is dismissed
@endHighlight()

View file

@ -60,6 +60,7 @@ module.exports = class CocoView extends Backbone.View
view.destroy() for id, view of @subviews
$('#modal-wrapper .modal').off 'hidden.bs.modal', @modalClosed
@endHighlight()
@getPointer(false).remove()
@[key] = undefined for key, value of @
@destroyed = true
@off = doNothing
@ -354,16 +355,17 @@ module.exports = class CocoView extends Backbone.View
setTimeout (=> $pointer.css transition: 'all 0.4s ease-in', transform: "rotate(#{@pointerRotation}rad) translate(-3px, #{@pointerRadialDistance}px)"), 800
endHighlight: ->
@getPointer().css('opacity', 0.0)
@getPointer(false).css('opacity', 0.0)
clearInterval @pointerInterval
clearTimeout @pointerDelayTimeout
clearTimeout @pointerDurationTimeout
@pointerInterval = @pointerDelayTimeout = @pointerDurationTimeout = null
getPointer: ->
return $pointer if ($pointer = @$el.find('.highlight-pointer')) and $pointer.length
$pointer = $('<img src="/images/level/pointer.png" class="highlight-pointer">')
@$el.append($pointer)
getPointer: (add=true) ->
return $pointer if ($pointer = $(".highlight-pointer[data-cid='#{@cid}']")) and ($pointer.length or not add)
$pointer = $("<img src='/images/level/pointer.png' class='highlight-pointer' data-cid='#{@cid}'>")
$pointer.css('z-index', 1040) if @$el.parents('#modal-wrapper').length
$('body').append($pointer)
$pointer
# Utilities

View file

@ -430,7 +430,7 @@ module.exports = class PlayLevelView extends RootView
viewArgs: [{supermodel: @supermodel, autoUnveil: true}, @levelID]
}
onWindowResize: (e) -> @endHighlight()
onWindowResize: (e) => @endHighlight()
onDisableControls: (e) ->
return if e.controls and not ('level' in e.controls)

View file

@ -656,6 +656,8 @@ module.exports = class SpellView extends CocoView
session.addGutterDecoration index, 'comment-line'
onAnnotationClick: ->
# @ is the gutter element
msg = "Edit line #{$(@).index() + 1} to fix it."
alertBox = $("<div class='alert alert-info fade in'>#{msg}</div>")
offset = $(@).offset()
offset.left -= 162 # default width of the Bootstrap alert here

View file

@ -64,7 +64,7 @@ module.exports = class PlayLevelModal extends ModalView
updateConfig: (callback, skipSessionSave) ->
sessionHeroConfig = @options.session.get('heroConfig') ? {}
lastHeroConfig = me.get('heroConfig') ? {}
thangType = @subviews.choose_hero_view.selectedHero.get 'original'
thangType = @subviews.choose_hero_view.selectedHero?.get('original') ? sessionHeroConfig.thangType ? lastHeroConfig.thangType
inventory = @subviews.inventory_view.getCurrentEquipmentConfig()
patchSession = patchMe = false
props = thangType: thangType, inventory: inventory
@ -101,6 +101,7 @@ module.exports = class PlayLevelModal extends ModalView
@chooseHeroView.onShown()
onClickPlayLevel: (e) ->
return if @$el.find('#play-level-button').prop 'disabled'
@showLoading()
@updateConfig =>
@navigatingToPlay = true