package com.red.circle.other.infra.database.mongo.entity.game.ludo;

import java.util.Arrays;
import java.util.Objects;

/**
 * 棋盘颜色.
 *
 * @author pengliang on 2022/3/8
 */
public enum CheckerboardColor {

  RED(1), GREEN(2), YELLOW(3), BLUE(4);

  private final int index;

  CheckerboardColor(int index) {
    this.index = index;
  }

  public int getIndex() {
    return index;
  }

  public static CheckerboardColor getByIndex(int index) {
    return Arrays.stream(CheckerboardColor.values())
        .filter(checkerboardColor -> Objects.equals(index, checkerboardColor.getIndex()))
        .findFirst()
        .orElse(null);
  }

}
