<commit_before>package de.cpgaertner.edu.inf.games.datacenter.command.go;

import de.cpgaertner.edu.inf.api.command.handler.CommandHandler;
import de.cpgaertner.edu.inf.api.level.Coordinate;
import de.cpgaertner.edu.inf.api.level.Location;
import de.cpgaertner.edu.inf.api.level.player.Player;

import java.io.IOException;

public class GoCommandHandler implements CommandHandler<GoCommand> {
    @Override
    public void handle(Player player, GoCommand cmd) throws IOException {
        assert player != null;
        assert cmd != null;


        Location.Direction dir = cmd.getDirection();

        // First check the sides of the location itself
        Location loc = player.getLevel().getAt(player.getPosition()).get(dir);

        if (loc == null) {
            Coordinate newPos = player.getPosition().get(cmd.getDirection());
            Location newLoc = player.getLevel().getAt(newPos);
            if (newLoc !=  null) {
                if (newLoc.isWalkable()) {
                    player.setPosition(newPos);
                    cmd.respondf("Now you are at %s, this is a location of the type '%s'.",
                            newPos,
                            newLoc.getClass().getSimpleName()
                    );
                    return;
                }
            }
        }

        cmd.respondf("You cannot walk into the location in the %s", cmd.getDirection());

    }
}<commit_msg>Now the go command supports Doors<commit_after>package de.cpgaertner.edu.inf.games.datacenter.command.go;

import de.cpgaertner.edu.inf.api.command.handler.CommandHandler;
import de.cpgaertner.edu.inf.api.level.Coordinate;
import de.cpgaertner.edu.inf.api.level.Location;
import de.cpgaertner.edu.inf.api.level.player.Player;

import java.io.IOException;

public class GoCommandHandler implements CommandHandler<GoCommand> {
    @Override
    public void handle(Player player, GoCommand cmd) throws IOException {
        assert player != null;
        assert cmd != null;


        Location.Direction dir = cmd.getDirection();

        // First check the sides of the location itself
        Location loc = player.getLevel().getAt(player.getPosition()).get(dir);

        if (loc == null || loc.isWalkable()) {
            Coordinate newPos = player.getPosition().get(cmd.getDirection());
            Location newLoc = player.getLevel().getAt(newPos);
            if (newLoc !=  null) {
                if (newLoc.isWalkable()) {
                    player.setPosition(newPos);
                    cmd.respondf("Now you are at %s, this is a location of the type '%s'.",
                            newPos,
                            newLoc.getClass().getSimpleName()
                    );
                    return;
                }
            }
        }

        cmd.respondf("You cannot walk into the location in the %s", cmd.getDirection());

    }
}
{'fraction_non_alphanumeric': 0.11014593467685893, 'fraction_numerical': 0.0, 'mean_word_length': 2.072572038420491, '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': '2772063', 'n_tokens_mistral': 801, 'n_tokens_neox': 775, 'n_words': 182}