<commit_before>package me.zombieranke.Schatttenwanderer;

import java.util.ArrayList;

import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Input;
import org.newdawn.slick.Music;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.Sound;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;
import org.newdawn.slick.state.transition.FadeInTransition;
import org.newdawn.slick.state.transition.FadeOutTransition;
public abstract class LevelHandler extends BasicGameState
{
	
	protected static final int levelOffset = 5;
	protected Player player;
	protected Target target;
	protected Exit exit;
	protected Watch watch;
	protected boolean alarm;
	protected int alarmTime;
	protected static final int alarmTimeDefault = 600;
	protected int playerHealth;
	protected static final int playerHealthDefault = 600;
	protected int playerEnergy;
	protected static final int playerEnergyDefault = 300;
	protected int durationChecker;
	protected int levelCount;
	protected ArrayList<SolidObject> solids = new ArrayList<SolidObject>();
	protected ArrayList<Laser> laser;
	protected ArrayList<Lever> lever;
	private boolean debug;
	private int state;
	private boolean isMoving;
	private boolean enemyIsMoving;
	private boolean mission;
	
	
	//Musik - bleibt ja gleich - vorerst zumindest
	protected Music alarmMusic;
	protected Music gameMusic;
	protected Sound exitSound;
	protected boolean exitSoundWasPlayed;
	protected Sound leverSound;
	
	
	public void reset()
	{
		alarm = false;
		laser = new ArrayList<Laser>();
		lever = new ArrayList<Lever>();
		debug = false;
		state = 1;
		isMoving = false;
		enemyIsMoving = false;
		mission = false;
	}
	
	public abstract void onLoad(GameContainer container) throws SlickException;
	
	public void initializeObjects(GameContainer container) throws SlickException
	{
		for(Laser l : laser){
			l.init(container.getWidth(),container.getHeight(),solids);
		}
		for(Lever l : lever){
			l.init();
		}
			watch.updateSight(solids);
			playerHealth = playerHealthDefault;
			playerEnergy = playerEnergyDefault;
			watch.setRotation(watch.getDirection()+180);
			player.setRotation(0);
			target.animation.setCurrentFrame(2);
			target.animation.stop();
			exit.animation.setCurrentFrame(0);
			exit.animation.stop();
		}
	
	@Override
	public void enter(GameContainer container, StateBasedGame game) throws SlickException
	{
		reset();
		onLoad(container);
	}

	@Override
	public void render(GameContainer container, StateBasedGame game, Graphics g) throws SlickException 
	{
		g.setColor(Color.white);
		g.fillRect(0, 0, container.getWidth(), container.getHeight());
		g.setColor(Color.black);
		g.drawString("Bewegung: Pfeiltasten\nSchalter bettigen: F\nStealth: C\nSprint: V", 40, 20);
		g.drawString("Wachenbewegung: WASD\nWachendrehung: Q,E", 300, 40);
		
		for(SolidObject w : solids)
		{
			w.render(g);
		}
		for(Laser l: laser)
		{
			l.render(g);
		}
		for(Lever l: lever)
		{
			l.render(g);
		}
		target.render(g);
		watch.render(g);
		player.render(g);
		exit.render(g);
		if(debug)
		{
			for(SolidObject w : solids)
			{
				w.renderCollisionArea(g);
			}
			player.renderCollisionArea(g);
			watch.renderCollisionArea(g);
			target.renderCollisionArea(g);
			for(Laser l: laser)
			{
				l.renderCollisionArea(g);
			}
			for(Lever l: lever)
			{
				l.renderCollisionArea(g);
			}
		}
		if(alarm) //Alarmbalken und Info oben
		{
			g.setColor(Color.red);
			g.drawString("ALARM", container.getWidth()/2, 50);
			g.fillRect(container.getWidth()/2-125, 70, alarmTime/2, 10);
		}
		
		//Lebensbar anzeigen
		g.setColor(new Color(0.2f,0.2f,0.2f));
		g.fillRect(755, 789, 310, 30);
		g.setColor(Color.green);
		g.fillRect(760, 794, playerHealth/2, 20); //300px Healthbar
		
		if (mission){
			g.drawString("Target successfully killed",40, 850);
			
		}
		
		//Energiebalken
		g.setColor(new Color(0.2f,0.2f,0.2f));
		g.fillRect(215, 789, 310, 30);
		g.setColor(Color.yellow);
		g.fillRect(220, 794, playerEnergy, 20); //300px Energybar
		
	}

