<commit_before>package engine.world;

import engine.collision.CollisionMatrix;
import engine.dialogue.AbstractManager;
import engine.dialogue.ConversationManager;
import engine.dialogue.DialogueDisplayControl;
import engine.dialogue.NPCResponseNode;
import engine.dialogue.NotificationManager;
import engine.gridobject.Door;
import engine.gridobject.GridObject;
import engine.gridobject.person.Enemy;
import engine.gridobject.person.Player;
import engine.state.DialogueState;
import engine.state.SaveState;
import engine.state.WalkAroundState;


public class WalkAroundWorldLooper extends GameLooper {

	WalkAroundWorld myWorld;

	public WalkAroundWorldLooper(WalkAroundWorld currentWorld) {
		super(currentWorld);
		myWorld = (WalkAroundWorld) getWorld();
		getWorld().getPlayer().setSurroundingsChecker(new SurroundingChecker(myWorld));
		getWorld().getPlayer().setState(new WalkAroundState(getWorld().getPlayer()));
		setDialogueDisplayControl();
		setMenuControl();
	}

	private void setDialogueDisplayControl() {
		for (GridObject go : (myWorld.getGridObjectList())) {
			//if (go instanceof Person) {
				go.setDialogueDisplayControl(new DialogueDisplayControl(myWorld));
			//}
		}
	}

	private void setMenuControl(){

		//		myWorld.setMenuDisplayer(new MenuManager());
		//myWorld.getPlayer().setMenuControl(new MenuControl(myWorld));
	}

	@Override
	public World doLoop() {
		if(myWorld.getPlayer().getState() instanceof WalkAroundState){
			checkCollisions( myWorld.getCollisionMatrix());
			for (GridObject go : (myWorld.getGridObjectList())) {
				go.move();
				Door d = myWorld.getPlayer().isDoorEntered();
				if(d!=null){
					return d.getWorld();
				}
				if(go instanceof Enemy){
					if(((Enemy) go).isBattle() && myWorld.getPlayer().getState() instanceof WalkAroundState){
						if(!((Enemy) go).getWasBattled()){
							return ((Enemy) go).getWorld();
						}
					}	
				}	
			} 
				
			} else if(myWorld.getPlayer().getState() instanceof SaveState){
				//	System.out.println("in instance of SaveState");
				SaveState saveState = (SaveState) myWorld.getPlayer().getState();
				if (saveState.isSavingState()) {
					saveState.setSavingState(false);
				//	System.out.println("saveWorld");
				    /// save world data 
				}
			}
//			if(myWorld.getPlayer().getWeaponList().size()>2){
//				NPCResponseNode n = new NPCResponseNode(myWorld.getPlayer(), "You have too many items");
////				System.out.println("Item found alert");
//				AbstractManager conversation = new ConversationManager(myWorld.getPlayer(), myWorld.getPlayer(), n);
//				myWorld.getPlayer().setState(new DialogueState(conversation));
//				myWorld.getPlayer().setInteractionBox(conversation);
//			}
		return null;
	}

	private void checkCollisions(CollisionMatrix cm) {
		for (int i = 0; i < ((WalkAroundWorld) getWorld()).getGridObjectList().size(); i++) {
			for (int j = 0; j < ((WalkAroundWorld) getWorld()).getGridObjectList().size(); j++) {
				if (myWorld.getGridObjectList().get(i).getBounds().intersects(
						myWorld.getGridObjectList().get(j).getBounds())) {
					if(cm!=null) {
						cm.getMatrix()[i][j].doCollision();
					}
				}
			}
		}
	}<commit_msg>cleanup<commit_after>package engine.world;

import engine.collision.CollisionMatrix;
import engine.dialogue.AbstractManager;
import engine.dialogue.ConversationManager;
import engine.dialogue.DialogueDisplayControl;
import engine.dialogue.NPCResponseNode;
import engine.dialogue.NotificationManager;
import engine.gridobject.Door;
import engine.gridobject.GridObject;
import engine.gridobject.person.Enemy;
import engine.gridobject.person.Player;
import engine.state.DialogueState;
import engine.state.SaveState;
import engine.state.WalkAroundState;


public class WalkAroundWorldLooper extends GameLooper {

	WalkAroundWorld myWorld;

	public WalkAroundWorldLooper(WalkAroundWorld currentWorld) {
		super(currentWorld);
		myWorld = (WalkAroundWorld) getWorld();
		getWorld().getPlayer().setSurroundingsChecker(new SurroundingChecker(myWorld));
		getWorld().getPlayer().setState(new WalkAroundState(getWorld().getPlayer()));
		setDialogueDisplayControl();
		setMenuControl();
	}

	private void setDialogueDisplayControl() {
		for (GridObject go : (myWorld.getGridObjectList())) {
			//if (go instanceof Person) {
				go.setDialogueDisplayControl(new DialogueDisplayControl(myWorld));
			//}
		}
	}

	private void setMenuControl(){

		//		myWorld.setMenuDisplayer(new MenuManager());
		//myWorld.getPlayer().setMenuControl(new MenuControl(myWorld));
	}

	@Override
	public World doLoop() {
		if(myWorld.getPlayer().getState() instanceof WalkAroundState){
			checkCollisions( myWorld.getCollisionMatrix());
			for (GridObject go : (myWorld.getGridObjectList())) {
				go.move();
				Door d = myWorld.getPlayer().isDoorEntered();
				if(d!=null){
					return d.getWorld();
				}
				if(go instanceof Enemy){
					if(((Enemy) go).isBattle() && myWorld.getPlayer().getState() instanceof WalkAroundState){
						if(!((Enemy) go).getWasBattled()){
							return ((Enemy) go).getWorld();
						}
					}	
				}	
			} 
				
		} else if(myWorld.getPlayer().getState() instanceof SaveState){
			//	System.out.println("in instance of SaveState");
			SaveState saveState = (SaveState) myWorld.getPlayer().getState();
			if (saveState.isSavingState()) {
				saveState.setSavingState(false);
			//	System.out.println("saveWorld");
			    /// save world data 
			}
		}
//			if(myWorld.getPlayer().getWeaponList().size()>2){
//				NPCResponseNode n = new NPCResponseNode(myWorld.getPlayer(), "You have too many items");
////				System.out.println("Item found alert");
//				AbstractManager conversation = new ConversationManager(myWorld.getPlayer(), myWorld.getPlayer(), n);
//				myWorld.getPlayer().setState(new DialogueState(conversation));
//				myWorld.getPlayer().setInteractionBox(conversation);
//			}
		return null;
	}

	private void checkCollisions(CollisionMatrix cm) {
		for (int i = 0; i < ((WalkAroundWorld) getWorld()).getGridObjectList().size(); i++) {
			for (int j = 0; j < ((WalkAroundWorld) getWorld()).getGridObjectList().size(); j++) {
				if (myWorld.getGridObjectList().get(i).getBounds().intersects(
						myWorld.getGridObjectList().get(j).getBounds())) {
					if(cm!=null) {
						cm.getMatrix()[i][j].doCollision();
					}
				}
			}
		}
	}
{'fraction_non_alphanumeric': 0.14536817102137767, 'fraction_numerical': 0.0009501187648456057, 'mean_word_length': 4.550087873462214, 'pattern_counts': {'":': 0, '<': 7, '<?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': '6191613', 'n_tokens_mistral': 2270, 'n_tokens_neox': 1961, 'n_words': 338}