From 0f7f45161544fe160c50abb7734b6b1a9c51a4a0 Mon Sep 17 00:00:00 2001 From: temitchell Date: Sun, 2 Feb 2003 07:50:10 +0000 Subject: [PATCH] - using new directory getting functions in the Plugin, makes python more better - converted the slots over, now easier to install - added a script that returns the directories for easy use git-svn-id: svn://svn.code.sf.net/p/crossfire/code/trunk/maps@1990 282e977c-c81d-0410-88c4-b93c2d0d6712 --- {unlinked/casino => python}/CFGamble.py | 6 ++-- python/CFgetPaths.py | 35 ++++++++++++++++++++ {unlinked => python}/casino/goldslots.py | 2 +- {unlinked => python}/casino/platinumslots.py | 2 +- {unlinked => python}/casino/silverslots.py | 2 +- unlinked/casino/casino_infernal | 18 +++++----- 6 files changed, 51 insertions(+), 14 deletions(-) rename {unlinked/casino => python}/CFGamble.py (88%) mode change 100755 => 100644 create mode 100644 python/CFgetPaths.py rename {unlinked => python}/casino/goldslots.py (97%) mode change 100755 => 100644 rename {unlinked => python}/casino/platinumslots.py (97%) mode change 100755 => 100644 rename {unlinked => python}/casino/silverslots.py (97%) mode change 100755 => 100644 diff --git a/unlinked/casino/CFGamble.py b/python/CFGamble.py old mode 100755 new mode 100644 similarity index 88% rename from unlinked/casino/CFGamble.py rename to python/CFGamble.py index febb31c70..24ef5afea --- a/unlinked/casino/CFGamble.py +++ b/python/CFGamble.py @@ -2,7 +2,9 @@ # Todd Mitchell #The Python control file for Slot Machines and other such nonsense #Please do not put CFPython functions in this file, -#but rather place these in the calling file +#but rather place these in the calling file (don't ask me why - it just feels right) + +import CFgetPaths import os.path import shelve import random @@ -11,7 +13,7 @@ class SlotMachine: #sets up the file that holds all the slotmachine jackpots #make sure this points to your writable var/crossfire directory #you can delete that file to reset all the slotmachine jackpots - slotfile = '/usr/local/CF/var/crossfire/SlotMachine_file' + slotfile = '%sSlotMachine_file' %(CFgetPaths.getPaths("localdir")) slotdb = {} def __init__(self,slotname,slotlist,minpot,maxpot): slotdb = shelve.open(self.slotfile) diff --git a/python/CFgetPaths.py b/python/CFgetPaths.py new file mode 100644 index 000000000..67055e08c --- /dev/null +++ b/python/CFgetPaths.py @@ -0,0 +1,35 @@ +## CFgetPaths.py +## Todd Mitchell (temitchell@sympatico.ca) +## Generates the proper Crossfire directory paths +## returns the absolute paths with a nice "/" at the end. + +import CFPython + +def getPaths(directory): + '''returns absolute path for crossfire directory specified. + Options are datadir, mapdir, uniquedir, localdir, playerdir, configdir, tempdir, all. + "all" will return a dictionary of all paths''' + +#Get the Paths + + datadir = "%s/" %(CFPython.GetDataDirectory()) + mapdir = "%s/%s/" %(datadir, CFPython.GetMapDirectory()) + uniquedir = "%s/%s/" %(datadir, CFPython.GetUniqueDirectory()) + localdir = "%s/" %(CFPython.GetLocalDirectory()) + playerdir = "%s/%s/" %(localdir, CFPython.GetPlayerDirectory()) + configdir = "%s/" %(CFPython.GetConfigurationDirectory()) + tempdir = "%s/" %(CFPython.GetTempDirectory()) + +#make the dictionary + + paths = {"datadir":datadir, "mapdir":mapdir, "uniquedir":uniquedir, "localdir":localdir, "playerdir":playerdir, "configdir":configdir, "tempdir":tempdir} + +#return the proper + + if directory == "all": + return paths + else: + try: + return paths[directory] + except KeyError: + return 0 diff --git a/unlinked/casino/goldslots.py b/python/casino/goldslots.py old mode 100755 new mode 100644 similarity index 97% rename from unlinked/casino/goldslots.py rename to python/casino/goldslots.py index 487cab208..606e2b239 --- a/unlinked/casino/goldslots.py +++ b/python/casino/goldslots.py @@ -4,7 +4,7 @@ import CFPython import sys -sys.path.append('/usr/local/CF/share/crossfire/maps/python') +sys.path.append('%s/%s/python' %(CFPython.GetDataDirectory(),CFPython.GetMapDirectory())) import CFGamble activator=CFPython.WhoIsActivator() diff --git a/unlinked/casino/platinumslots.py b/python/casino/platinumslots.py old mode 100755 new mode 100644 similarity index 97% rename from unlinked/casino/platinumslots.py rename to python/casino/platinumslots.py index 8f672bcba..2ee41c598 --- a/unlinked/casino/platinumslots.py +++ b/python/casino/platinumslots.py @@ -4,7 +4,7 @@ import CFPython import sys -sys.path.append('/usr/local/CF/share/crossfire/maps/python') +sys.path.append('%s/%s/python' %(CFPython.GetDataDirectory(),CFPython.GetMapDirectory())) import CFGamble activator=CFPython.WhoIsActivator() diff --git a/unlinked/casino/silverslots.py b/python/casino/silverslots.py old mode 100755 new mode 100644 similarity index 97% rename from unlinked/casino/silverslots.py rename to python/casino/silverslots.py index ab614ccd3..d7a7a0c87 --- a/unlinked/casino/silverslots.py +++ b/python/casino/silverslots.py @@ -3,7 +3,7 @@ import CFPython import sys -sys.path.append('/usr/local/CF/share/crossfire/maps/python') +sys.path.append('%s/%s/python' %(CFPython.GetDataDirectory(),CFPython.GetMapDirectory())) import CFGamble activator=CFPython.WhoIsActivator() diff --git a/unlinked/casino/casino_infernal b/unlinked/casino/casino_infernal index 6e2959b75..91566f88d 100755 --- a/unlinked/casino/casino_infernal +++ b/unlinked/casino/casino_infernal @@ -237,7 +237,7 @@ Drop a platinum coin to play. endmsg title Slot event_apply_plugin Python -event_apply /unlinked/casino/platinumslots.py +event_apply /python/casino/platinumslots.py x 1 y 8 end @@ -263,7 +263,7 @@ msg Drop a gold coin to play. endmsg event_apply_plugin Python -event_apply /unlinked/casino/goldslots.py +event_apply /python/casino/goldslots.py title Slot x 1 y 10 @@ -291,7 +291,7 @@ Drop a silver coin to play. endmsg title Slot event_apply_plugin Python -event_apply /unlinked/casino/silverslots.py +event_apply /python/casino/silverslots.py x 1 y 12 end @@ -417,7 +417,7 @@ Drop a platinum coin to play. endmsg title Slot event_apply_plugin Python -event_apply /unlinked/casino/platinumslots.py +event_apply /python/casino/platinumslots.py x 2 y 8 end @@ -444,7 +444,7 @@ Drop a gold coin to play. endmsg title Slot event_apply_plugin Python -event_apply /unlinked/casino/goldslots.py +event_apply /python/casino/goldslots.py x 2 y 10 end @@ -471,7 +471,7 @@ Drop a silver coin to play. endmsg title Slot event_apply_plugin Python -event_apply /unlinked/casino/silverslots.py +event_apply /python/casino/silverslots.py x 2 y 12 end @@ -597,7 +597,7 @@ Drop a platinum coin to play. endmsg title Slot event_apply_plugin Python -event_apply /unlinked/casino/platinumslots.py +event_apply /python/casino/platinumslots.py x 3 y 8 end @@ -624,7 +624,7 @@ Drop a gold coin to play. endmsg title Slot event_apply_plugin Python -event_apply /unlinked/casino/goldslots.py +event_apply /python/casino/goldslots.py x 3 y 10 end @@ -651,7 +651,7 @@ Drop a silver coin to play. endmsg title Slot event_apply_plugin Python -event_apply /unlinked/casino/silverslots.py +event_apply /python/casino/silverslots.py x 3 y 12 end