Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/model.py
diff options
context:
space:
mode:
authorSimon Schampijer <simon@schampijer.de>2007-07-02 21:09:26 (GMT)
committer Simon Schampijer <simon@schampijer.de>2007-07-02 21:09:26 (GMT)
commit73859e45443e762bdbae8a1ce9120bf4828873f6 (patch)
treedcb448e318409adb3586767ec224feb41ca777f7 /model.py
parentea34d78e90d00587d1036d8847d966e2a759099e (diff)
First networking stuff is working. Getting closer to a first release. Code to change tiles back when not the same must be added now.
Diffstat (limited to 'model.py')
-rw-r--r--model.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/model.py b/model.py
index fcd319d..510c9c4 100644
--- a/model.py
+++ b/model.py
@@ -3,6 +3,8 @@ import os
import logging
import random
+IMAGES_PATH = os.path.join(os.path.dirname(__file__),'games/drumgit/images')
+
class Model(object):
def __init__(self, gamepath, dtdpath, name='noname'):
self.name = name
@@ -31,12 +33,12 @@ class Model(object):
for elem in res:
attributes = elem.get_properties()
pair = []
- idpair = ''
+ idpair = 0
for attribute in attributes:
if(attribute.name == 'text'):
pass
if(attribute.name == 'id'):
- idpair = attribute.content
+ idpair = int(attribute.content)
if(attribute.name == 'mother'):
pair.append(attribute.content)
if(attribute.name == 'child'):
@@ -82,6 +84,18 @@ class Model(object):
random.shuffle(self.grid)
print 'self.grid after shufle: %s'%self.grid
+ def gettile(self, tilenum):
+ pairkey, moch = self.grid[tilenum]
+ obj = os.path.join(IMAGES_PATH, self.pairs[pairkey][moch])
+ color = self.pairs[pairkey][2]
+ # logger.debug('obj=%s color=%s'%(obj, color))
+ return (obj, color)
+
+ def same(self, a, b):
+ pairkeya, moch = self.grid[a]
+ pairkeyb, moch = self.grid[b]
+ return (pairkeya == pairkeyb)
+
if __name__ == '__main__':
print "[Read game from file] "