#!/usr/libexec/poker3d/underware
# -*- python -*-
#
# Copyright (C) 2005, 2006 Mekensleep
#
# Mekensleep
# 24 rue vieille du temple
# 75004 Paris
#       licensing@mekensleep.com
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
#
# Authors:
#  Loic Dachary <loic@gnu.org>
#
import sys
import os

import platform

if platform.system() == "Windows":
  if os.path.exists("../../../../underware"):
     sys.path.insert(0, "../../../../pokersource/poker-engine")
     sys.path.insert(0, "../../../../pokersource/poker-network")
     sys.path.insert(0, "../../../../pokersource/pypoker-eval")
     sys.path.insert(0, "../../../../underware/underware/python")
     sys.path.insert(0, "../../../../underware/underware/examples")
else:
  sys.path.insert(0, "/usr/lib/python2.5/site-packages")
  sys.path.insert(0, "../../python/underware/.libs")
  sys.path.insert(0, "../../python/underware")
  sys.path.insert(0, "./..")

import getopt

from poker.poker3d import run


def usage():
    print """
poker3d [--datadir=<directory>] [--upgradesdir=<directory>] [--pokernetwork-upgradesdir=<directory>] [--help] [settings.xml] ...
"""

def main():
    try:
        opts, args = getopt.getopt(sys.argv[1:], "hdpu", ["help", "datadir=", "pokernetwork-upgradesdir=", "upgradesdir=" ])
    except getopt.GetoptError:
        usage()
        sys.exit(2)
    datadir = "/usr/share/poker3d"
    pokernetwork_upgradesdir = "/usr/share/poker-network/upgrades/poker.client"
    upgradesdir = "/usr/share/poker3d/upgrades"
    for o, a in opts:
        if o in ("-h", "--help"):
            usage()
            sys.exit(0)
        if o in ("-d", "--datadir"):
            datadir = a
        if o in ("-p", "--pokernetwork-upgradesdir"):
            pokernetwork_upgradesdir = a
        if o in ("-u", "--upgradesdir"):
            upgradesdir = a

    run(args, datadir, "poker3d", upgradesdir, pokernetwork_upgradesdir)

    return 0

if __name__ == "__main__":
    #sys.exit(main())
    main()
