include ./quest-rewards
include ../mixins
include ../avatar/generated_avatar

mixin questInfo
  .pull-right-sm.text-center
    .col-centered(class='quest_{{::selectedQuest.key}}')
    div(ng-if='::selectedQuest.boss')
      h4 {{::selectedQuest.boss.name()}}
      .well.well-sm
        p
          strong=env.t('bossHP') + ': '
          | {{::selectedQuest.boss.hp}}
        p
          strong=env.t('bossStrength') + ': '
          | {{::selectedQuest.boss.str}}
    div(ng-if='::selectedQuest.collect')
      h4=env.t('itemsToCollect')
      .well.well-sm
        p(ng-repeat='(k,v) in ::selectedQuest.collect')
          | {{:: env.t('collectionItems', { number: selectedQuest.collect[k].count, items: selectedQuest.collect[k].text() })}}
  div(ng-bind-html='::selectedQuest.notes()')
  quest-rewards(key='{{::selectedQuest.key}}', header=env.t('rewards'))

script(type='text/ng-template', id='modals/questCompleted.html')
  .modal-header
    h4 "{{::Content.quests[user.party.quest.completed].text()}}"
      =env.t('completed')
  .modal-body
    .col-centered(ng-class='::Content.quests[user.party.quest.completed].completion() ? "pull-right-sm" : ""', class='quest_{{user.party.quest.completed}}')
    p(ng-bind-html='::Content.quests[user.party.quest.completed].completion()')
    quest-rewards(key='{{user.party.quest.completed}}', header=env.t('youReceived'))
  .modal-footer
    button.btn.btn-primary(ng-click='set({"party.quest.completed":""}); $close()')=env.t('ok')

script(type='text/ng-template', id='modals/showQuest.html')
  .modal-header
    h4 {{::selectedQuest.text()}}
  .modal-body
    +questInfo
    hr
    div(class="#{env.worldDmg.quests ? 'npc_ian_broken' : 'npc_ian'}").pull-left
    p(ng-if='!env.worldDmg.quests')=env.t('questSend')
    p(ng-if='!env.worldDmg.quests')=env.t('questWarning')
    p(ng-if='env.worldDmg.quests')=env.t('questSendBroken')
    p(ng-if='env.worldDmg.quests')=env.t('questWarningBroken')
  .modal-footer
    button.btn.btn-default(ng-click='closeQuest(); $close()')=env.t('cancel')
    button.btn.btn-primary(ng-click='questInit()')
      | {{:: party.memberCount > 1  ? env.t('inviteParty') : env.t('startQuest')}}

script(type='text/ng-template', id='modals/buyQuest.html')
  .modal-header
    h4 {{::selectedQuest.text()}}
  .modal-body
    +questInfo
  .modal-footer
    button.btn.btn-default(ng-click='closeQuest(); $close()')=env.t('neverMind')
    button.btn.btn-primary(ng-if='::selectedQuest.category !== "gold"', ng-click='purchase("quests", quest); closeQuest(); $close()')=env.t('buyQuest') + ': {{::selectedQuest.value}} ' + env.t('gems')
    button.btn.btn-primary(ng-if='::selectedQuest.category === "gold"', ng-click='User.buyQuest({params:{key:selectedQuest.key}}); closeQuest(); $close()')=env.t('buyQuest') + ': {{::selectedQuest.goldValue}} ' + env.t('gold')

script(type='text/ng-template', id='modals/questInvitation.html')
  .modal-header
    h4=env.t('questInvitation')
      |&nbsp;{{::Content.quests[user.party.quest.key].text()}}
  .modal-body
    .pull-right-sm.text-center
      .col-centered(class='quest_{{::Content.quests[user.party.quest.key].key}}')
      div(ng-if='::Content.quests[user.party.quest.key].boss')
        h4 {{::Content.quests[user.party.quest.key].boss.name()}}
        p
          strong=env.t('bossHP') + ': '
          | {{::Content.quests[user.party.quest.key].boss.hp}}
        p
          strong=env.t('bossStrength') + ': '
          | {{::Content.quests[user.party.quest.key].boss.str}}
      div(ng-if='::Content.quests[user.party.quest.key].collect')
        p(ng-repeat='(k,v) in ::Content.quests[user.party.quest.key].collect')
          strong=env.t('collect') + ': '
          | {{::Content.quests[user.party.quest.key].collect[k].count}} {{::Content.quests[user.party.quest.key].collect[k].text()}}
    div(ng-bind-html='::Content.quests[user.party.quest.key].notes()')
    quest-rewards(key='{{::user.party.quest.key}}', header=env.t('rewards'))
  .modal-footer
    button.btn.btn-default(ng-click='questHold = true; $close()')=env.t('askLater')
    button.btn.btn-default(ng-click='questReject(); $close()')=env.t('reject')
    button.btn.btn-primary(ng-click='questAccept(); $close()')=env.t('accept')

script(type='text/ng-template', id='modals/questDrop.html')
  - var tweet = env.t('questUnlockShare');
  .modal-content(style='min-width:28em')
    .modal-body.text-center
      h3=env.t('unlockedAQuest')
      p {{::selectedQuest.text()}}
      .container-fluid
        .row(style='margin-bottom:1em', ng-controller='UserCtrl')
          .col-xs-4(style='padding:0')
            .herobox(style='padding:0; width: 0; height: 0')
              .character-sprites(style='width:0')
                +generatedAvatar
          .col-xs-4(style='padding:0')
            .herobox(style='width: 6.7em; height: 5em; position: absolute')
              .avatar-level(ng-class='userLevelStyle(user)')=env.t('level')+' {{user.stats.lvl}}'
          .col-xs-4(style='margin-top:1.5em')
            .quest-icon(class='inventory_quest_scroll_{{::selectedQuest.key}}')
      h4!=env.t('leveledUpReceivedQuest', {level:'{{user.stats.lvl}}'})
      .row(style='margin-top:2em')
        button.btn.btn-primary(ng-click='inviteOrStartParty(party); $close()', ng-if='!User.user.party._id')=env.t('startAParty')
        button.btn.btn-primary(ng-click='inviteOrStartParty(party); $close()', ng-if='!User.user.party._id && !party.members')=env.t('battleWithFriends')
        button.btn.btn-primary(ng-click='questInit(); $close()', ng-if='party.members')=env.t('inviteParty')
        button.btn.btn-default(ng-click='closeQuest(); $close()')=env.t('questLater')
    .modal-footer(style='margin-top:0', ng-init='loadWidgets()')
      .container-fluid
        .row
          .col-xs-3
            a.twitter-share-button(href='https://twitter.com/intent/tweet?text=#{tweet}&via=habitica&url=#{env.BASE_URL}/social/unlock-quest&count=none')=env.t('tweet')
          .col-xs-4(style='margin-left:.8em')
            .fb-share-button(data-href='#{env.BASE_URL}/social/unlock-quest', data-layout='button')
          .col-xs-4(style='margin-left:.8em')
            a.tumblr-share-button(data-href='#{env.BASE_URL}/social/unlock-quest', data-notes='none')

script(type='text/ng-template', id='modals/ownedQuests.html')
  .modal-header
    h4=env.t('whichQuestStart')
  .modal-body
    +ownedQuests(false,'top')
  .modal-footer
    h4.pull-left
      a(ui-sref='options.inventory.quests', ng-click='$close()')=env.t('getMoreQuests')
    button.btn.btn-default.pull-right(ng-click='$close()')=env.t('neverMind')