	@Override
	public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException 
	{
		Input input = container.getInput();
		
		state = 0;
		
		player.animation.update(delta);
		watch.animation.update(delta);
		exit.animation.update(delta);
		
		checkAlarm();
		
    	if(!alarm && (playerHealth<(playerHealthDefault/2)))
    	{
    		playerHealth++;
    	}
    	<commit_msg>Umstellung der Lebens- und Energieberechnung auf Float statt int<commit_after>package me.zombieranke.Schatttenwanderer;

import java.util.ArrayList;

import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Input;
import org.newdawn.slick.Music;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.Sound;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;
import org.newdawn.slick.state.transition.FadeInTransition;
import org.newdawn.slick.state.transition.FadeOutTransition;
public abstract class LevelHandler extends BasicGameState
{
	
	protected static final int levelOffset = 5;
	protected Player player;
	protected Target target;
	protected Exit exit;
	protected Watch watch;
	protected boolean alarm;
	protected int alarmTime;
	protected static final int alarmTimeDefault = 600;
	protected float playerHealth;
	protected static final float playerHealthDefault = 300;
	protected float playerEnergy;
	protected static final float playerEnergyDefault = 300;
	protected int durationChecker;
	protected int levelCount;
	protected ArrayList<SolidObject> solids = new ArrayList<SolidObject>();
	protected ArrayList<Laser> laser;
	protected ArrayList<Lever> lever;
	private boolean debug;
	private int state;
	private boolean isMoving;
	private boolean enemyIsMoving;
	private boolean mission;
	
	
	//Musik - bleibt ja gleich - vorerst zumindest
	protected Music alarmMusic;
	protected Music gameMusic;
	protected Sound exitSound;
	protected boolean exitSoundWasPlayed;
	protected Sound leverSound;
	
	
	public void reset()
	{
		alarm = false;
		laser = new ArrayList<Laser>();
		lever = new ArrayList<Lever>();
		debug = false;
		state = 1;
		isMoving = false;
		enemyIsMoving = false;
		mission = false;
	}
	
	public abstract void onLoad(GameContainer container) throws SlickException;
	
	public void initializeObjects(GameContainer container) throws SlickException
	{
		for(Laser l : laser){
			l.init(container.getWidth(),container.getHeight(),solids);
		}
		for(Lever l : lever){
			l.init();
		}
			watch.updateSight(solids);
			playerHealth = playerHealthDefault;
			playerEnergy = playerEnergyDefault;
			watch.setRotation(watch.getDirection()+180);
			player.setRotation(0);
			target.animation.setCurrentFrame(2);
			target.animation.stop();
			exit.animation.setCurrentFrame(0);
			exit.animation.stop();
		}
	
	@Override
	public void enter(GameContainer container, StateBasedGame game) throws SlickException
	{
		reset();
		onLoad(container);
	}

	@Override
	public void render(GameContainer container, StateBasedGame game, Graphics g) throws SlickException 
	{
		g.setColor(Color.white);
		g.fillRect(0, 0, container.getWidth(), container.getHeight());
		g.setColor(Color.black);
		g.drawString("Bewegung: Pfeiltasten\nSchalter bettigen: F\nStealth: C\nSprint: V", 40, 20);
		g.drawString("Wachenbewegung: WASD\nWachendrehung: Q,E", 300, 40);
		
		for(SolidObject w : solids)
		{
			w.render(g);
		}
		for(Laser l: laser)
		{
			l.render(g);
		}
		for(Lever l: lever)
		{
			l.render(g);
		}
		target.render(g);
		watch.render(g);
		player.render(g);
		exit.render(g);
		if(debug)
		{
			for(SolidObject w : solids)
			{
				w.renderCollisionArea(g);
			}
			player.renderCollisionArea(g);
			watch.renderCollisionArea(g);
			target.renderCollisionArea(g);
			for(Laser l: laser)
			{
				l.renderCollisionArea(g);
			}
			for(Lever l: lever)
			{
				l.renderCollisionArea(g);
			}
		}
		if(alarm) //Alarmbalken und Info oben
		{
			g.setColor(Color.red);
			g.drawString("ALARM", container.getWidth()/2, 50);
			g.fillRect(container.getWidth()/2-125, 70, alarmTime/2, 10);
		}
		
		//Lebensbar anzeigen
		g.setColor(new Color(0.2f,0.2f,0.2f));
		g.fillRect(755, 789, 310, 30);
		g.setColor(Color.green);
		g.fillRect(760, 794, playerHealth, 20); //300px Healthbar
		
		if (mission){
			g.drawString("Target successfully killed",40, 850);
			
		}
		
		//Energiebalken
		g.setColor(new Color(0.2f,0.2f,0.2f));
		g.fillRect(215, 789, 310, 30);
		g.setColor(Color.yellow);
		g.fillRect(220, 794, playerEnergy, 20); //300px Energybar
		
	}

	@Override
	public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException 
	{
		Input input = container.getInput();
		
		state = 0;
		
		player.animation.update(delta);
		watch.animation.update(delta);
		exit.animation.update(delta);
		
		checkAlarm();
		
    	if(!alarm && (playerHealth<(playerHealthDefault/2)))
    	{
    		playerHealth += 0.5;
    	}
    	
{'fraction_non_alphanumeric': 0.11579063118539697, 'fraction_numerical': 0.022982186056740708, 'mean_word_length': 4.251154734411085, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 15, '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': '527001', 'n_tokens_mistral': 3588, 'n_tokens_neox': 3073, 'n_words': 669}