<commit_before>package orwell.proxy.robot;

import lejos.mf.common.UnitMessage;
import lejos.mf.common.UnitMessageType;
import orwell.messages.Controller;

/**
 * Created by <NAME> on 5/18/15.
 */
public class InputFire implements IRobotInput {

    private final static String FIRE_PAYLOAD_HEADER = "input fire ";
    private Controller.Input.Fire fire;
    private boolean hasFire = false;

    public void setFire(final Controller.Input.Fire fire) {
        this.fire = fire;
        this.hasFire = true;
    }

    public boolean hasFire() {
        return hasFire;
    }

    @Override
    public void accept(final IRobotInputVisitor visitor) {
        visitor.visit(this);
    }

    public void sendUnitMessageTo(final IRobot robot) {
        // "input fire fireWeapon1 fireWeapon2"
        robot.sendUnitMessage(new UnitMessage(UnitMessageType.Command, FIRE_PAYLOAD_HEADER + fire.getWeapon1() + " " + fire.getWeapon2()));
    }
}<commit_msg>Filter input fire sent to the robot : nothing is sent if all fire weapons are false<commit_after>package orwell.proxy.robot;

import lejos.mf.common.UnitMessage;
import lejos.mf.common.UnitMessageType;
import orwell.messages.Controller;

/**
 * Created by <NAME> on 5/18/15.
 */
public class InputFire implements IRobotInput {

    private final static String FIRE_PAYLOAD_HEADER = "input fire ";
    private Controller.Input.Fire fire;
    private boolean hasFire = false;

    public void setFire(final Controller.Input.Fire fire) {
        this.fire = fire;
        this.hasFire = true;
    }

    public boolean hasFire() {
        return hasFire;
    }

    @Override
    public void accept(final IRobotInputVisitor visitor) {
        visitor.visit(this);
    }

    public void sendUnitMessageTo(final IRobot robot) {
        // "input fire fireWeapon1 fireWeapon2"
        if (fire.getWeapon1() || fire.getWeapon2()) // We avoid flooding the robot if there is no fire
            robot.sendUnitMessage(
                    new UnitMessage(
                            UnitMessageType.Command, FIRE_PAYLOAD_HEADER +
                            fire.getWeapon1() + " " + fire.getWeapon2())
            );
    }
}
{'fraction_non_alphanumeric': 0.0909510618651893, 'fraction_numerical': 0.009233610341643583, 'mean_word_length': 2.7042735042735044, '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': '1116215', 'n_tokens_mistral': 644, 'n_tokens_neox': 628, 'n_words': 164}