*/
    public static int playerXCount(ArrayList<Player> players, String s, Card source) {
        if (players.size() == 0) return 0;

        final String[] l = s.split("/");
        final String[] m = parseMath(l);

        int n = 0;

        // count valid cards on the battlefield
        if (l[0].contains("Valid")) {
            String restrictions = l[0].replace("Valid ", "");
            final String rest[] = restrictions.split(",");
            CardList cardsonbattlefield = AllZoneUtil.getCardsInPlay();
            cardsonbattlefield = cardsonbattlefield.getValidCards(rest, players.get(0), source);

            n = cardsonbattlefield.size();

            return doXMath(n, m, source);
        }
        

        final String[] sq;
        sq = l[0].split("\\.");

        if (sq[0].contains("CardsInHand")) {
            if (players.size() > 0) {
                return doXMath(AllZoneUtil.getPlayerHand(players.get(0)).size(), m, source);
            }
        }

        if (sq[0].contains("CardsInLibrary")) {
            if (players.size() > 0) {
                return doXMath(AllZoneUtil.getPlayerCardsInLibrary(players.get(0)).size(), m, source);
            }
        }
        
        if (sq[0].contains("CardsInGraveyard")) {
        	if (players.size() > 0) {
        		return doXMath(AllZoneUtil.getPlayerGraveyard(players.get(0)).size(), m, source);
        	}
        }
        if (sq[0].contains("LandsInGraveyard"))
            if (players.size() > 0) {
                return doXMath(AllZoneUtil.getPlayerTypeInGraveyard(players.get(0), "Land").size(), m, source);
            }

        if (sq[0].contains("CreaturesInPlay")) {
            if (players.size() > 0) {
                return doXMath(AllZoneUtil.getCreaturesInPlay(players.get(0)).size(), m, source);
            }
        }

        if (sq[0].contains("CardsInPlay")) {
            if (players.size() > 0) {
                return doXMath(AllZoneUtil.getPlayerCardsInPlay(players.get(0)).size(), m, source);
            }
        }

        if (sq[0].contains("LifeTotal")) {
            if (players.size() > 0) {
                return doXMath(players.get(0).getLife(), m, source);
            }
        }

        if (sq[0].contains("TopOfLibraryCMC")) {
            if (players.size() > 0) {
                return doXMath(AllZoneUtil.getPlayerCardsInLibrary(players.get(0), 1).getTotalConvertedManaCost(), m, source);
            }
        }

        return doXMath(n, m, source);
    }