package org.academiadecodigo.bootcamp11.rockpaperscissors;

/**
 * MIT License
 * (c) 2017 Ricardo Constantino
 */
public enum Hand {
    ROCK("Rock"),
    PAPER("Paper"),
    SCISSORS("Scissors"),
    LIZARD("Lizard"),
    SPOCK("Spock");

    private String name;
    private Hand[] losesTo;

    Hand(String name) {
        this.name = name;
    }

    public String getName() {
        return this.name;
    }

    // fills hands with counters to themselves
    public void addLosesTo(Hand[] hands) {
        this.losesTo = hands;
    }

    public boolean losesTo(Hand two) {
        for (Hand counter : this.losesTo) {
            if (two == counter) {
                // we found a counter hand
                return true;
            }
        }
        return false;
    }
}