mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-03-13 22:49:51 -04:00
Pre-assigning and limiting owned items based on level for now.
This commit is contained in:
parent
e1790d5159
commit
389f6fb9c1
4 changed files with 60 additions and 40 deletions
|
@ -77,11 +77,12 @@ $stashWidth: $totalWidth - $equippedWidth - $stashMargin
|
|||
height: 100%
|
||||
background-size: cover
|
||||
border: 2px solid #888
|
||||
@include opacity(0.75)
|
||||
|
||||
&[data-slot="waist"], &[data-slot="pet"], &[data-slot="minion"], &[data-slot="misc-1"]
|
||||
// My spooging of the other placeholders had them dimmed; these didn't.
|
||||
.placeholder
|
||||
@include opacity(0.5)
|
||||
@include opacity(0.35)
|
||||
border-color: black
|
||||
&.selected
|
||||
&[data-slot="waist"], &[data-slot="pet"], &[data-slot="minion"], &[data-slot="misc-1"]
|
||||
|
@ -151,16 +152,18 @@ $stashWidth: $totalWidth - $equippedWidth - $stashMargin
|
|||
border: 2px solid #ccc
|
||||
padding: 4px
|
||||
background-color: white
|
||||
|
||||
|
||||
h3
|
||||
margin-bottom: 5px
|
||||
|
||||
.list-group-item.active
|
||||
background-color: #e0f0f5
|
||||
|
||||
.list-group-item.equipped
|
||||
display: none
|
||||
.list-group-item
|
||||
padding: 8px 0
|
||||
img
|
||||
width: 50px
|
||||
height: 50px
|
||||
margin-right: 5px
|
||||
|
||||
&.active
|
||||
background-color: #e0f0f5
|
||||
&.equipped
|
||||
display: none
|
||||
|
||||
.item-view
|
||||
cursor: pointer
|
||||
|
@ -187,7 +190,7 @@ $stashWidth: $totalWidth - $equippedWidth - $stashMargin
|
|||
height: -webkit-calc(50% - $selectedItemMargin / 2)
|
||||
height: calc(50% - $selectedItemMargin / 2)
|
||||
width: 100%
|
||||
padding: 20px 10px 10px 10px
|
||||
padding: 10px 5px 10px 10px
|
||||
|
||||
img
|
||||
margin-top: 21px
|
||||
|
@ -199,6 +202,10 @@ $stashWidth: $totalWidth - $equippedWidth - $stashMargin
|
|||
|
||||
#selected-equipped-item
|
||||
margin-bottom: $selectedItemMargin
|
||||
padding-bottom: 20px
|
||||
|
||||
#selected-available-item
|
||||
padding-top: 15px
|
||||
|
||||
#swap-button
|
||||
position: absolute
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
.placeholder
|
||||
.item-container
|
||||
if equipment[slot]
|
||||
.replace-me(data-item-id=equipment[slot].id)
|
||||
.replace-me(data-item-id=equipment[slot].get('original'))
|
||||
|
||||
.item-slot-column.pull-left
|
||||
for slot in ['torso', 'gloves', 'left-hand', 'minion']
|
||||
|
@ -13,10 +13,9 @@
|
|||
.placeholder
|
||||
.item-container
|
||||
if equipment[slot]
|
||||
.replace-me(data-item-id=equipment[slot].id)
|
||||
.replace-me(data-item-id=equipment[slot].get('original'))
|
||||
|
||||
.hero-container
|
||||
//(data-hero-id=hero.get('original'))
|
||||
canvas.equipped-hero-canvas
|
||||
#selected-items
|
||||
#selected-equipped-item.well
|
||||
|
@ -32,7 +31,7 @@
|
|||
.placeholder
|
||||
.item-container
|
||||
if equipment[slot]
|
||||
.replace-me(data-item-id=equipment[slot].id)
|
||||
.replace-me(data-item-id=equipment[slot].get('original'))
|
||||
|
||||
hr.slot-row-separator
|
||||
|
||||
|
@ -42,26 +41,10 @@
|
|||
.placeholder
|
||||
.item-container
|
||||
if equipment[slot]
|
||||
.replace-me(data-item-id=equipment[slot].id)
|
||||
|
||||
|
||||
//- for (var i=0; i < slots.length; i += 3) {
|
||||
// div
|
||||
// - for (var j=i; j < slots.length && j < i + 3; j++) {
|
||||
// - var slot = slots[j];
|
||||
// div.panel.panel-default.item-slot(data-slot=slot)
|
||||
// .panel-heading
|
||||
// .panel-title.slot-name= slot
|
||||
// .panel-body.slot-item
|
||||
// if equipment[slot]
|
||||
// - var item = equipment[slot]
|
||||
// .replace-me(data-item-id=item.id)
|
||||
// - }
|
||||
// .clearfix
|
||||
//- }
|
||||
.replace-me(data-item-id=equipment[slot].get('original'))
|
||||
|
||||
#available-equipment
|
||||
h4#stash-description
|
||||
for item in items
|
||||
.list-group-item(class=item.classes, data-item-id=item.id)
|
||||
.list-group-item(class=item.classes, data-item-id=item.get('original'))
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
img(src=item.getPortraitURL()).img-thumbnail
|
||||
img(src=item.getPortraitURL())
|
||||
div.item-info
|
||||
if includes.name
|
||||
strong= item.get('name')
|
||||
h4= item.get('name')
|
||||
if includes.stats || (includes.props && props.length)
|
||||
ul.list-unstyled
|
||||
if includes.stats
|
||||
|
|
|
@ -29,6 +29,7 @@ module.exports = class InventoryView extends CocoView
|
|||
super(arguments...)
|
||||
@items = new CocoCollection([], {model: ThangType})
|
||||
@equipment = options.equipment or @options.session?.get('heroConfig')?.inventory or me.get('heroConfig')?.inventory or {}
|
||||
@assignLevelEquipment()
|
||||
@items.url = '/db/thang.type?view=items&project=name,components,original,rasterIcon'
|
||||
@supermodel.loadCollection(@items, 'items')
|
||||
|
||||
|
@ -37,6 +38,7 @@ module.exports = class InventoryView extends CocoView
|
|||
super()
|
||||
|
||||
onLoaded: ->
|
||||
@items.models = _.filter(@items.models, (item) => item.get('original') in @allowedItems) if @allowedItems
|
||||
super()
|
||||
|
||||
getRenderData: (context={}) ->
|
||||
|
@ -59,7 +61,7 @@ module.exports = class InventoryView extends CocoView
|
|||
super()
|
||||
return unless @supermodel.finished()
|
||||
|
||||
keys = (item.id for item in @items.models)
|
||||
keys = (item.get('original') for item in @items.models)
|
||||
itemMap = _.zipObject keys, @items.models
|
||||
|
||||
# Fill in equipped items
|
||||
|
@ -78,19 +80,18 @@ module.exports = class InventoryView extends CocoView
|
|||
itemView.render()
|
||||
$(availableItemEl).append(itemView.$el)
|
||||
@registerSubView(itemView)
|
||||
dragHelper = itemView.$el.find('img').clone().removeClass('img-thumbnail').addClass('draggable-item')
|
||||
dragHelper = itemView.$el.find('img').clone().addClass('draggable-item')
|
||||
do (dragHelper, itemView) =>
|
||||
itemView.$el.draggable
|
||||
revert: 'invalid'
|
||||
appendTo: @$el
|
||||
cursorAt: {left: 35.5, top: 35.5}
|
||||
#distance: 10
|
||||
helper: -> dragHelper
|
||||
revertDuration: 200
|
||||
scroll: false
|
||||
zIndex: 100
|
||||
itemView.$el.on 'dragstart', =>
|
||||
@onAvailableItemClick target: itemView.$el.parent()
|
||||
@onAvailableItemClick target: itemView.$el.parent() unless itemView.$el.parent().hasClass 'active'
|
||||
|
||||
for itemSlot in @$el.find '.item-slot'
|
||||
slot = $(itemSlot).data 'slot'
|
||||
|
@ -101,7 +102,7 @@ module.exports = class InventoryView extends CocoView
|
|||
accept: (el) -> $(el).parent().hasClass slot
|
||||
activeClass: 'droppable'
|
||||
hoverClass: 'droppable-hover'
|
||||
tolerance: 'pointer'
|
||||
tolerance: 'touch'
|
||||
|
||||
@$el.find('#selected-items').hide() # Hide until one is selected
|
||||
@delegateEvents()
|
||||
|
@ -123,6 +124,7 @@ module.exports = class InventoryView extends CocoView
|
|||
@unselectAllAvailableEquipment() if slot.hasClass('disabled')
|
||||
if wasActive
|
||||
@hideSelectedSlotItem()
|
||||
@unselectAllAvailableEquipment()
|
||||
else
|
||||
@selectSlot(slot)
|
||||
@onSelectionChanged()
|
||||
|
@ -282,6 +284,34 @@ module.exports = class InventoryView extends CocoView
|
|||
config[slotName] = item.get('original')
|
||||
config
|
||||
|
||||
assignLevelEquipment: ->
|
||||
# This is temporary, until we have a more general way of awarding items and configuring needed/restricted items per level.
|
||||
gear =
|
||||
'simple-boots': '53e237bf53457600003e3f05'
|
||||
'longsword': '53e218d853457600003e3ebe'
|
||||
'leather-tunic': '53e22eac53457600003e3efc'
|
||||
'programmaticon-i': '53e4108204c00d4607a89f78'
|
||||
'crude-glasses': '53e238df53457600003e3f0b'
|
||||
'builders-hammer': '53f4e6e3d822c23505b74f42'
|
||||
gearByLevel =
|
||||
'dungeons-of-kithgard': {feet: 'simple-boots'}
|
||||
'gems-in-the-deep': {feet: 'simple-boots'}
|
||||
'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-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'}
|
||||
necessaryGear = gearByLevel[@options.levelID]
|
||||
for slot, item of necessaryGear ? {}
|
||||
@equipment[slot] ?= gear[item]
|
||||
@allowedItems = _.values gear if necessaryGear # If it's one of these levels, don't show the extra items.
|
||||
|
||||
onHeroSelectionUpdated: (e) ->
|
||||
@selectedHero = e.hero
|
||||
@loadHero()
|
||||
|
|
Loading…
Reference in a new issue