<commit_before>package com.shade.states;

import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.Input;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;

import com.shade.controls.Button;
import com.shade.controls.ClickListener;
import com.shade.controls.ControlListener;
import com.shade.controls.ControlSlice;
import com.shade.controls.ScoreControl;
import com.shade.controls.CounterControl;
import com.shade.controls.MeterControl;
import com.shade.controls.SerialStats;
import com.shade.controls.SlickButton;
import com.shade.controls.StatsControl;
import com.shade.controls.DayPhaseTimer.DayLightStatus;
import com.shade.levels.LevelManager;
import com.shade.levels.Model;
import com.shade.util.ResourceManager;

public class InGameState extends BasicGameState {

    public static final int ID = 3;

    private StateBasedGame game;
    private MasterState master;
    private ResourceManager resource;
    private int currentLevel, totalLevelsPlayed;
    private Model level;
    private LevelManager levels;
    private MeterControl meter;
    private CounterControl counter;
    private SlickButton play, back;

    public StatsControl stats;

    public InGameState(MasterState m) throws SlickException {
        levels = new LevelManager();
        master = m;
        resource = m.resource;
        resource.register("counter", "states/ingame/counter.png");
        resource.register("resume-up", "states/ingame/resume-up.png");
        resource.register("resume-down", "states/ingame/resume-down.png");
        resource.register("back-up", "states/common/back-up.png");
        resource.register("back-down", "states/common/back-down.png");
        initControls();
        initButtons();
    }

    @Override
    public int getID() {
        return ID;
    }

    /**
     * Play a game starting from the first level.
     */
    public void newGame() {
        currentLevel = 1;
        totalLevelsPlayed = 1;
        initLevel();
        resetControls();
        master.scorecard.reset();
        stats.reset();
    }

    public void newGame(int level) {
        currentLevel = level;
        totalLevelsPlayed = 1;
        initLevel();
        resetControls();
        master.scorecard.reset();
        stats.reset();
    }

    /**
     * Play a game starting from the level after the current one.
     */
    public void nextLevel() {
        currentLevel++;
        totalLevelsPlayed++;
        initLevel();
        resetControls();
        master.scorecard.reset();
    }

    /**
     * Play a game starting from the current level.
     */
    public void currentLevel() {
        initLevel();
        master.scorecard.rollbackLevel();
        resetControls();
    }

    private void initLevel() {
        if (currentLevel < levels.size()) {
            level = levels.get(currentLevel);
        }
    }

    /**
     * Requires level to be correctly set.
     */
    private void resetControls() {
        meter.reset();
        counter.reset(level.getPar());
    }

    private void addBackControls() {
        master.control.add(counter);
        master.control.add(meter);
    }

    public void init(GameContainer container, StateBasedGame game)
            throws SlickException {
        throw new RuntimeException("InGameState was init'd!");
    }

    @Override
    public void enter(GameContainer container, StateBasedGame game) {
        this.game = game;
        master.timer.reset();
        if (!master.dimmer.reversed()) {
            master.dimmer.rewind();
        }
        master.control.load(level);
        master.music.fade(MasterState.SECONDS_OF_DAYLIGHT, .1f, false);
        addBackControls();
        if (currentLevel < levels.size()
                && !master.levelsLock.isUnlocked(currentLevel)) {
            master.levelsLock.unlock(currentLevel);
        }
    }

    private void safeExit(StateBasedGame game, int id) {
        master.control.flushControls();
        master.control.killPlayer();
        master.music.fade(2000, 1f, false);
        game.enterState(id);
    }

