<commit_before>import { Component, ViewChild } from "@angular/core";

import * as _ from "lodash";

import { InitiativeListComponent } from "./initiative-list/initiative-list.component";
import { CreatureInitiative } from "./models/creature-initiative";

@Component({
  selector: "dnd-initiative-tracker",
  templateUrl: "./initiative-tracker.component.html"
})
export class InitiativeTrackerComponent {
  @ViewChild("list") initiativeList: InitiativeListComponent;

  currentInitiative: number;
  currentRound = 0;

  onResetClick() {
    this.initiativeList.clear();
    this.currentInitiative = undefined;
    this.currentRound = 0;
  }

  onNextClick() {
    const creatures = this.initiativeList.creatures;
    if (!this.currentInitiative) {
      this.currentInitiative = creatures[0].initiative;
      this.currentRound = 1;
    } else {
      const nextCreatures = creatures.filter(c => c.initiative < this.currentInitiative && c.active);
      if (nextCreatures.length > 0) {
        this.currentInitiative = nextCreatures[0].initiative;
      } else {
        this.currentInitiative = creatures[0].initiative;
        this.currentRound++;
      }
    }
  }
};<commit_msg>Fix initiative when first creature is inactive.<commit_after>import { Component, ViewChild } from "@angular/core";

import * as _ from "lodash";

import { InitiativeListComponent } from "./initiative-list/initiative-list.component";
import { CreatureInitiative } from "./models/creature-initiative";

@Component({
  selector: "dnd-initiative-tracker",
  templateUrl: "./initiative-tracker.component.html"
})
export class InitiativeTrackerComponent {
  @ViewChild("list") initiativeList: InitiativeListComponent;

  currentInitiative: number;
  currentRound = 0;

  onResetClick() {
    this.initiativeList.clear();
    this.currentInitiative = undefined;
    this.currentRound = 0;
  }

  onNextClick() {
    const activeCreatures = this.initiativeList.creatures.filter(c => c.active);
    if (!this.currentInitiative) {
      this.currentInitiative = activeCreatures[0].initiative;
      this.currentRound = 1;
    } else {
      const nextCreatures = activeCreatures.filter(c => c.initiative < this.currentInitiative);
      if (nextCreatures.length > 0) {
        this.currentInitiative = nextCreatures[0].initiative;
      } else {
        this.currentInitiative = activeCreatures[0].initiative;
        this.currentRound++;
      }
    }
  }
};
{'fraction_non_alphanumeric': 0.12098765432098765, 'fraction_numerical': 0.005761316872427984, 'mean_word_length': 3.7948717948717947, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3953439', 'n_tokens_mistral': 726, 'n_tokens_neox': 702, 'n_words': 134}