uonline/uonline

View on GitHub
views/inventory.jade

Summary

Maintainability
Test Coverage
mixin item(x, button, renderType)
    | #{ x.name }
    | #{' '}
    if button === 'unequip'
        +post('/action/unequip', {id: x.id}, true)
            button.btn.btn-default.btn-xs
                span.glyphicon.glyphicon-chevron-left
                | #{' '}
                | Снять
    if button === 'equip'
        +post('/action/equip', {id: x.id}, true)
            button.btn.btn-default.btn-xs
                span.glyphicon.glyphicon-chevron-right
                | #{' '}
                | Надеть
    if renderType
        br
        span.text-muted
            | #{x.type}
            if !!x.class
                | , #{x.class}, #{x.kind}
            if !!x.armor_class
                | , #{x.armor_class}
    br
    span(class=(x.strength===0?'text-danger':''))
        span.glyphicon.glyphicon-cog(title='Прочность')
        | #{' '}
        | #{ x.strength }/#{ x.strength_max }
    if x.type !== 'weapon-one-handed' && x.type !== 'weapon-two-handed'
        | #{' '} #{' '}
        span.glyphicon.glyphicon-stop(title='Покрытие тела')
        | #{' '}
        | #{ x.coverage }%
        if x.type === 'shield'
            - var size = 'средний'
            if x.coverage > 45
                - size = 'большой'
            if x.damage > 0
                - size = 'малый'
            | #{' '}
            span.text-muted (#{size})
    if x.damage > 0
        | #{' '} #{' '}
        span.glyphicon.glyphicon-tint(title='Бонус к урону при ударе')
        //- | #{' '}
        | #{ x.damage }

mixin slot(types, title, capacity)
    - if (typeof(types) === 'string') { types = [types]; }
    - if (!capacity) capacity = 1
    - var items;
    - items = equipment.filter(function(x){ return types.indexOf(x.type) >= 0 })
    //- ...and render
    tr
        td(class=(items.length > 0 ? 'text-warning':'text-muted'))
            | #{title}
            if capacity > 1
                | #{' '}
                | (#{items.length}/#{capacity})
        td
            if items.length == 0
                | -

            each x in items
                div.paragraph
                    +item(x, 'unequip', true)


extends layout
block title
    | Инвентарь
block content
    div.page-header
        h1 Инвентарь
    if character.fight_mode == true
        a.pjax.btn.btn-default(href='/game/')
            i.glyphicon.glyphicon-chevron-left
            | #{' '}Вернуться в бой
        hr
    div.row
        div.col-md-6
            if backpack.length === 0
                h3 Рюкзак
                p В рюкзаке ничего нет.
            else
                table.table.table-hover.table-condensed
                    thead: tr: td
                        h3 Рюкзак
                        p.text-muted
                            | #{backpack.length}
                            | #{' '}
                            | #{plural(backpack.length, ['предмет', 'предмета', 'предметов'])}
                    tbody
                        each x in backpack
                            tr
                                td
                                    +item(x, 'equip', true)
            //-p У вас в рюкзаке ничего нет. Это нормально, потому что на этом сервере нет предметов.
            //-p У вас в рюкзаке ничего нет.
            //-Собирайте предметы с убитых монстров, покупайте у торговцев и делайте сами из подручных материалов.
        div.col-md-6
            table.table.table-hover.table-condensed
                thead: tr: td(colspan=2): h3 Оружие
                tbody
                    +slot(['weapon-two-handed', 'weapon-one-handed'], 'Правая рука')
                    +slot(['weapon-two-handed', 'shield'], 'Левая рука')
            table.table.table-hover.table-condensed
                thead: tr: td(colspan=2): h3 Экипировка
                tbody
                    +slot('hat', 'Голова')
                    +slot('necklace', 'Шея', 3)
                    +slot('pouldron-left', 'Левое плечо')
                    +slot('pouldron-right', 'Правое плечо')
                    +slot('coat', 'Торс')
                    if character.race !== 'orc'
                        +slot('breastplate', 'Грудь')
                    +slot('belt', 'Пояс')
                    +slot('vambrace-left', 'Левое предплечье')
                    +slot('vambrace-right', 'Правое предплечье')
                    +slot('gloves', 'Руки')
                    +slot('ring', 'Пальцы', 10)
                    +slot('pants', 'Ноги')
                    +slot('cuisse', 'Бёдра')
                    +slot('chausses', 'Голени')
                    +slot('boots', 'Обувь')
            if character.race === 'orc'
                p
                    span.glyphicon.glyphicon-info-sign
                    | #{' '}
                    | В отличие от других рас, орки не носят нагрудников.
            h3 Читерская кнопка
            +post('/ajax/cheatFixAll', {}, true)
                button.btn.btn-default
                    span.glyphicon.glyphicon-cog
                    | #{' '}
                    | Починить все предметы всем игрокам