    public void exit(StateBasedGame game, int id) {
        recordMileage();
        recordDamage();
        recordMushroomsCollected();
        safeExit(game, id);
        if (parWasMet()) {
            String stat = "level-" + currentLevel + "-clear";
            SerialStats.write(stat, 1);
        }
    }<commit_msg>removing out-of-date unlocking from in-game state<commit_after>package com.shade.states;

import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.Input;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;

import com.shade.controls.Button;
import com.shade.controls.ClickListener;
import com.shade.controls.ControlListener;
import com.shade.controls.ControlSlice;
import com.shade.controls.ScoreControl;
import com.shade.controls.CounterControl;
import com.shade.controls.MeterControl;
import com.shade.controls.SerialStats;
import com.shade.controls.SlickButton;
import com.shade.controls.StatsControl;
import com.shade.controls.DayPhaseTimer.DayLightStatus;
import com.shade.levels.LevelManager;
import com.shade.levels.Model;
import com.shade.util.ResourceManager;

public class InGameState extends BasicGameState {

    public static final int ID = 3;

    private StateBasedGame game;
    private MasterState master;
    private ResourceManager resource;
    private int currentLevel, totalLevelsPlayed;
    private Model level;
    private LevelManager levels;
    private MeterControl meter;
    private CounterControl counter;
    private SlickButton play, back;

    public StatsControl stats;

    public InGameState(MasterState m) throws SlickException {
        levels = new LevelManager();
        master = m;
        resource = m.resource;
        resource.register("counter", "states/ingame/counter.png");
        resource.register("resume-up", "states/ingame/resume-up.png");
        resource.register("resume-down", "states/ingame/resume-down.png");
        resource.register("back-up", "states/common/back-up.png");
        resource.register("back-down", "states/common/back-down.png");
        initControls();
        initButtons();
    }

    @Override
    public int getID() {
        return ID;
    }

    /**
     * Play a game starting from the first level.
     */
    public void newGame() {
        currentLevel = 1;
        totalLevelsPlayed = 1;
        initLevel();
        resetControls();
        master.scorecard.reset();
        stats.reset();
    }

    public void newGame(int level) {
        currentLevel = level;
        totalLevelsPlayed = 1;
        initLevel();
        resetControls();
        master.scorecard.reset();
        stats.reset();
    }

    /**
     * Play a game starting from the level after the current one.
     */
    public void nextLevel() {
        currentLevel++;
        totalLevelsPlayed++;
        initLevel();
        resetControls();
        master.scorecard.reset();
    }

    /**
     * Play a game starting from the current level.
     */
    public void currentLevel() {
        initLevel();
        master.scorecard.rollbackLevel();
        resetControls();
    }

    private void initLevel() {
        if (currentLevel < levels.size()) {
            level = levels.get(currentLevel);
        }
    }

    /**
     * Requires level to be correctly set.
     */
    private void resetControls() {
        meter.reset();
        counter.reset(level.getPar());
    }

    private void addBackControls() {
        master.control.add(counter);
        master.control.add(meter);
    }

    public void init(GameContainer container, StateBasedGame game)
            throws SlickException {
        throw new RuntimeException("InGameState was init'd!");
    }

    @Override
    public void enter(GameContainer container, StateBasedGame game) {
        this.game = game;
        master.timer.reset();
        if (!master.dimmer.reversed()) {
            master.dimmer.rewind();
        }
        master.control.load(level);
        master.music.fade(MasterState.SECONDS_OF_DAYLIGHT, .1f, false);
        addBackControls();
    }

    private void safeExit(StateBasedGame game, int id) {
        master.control.flushControls();
        master.control.killPlayer();
        master.music.fade(2000, 1f, false);
        game.enterState(id);
    }

    public void exit(StateBasedGame game, int id) {
        recordMileage();
        recordDamage();
        recordMushroomsCollected();
        safeExit(game, id);
        if (parWasMet()) {
            String stat = "level-" + currentLevel + "-clear";
            SerialStats.write(stat, 1);
        }
    }
{'fraction_non_alphanumeric': 0.11026188602899854, 'fraction_numerical': 0.002472743621445431, 'mean_word_length': 2.5835682641965363, 'pattern_counts': {'":': 0, '<': 6, '<?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': '4923092', 'n_tokens_mistral': 2578, 'n_tokens_neox': 2503, 'n_words': 546}