--sets everything we need (global variables, constants) and imports all files

--constants
--cards power
NOVALUE=0
JACK=11
KNIGHT=12
QUEEN=13
KING=14
ACE=15
TWO=16
TRUMP=17

--imports all lua files
dofile("imports.lua")

--simple vars like colors, needed for the alert() method
white=Color.new(255,255,255)
black=Color.new(0,0,0)
grey=Color.new(110,110,110)
red=Color.new(255,0,0)

alert("loading preferences...", 10)
--load all preferences
USERPREF=loadPropertiesFile("configuration/preferences.properties")
GAMEPREF=loadPropertiesFile("configuration/game.properties")
CARDSPREF=loadPropertiesFile("images/cards/"..USERPREF["cards"].."/cards.properties")
ICONSPREF={}
ICONSPREF["playersNum"]=loadPropertiesFile("images/icons/playersNum/"..USERPREF["playersNumIcons"].."/playersNumIcons.properties")
ICONSPREF["ranks"]=loadPropertiesFile("images/icons/ranks/"..USERPREF["ranksIcons"].."/ranksIcons.properties")
ICONSPREF["states"]=loadPropertiesFile("images/icons/states/"..USERPREF["statesIcons"].."/statesIcons.properties")
BUBBLESPREF=loadPropertiesFile("images/speechbubbles/"..USERPREF["speechbubbles"].."/speechbubbles.properties")
CARPETPREF=loadPropertiesFile("images/carpets/"..USERPREF["carpet"].."/carpet.properties")
CURSORPREF=loadPropertiesFile("images/cursors/"..USERPREF["cursor"].."/cursor.properties")

FONTS=loadFonts()

if USERPREF["activateUSB"] then
	System.usbDiskModeActivate()	
end

colorProperties=loadPropertiesFile("configuration/colors.properties")
colors={}
colors["neutral In"]=colorProperties["colorNeutralIn"]
colors["neutral Out"]=colorProperties["colorNeutralOut"]
colors["president In"]=colorProperties["colorPresidentIn"]
colors["president Out"]=colorProperties["colorPresidentOut"]
colors["vice president In"]=colorProperties["colorVicePresidentIn"]
colors["vice president Out"]=colorProperties["colorVicePresidentOut"]
colors["vice asshole In"]=colorProperties["colorViceAssholeIn"]
colors["vice asshole Out"]=colorProperties["colorViceAssholeOut"]
colors["asshole In"]=colorProperties["colorAssholeIn"]
colors["asshole Out"]=colorProperties["colorAssholeOut"]
colorProperties=nil

--load all images (and alerts the user of whats going on)
drawSplashScreen()
alert("loading carpet...")
background=Image.load("images/carpets/"..USERPREF["carpet"].."/carpet.png")
drawSplashScreen()
--state icons, cursor etc
alert("loading icons...")
iconImages={}
iconImages["playersNum"]=loadPlayersNumIconImages(USERPREF["playersNumIcons"])
iconImages["ranks"]=loadRankIconImages(USERPREF["ranksIcons"])
iconImages["states"]=loadStatesIconImages(USERPREF["statesIcons"])
drawSplashScreen()
--images of the cards
alert("loading cards...")
cardImages=loadCardImages(USERPREF["cards"])
drawSplashScreen()
--images to display menus
alert("loading menu images...")
menuImages=loadMenuImages()
drawSplashScreen()
alert("loading speech bubbles images")
bubbleImages=loadBubbleImages(USERPREF["speechbubbles"])
drawSplashScreen()


--initialize the structure (the global variables we will manipulate)
alert("preparing structure...")
mainDeck=prepareMainDeck() --the deck where all cards are in, and where they go once used
players=preparePlayers() -- the 4 players
ingameCursor=prepareIngameCursor() -- the cursor for the user, to select cards
tableDeck={} -- the cards currently played
speechBubbles=prepareSpeechBubbles()














