<commit_before>import {inject} from 'aurelia-framework';
import {ApplicationState} from '../applicationState';
import {DialogService} from 'aurelia-dialog';
import {AddWeapon} from './dialogs/addWeapon';
import {EditMaterial} from './dialogs/editMaterial';
import {EditWondrousItem} from './dialogs/editWondrousItem';
import {AddRing} from './dialogs/addRing';

@inject(ApplicationState, DialogService)
export class equipment {
  canActivate(params, routeConfig, navigationInstruction) {
    return (!!this.loadedCharacter);
  }

  constructor(appState, dialogService) {
    this.appState = appState;
    this.dialogService = dialogService;

    this.loadedCharacter = this.appState.loadedCharacter;
    this.armor = this.loadedCharacter.armor;
    this.weapons = this.loadedCharacter.weapons;
    this.rings = this.loadedCharacter.rings;
    this.wondrousItems = this.loadedCharacter.wondrousItems;

    this.computeTotalWeight();
  }

  computeTotalWeight() {
    this.totalWeight = this.armor.weight;

    for (var item of this.wondrousItems) {
      this.totalWeight += item.weight;
    }
    for (var item of this.weapons) {
      this.totalWeight += item.weight;
    }
  }

  addWeapon() {
    let weapon = {
      name: '',
      damage: '',
      crit: '',
      weight: 0,
      value: 0,
      isMasterwork: false,
      weaponBonus: '',
      material: {},
      enchantments: []
    }
    this.dialogService.open({ viewModel: AddWeapon, model: weapon }).then(response => {
      if (!response.wasCancelled) {
        this.weapons.push(response.output);
      }
    });
  }

  editWeapon(weapon) {
    this.dialogService.open({ viewModel: AddWeapon, model: weapon });
  }

  deleteWeapon(weapon) {<commit_msg>Templated material for new weapons.<commit_after>import {inject} from 'aurelia-framework';
import {ApplicationState} from '../applicationState';
import {DialogService} from 'aurelia-dialog';
import {AddWeapon} from './dialogs/addWeapon';
import {EditMaterial} from './dialogs/editMaterial';
import {EditWondrousItem} from './dialogs/editWondrousItem';
import {AddRing} from './dialogs/addRing';

@inject(ApplicationState, DialogService)
export class equipment {
  canActivate(params, routeConfig, navigationInstruction) {
    return (!!this.loadedCharacter);
  }

  constructor(appState, dialogService) {
    this.appState = appState;
    this.dialogService = dialogService;

    this.loadedCharacter = this.appState.loadedCharacter;
    this.armor = this.loadedCharacter.armor;
    this.weapons = this.loadedCharacter.weapons;
    this.rings = this.loadedCharacter.rings;
    this.wondrousItems = this.loadedCharacter.wondrousItems;

    this.computeTotalWeight();
  }

  computeTotalWeight() {
    this.totalWeight = this.armor.weight;

    for (var item of this.wondrousItems) {
      this.totalWeight += item.weight;
    }
    for (var item of this.weapons) {
      this.totalWeight += item.weight;
    }
  }

  addWeapon() {
    let weapon = {
      name: '',
      damage: '',
      crit: '',
      weight: 0,
      value: 0,
      isMasterwork: false,
      weaponBonus: '',
      material: {
        name: '',
        hpIn: 0,
        hardness: 0,
        description: ''
      },
      enchantments: []
    }
    this.dialogService.open({ viewModel: AddWeapon, model: weapon }).then(response => {
      if (!response.wasCancelled) {
        this.weapons.push(response.output);
      }
    });
  }

  editWeapon(weapon) {
    this.dialogService.open({ viewModel: AddWeapon, model: weapon });
  }

  deleteWeapon(weapon) {
{'fraction_non_alphanumeric': 0.12905043674274444, 'fraction_numerical': 0.0016906170752324597, 'mean_word_length': 3.2617046818727493, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1522947', 'n_tokens_mistral': 1117, 'n_tokens_neox': 1087, 'n_words': 216}