<commit_before>package uk.co.alynn.games.suchrobot;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.viewport.FitViewport;
import com.badlogic.gdx.utils.viewport.Viewport;

public class MainMode implements GameMode {
    public static final float WORLD_WIDTH = 1024.0f;
    public static final float WORLD_HEIGHT = 640.0f;
    private SpriteBatch batch = null;
    private Viewport viewport = null;
    private NodeSet nodes = null;
    private List<Robot> robots = new ArrayList<Robot>();
    private Robot selectedRobot = null;
    private double dayCounter;

    private final boolean DEBUG = false;
    private Box box;

    public MainMode(Box box) {
        this.box = box;
    }

    @Override
    public void start() {
        viewport = new FitViewport(WORLD_WIDTH, WORLD_HEIGHT);
        batch = new SpriteBatch();

        viewport.update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

        try {
            nodes = NodeSetReader.readNodeSet("nodes.txt");
        } catch (IOException e) {
            throw new RuntimeException("Couldn't read nodes", e);
        }

        int requiredRobots = box.robots;
        for (PathNode node : nodes) {
            if (node.type == NodeType.SPAWNER) {
                Robot robot = new Robot(nodes, node);
                robots.add(robot);
                requiredRobots -= 1;
                if (requiredRobots == 0)
                    break;
            }
        }
        if (requiredRobots > 0) {
            throw new RuntimeException("Not enough spawn pads.");
        }

        dayCounter = 0;
    }

    @Override
    public void stop() {
        batch.dispose();
    }

