<commit_before>import Common from '../../Common';
import frames from '../../../sprite-frames';
import { addCharacter, moveCharacter, removeCharacter } from '../../../world';
import { clone } from '../../../utils';

export default class CommonCharacter extends Common {
  constructor(game, x, y, sprite, frame, id, objectType) {
    super(game, x, y, sprite, frame, id, objectType);

    this.game.state.states.Game.groups.character.add(this);

    addCharacter(this.tile, this.objectType);
  }

  move(nextPixelCoord) {
    if (this.cursor) {
      this.cursor.move();
    }

    const oldTileCoord = this.tile;

    super.move(nextPixelCoord, function() {
      moveCharacter(oldTileCoord, this.tile, this.objectType);
    });
  }

  face(direction) {
    const frameName = frames.CHARACTER['STAND_' + direction];
    this.frame = frameName;

    this.faceDirection = direction;
  }

  resetObject() {
    super.resetObject();
    
    addCharacter(this.tile, this.objectType);
  }

  destroy() {
    removeCharacter(this.tile, this.objectType);

    super.destroy();
  }
}
<commit_msg>Don't allow moving to tile out of bounds<commit_after>import Common from '../../Common';
import frames from '../../../sprite-frames';
import config from '../../../config';
import { addCharacter, moveCharacter, removeCharacter } from '../../../world';
import { clone } from '../../../utils';
import { pixelToTile } from '../../../tiles';

export default class CommonCharacter extends Common {
  constructor(game, x, y, sprite, frame, id, objectType) {
    super(game, x, y, sprite, frame, id, objectType);

    this.game.state.states.Game.groups.character.add(this);

    addCharacter(this.tile, this.objectType);
  }

  move(nextPixelCoord) {
    const tileCoord = pixelToTile(nextPixelCoord);
    if (tileCoord.x < 0 || tileCoord.x >= config.mapWidth || tileCoord.y < 0 || tileCoord.y >= config.mapHeight) return;

    if (this.cursor) {
      this.cursor.move();
    }

    const oldTileCoord = this.tile;

    super.move(nextPixelCoord, function() {
      moveCharacter(oldTileCoord, this.tile, this.objectType);
    });
  }

  face(direction) {
    const frameName = frames.CHARACTER['STAND_' + direction];
    this.frame = frameName;

    this.faceDirection = direction;
  }

  resetObject() {
    super.resetObject();

    addCharacter(this.tile, this.objectType);
  }

  destroy() {
    removeCharacter(this.tile, this.objectType);

    super.destroy();
  }
}

{'fraction_non_alphanumeric': 0.16055419722901385, 'fraction_numerical': 0.0008149959250203749, 'mean_word_length': 3.1469594594594597, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4108469', 'n_tokens_mistral': 761, 'n_tokens_neox': 739, 'n_words': 168}