package com.codingame.game.engine;

public class Constants
{
  // CG Optimization puzzle constraints:
  // - Max 30s runtime for each of the validators
  // - Max 50 validators

  public static int TURNLIMIT = 606;
  public static int TIMELIMIT_INIT = 1_000;
  public static int TIMELIMIT_TURN = 50;

  public static int FRAMEDURATION=500;
  public static int FRAMEDURATION_SUMMARY = 2000;


  public static int VIS_SCREEN_WIDTH = 1920;
  public static int VIS_SCREEN_HEIGHT = 1080;


  public static int MAX_MAP = 1000;
  public static int MAX_PATH = 10;

  public static int XY(int x, int y) {return x*MAX_MAP+y;}
  public static int X(int xy) {return xy/MAX_MAP;}
  public static int Y(int xy) {return xy%MAX_MAP;}
  public static int D(int xy, String dir) {
    switch (dir)
    {
      case "N": return XY(X(xy), Y(xy)-1);
      case "S": return XY(X(xy), Y(xy)+1);
      case "W": return XY(X(xy)-1, Y(xy));
      case "E": return XY(X(xy)+1, Y(xy));
      default: return -1;
    }
  }
  public static String[] ItoD = new String[] {"N", "S", "W", "E"};
  public static Integer[] ItoDX = new Integer[] {0, 0, -1, 1};
  public static Integer[] ItoDY = new Integer[] {-1, 1, 0, 0};
  public static Integer[] ItoREV = new Integer[] {1, 0, 3, 2};

  public static int DtoI(char dir) {
    switch (dir)
    {
      case 'N': return 0;
      case 'S': return 1;
      case 'W': return 2;
      case 'E': return 3;
      default: return -1;
    }
  }

  public static String REVDIR(String dir) {
    switch (dir)
    {
      case "N": return "S";
      case "S": return "N";
      case "W": return "E";
      case "E": return "W";
      default: return "X";
    }
  }
}
