package com.alterdekim.game.utils;

import org.javatuples.Pair;

public class GameUtils {

    public static final Long EmptyGoodId = 360L;
    public static final Integer EmptyMRId = 98;
    public static int extractLocationId(String s) {
        String[] r = s.split("\\$");
        if( r.length < 3) return 0;
        return Integer.parseInt(r[2]);
    }

    // returns true if it's user's club
    public static Pair<Integer, Boolean> getPlayerIdFromNegative(long l) {
        if (l < -4294967295L) {
            return Pair.with((int) (Math.abs(l) >> 32), true);
        }
        return Pair.with((int) Math.abs(l), false);
    }

    public static long convertToSpecialLocation(int playerId, boolean isHome) {
        return -(isHome ? (long) playerId : ((long) playerId) << 32);
    }
}
