mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-28 01:55:38 -05:00
Layed the view framework for a new hero victory modal.
This commit is contained in:
parent
19e6b9d095
commit
1dda6bfcfc
4 changed files with 93 additions and 2 deletions
2
app/styles/play/level/modal/hero-victory-modal.sass
Normal file
2
app/styles/play/level/modal/hero-victory-modal.sass
Normal file
|
@ -0,0 +1,2 @@
|
|||
#hero-victory-modal
|
||||
color: red
|
34
app/templates/play/level/modal/hero-victory-modal.jade
Normal file
34
app/templates/play/level/modal/hero-victory-modal.jade
Normal file
|
@ -0,0 +1,34 @@
|
|||
extends /templates/modal/modal_base
|
||||
block modal-header-content
|
||||
h3
|
||||
span(data-i18n="play_level.victory_title_prefix")
|
||||
span= levelName
|
||||
span(data-i18n="play_level.victory_title_suffix") Complete
|
||||
|
||||
block modal-body-content
|
||||
h4 Achievements Unlocked
|
||||
|
||||
for achievement in achievements
|
||||
.panel
|
||||
img(src=achievement.getImageURL())
|
||||
h5= achievement.get('name')
|
||||
p= achievement.get('description')
|
||||
if achievement.completed
|
||||
strong Completed
|
||||
else
|
||||
strong Incomplete
|
||||
p Earned #{achievement.get('worth')} xp.
|
||||
- var rewards = achievement.get('rewards') || {};
|
||||
if rewards.gems
|
||||
p Earned #{achievement.get('rewards').gems} gems.
|
||||
if rewards.heroes
|
||||
for hero in rewards.heroes
|
||||
- var hero = thangTypes[hero];
|
||||
img(src=hero.getPortraitURL())
|
||||
if rewards.items
|
||||
for item in rewards.items
|
||||
- var item = thangTypes[item];
|
||||
img(src=item.getPortraitURL())
|
||||
|
||||
block modal-footer-content
|
||||
| footer
|
|
@ -32,6 +32,7 @@ GoalsView = require './LevelGoalsView'
|
|||
LevelFlagsView = require './LevelFlagsView'
|
||||
GoldView = require './LevelGoldView'
|
||||
VictoryModal = require './modal/VictoryModal'
|
||||
HeroVictoryModal = require './modal/HeroVictoryModal'
|
||||
InfiniteLoopModal = require './modal/InfiniteLoopModal'
|
||||
GameMenuModal = require 'views/game-menu/GameMenuModal'
|
||||
|
||||
|
@ -196,6 +197,11 @@ module.exports = class PlayLevelView extends RootView
|
|||
@insertSubviews()
|
||||
@initVolume()
|
||||
@listenTo(@session, 'change:multiplayer', @onMultiplayerChanged)
|
||||
|
||||
# testing
|
||||
# modal = new HeroVictoryModal({session: @session, level: @level})
|
||||
# @openModalView(modal)
|
||||
|
||||
@originalSessionState = $.extend(true, {}, @session.get('state'))
|
||||
@register()
|
||||
@controlBar.setBus(@bus)
|
||||
|
@ -450,8 +456,10 @@ module.exports = class PlayLevelView extends RootView
|
|||
|
||||
showVictory: ->
|
||||
options = {level: @level, supermodel: @supermodel, session: @session}
|
||||
docs = new VictoryModal(options)
|
||||
@openModalView(docs)
|
||||
# ModalClass = if @level.get('type', true) is 'hero' then HeroVictoryModal else VictoryModal
|
||||
# victoryModal = new ModalClass(options)
|
||||
victoryModal = new VictoryModal(options)
|
||||
@openModalView(victoryModal)
|
||||
if me.get('anonymous')
|
||||
window.nextLevelURL = @getNextLevelURL() # Signup will go here on completion instead of reloading.
|
||||
|
||||
|
|
47
app/views/play/level/modal/HeroVictoryModal.coffee
Normal file
47
app/views/play/level/modal/HeroVictoryModal.coffee
Normal file
|
@ -0,0 +1,47 @@
|
|||
ModalView = require 'views/kinds/ModalView'
|
||||
template = require 'templates/play/level/modal/hero-victory-modal'
|
||||
Achievement = require 'models/Achievement'
|
||||
CocoCollection = require 'collections/CocoCollection'
|
||||
LocalMongo = require 'lib/LocalMongo'
|
||||
utils = require 'lib/utils'
|
||||
ThangType = require 'models/ThangType'
|
||||
|
||||
module.exports = class UnnamedView extends ModalView
|
||||
id: 'hero-victory-modal'
|
||||
template: template
|
||||
|
||||
constructor: (options) ->
|
||||
super(options)
|
||||
@session = options.session
|
||||
@level = options.level
|
||||
achievements = new CocoCollection([], {
|
||||
url: "/db/achievement?related=#{@session.get('level').original}"
|
||||
model: Achievement
|
||||
})
|
||||
@thangTypes = {}
|
||||
@achievements = @supermodel.loadCollection(achievements, 'achievements').model
|
||||
@listenToOnce @achievements, 'sync', @onAchievementsLoaded
|
||||
|
||||
onAchievementsLoaded: ->
|
||||
thangTypeOriginals = []
|
||||
for achievement in @achievements.models
|
||||
rewards = achievement.get('rewards')
|
||||
console.log 'rewards', rewards
|
||||
thangTypeOriginals.push rewards.heroes or []
|
||||
thangTypeOriginals.push rewards.items or []
|
||||
thangTypeOriginals = _.uniq _.flatten thangTypeOriginals
|
||||
console.log 'thang type originals?', thangTypeOriginals
|
||||
for thangTypeOriginal in thangTypeOriginals
|
||||
thangType = new ThangType()
|
||||
thangType.url = "/db/thang.type/#{thangTypeOriginal}/version"
|
||||
thangType.project = ['original', 'rasterIcon']
|
||||
@thangTypes[thangTypeOriginal] = @supermodel.loadModel(thangType, 'thang').model
|
||||
|
||||
getRenderData: ->
|
||||
c = super()
|
||||
c.levelName = utils.i18n @level.attributes, 'name'
|
||||
for achievement in @achievements.models
|
||||
achievement.completed = LocalMongo.matchesQuery(@session.attributes, achievement.get('query'))
|
||||
c.achievements = @achievements.models
|
||||
c.thangTypes = @thangTypes
|
||||
return c
|
Loading…
Reference in a new issue