    @Override
    public GameMode tick() {
        final float CURVE_A = 10.0f, CURVE_B = 8.0f, CURVE_C = 7.0f;

        batch.setProjectionMatrix(viewport.getCamera().combined);
        renderBG();
        float dt = Gdx.graphics.getDeltaTime();

        ShapeRenderer sr = new ShapeRenderer();
        sr.setProjectionMatrix(viewport.getCamera().combined);

        for (Robot robot : robots) {
            robot.update(dt);

            PathNode visited = robot.at();
            if (visited != null) {
                switch (visited.type) {
                case WELL:
                    if (robot.available() && robot.accumulatedTimeAt > 2.0
                            && visited.reserves != 0) {
                        robot.pickUp(CargoType.WATER);
                        if (visited.reserves > 0) {
                            visited.reserves -= 1;
                        }
                    }
                    break;
                case BASE:
                    if (robot.offload(CargoType.WATER)) {
                        box.water += 1;
                    } else if (robot.offload(CargoType.METAL)) {
                        box.metal += 1;
                    } else if (robot.offload(CargoType.SALVAGE)) {
                        box.salvage += 1;
                    }
                    break;
                case WRECKAGE:
                    if (robot.available() && robot.accumulatedTimeAt > 5.0
                            && visited.reserves != 0) {
                        robot.pickUp(CargoType.SALVAGE);
                        visited.reserves -= 1;
                    }
                    break;
                case MINE:
                    if (robot.available() && robot.accumulatedTimeAt > 3.5
                            && visited.reserves != 0) {
                        robot.pickUp(CargoType.METAL);
                        if (visited.reserves > 0) {
                            visited.reserves -= 1;
                        }
                    }
                    break;
                default:
                    break;
                }
            }
        }
        sr.begin(ShapeType.Line);
        sr.setColor(Color.YELLOW);
        if (selectedRobot != null) {
            sr.curve(selectedRobot.x() - CURVE_A, selectedRobot.y(),
                    selectedRobot.x() - CURVE_B, selectedRobot.y() + CURVE_C,
                    selectedRobot.x() + CURVE_B, selectedRobot.y() + CURVE_C,
                    selectedRobot.x() + CURVE_A, selectedRobot.y(), 32);
        }
        sr.end();

        batch.begin();
        for (PathNode node : nodes) {
            Sprite spr = null;
            switch (node.type) {
            case WELL:
                if (node.reserves == 0) {
                    spr = Sprite.NODE_WELL_DEPLETED;
                } else {
                    spr = Sprite.NODE_WELL;
                }
                break;
            case MINE:
                if (node.reserves == 0) {
                    spr = Sprite.NODE_MINE_DEPLETED;
                } else {
                    spr = Sprite.NODE_MINE;
                }
                break;
            case BASE:
                spr = Sprite.NODE_SHIP;
                break;
            case WRECKAGE:
                spr = Sprite.NODE_SALVAGE;
                break;
            case WAYPOINT:
            case SPAWNER:
                if (DEBUG) {
                    spr = Sprite.NODE_DEBUG;
                }
                break;
            }
            if (spr != null) {
                spr.draw(batch, node.x, node.y);
            }
        }
        for (Robot robot : robots) {
            Sprite.ROBOT_IDLE.draw(batch, robot.x(), robot.y());
        }

        BitmapFont fnt = Overlord.get().assetManager.get("bitstream.fnt",
                BitmapFont.class);
        batch.setShader(Overlord.get().getFontShader());
        fnt.drawMultiLine(batch, "Water: " + box.water + "\nMetal: "<commit_msg>Get rid of taken Salvage<commit_after>package uk.co.alynn.games.suchrobot;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.viewport.FitViewport;
import com.badlogic.gdx.utils.viewport.Viewport;

public class MainMode implements GameMode {
    public static final float WORLD_WIDTH = 1024.0f;
    public static final float WORLD_HEIGHT = 640.0f;
    private SpriteBatch batch = null;
    private Viewport viewport = null;
    private NodeSet nodes = null;
    private List<Robot> robots = new ArrayList<Robot>();
    private Robot selectedRobot = null;
    private double dayCounter;

    private final boolean DEBUG = false;
    private Box box;

    public MainMode(Box box) {
        this.box = box;
    }

    @Override
    public void start() {
        viewport = new FitViewport(WORLD_WIDTH, WORLD_HEIGHT);
        batch = new SpriteBatch();

        viewport.update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

        try {
            nodes = NodeSetReader.readNodeSet("nodes.txt");
        } catch (IOException e) {
            throw new RuntimeException("Couldn't read nodes", e);
        }

        int requiredRobots = box.robots;
        for (PathNode node : nodes) {
            if (node.type == NodeType.SPAWNER) {
                Robot robot = new Robot(nodes, node);
                robots.add(robot);
                requiredRobots -= 1;
                if (requiredRobots == 0)
                    break;
            }
        }
        if (requiredRobots > 0) {
            throw new RuntimeException("Not enough spawn pads.");
        }

        dayCounter = 0;
    }

    @Override
    public void stop() {
        batch.dispose();
    }

    @Override
    public GameMode tick() {
        final float CURVE_A = 10.0f, CURVE_B = 8.0f, CURVE_C = 7.0f;

        batch.setProjectionMatrix(viewport.getCamera().combined);
        renderBG();
        float dt = Gdx.graphics.getDeltaTime();

        ShapeRenderer sr = new ShapeRenderer();
        sr.setProjectionMatrix(viewport.getCamera().combined);

        for (Robot robot : robots) {
            robot.update(dt);

            PathNode visited = robot.at();
            if (visited != null) {
                switch (visited.type) {
                case WELL:
                    if (robot.available() && robot.accumulatedTimeAt > 2.0
                            && visited.reserves != 0) {
                        robot.pickUp(CargoType.WATER);
                        if (visited.reserves > 0) {
                            visited.reserves -= 1;
                        }
                    }
                    break;
                case BASE:
                    if (robot.offload(CargoType.WATER)) {
                        box.water += 1;
                    } else if (robot.offload(CargoType.METAL)) {
                        box.metal += 1;
                    } else if (robot.offload(CargoType.SALVAGE)) {
                        box.salvage += 1;
                    }
                    break;
                case WRECKAGE:
                    if (robot.available() && robot.accumulatedTimeAt > 5.0
                            && visited.reserves != 0) {
                        robot.pickUp(CargoType.SALVAGE);
                        visited.reserves -= 1;
                    }
                    break;
                case MINE:
                    if (robot.available() && robot.accumulatedTimeAt > 3.5
                            && visited.reserves != 0) {
                        robot.pickUp(CargoType.METAL);
                        if (visited.reserves > 0) {
                            visited.reserves -= 1;
                        }
                    }
                    break;
                default:
                    break;
                }
            }
        }
        sr.begin(ShapeType.Line);
        sr.setColor(Color.YELLOW);
        if (selectedRobot != null) {
            sr.curve(selectedRobot.x() - CURVE_A, selectedRobot.y(),
                    selectedRobot.x() - CURVE_B, selectedRobot.y() + CURVE_C,
                    selectedRobot.x() + CURVE_B, selectedRobot.y() + CURVE_C,
                    selectedRobot.x() + CURVE_A, selectedRobot.y(), 32);
        }
        sr.end();

        batch.begin();
        for (PathNode node : nodes) {
            Sprite spr = null;
            switch (node.type) {
            case WELL:
                if (node.reserves == 0) {
                    spr = Sprite.NODE_WELL_DEPLETED;
                } else {
                    spr = Sprite.NODE_WELL;
                }
                break;
            case MINE:
                if (node.reserves == 0) {
                    spr = Sprite.NODE_MINE_DEPLETED;
                } else {
                    spr = Sprite.NODE_MINE;
                }
                break;
            case BASE:
                spr = Sprite.NODE_SHIP;
                break;
            case WRECKAGE:
                if (node.reserves != 0) {
                    spr = Sprite.NODE_SALVAGE;
                }
                break;
            case WAYPOINT:
            case SPAWNER:
                if (DEBUG) {
                    spr = Sprite.NODE_DEBUG;
                }
                break;
            }
            if (spr != null) {
                spr.draw(batch, node.x, node.y);
            }
        }
        for (Robot robot : robots) {
            Sprite.ROBOT_IDLE.draw(batch, robot.x(), robot.y());
        }

        BitmapFont fnt = Overlord.get().assetManager.get("bitstream.fnt",
                BitmapFont.class);
        batch.setShader(Overlord.get().getFontShader());
        fnt.drawMultiLine(batch, "Water: " + box.water + "\nMetal: "
{'fraction_non_alphanumeric': 0.10157085286618965, 'fraction_numerical': 0.007319680894810428, 'mean_word_length': 1.3100303951367782, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 19, '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': '5005921', 'n_tokens_mistral': 3675, 'n_tokens_neox': 3357, 'n_words': 677}