<commit_before>/**
 * @license
 * Copyright 2013 Google LLC
 * SPDX-License-Identifier: Apache-2.0
 */

/**
 * @fileoverview A single avatar.
 * @author <EMAIL> (<NAME>)
 */
'use strict';

goog.provide('Pond.Avatar');

goog.require('Blockly.utils.Coordinate');
goog.require('Blockly.utils.math');
goog.require('BlocklyGames');


Avatar = class {
  /**
   * Class for a avatar.
   * @param {string} name Avatar's name.
   * @param {!Blockly.utils.Coordinate} startLoc Start location.
   * @param {?number} startDamage Initial damage to avatar (0-100, default 0).
   * @param {boolean} editable Allow user to edit code.
   * @param {!Pond.Battle} battle The battle featuring the avatar.
   */
  constructor(name, startLoc, startDamage, editable, battle) {
    this.name = name;
    this.startLoc_ = startLoc;
    this.startDamage_ = startDamage || 0;
    this.editable = editable;
    this.battle_ = battle;
    this.loc = new Blockly.utils.Coordinate();
    this.reset();
    this.visualizationIndex = battle.AVATARS.length;
    battle.AVATARS.push(this);
    console.log(this + ' loaded.');
  }

  /**
   * Has this avatar fully loaded and started playing?
   */
  started = false;

  /**
   * Has the avatar been killed?
   */
  dead = false;

  /**
   * Damage of this avatar (0 = perfect, 100 = dead).
   */
  damage = 0;

  /**
   * Heading the avatar is moving in (0 - 360).
   */
  degree = 0;

  /**
   * Direction the avatar's head is facing (0 - 360).
   */
  facing = 0;

  /**
   * Speed the avatar is actually moving (0 - 100).
   */
  speed = 0;

  /**
   * Speed the avatar is aiming to move at (0 - 100).
   */
  desiredSpeed = 0;

  /**
   * X/Y location of the avatar (0 - 100).
   * @type Blockly.utils.Coordinate
   */
  loc = null;

  /**
   * Date of last missile.
   */
  lastMissile = 0;

  /**
   * A text representation of this avatar for debugging purposes.
   * @returns {string} String representation.
   */
  toString() {
    return '[' + this.name + ']';
  }

  /**
   * Sets the code for this avatar.
   * @param {string|undefined} blockly Blockly XML, or undefined if no Blockly.
   * @param {string|undefined} js JavaScript source, or undefined if no JS.
   * @param {string} compiled Executable ES5 code (generated by Blockly or Babel).
   */
  setCode(blockly, js, compiled) {
    this.blockly = blockly;
    this.js = js;
    this.compiled = compiled;
  }

  /**
   * Reset this avatar to a starting state.
   */
  reset() {
    delete this.started;
    delete this.dead;
    delete this.speed;
    delete this.desiredSpeed;
    delete this.lastMissile;<commit_msg>Fix ES6 conversion of Pond's avatar class.<commit_after>/**
 * @license
 * Copyright 2013 Google LLC
 * SPDX-License-Identifier: Apache-2.0
 */

/**
 * @fileoverview A single avatar.
 * @author <EMAIL> (<NAME>)
 */
'use strict';

goog.provide('Pond.Avatar');

goog.require('Blockly.utils.Coordinate');
goog.require('Blockly.utils.math');
goog.require('BlocklyGames');


Pond.Avatar = class {
  /**
   * Class for a avatar.
   * @param {string} name Avatar's name.
   * @param {!Blockly.utils.Coordinate} startLoc Start location.
   * @param {?number} startDamage Initial damage to avatar (0-100, default 0).
   * @param {boolean} editable Allow user to edit code.
   * @param {!Pond.Battle} battle The battle featuring the avatar.
   */
  constructor(name, startLoc, startDamage, editable, battle) {
    this.name = name;
    this.startLoc_ = startLoc;
    this.startDamage_ = startDamage || 0;
    this.editable = editable;
    this.battle_ = battle;
    this.loc = new Blockly.utils.Coordinate();

    /**
     * Has this avatar fully loaded and started playing?
     */
    this.started = false;
    /**
     * Has the avatar been killed?
     */
    this.dead = false;
    /**
     * Damage of this avatar (0 = perfect, 100 = dead).
     */
    this.damage = 0;
    /**
     * Heading the avatar is moving in (0 - 360).
     */
    this.degree = 0;
    /**
     * Direction the avatar's head is facing (0 - 360).
     */
    this.facing = 0;
    /**
     * Speed the avatar is actually moving (0 - 100).
     */
    this.speed = 0;
    /**
     * Speed the avatar is aiming to move at (0 - 100).
     */
    this.desiredSpeed = 0;
    /**
     * X/Y location of the avatar (0 - 100).
     * @type Blockly.utils.Coordinate
     */
    this.loc = null;
    /**
     * Date of last missile.
     */
    this.lastMissile = 0;

    this.reset();
    this.visualizationIndex = battle.AVATARS.length;
    battle.AVATARS.push(this);
    console.log(this + ' loaded.');
  }

  /**
   * A text representation of this avatar for debugging purposes.
   * @returns {string} String representation.
   */
  toString() {
    return '[' + this.name + ']';
  }

  /**
   * Sets the code for this avatar.
   * @param {string|undefined} blockly Blockly XML, or undefined if no Blockly.
   * @param {string|undefined} js JavaScript source, or undefined if no JS.
   * @param {string} compiled Executable ES5 code (generated by Blockly or Babel).
   */
  setCode(blockly, js, compiled) {
    this.blockly = blockly;
    this.js = js;
    this.compiled = compiled;
  }

  /**
   * Reset this avatar to a starting state.
   */
  reset() {
    delete this.started;
    delete this.dead;
    delete this.speed;
    delete this.desiredSpeed;
    delete this.lastMissile;
{'fraction_non_alphanumeric': 0.1368735976065819, 'fraction_numerical': 0.016267763649962602, 'mean_word_length': 2.5121470781352593, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '6482099', 'n_tokens_mistral': 1862, 'n_tokens_neox': 1725, 'n_words': 513}