<commit_before>package command.concrete;

import visitor.abstracts.Position;
import command.abstracts.MoveCommand;

public class LeftCommand extends MoveCommand {

	@Override
	public void execute() {
		if (this.getCharacter().getPosition().y == 0) {
			throw new IllegalStateException("Cannot move to the left!");
		}

		Position currentPosition = this.getCharacter().getPosition();
		this.getField().moveCharacter(this.getCharacter(),
				new Position(currentPosition.x, currentPosition.y - 1));
	}

}<commit_msg>added a check for another Character on the left when moving left<commit_after>package command.concrete;

import visitor.abstracts.Position;
import command.abstracts.MoveCommand;
import visitor.abstracts.Character;

public class LeftCommand extends MoveCommand {

	@Override
	public void execute() {
		if (this.getCharacter().getPosition().y == 0) {
			throw new IllegalStateException("Cannot move to the left!");
		}
		
		Position currentPosition = this.getCharacter().getPosition();
		Position newPosition = new Position(currentPosition.x, currentPosition.y - 1);
				
		if(this.getField().getElements()[newPosition.x][newPosition.y] instanceof Character){
			throw new IllegalStateException("Cannot move to the left!");
		}
		
		this.getField().moveCharacter(this.getCharacter(),
				newPosition);
	}
}
{'fraction_non_alphanumeric': 0.11456752655538695, 'fraction_numerical': 0.0030349013657056147, 'mean_word_length': 5.192488262910798, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7304584', 'n_tokens_mistral': 394, 'n_tokens_neox': 352, 'n_words': 92}