comparison orpg/orpgCore.py @ 0:4385a7d0efd1 grumpy-goblin

Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
author sirebral
date Tue, 14 Jul 2009 16:41:58 -0500
parents
children 73d9286c22cf
comparison
equal deleted inserted replaced
-1:000000000000 0:4385a7d0efd1
1 #!/usr/bin/env python
2 # Copyright (C) 2000-2006 The OpenRPG Project
3 #
4 # openrpg-dev@lists.sourceforge.net
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 # --
20 #
21 # File: main.py
22 # Author: Chris Davis
23 # Maintainer:
24 # Version:
25 # $Id: orpgCore.py,v 1.8 2006/11/12 00:10:37 digitalxero Exp $
26 #
27 # Description: This is the core functionality that is used by both the client and server.
28 # As well as everything in here should be global to every file
29 #
30
31 __version__ = "$Id: orpgCore.py,v 1.8 2006/11/12 00:10:37 digitalxero Exp $"
32
33 import time
34 from string import *
35 import os
36 import os.path
37 import thread
38 import traceback
39 import sys
40 import systempath
41 import re
42 import string
43 import urllib
44 import webbrowser
45 import random
46
47 #########################
48 ## Error Types
49 #########################
50 ORPG_CRITICAL = 1
51 ORPG_GENERAL = 2
52 ORPG_INFO = 4
53 ORPG_NOTE = 8
54 ORPG_DEBUG = 16
55
56 ########################
57 ## openrpg object
58 ########################
59
60 class ORPGStorage(object):
61 __components = {}
62
63 def add_component(self, key, com):
64 self.__components[key] = com
65
66 def get_component(self, key):
67 if self.__components.has_key(key):
68 return self.__components[key]
69 else:
70 return None
71
72 def singleton(cls):
73 instances = {}
74 def getinstance():
75 if cls not in instances:
76 instances[cls] = cls()
77 return instances[cls]
78 return getinstance
79
80 ORPGStorage = singleton(ORPGStorage)
81 open_rpg = ORPGStorage()