All files / app/component/backgammon backgammon.component.html

35.09% Statements 73/208
30.1% Branches 28/93
0% Functions 0/24
49.59% Lines 61/123

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 21420x                                                     10x 20x   20x   20x 10x   20x             10x 10x 20x   20x   20x 10x   20x             10x 10x 20x   20x     20x 10x   20x               10x 10x 20x   20x   20x 10x   20x               10x 20x     10x 20x             10x 10x 20x 10x     10x     10x             20x 10x     10x     10x       10x 10x 20x             10x 10x 20x 10x     10x     10x             20x 10x     10x     10x       10x 20x                                                     10x         10x         10x     10x        
@for (s of spots; track s.index) {
  <div class="backgammon-spot"
       [style.grid-column]="s.col > 6 ? s.col + 2 : s.col + 1"
       [style.grid-row]="s.top ? 1 : 2"
       [class.move]="s.move"
       [class.red]="s.red"
       [class.top]="s.top"
       [class.drag-source]="dragSource===s.index"
       cdkDropList
       [cdkDropListData]="s.index"
       (cdkDropListDropped)="drop($any($event))"
       (click)="onClick(s.index)"
       (contextmenu)="moveHighest($event, s.index)">
    @for (p of s.pieces; track pi; let pi = $index) {
      <div class="backgammon-piece"
           [class.stacked]="pi > 4"
           [class.double-stacked]="pi > 9"
           [class.hidden]="animatedPiece && animatedPiece.from === s.index && pi === s.pieces.length - 1"
           [class.glow]="pi >= s.pieces.length - (lastMovedSpots[s.index] || 0)"
           cdkDrag
           cdkDragBoundary=".backgammon-board"
           (cdkDragStarted)="onDragStarted(s.index)"
           (cdkDragExited)="dragSource = -1"
           [cdkDragData]="p">{{ drawPiece(p) }}</div>
    }
  </div>
}
<div class="backgammon-off black"
     [style.grid-column]="1"
     [style.grid-row]="1"
     [class.move]="moveBlackOff"
     cdkDropList
     [cdkDropListData]="-2"
     (cdkDropListDropped)="drop($any($event))"
     (click)="onClickOff()">
  @for (p of blackOff; track pi; let pi = $index) {
    <div class="backgammon-piece"
         [class.stacked]="pi > 4"
         [class.double-stacked]="pi > 9"
         [class.glow]="pi >= blackOff.length - (lastMovedOff['b'] || 0)"
         [class.translate]="turn === 'b' && translate === -2 && pi === blackOff.length - 1">{{ drawPiece(p) }}</div>
  }
</div>
<div class="backgammon-off red"
     [style.grid-column]="1"
     [style.grid-row]="2"
     [class.move]="moveRedOff"
     cdkDropList
     [cdkDropListData]="-2"
     (cdkDropListDropped)="drop($any($event))"
     (click)="onClickOff()">
  @for (p of redOff; track pi; let pi = $index) {
    <div class="backgammon-piece"
         [class.stacked]="pi > 4"
         [class.double-stacked]="pi > 9"
         [class.glow]="pi >= redOff.length - (lastMovedOff['r'] || 0)"
         [class.translate]="turn === 'r' && translate === -2 && pi === redOff.length - 1">{{ drawPiece(p) }}</div>
  }
</div>
<div class="backgammon-bar black"
     [style.grid-column]="8"
     [style.grid-row]="1"
     [class.move]="moves[-2]"
     [class.drag-source]="dragSource===-1"
     cdkDropList
     [cdkDropListData]="-1"
     (click)="onClickBar()"
     (contextmenu)="moveBarHighest($event)">
  @for (p of blackBar; track pi; let pi = $index) {
    <div class="backgammon-piece"
         [class.hidden]="animatedPiece && animatedPiece.from === -1 && animatedPiece.piece === 'b' && pi === blackBar.length - 1"
         cdkDrag
         cdkDragBoundary=".backgammon-board"
         (cdkDragStarted)="onDragStarted(-1)"
         [cdkDragData]="p">{{ drawPiece(p) }}</div>
  }
</div>
<div class="backgammon-bar red"
     [style.grid-column]="8"
     [style.grid-row]="2"
     [class.drag-source]="dragSource===-1"
     cdkDropList
     [cdkDropListData]="-1"
     (click)="onClickBar()"
     (contextmenu)="moveBarHighest($event)">
  @for (p of redBar; track p; let pi = $index) {
    <div class="backgammon-piece"
         [class.hidden]="animatedPiece && animatedPiece.from === -1 && animatedPiece.piece === 'r' && pi === redBar.length - 1"
         cdkDrag
         cdkDragBoundary=".backgammon-board"
         (cdkDragStarted)="onDragStarted(-1)"
         [cdkDragData]="p">{{ drawPiece(p) }}</div>
  }
