mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-23 15:48:11 -05:00
Fixtures set up, demo start
This commit is contained in:
parent
b5702bc314
commit
9055612b24
8 changed files with 61 additions and 5 deletions
|
@ -1,4 +1,6 @@
|
||||||
CocoCollection = require 'collections/CocoCollection'
|
CocoCollection = require 'collections/CocoCollection'
|
||||||
|
Achievement = require 'models/Achievement'
|
||||||
|
|
||||||
module.exports = class AchievementCollection extends CocoCollection
|
module.exports = class AchievementCollection extends CocoCollection
|
||||||
url: '/db/achievement'
|
url: '/db/achievement'
|
||||||
|
model: Achievement
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
CocoCollection = require 'collections/CocoCollection'
|
CocoCollection = require 'collections/CocoCollection'
|
||||||
|
EarnedAchievement = require 'models/EarnedAchievement'
|
||||||
|
|
||||||
module.exports = class EarnedAchievementCollection extends CocoCollection
|
module.exports = class EarnedAchievementCollection extends CocoCollection
|
||||||
|
model: EarnedAchievement
|
||||||
|
|
||||||
initialize: (me = require('lib/auth').me) ->
|
initialize: (me = require('lib/auth').me) ->
|
||||||
@url = "/db/user/#{me.id}/achievements"
|
@url = "/db/user/#{me.id}/achievements"
|
||||||
|
|
|
@ -60,8 +60,6 @@ module.exports = class SuperModel extends Backbone.Model
|
||||||
@addCollection collection
|
@addCollection collection
|
||||||
@listenTo collection, 'sync', (c) ->
|
@listenTo collection, 'sync', (c) ->
|
||||||
console.debug 'Registering collection', url
|
console.debug 'Registering collection', url
|
||||||
console.debug c
|
|
||||||
console.debug collection
|
|
||||||
@registerCollection c
|
@registerCollection c
|
||||||
res = @addModelResource(collection, name, fetchOptions, value)
|
res = @addModelResource(collection, name, fetchOptions, value)
|
||||||
res.load() if not (res.isLoading or res.isLoaded)
|
res.load() if not (res.isLoading or res.isLoaded)
|
||||||
|
|
|
@ -111,7 +111,7 @@ module.exports = class AchievementEditView extends View
|
||||||
|
|
||||||
recalculateAchievement: =>
|
recalculateAchievement: =>
|
||||||
$.ajax
|
$.ajax
|
||||||
data: JSON.stringify(achievements: [@achievement.get('slug') or @achievement.get('_id')])
|
data: JSON.stringify(earnedAchievements: [@achievement.get('slug') or @achievement.get('_id')])
|
||||||
success: (data, status, jqXHR) ->
|
success: (data, status, jqXHR) ->
|
||||||
noty
|
noty
|
||||||
timeout: 5000
|
timeout: 5000
|
||||||
|
|
|
@ -25,3 +25,8 @@ module.exports = class UserView extends RootView
|
||||||
isMe: -> @nameOrID is me.id
|
isMe: -> @nameOrID is me.id
|
||||||
|
|
||||||
onUserLoaded: ->
|
onUserLoaded: ->
|
||||||
|
console.log 'onUserLoaded'
|
||||||
|
|
||||||
|
onLoaded: ->
|
||||||
|
console.log 'onLoaded'
|
||||||
|
super()
|
||||||
|
|
|
@ -17,4 +17,6 @@ module.exports = class UserAchievementsView extends UserView
|
||||||
super options, nameOrID
|
super options, nameOrID
|
||||||
|
|
||||||
onUserLoaded: (user) ->
|
onUserLoaded: (user) ->
|
||||||
@achievements = @supermodel.loadCollection(new AchievementCollection(@user), 'achievements').model
|
super user
|
||||||
|
@earnedAchievements = @supermodel.loadCollection(new EarnedAchievementCollection(@user), 'achievements').model
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
module.exports.DungeonArenaStarted =
|
now = new Date()
|
||||||
|
oneDayBefore = (new Date now).setDate(now.getDate() - 1)
|
||||||
|
|
||||||
|
module.exports.DungeonArenaStarted = DungeonArenaStarted =
|
||||||
|
_id: '53ba76249259823746b6b481'
|
||||||
name: 'Dungeon Arena Started'
|
name: 'Dungeon Arena Started'
|
||||||
description: 'Started playing Dungeon Arena. '
|
description: 'Started playing Dungeon Arena. '
|
||||||
worth: 3
|
worth: 3
|
||||||
|
@ -6,3 +10,40 @@ module.exports.DungeonArenaStarted =
|
||||||
query: "{\"level.original\":\"dungeon-arena\"}"
|
query: "{\"level.original\":\"dungeon-arena\"}"
|
||||||
userField: 'creator'
|
userField: 'creator'
|
||||||
|
|
||||||
|
module.exports.Simulated = Simulated =
|
||||||
|
_id: '53ba76249259823746b6b482'
|
||||||
|
name: 'Simulated'
|
||||||
|
description: 'Simulated Games.'
|
||||||
|
worth: 1
|
||||||
|
collection: 'users'
|
||||||
|
query: "{\"simulatedBy\":{\"$gt\":0}}"
|
||||||
|
userField: '_id'
|
||||||
|
proportionalTo: 'simulatedBy'
|
||||||
|
|
||||||
|
module.exports.DungeonArenaStartedEarned = DungeonArenaStartedEarned =
|
||||||
|
user: ''
|
||||||
|
achievement: DungeonArenaStarted._id
|
||||||
|
collection: DungeonArenaStarted.collection
|
||||||
|
achievementName: DungeonArenaStarted.name
|
||||||
|
created: now
|
||||||
|
changed: now
|
||||||
|
achievedAmount: 1
|
||||||
|
earnedPoints: 3
|
||||||
|
previouslyAchievedAmount: 0
|
||||||
|
notified: true
|
||||||
|
|
||||||
|
module.exports.SimulatedEarned = SimulatedEarned =
|
||||||
|
user: ''
|
||||||
|
achievement: Simulated._id
|
||||||
|
collection: Simulated.collection
|
||||||
|
achievementName: Simulated.name
|
||||||
|
created: now
|
||||||
|
changed: now
|
||||||
|
achievedAmount: 6
|
||||||
|
earnedPoints: 6
|
||||||
|
previouslyAchievedAmount: 5
|
||||||
|
notified: true
|
||||||
|
|
||||||
|
|
||||||
|
module.exports.achievements = [DungeonArenaStarted, Simulated]
|
||||||
|
module.exports.earnedAchievements = [DungeonArenaStartedEarned, SimulatedEarned]
|
||||||
|
|
|
@ -9,4 +9,10 @@ fixtures = require '../../fixtures/achievements'
|
||||||
|
|
||||||
module.exports = ->
|
module.exports = ->
|
||||||
view = new UserAchievementsView {}, me.get '_id'
|
view = new UserAchievementsView {}, me.get '_id'
|
||||||
|
|
||||||
|
request = jasmine.Ajax.requests.mostRecent()
|
||||||
|
request.response
|
||||||
|
status: 200
|
||||||
|
responseText: JSON.stringify fixtures.earnedAchievements
|
||||||
|
|
||||||
view.render()
|
view.render()
|
||||||
|
|
Loading…
Reference in a new issue