<commit_before>/**
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

import * as React from 'react';
import { Injury } from '../../../core/core';
import { Part } from './Part';
import { Label } from './Label';
import { WoundColors } from '../classes/WoundColors';

const colors: WoundColors = new WoundColors();

const pct66: number = 2.0/3.0;
const pct33: number = 1.0/3.0;

export interface DollState { }
export interface DollProps {
  injuries: Injury[];
}

function getState(damage: number, max: number): number {
  if (max == 0)
    return 0;

  const pct: number = damage / max;
  if (pct > pct66) return 0;
  if (pct > pct33) return 1;
  if (pct > 0.0) return 2;
  return 3;
}

// TEMP: Until we know the official client Part ID map
function getPart(clientId: number): number {
  switch (clientId) {
    case 0: return 3;
    case 1: return 1;
    case 2: return 2;
    case 3: return 0;
    case 4: return 4;
    case 5: return 5;
  }
  return -1;
}

// Maps part IDs to injury objects.  If an injury for a part is not availale, returns
// an injury that represents full health

class InjuryMap {
  private map : Injury[] = [];
  public length: number = 6;
  constructor() {
    for (let i = 0; i < this.length; i++) {
      this.map[i] = new Injury();
    }
  }
  addInjury(injury:Injury) {
    this.map[injury.part].refresh(injury);
  }
  getInjury(i : number) : Injury {
    if (this.length > i && i >= 0) {
      return this.map[i];
    }
    const defaultInjury : Injury = new Injury();<commit_msg>New mapping from server to ui parts.<commit_after>/**
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

import * as React from 'react';
import { Injury } from '../../../core/core';
import { Part } from './Part';
import { Label } from './Label';
import { WoundColors } from '../classes/WoundColors';

const colors: WoundColors = new WoundColors();

const pct66: number = 2.0/3.0;
const pct33: number = 1.0/3.0;

export interface DollState { }
export interface DollProps {
  injuries: Injury[];
}

function getState(damage: number, max: number): number {
  if (max == 0)
    return 0;

  const pct: number = damage / max;
  if (pct > pct66) return 0;
  if (pct > pct33) return 1;
  if (pct > 0.0) return 2;
  return 3;
}

// TEMP: Until we know the official client Part ID map
function getPart(clientId: number): number {
  switch (clientId) {
    case 0: return 3;
    case 1: return 0;
    case 2: return 1;
    case 3: return 2;
    case 4: return 4;
    case 5: return 5;
  }
  return -1;
}

// Maps part IDs to injury objects.  If an injury for a part is not availale, returns
// an injury that represents full health

class InjuryMap {
  private map : Injury[] = [];
  public length: number = 6;
  constructor() {
    for (let i = 0; i < this.length; i++) {
      this.map[i] = new Injury();
    }
  }
  addInjury(injury:Injury) {
    this.map[injury.part].refresh(injury);
  }
  getInjury(i : number) : Injury {
    if (this.length > i && i >= 0) {
      return this.map[i];
    }
    const defaultInjury : Injury = new Injury();
{'fraction_non_alphanumeric': 0.13486156594224472, 'fraction_numerical': 0.026198273295623697, 'mean_word_length': 2.826879271070615, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '3861593', 'n_tokens_mistral': 1245, 'n_tokens_neox': 1130, 'n_words': 427}