</div>
@if (animatedPiece) {
  <div class="backgammon-piece animated-piece">{{ drawPiece(animatedPiece.piece) }}</div>
}
<div class="red dice bubble"
     [class.winner]="winner === 'r'"
     [class.backgammon]="winner === 'r' && backgammon"
     [class.gammon]="winner === 'r' && gammon"
     [class.clickme]="!winner && (first && turn === 'r' || !moves.length && turn === 'b')"
     [class.play]="moves.length && turn === 'r'"
     [class.rolling]="rolling === 'r'"
     [class.disabled]="winner || moves.length || redDice[0] && turn !== 'b'"
     (click)="roll('r')"
     i18n-title title="Red">
  @if (winner === 'r') {
    <div i18n>
      Red Wins
      @if (backgammon) {
        <span i18n-title title="Backgammon">🎲️🎲️🎲️</span>
      }
      @if (gammon && !backgammon) {
        <span i18n-title title="Gammon">🎲️🎲️</span>
      }
      @if (!gammon) {
        <span>��️</span>
      }
    </div>
  }
  @if (!redDice[0]) {
    <div i18n>🎲️ Roll</div>
  } @else {
    @if (redDice[0] && !redDice[1]) {
      <div i18n>{{ redDice[0] }}</div>
    } @else {
      @if (redDice[1]) {
        <div i18n>{{ redDice[0] }} - {{ redDice[1] }}</div>
      }
    }
  }
</div>
<div class="black dice bubble"
     [class.winner]="winner === 'b'"
     [class.backgammon]="winner === 'b' && backgammon"
     [class.gammon]="winner === 'b' && gammon"
     [class.clickme]="!winner && (first && turn === 'b' || !moves.length && turn === 'r')"
     [class.play]="moves.length && turn === 'b'"
     [class.rolling]="rolling === 'b'"
     [class.disabled]="winner || moves.length || blackDice[0] && turn !== 'r'"
     (click)="roll('b')"
     i18n-title title="Black">
  @if (winner === 'b') {
    <div i18n>
      Black Wins
      @if (backgammon) {
        <span i18n-title title="Backgammon">🎲️🎲️🎲️</span>
      }
      @if (gammon && !backgammon) {
        <span i18n-title title="Gammon">🎲️🎲️</span>
      }
      @if (!gammon) {
        <span>��️</span>
      }
    </div>
  }
  @if (!blackDice[0]) {
    <div i18n>🎲️ Roll</div>
  } @else {
    @if (blackDice[0] && !blackDice[1]) {
      <div i18n>{{ blackDice[0] }}</div>
    } @else {
      @if (blackDice[1]) {
        <div i18n>{{ blackDice[0] }} - {{ blackDice[1] }}</div>
      }
    }
  }
</div>
@if (replayMode) {
  <div class="replay-controls">
    <div class="scrubber-container">
      <input type="range"
             class="scrubber-bar"
             [min]="0"
             [max]="replayAnimations.length + 1"
             [value]="replayPosition"
             (pointerdown)="startSeeking()"
             (input)="seek($any($event.target).value)"
             (pointerup)="endSeeking()">
      <div class="scrubber-ticks">
        @for (eventPos of importantEvents; track eventPos) {
          <div class="scrubber-tick"
               [style.left.%]="(eventPos / replayAnimations.length) * 100"
               [title]="importantEventTypes.get(eventPos) || 'Important event'">
            <span class="tick-emoji" 
                  (click)="snapToEvent(eventPos)">{{ getEventEmoji(eventPos) }}</span>
          </div>
        }
      </div>
    </div>
    <div class="control-buttons">
      @if (!replayPlaying) {
        <button type="button"
                class="replay-btn play-btn"
                (click)="playReplay()"
                i18n-title title="Play">▶️</button>
      } @else {
        <button type="button"
                class="replay-btn pause-btn"
                (click)="pauseReplay()"
                i18n-title title="Pause">⏸️</button>
      }
      <button type="button"
              class="replay-btn"
              (click)="replayFastForward()"
              i18n-title title="Change playback speed">⏩️ {{ replaySpeed }}x</button>
    </div>
    <div class="replay-info">
      <span i18n>Move {{ floor(replayPosition) }} / {{ replayAnimations.length }}</span>
    </div>
  </div>
}