Web · Wiki · Activities · Blog · Lists · Chat · Meeting · Bugs · Git · Translate · Archive · People · Donate

Commit b2da2ffe0b74dda78a825c910fca5f3620b9b6e7

- added new model
- the config files for games have changed to use xml
  added reading and writing of the config files
- adopted the ui to use the model
- adopted the dbus methods to send the new grid when a game changes
- fixed some buddy left issues
- cleaned the misc folder
  
1<?xml version="1.0" encoding="utf-8"?>
2<!-- Generator: Adobe Illustrator 12.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 51448) -->
3<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [
4 <!ENTITY ns_svg "http://www.w3.org/2000/svg">
5 <!ENTITY ns_xlink "http://www.w3.org/1999/xlink">
6 <!ENTITY stroke_color "#000000">
7 <!ENTITY fill_color "#AAAAAA">
8]>
9<svg version="1.1" id="Icon" xmlns="&ns_svg;" xmlns:xlink="&ns_xlink;" width="43.584" height="43.292"
10 viewBox="0 0 43.584 43.292" overflow="visible" enable-background="new 0 0 43.584 43.292" xml:space="preserve">
11<rect x="1.75" y="1.75" fill="#FFFFFF" stroke="&stroke_color;" stroke-width="3.5" width="10" height="10"/>
12<rect x="17.084" y="1.75" fill="&fill_color;" stroke="&stroke_color;" stroke-width="3.5" width="10" height="10"/>
13<rect x="31.834" y="1.75" fill="&fill_color;" stroke="&stroke_color;" stroke-width="3.5" width="10" height="10"/>
14<rect x="1.75" y="16.667" fill="&fill_color;" stroke="&stroke_color;" stroke-width="3.5" width="10" height="10"/>
15<rect x="17.084" y="16.667" fill="&fill_color;" stroke="&stroke_color;" stroke-width="3.5" width="10" height="10"/>
16<rect x="31.834" y="16.667" fill="&fill_color;" stroke="&stroke_color;" stroke-width="3.5" width="10" height="10"/>
17<rect x="1.75" y="31.542" fill="&fill_color;" stroke="&stroke_color;" stroke-width="3.5" width="10" height="10"/>
18<rect x="17.084" y="31.542" fill="#FFFFFF" stroke="&stroke_color;" stroke-width="3.5" width="10" height="10"/>
19<rect x="31.834" y="31.542" fill="&fill_color;" stroke="&stroke_color;" stroke-width="3.5" width="10" height="10"/>
20</svg>
  
1<?xml version="1.0" encoding="utf-8"?>
2<!-- Generator: Adobe Illustrator 12.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 51448) -->
3<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [
4 <!ENTITY ns_svg "http://www.w3.org/2000/svg">
5 <!ENTITY ns_xlink "http://www.w3.org/1999/xlink">
6 <!ENTITY stroke_color "#000000">
7 <!ENTITY fill_color "#AAAAAA">
8]>
9<svg version="1.1" id="Icon" xmlns="&ns_svg;" xmlns:xlink="&ns_xlink;" width="43.584" height="43.292"
10 viewBox="0 0 43.584 43.292" overflow="visible" enable-background="new 0 0 43.584 43.292" xml:space="preserve">
11<rect x="1.75" y="1.75" fill="#FFFFFF" stroke="&stroke_color;" stroke-width="3.5" width="10" height="10"/>
12<rect x="17.084" y="1.75" fill="&fill_color;" stroke="&stroke_color;" stroke-width="3.5" width="10" height="10"/>
13<rect x="31.834" y="1.75" fill="&fill_color;" stroke="&stroke_color;" stroke-width="3.5" width="10" height="10"/>
14<rect x="1.75" y="16.667" fill="&fill_color;" stroke="&stroke_color;" stroke-width="3.5" width="10" height="10"/>
15<rect x="17.084" y="16.667" fill="&fill_color;" stroke="&stroke_color;" stroke-width="3.5" width="10" height="10"/>
16<rect x="31.834" y="16.667" fill="&fill_color;" stroke="&stroke_color;" stroke-width="3.5" width="10" height="10"/>
17<rect x="1.75" y="31.542" fill="&fill_color;" stroke="&stroke_color;" stroke-width="3.5" width="10" height="10"/>
18<rect x="17.084" y="31.542" fill="#FFFFFF" stroke="&stroke_color;" stroke-width="3.5" width="10" height="10"/>
19<rect x="31.834" y="31.542" fill="&fill_color;" stroke="&stroke_color;" stroke-width="3.5" width="10" height="10"/>
20</svg>
  
6363 self.table_positions = {}
6464
6565 # Build the table
66 if data['divided']=='True':
66 if data['divided']=='1':
6767 text1 = str(self.data['face1'])
6868 text2 = str(self.data['face2'])
6969 else:
7171 text2 = str(self.data['face'])
7272 buffer_card_1 = svgcard.SvgCard(-1, {'front_border':{'opacity':'0'}, 'front_h_border':{'opacity':'0.5'}, 'back_text':{'card_text':text1}}, {}, None, self.card_size)
7373 buffer_card_2 = svgcard.SvgCard(-1, {'front_border':{'opacity':'0'}, 'front_h_border':{'opacity':'0.5'}, 'back_text':{'card_text':text2}}, {}, None, self.card_size)
74
75 self.game_dir = os.path.join(os.path.dirname(__file__), 'games')
74
7675 x = 0
7776 y = 0
7877 id = 0
79 for card in self.cards_data:
80 if card[1] <> '':
81 jpg = os.path.join(self.game_dir, self.data['game_name']+'/images/'+str(card[1]))
78
79 for card in self.cards_data:
80 if card.get('img', None):
81 jpg = card['img']
8282 else:
8383 jpg = None
8484 props = {}
8585 props['front_border'] = {'opacity':'1'}
8686 props['front_h_border'] ={'opacity':'1'}
87 props['front_text']= {'card_text':card[3], 'card_line1':card[4], 'card_line2':card[5], 'card_line3':card[6], 'card_line4':card[7]}
87 props['front_text']= {'card_text':card.get('char', ''), 'card_line1':'', 'card_line2':'', 'card_line3':'', 'card_line4':''}
8888
89 if card[0]== '1':
89 if card['ab']== 'a':
9090 buffer_card = buffer_card_1
91 else:
91 elif card['ab']== 'b':
9292 buffer_card = buffer_card_2
9393
9494 card = svgcard.SvgCard(id, props, buffer_card.get_cache(), jpg, self.card_size)
game.py
(47 / 42)
  
2929
3030import gobject
3131
32from model import Model
33
3234_logger = logging.getLogger('memorize-activity')
3335
3436SERVICE = "org.laptop.Memorize"
7070 self.game_dir = os.path.join(os.path.dirname(__file__), 'games')
7171 self.messenger = None
7272 self.sentitive = True
73 self.model = Model(os.path.dirname(__file__))
74
75 def load_game(self, game_name, size):
76 if self.model.read(game_name) == 0:
77 self.model.def_grid(size)
78 self.model.data['running'] = 'False'
79 logging.debug(' Read setup file %s: %s '%(game_name, self.model.grid))
80 self.emit('load_game', self.model.data, self.model.grid)
81 else:
82 logging.error(' Reading setup file %s'%game_name)
7383
74 def load_game(self, game_name, size):
75 tuple = self.read_config(game_name, size)
76 self.data = tuple[0]
77 self.grid = tuple[1]
78 self.data['running'] = 'False'
79 self.emit('load_game', self.data, self.grid)
80
8184 def add_buddy(self, buddy, score = 0):
8285 _logger.debug('Buddy %r was added to game', buddy.props.nick)
8386 self.players.append(buddy)
9292 self.change_turn()
9393
9494 def rem_buddy(self, buddy):
95 _logger.debug('Buddy %r was removed to game', buddy.props.nick)
95 _logger.debug('Buddy %r was removed from game', buddy.props.nick)
9696 index = self.players.index(buddy)
9797 del self.players[index]
9898 del (self.players_score[buddy])
99 if self.current_player == buddy and len(self.players) <> 0:
99 if self.current_player == buddy and len(self.players) >= 2: ### fix from <> 0
100100 self.change_turn()
101101 self.emit('rem_buddy', buddy)
102102
116116 return
117117
118118 # Handle groups if needed
119 if self.data['divided'] == 'True':
120 if self.last_flipped == -1 and id >= (len(self.grid)/2):
119 if self.model.data['divided'] == '1':
120 if self.last_flipped == -1 and id >= (len(self.model.grid)/2):
121121 return
122 if self.last_flipped <> -1 and id < (len(self.grid)/2):
122 if self.last_flipped <> -1 and id < (len(self.model.grid)/2):
123123 return
124 self.data['running'] = 'True'
124 self.model.data['running'] = 'True'
125125
126126 # First card case
127127 if self.last_flipped == -1:
128128 self.last_flipped = id
129 self.grid[id][8] = 1
129 self.model.grid[id]['state'] = '1'
130130 self.emit('flip-card', id)
131131 if not signal:
132132 self.emit('flip-card-signal', id)
133 if self.data['divided'] == 'True':
133 if self.model.data['divided'] == '1':
134134 self.card_highlighted(widget, -1, False)
135135
136 # Pair matched
137 elif self.grid[self.last_flipped][-1] == self.grid[id][-1]:
136 # Pair matched
137 elif self.model.grid[self.last_flipped]['pairkey'] == self.model.grid[id]['pairkey']:
138138 stroke_color, fill_color = self.current_player.props.color.split(',')
139139 self.emit('set-border', id, stroke_color, fill_color)
140140 self.emit('set-border', self.last_flipped, stroke_color, fill_color)
141141 self.increase_point(self.current_player)
142 self.grid[id][8] = 1
142 self.model.grid[id]['state'] = '1'
143143 self.emit('flip-card', id)
144 if self.data['divided'] == 'True':
144 if self.model.data['divided'] == '1':
145145 self.card_highlighted(widget, -1, False)
146146 if not signal:
147147 self.emit('flip-card-signal', id)
148148 self.last_flipped = -1
149149 # Pair don't match
150 elif self.grid[self.last_flipped][-1] <> self.grid[id][-1]:
150 elif self.model.grid[self.last_flipped]['pairkey'] != self.model.grid[id]['pairkey']:
151151 self.emit('flip-card', id)
152152 if not signal:
153153 self.emit('flip-card-signal', id)
154 self.grid[id][8] = 1
155 time.sleep(2)
154 self.model.grid[id]['state'] = '1'
155 time.sleep(2) ### gobject.timeout() here?
156156 self.emit('flop-card', id)
157 self.grid[id][8] = 0
157 self.model.grid[id]['state'] = '0'
158158 self.emit('flop-card', self.last_flipped)
159 if self.data['divided'] == 'True':
159 if self.model.data['divided'] == '1':
160160 self.card_highlighted(widget, -1, False)
161161 # self.emit('highlight-card', id, True)
162 self.grid[self.last_flipped][8] = 0
162 self.model.grid[self.last_flipped]['state'] = '0'
163163 self.last_flipped = -1
164164 self.change_turn()
165165
171171
172172 if not self.sentitive:
173173 return
174 if self.data['divided'] == 'True':
175 if self.last_flipped == -1 and id >= (len(self.grid)/2):
174 if self.model.data['divided'] == '1':
175 if self.last_flipped == -1 and id >= (len(self.model.grid)/2):
176176 return
177 if self.last_flipped <> -1 and id < (len(self.grid)/2):
177 if self.last_flipped <> -1 and id < (len(self.model.grid)/2):
178178 return
179179 self.emit('highlight-card', self.last_highlight, False)
180 if mouse and self.grid[id][8]==0:
180 if mouse and self.model.grid[id]['state']=='0':
181181 self.emit('highlight-card', id, True)
182182 if not mouse:
183183 self.emit('highlight-card', id, True)
187187 def increase_point(self, buddy):
188188 self.players_score[buddy] += 1
189189 self.emit('increase-score', buddy)
190
191 def read_config(self, game_name, size = 100):
190
191 def read_config2(self, game_name, size = 100):
192192 filename = os.path.join(self.game_dir, game_name +'/'+game_name+'.mem')
193193 # seed = random.randint(0, 14567)
194194 temp1 = []
232232 fd.close()
233233
234234 # Shuffle cards order
235 if data['divided']=='True':
235 if data['divided']==1:
236236 random.shuffle(temp1)
237237 random.shuffle(temp2)
238238 temp1.extend(temp2)
243243 return data, temp1
244244
245245 def get_grid(self):
246 return self.grid
246 return self.model.grid
247247
248248 def get_data(self):
249 return self.data
249 return self.model.data
250250
251251 def change_game(self, game_name, size):
252 tuple = self.read_config(game_name, size)
253 data = tuple[0]
254 grid = tuple[1]
255 self.load_remote(grid, data, False)
252 if self.model.read(game_name) == 0:
253 self.model.def_grid(size)
254 self.load_remote(self.model.grid, self.model.data, False)
255 else:
256 logging.error(' Reading setup file %s'%game_name)
256257
257
258258 def load_remote(self, grid, data, signal = False):
259 self.grid = grid
260 self.data = data
259 self.model.grid = grid
260 self.model.data = data
261261 self.emit('reset_scoreboard')
262262 self.emit('change_game', self.get_data(), self.get_grid())
263263 if not signal:
268268 self.last_flipped = -1
269269 self.last_highlight = 1
270270 self.change_turn()
271 self.data['running'] = 'False'
271 self.model.data['running'] = 'False'
272272
273273 def set_messenger(self, messenger):
274274 self.messenger = messenger
  
1game_name=addition
2score_sound=score.wav
3win_sound=score.wav
4divided=false
5face=
6# Cards
7,,,,,,1+1,,,,,2,,,,
8,,,,,,1+2,,,,,3,,,,
9,,,,,,2+2,,,,,4,,,,
10,,,,,,2+3,,,,,5,,,,
11,,,,,,3+3,,,,,6,,,,
12,,,,,,3+4,,,,,7,,,,
13,,,,,,4+4,,,,,8,,,,
14,,,,,,4+5,,,,,9,,,,
15,,,,,,5+5,,,,,10,,,,
16,,,,,,5+6,,,,,11,,,,
17,,,,,,6+6,,,,,12,,,,
18,,,,,,6+7,,,,,13,,,,
19,,,,,,7+7,,,,,14,,,,
20,,,,,,7+8,,,,,15,,,,
21,,,,,,8+8,,,,,16,,,,
22,,,,,,8+9,,,,,17,,,,
23,,,,,,9+9,,,,,18,,,,
24,,,,,,10+9,,,,,19,,,,
1<?xml version="1.0"?>
2<memorize name="addition" scoresnd="score.wav" winsnd="win.wav" divided="0" >
3
4 <pair achar="1+1" bchar="2" bcharalign="2" />
5 <pair achar="1+2" bchar="3" />
6 <pair achar="2+2" bchar="4" />
7 <pair achar="2+3" bchar="5" />
8 <pair achar="3+3" bchar="6" />
9 <pair achar="3+4" bchar="7" />
10 <pair achar="4+4" acharalign="4" bchar="8" />
11 <pair achar="4+5" bchar="9" />
12 <pair achar="5+5" bchar="10" />
13 <pair achar="5+6" bchar="11" />
14 <pair achar="6+6" bchar="12" bcharalign="3"/>
15 <pair achar="6+7" bchar="13" />
16 <pair achar="7+7" bchar="14" />
17 <pair achar="7+8" bchar="15" />
18 <pair achar="8+8" bchar="16" />
19 <pair achar="8+9" bchar="17" />
20 <pair achar="9+9" bchar="18" />
21 <pair achar="10+9" bchar="19" />
22
23</memorize>
  
1<?xml version="1.0"?>
2<memorize name="drumgit" scoresnd="score.wav" winsnd="win.wav" divided="0" >
3
4 <pair aimg="drumkit1_b.jpg" asnd="beat1_a.aiff" bimg="drumkit1_b.jpg" bsnd="beat1_a.aiff" color="100" />
5 <pair aimg="drumkit2_b.jpg" asnd="beat1_b.aiff" bimg="drumkit2_b.jpg" bsnd="beat1_b.aiff" color="100" />
6 <pair aimg="drumkit3_b.jpg" asnd="beat1_c.aiff" bimg="drumkit3_b.jpg" bsnd="beat1_c.aiff" color="100" />
7 <pair aimg="drumkit4_b.jpg" asnd="beat8.aiff" bimg="drumkit4_b.jpg" bsnd="beat8.aiff" color="100" />
8
9 <pair aimg="drumkit6_b.jpg" asnd="beat3.aiff" bimg="drumkit6_b.jpg" bsnd="beat3.aiff" color="100" />
10 <pair aimg="drumkit7_b.jpg" asnd="beat4.aiff" bimg="drumkit7_b.jpg" bsnd="beat4.aiff" color="100" />
11 <pair aimg="drumkit8_b.jpg" asnd="beat14.aiff" bimg="drumkit8_b.jpg" bsnd="beat14.aiff" color="100" />
12 <pair aimg="drumkit9_b.jpg" asnd="beat6_2.aiff" bimg="drumkit9_b.jpg" bsnd="beat6_2.aiff" color="100" />
13
14 <pair aimg="guitar1_2.jpg" asnd="bending_a.aiff" bimg="guitar1_2.jpg" bsnd="bending_a.aiff" color="100" />
15 <pair aimg="guitar2_2.jpg" asnd="bending_b.aiff" bimg="guitar2_2.jpg" bsnd="bending_b.aiff" color="100" />
16 <pair aimg="guitar3_2.jpg" asnd="flashcomp2a.aiff" bimg="guitar3_2.jpg" bsnd="flashcomp2a.aiff" color="100" />
17 <pair aimg="guitar4_2.jpg" asnd="flashcomp2b.aiff" bimg="guitar4_2.jpg" bsnd="flashcomp2b.aiff" color="100" />
18
19 <pair aimg="guitar5_2.jpg" asnd="gedaempft.aiff" bimg="guitar5_2.jpg" bsnd="gedaempft.aiff" color="100" />
20 <pair aimg="guitar6_2.jpg" asnd="gedaempft.aiff" bimg="guitar6_2.jpg" bsnd="gedaempft.aiff" color="100" />
21 <pair aimg="guitar7_2.jpg" asnd="ungedaempft.aiff" bimg="guitar7_2.jpg" bsnd="ungedaempft.aiff" color="100" />
22 <pair aimg="guitar8_2.jpg" asnd="jimi4.aiff" bimg="guitar8_2.jpg" bsnd="jimi4.aiff" color="100" />
23
24</memorize>
25
26<!--
127game_name=drumgit
228score_sound=score.wav
329win_sound=score.wav
5454,guitar10_2.jpg,guitcello.wav,,,,,,,guitar10_2.jpg,guitcello.wav,,,,,
5555,guitar11_2.jpg,flasholet4.wav,,,,,,,guitar11_2.jpg,flasholet4.wav,,,,,
5656,guitar12_2.jpg,jimi1.wav,,,,,,,guitar12_2.jpg,jimi1.wav,,,,,
57-->
  
1game_name=letters1
2score_sound=score.wav
3win_sound=score.wav
4divided=True
5face1=1
6face2=2
7# Cards
81,,,A,,,,,2,,,a,,,,
91,,,E,,,,,2,,,e,,,,
101,,,I,,,,,2,,,i,,,,
111,,,O,,,,,2,,,o,,,,
121,,,U,,,,,2,,,u,,,,
131,,,B,,,,,2,,,b,,,,
141,,,C,,,,,2,,,c,,,,
151,,,D,,,,,2,,,d,,,,
161,,,F,,,,,2,,,f,,,,
171,,,G,,,,,2,,,g,,,,
181,,,H,,,,,2,,,h,,,,
191,,,J,,,,,2,,,j,,,,
201,,,K,,,,,2,,,k,,,,
211,,,L,,,,,2,,,l,,,,
221,,,M,,,,,2,,,m,,,,
231,,,N,,,,,2,,,n,,,,
241,,,P,,,,,2,,,p,,,,
251,,,Q,,,,,2,,,q,,,,
1<?xml version="1.0"?>
2<memorize name="letters1" scoresnd="score.wav" winsnd="win.wav" divided="1" face1="1" face2="2" >
3
4 <pair achar="A" bchar="a" />
5 <pair achar="E" bchar="e" />
6 <pair achar="I" bchar="i" />
7 <pair achar="O" bchar="o" />
8 <pair achar="U" bchar="u" />
9 <pair achar="B" bchar="b" />
10 <pair achar="C" bchar="c" />
11 <pair achar="D" bchar="d" />
12 <pair achar="F" bchar="f" />
13 <pair achar="G" bchar="g" />
14 <pair achar="H" bchar="h" />
15 <pair achar="J" bchar="j" />
16 <pair achar="K" bchar="k" />
17 <pair achar="L" bchar="l" />
18 <pair achar="M" bchar="m" />
19 <pair achar="N" bchar="n" />
20 <pair achar="P" bchar="p" />
21 <pair achar="Q" bchar="q" />
22
23</memorize>
  
1game_name=letters2
2score_sound=score.wav
3win_sound=score.wav
4divided=True
5face1=1
6face2=2
7# Cards
81,,,A,,,,,2,,,a,,,,
91,,,E,,,,,2,,,e,,,,
101,,,I,,,,,2,,,i,,,,
111,,,O,,,,,2,,,o,,,,
121,,,U,,,,,2,,,u,,,,
131,,,L,,,,,2,,,l,,,,
141,,,M,,,,,2,,,m,,,,
151,,,N,,,,,2,,,n,,,,
161,,,P,,,,,2,,,p,,,,
171,,,Q,,,,,2,,,q,,,,
181,,,R,,,,,2,,,r,,,,
191,,,S,,,,,2,,,s,,,,
201,,,T,,,,,2,,,t,,,,
211,,,V,,,,,2,,,v,,,,
221,,,W,,,,,2,,,w,,,,
231,,,X,,,,,2,,,x,,,,
241,,,Y,,,,,2,,,y,,,,
251,,,Z,,,,,2,,,z,,,,
1<?xml version="1.0"?>
2<memorize name="letters2" scoresnd="score.wav" winsnd="win.wav" divided="1" face1="1" face2="2" >
3
4 <pair achar="A" bchar="a" />
5 <pair achar="E" bchar="e" />
6 <pair achar="I" bchar="i" />
7 <pair achar="O" bchar="o" />
8 <pair achar="U" bchar="u" />
9
10 <pair achar="L" bchar="l" />
11 <pair achar="M" bchar="m" />
12 <pair achar="N" bchar="n" />
13 <pair achar="P" bchar="p" />
14 <pair achar="Q" bchar="q" />
15 <pair achar="R" bchar="r" />
16 <pair achar="S" bchar="s" />
17 <pair achar="T" bchar="t" />
18 <pair achar="V" bchar="v" />
19 <pair achar="W" bchar="w" />
20 <pair achar="X" bchar="x" />
21 <pair achar="Y" bchar="y" />
22 <pair achar="Z" bchar="z" />
23
24</memorize>
  
1<?xml version="1.0"?>
2<memorize name="numbers" scoresnd="score.wav" winsnd="win.wav" divided="1" face1="1" face2="2" >
3
4 <pair achar="1" asnd="01.wav" bimg="01x.jpg" bsnd="01.wav" />
5 <pair achar="2" asnd="02.wav" bimg="02x.jpg" bsnd="02.wav" />
6 <pair achar="3" asnd="03.wav" bimg="03x.jpg" bsnd="03.wav" />
7 <pair achar="4" asnd="04.wav" bimg="04x.jpg" bsnd="04.wav" />
8 <pair achar="5" asnd="05.wav" bimg="05x.jpg" bsnd="05.wav" />
9 <pair achar="6" asnd="06.wav" bimg="06x.jpg" bsnd="06.wav" />
10 <pair achar="7" asnd="07.wav" bimg="07x.jpg" bsnd="07.wav" />
11 <pair achar="8" asnd="08.wav" bimg="08x.jpg" bsnd="08.wav" />
12 <pair achar="9" asnd="09.wav" bimg="09x.jpg" bsnd="09.wav" />
13 <pair achar="10" asnd="10.wav" bimg="10x.jpg" bsnd="10.wav" />
14 <pair achar="11" asnd="11.wav" bimg="11x.jpg" bsnd="11.wav" />
15 <pair achar="12" asnd="12.wav" bimg="12x.jpg" bsnd="12.wav" />
16 <pair achar="13" asnd="13.wav" bimg="13x.jpg" bsnd="13.wav" />
17 <pair achar="14" asnd="14.wav" bimg="14x.jpg" bsnd="14.wav" />
18 <pair achar="15" asnd="15.wav" bimg="15x.jpg" bsnd="15.wav" />
19
20</memorize>
21
22<!--
123game_name=numbers
224score_sound=score.wav
325win_sound=score.wav
42421,,13.wav,13,,,,,2,13x.jpg,13.wav,,,,,
43431,,14.wav,14,,,,,2,14x.jpg,14.wav,,,,,
44441,,15.wav,15,,,,,2,15x.jpg,15.wav,,,,,
45-->
  
1game_name=phonemes
2score_sound=score.wav
3win_sound=score.wav
4divided=True
5face1=1
6face2=2
7# Cards
1<?xml version="1.0"?>
2<memorize name="phonemes" scoresnd="score.wav" winsnd="win.wav" divided="1" face1="1" face2="2" >
3
4 <pair aimg="agua1.jpg" asnd="agua1.wav" bimg="agua2.jpg" bsnd="agua2.wav" />
5 <pair aimg="bola1.jpg" asnd="bola1.wav" bimg="bola2.jpg" bsnd="bola2.wav" />
6 <pair aimg="casa1.jpg" asnd="casa1.wav" bimg="casa2.jpg" bsnd="casa2.wav" />
7 <pair aimg="ema1.jpg" asnd="ema1..wav" bimg="ema2.jpg" bsnd="ema2.wav" />
8 <pair aimg="frutas1.jpg" asnd="frutas1.wav" bimg="frutas2.jpg" bsnd="frutas2.wav" />
9 <pair aimg="homem1.jpg" asnd="homem1.wav" bimg="homem2.jpg" bsnd="homem2.wav" />
10 <pair aimg="ioio1.jpg" asnd="ioio1.wav" bimg="ioio2.jpg" bsnd="ioio2.wav" />
11 <pair aimg="kiwi1.jpg" asnd="kiwi1.wav" bimg="kiwi2.jpg" bsnd="kiwi2.wav" />
12 <pair aimg="ovo1.jpg" asnd="ovo1.wav" bimg="ovo2.jpg" bsnd="ovo2.wav" />
13 <pair aimg="peixe1.jpg" asnd="peixe1.wav" bimg="peixe2.jpg" bsnd="peixe2.wav" />
14 <pair aimg="queijo1.jpg" asnd="queijo1.wav" bimg="queijo2.jpg" bsnd="queijo2.wav" />
15 <pair aimg="roda1.jpg" asnd="roda1.wav" bimg="roda2.jpg" bsnd="roda2.wav" />
16 <pair aimg="sapo1.jpg" asnd="sapo1.wav" bimg="sapo2.jpg" bsnd="sapo2.wav" />
17 <pair aimg="uva1.jpg" asnd="uva1.wav" bimg="uva2.jpg" bsnd="uva2.wav" />
18 <pair aimg="zebra1.jpg" asnd="zebra1.wav" bimg="zebra2.jpg" bsnd="zebra2.wav" />
19
20</memorize>
21
22<!--
8231,agua1.jpg,agua1.wav,,,,,Á_ _ _,2,agua2.jpg,agua2.wav,,,,,_GUA
9241,bola1.jpg,bola1.wav,,,,,BO_ _,2,bola2.jpg,bola2.wav,,,,,_ _LA
10251,casa1.jpg,casa1.wav,,,,,CA_ _,2,casa2.jpg,casa2.wav,,,,,_ _SA
35351,sapo1.jpg,sapo1.wav,,,,,SA_ _,2,sapo2.jpg,sapo2.wav,,,,,_ _PO
36361,uva1.jpg,uva1.wav,,,,,U_ _,2,uva2.jpg,uva2.wav,,,,,_VA
37371,zebra1.jpg,zebra1.wav,,,,,ZE_ _ _,2,zebra2.jpg,zebra2.wav,,,,,_ _BRA
38-->
  
22
33<!ELEMENT memorize (#PCDATA|pair)*>
44<!ATTLIST memorize
5 name CDATA #REQUIRED
6 scoresnd CDATA #IMPLIED
7 winsnd CDATA #IMPLIED
8 divided CDATA #IMPLIED
9 face CDATA #IMPLIED
5 name CDATA #REQUIRED
6 scoresnd CDATA #IMPLIED
7 winsnd CDATA #IMPLIED
8 divided CDATA #IMPLIED
9 face CDATA #IMPLIED
10 face1 CDATA #IMPLIED
11 face2 CDATA #IMPLIED
1012>
1113
1214<!ELEMENT pair (#PCDATA)* >
2020 bsnd CDATA #IMPLIED
2121 bchar CDATA #IMPLIED
2222 color CDATA #IMPLIED
23 acharalign CDATA #IMPLIED
24 bcharalign CDATA #IMPLIED
2325>
  
8787 self.activity.change_game(game_name, game_size)
8888
8989 def update_toolbar(self, widget, data, grid):
90 game = data.get('game_name')
90 game = data.get('name')
9191 size = data.get('size')
9292 self._lock = True
9393 game_index = self.games.index(game)
messenger.py
(14 / 6)
  
4040 self._tube.watch_participants(self.participant_change_cb)
4141
4242 def participant_change_cb(self, added, removed):
43 _logger.debug('Participants change add=%s rem=%s' %(added, removed))
44
4345 if not self.entered:
4446 self._tube.add_signal_receiver(self._flip_receiver, '_flip_signal', IFACE, path=PATH, sender_keyword='sender')
4547 self._tube.add_signal_receiver(self._change_game_receiver, '_change_game_signal', IFACE, path=PATH, sender_keyword='sender')
6363 ''' Someone joined the game, so sync the new player '''
6464 _logger.debug('The new player %s has joined', sender)
6565 self.ordered_bus_names.append(sender)
66 _logger.debug('The grid to send: %s', self.game.get_grid())
67 _logger.debug('The data to send: %s', self.game.get_data())
6668 self._tube.get_object(sender, PATH).load_game(self.ordered_bus_names, self.game.get_grid(), self.game.get_data(), self.game.waiting_players, dbus_interface=IFACE)
69 _logger.debug('Sent the game state')
6770
6871 #@dbus.service.method(dbus_interface=IFACE, in_signature='asss', out_signature='')
69 @dbus.service.method(dbus_interface=IFACE, in_signature='asa(ssssssssiii)a{ss}av', out_signature='')
72 #@dbus.service.method(dbus_interface=IFACE, in_signature='asa(ssssssssiii)a{ss}av', out_signature='')
73 @dbus.service.method(dbus_interface=IFACE, in_signature='asaa{ss}a{ss}av', out_signature='')
7074 def load_game(self, bus_names, grid, data,list):
7175 ''' Sync the game with with players '''
7276 _logger.debug('Data received to sync game data')
77 _logger.debug('grid %s '%grid)
7378 self.ordered_bus_names = bus_names
7479 self.player_id = bus_names.index(self._tube.get_unique_name())
7580 self._change_game_receiver(grid,data,self.ordered_bus_names[0])
103103 _logger.debug('Sending changed game message')
104104 self._change_game_signal(grid, data)
105105
106 @dbus.service.signal(IFACE, signature='a(ssssssssiii)a{ss}')
106 #@dbus.service.signal(IFACE, signature='a(ssssssssiii)a{ss}')
107 @dbus.service.signal(IFACE, signature='aa{ss}a{ss}')
107108 def _change_game_signal(self, grid, data):
108109 _logger.debug('Notifing other players that you changed the game')
109110 ''' Notify current players that you changed the game '''
115115
116116 if self._tube.self_handle <> handle:
117117 _logger.debug('Game changed by other player')
118 new_grid = []
119 for card in grid:
120 new_grid.append(map(lambda x: str(x), card[:8])+[int(card[8]), int(card[9]), int(card[10])])
121 self.game.load_remote(new_grid, data, True)
118 #new_grid = []
119 #for card in grid:
120 # new_grid.append(map(lambda x: str(x), card[:8])+[int(card[8]), int(card[9]), int(card[10])])
121 self.game.load_remote(grid, data, True)
122122
  
1<?xml version="1.0"?>
2<memorize name="addition" scoresnd="score.wav" winsnd="win.wav" divided="False" face="" >
3
4 <pair achar="1+1" bchar="2" />
5 <pair achar="1+2" bchar="3" />
6 <pair achar="2+2" bchar="4" />
7 <pair achar="2+3" bchar="5" />
8 <pair achar="3+3" bchar="6" />
9 <pair achar="3+4" bchar="7" />
10 <pair achar="4+4" bchar="8" />
11 <pair achar="4+5" bchar="9" />
12 <pair achar="5+5" bchar="10" />
13 <pair achar="5+6" bchar="11" />
14 <pair achar="6+6" bchar="12" />
15 <pair achar="6+7" bchar="13" />
16 <pair achar="7+7" bchar="14" />
17 <pair achar="7+8" bchar="15" />
18 <pair achar="8+8" bchar="16" />
19 <pair achar="8+9" bchar="17" />
20 <pair achar="9+9" bchar="18" />
21 <pair achar="10+9" bchar="19" />
22
23</memorize>
  
1<?xml version="1.0"?>
2<memorize name="drumgit" scoresnd="score.wav" winsnd="win.wav" divided="False" face="" >
3
4 <pair aimg="drumkit1_b.jpg" asnd="beat1_a.aiff" bimg="drumkit1_b.jpg" bsnd="beat1_a.aiff" color="100" />
5 <pair aimg="drumkit2_b.jpg" asnd="beat1_b.aiff" bimg="drumkit2_b.jpg" bsnd="beat1_b.aiff" color="100" />
6 <pair aimg="drumkit3_b.jpg" asnd="beat1_c.aiff" bimg="drumkit3_b.jpg" bsnd="beat1_c.aiff" color="100" />
7 <pair aimg="drumkit4_b.jpg" asnd="beat8.aiff" bimg="drumkit4_b.jpg" bsnd="beat8.aiff" color="100" />
8
9 <pair aimg="drumkit6_b.jpg" asnd="beat3.aiff" bimg="drumkit6_b.jpg" bsnd="beat3.aiff" color="100" />
10 <pair aimg="drumkit7_b.jpg" asnd="beat4.aiff" bimg="drumkit7_b.jpg" bsnd="beat4.aiff" color="100" />
11 <pair aimg="drumkit8_b.jpg" asnd="beat14.aiff" bimg="drumkit8_b.jpg" bsnd="beat14.aiff" color="100" />
12 <pair aimg="drumkit9_b.jpg" asnd="beat6_2.aiff" bimg="drumkit9_b.jpg" bsnd="beat6_2.aiff" color="100" />
13
14 <pair aimg="guitar1_2.jpg" asnd="bending_a.aiff" bimg="guitar1_2.jpg" bsnd="bending_a.aiff" color="100" />
15 <pair aimg="guitar2_2.jpg" asnd="bending_b.aiff" bimg="guitar2_2.jpg" bsnd="bending_b.aiff" color="100" />
16 <pair aimg="guitar3_2.jpg" asnd="flashcomp2a.aiff" bimg="guitar3_2.jpg" bsnd="flashcomp2a.aiff" color="100" />
17 <pair aimg="guitar4_2.jpg" asnd="flashcomp2b.aiff" bimg="guitar4_2.jpg" bsnd="flashcomp2b.aiff" color="100" />
18
19 <pair aimg="guitar5_2.jpg" asnd="gedaempft.aiff" bimg="guitar5_2.jpg" bsnd="gedaempft.aiff" color="100" />
20 <pair aimg="guitar6_2.jpg" asnd="gedaempft.aiff" bimg="guitar6_2.jpg" bsnd="gedaempft.aiff" color="100" />
21 <pair aimg="guitar7_2.jpg" asnd="ungedaempft.aiff" bimg="guitar7_2.jpg" bsnd="ungedaempft.aiff" color="100" />
22 <pair aimg="guitar8_2.jpg" asnd="jimi4.aiff" bimg="guitar8_2.jpg" bsnd="jimi4.aiff" color="100" />
23
24</memorize>
model.py
(154 / 99)
  
2323import random
2424import gobject
2525
26IMAGES_PATH = 'games/drumgit/images'
27SOUNDS_PATH = 'games/drumgit/sounds'
28GAME_PATH = ''
29
3026_logger = logging.getLogger('model')
3127
32
3328class Pair(gobject.GObject):
3429 __gproperties__ = {
3530 'aimg' : (str, None, None, None, gobject.PARAM_READWRITE),
3631 'asnd' : (str, None, None, None, gobject.PARAM_READWRITE),
3732 'achar' : (str, None, None, None, gobject.PARAM_READWRITE),
33 'acharalign' : (str, None, None, None, gobject.PARAM_READWRITE),
3834 'bimg' : (str, None, None, None, gobject.PARAM_READWRITE),
3935 'bsnd' : (str, None, None, None, gobject.PARAM_READWRITE),
4036 'bchar' : (str, None, None, None, gobject.PARAM_READWRITE),
37 'bcharalign': (str, None, None, None, gobject.PARAM_READWRITE),
4138 'color': (gobject.TYPE_INT, 'Base', 'Base', 0, 10, 0, gobject.PARAM_READWRITE)
4239 }
4340
4441 def __init__(self):
4542 gobject.GObject.__init__(self)
46 self._properties = {'aimg':None, 'asnd':None, 'bimg':None, 'bsnd':None, 'color':100}
43 self._properties = {'aimg':None, 'asnd':None, 'achar':None, 'acharalign':'1', 'bimg':None,
44 'bsnd':None, 'bchar':None, 'bcharalign':1, 'color':100}
4745
4846 def do_get_property(self, pspec):
4947 """Retrieve a particular property from our property dictionary
5252 return self._properties["asnd"]
5353 elif pspec.name == "achar":
5454 return self._properties["achar"]
55 elif pspec.name == "acharalign":
56 return self._properties["acharalign"]
5557 elif pspec.name == "bimg":
5658 return self._properties["bimg"]
5759 elif pspec.name == "bsnd":
5860 return self._properties["bsnd"]
5961 elif pspec.name == "bchar":
6062 return self._properties["bchar"]
63 elif pspec.name == "bcharalign":
64 return self._properties["bcharalign"]
6165 elif pspec.name == "color":
6266 return self._properties["color"]
6367
7272 self._properties["asnd"] = value
7373 elif name == "achar":
7474 self._properties["achar"] = value
75 elif name == "acharalign":
76 self._properties["acharalign"] = int(value)
7577 elif name == "bimg":
7678 self._properties["bimg"] = value
7779 elif name == "bsnd":
7880 self._properties["bsnd"] = value
7981 elif name == "bchar":
8082 self._properties["bchar"] = value
83 elif name == "bcharalign":
84 self._properties["bcharalign"] = value
8185 elif name == "color":
82 self._properties["color"] = int(value)
83 '''
84 def do_set_property(self, props, value):
85 if props.name == 'a_img':
86 self._properties['a_img'] = value
87 '''
86 self._properties["color"] = value
8887
88
8989class Model(object):
9090 ''' The model of the activity. Contains methods to read and save
9191 the configuration for a game from xml. Stores the pairs and grid
9292 information.
93 '''
94 def __init__(self, gamepath, dtdpath, name='noname'):
93 '''
94 _GAMES_PATH = os.path.join(os.path.dirname(__file__), 'games')
95
96 def __init__(self, dtdpath):
9597 self.data = {}
96 self.gamepath = gamepath
9798 self.dtdpath = dtdpath
98
99 self.data['face'] = ''
100
99101 try:
100102 self.dtd = libxml2.parseDTD(None, os.path.join(self.dtdpath, 'memorize.dtd'))
101103 except libxml2.parserError, e:
116116 self.started = 0
117117 self.count = 0
118118
119 def read(self, filename):
119 def read(self, gamename):
120120 ''' reades the configuration from an xml file '''
121 self.data['path'] = os.path.join( self._GAMES_PATH, gamename)
122 self.data['pathimg'] = os.path.join(self.data['path'], 'images')
123 self.data['pathsnd'] = os.path.join(self.data['path'], 'sounds')
124 self.pairs = {}
125
121126 try:
122 doc = libxml2.parseFile(os.path.join(self.gamepath, filename))
127 doc = libxml2.parseFile(os.path.join(self.data['path'], gamename+'.mem'))
123128 if doc.validateDtd(self.ctxt, self.dtd):
124129
125130 # get the requested nodes
142142 pass
143143 else:
144144 pair.set_property(attribute.name, attribute.content)
145 self.pairs[self.idpair] = pair
145 self.pairs[str(self.idpair)] = pair
146146 self.idpair+=1
147147 elif( elem.name == 'memorize' ):
148148 for attribute in attributes:
149149 if(attribute.name == 'text'):
150150 pass
151151 elif(attribute.name == 'name'):
152 self.data['game_name'] = attribute.content
152 self.data['name'] = attribute.content
153153 elif(attribute.name == 'scoresnd'):
154154 self.data['scoresnd'] = attribute.content
155155 elif(attribute.name == 'winsnd'):
156156 self.data['winsnd'] = attribute.content
157157 elif(attribute.name == 'divided'):
158158 self.data['divided'] = attribute.content
159 elif(attribute.name == 'divided'):
160 self.data['divided'] = attribute.content
161159 elif(attribute.name == 'face'):
162160 self.data['face'] = attribute.content
163161 elif(attribute.name == 'face1'):
164162 self.data['face1'] = attribute.content
165163 elif(attribute.name == 'face2'):
166 self.data['face2'] = attribute.content
164 self.data['face2'] = attribute.content
167165 xpa.xpathFreeContext()
168166 else:
169167 _logger.error('Error in validation of the file')
168 return 1
170169 doc.freeDoc()
170 return 0
171171 except libxml2.parserError, e:
172172 _logger.error('Error parsing file ' +str(e))
173
173 return 2
174174
175175 def save(self, filename):
176176 ''' saves the configuration to an xml file '''
177177 doc = libxml2.newDoc("1.0")
178178 root = doc.newChild(None, "memorize", None)
179 root.setProp("name", self.data['game_name'])
179 root.setProp("name", self.data['name'])
180180 ### Fixme: add other attributes here
181181 for key in self.pairs:
182182
203203 def def_grid(self, size):
204204 ''' create the grid for the play from the pairs information
205205 and shuffles the grid so they always appear in a different
206 place
207 grid [pair_key, a_or_b, flipstatus]
206 place
208207 '''
209 _logger.debug(' pairs: %s', self.pairs)
208 psize=(size*size/2)
209 _logger.debug('Size requested: %d' %psize)
210 self.grid = []
211 temp1 = []
212 temp2 = []
210213 i=0
211214 for key in self.pairs.iterkeys():
212 if i < size:
213 self.grid.append([key, 0, 0])
214 self.grid.append([key, 1, 0])
215 if i < psize:
216 elem = {}
217 elem['pairkey'] = key
218 elem['state'] = '0'
219 elem['ab'] = 'a'
220 if self.pairs[key].props.aimg != None:
221 elem['img'] = os.path.join(self.data['pathimg'], self.pairs[key].props.aimg)
222 if self.pairs[key].props.asnd != None:
223 elem['snd'] = os.path.join(self.data['pathsnd'], self.pairs[key].props.asnd)
224 if self.pairs[key].props.achar != None:
225 elem['char'] = self.pairs[key].props.achar
226 elem['charalign'] = self.pairs[key].props.acharalign
227 temp1.append(elem)
228
229 elem = {}
230 elem['pairkey'] = key
231 elem['state'] = '0'
232 elem['ab'] = 'b'
233 if self.pairs[key].props.bimg != None:
234 elem['img'] = os.path.join(self.data['pathimg'], self.pairs[key].props.bimg)
235 if self.pairs[key].props.bsnd != None:
236 elem['snd'] = os.path.join(self.data['pathsnd'], self.pairs[key].props.bsnd)
237 if self.pairs[key].props.bchar != None:
238 elem['char'] = self.pairs[key].props.bchar
239 elem['charalign'] = self.pairs[key].props.bcharalign
240 temp2.append(elem)
215241 i+=1
216242 else:
217243 break
218
244
219245 numpairs = len(self.pairs)
220 if numpairs < size:
221 _logger.debug('We did not have enough pairs. requested=%s had=%s' %(numpairs, size))
246 if numpairs < psize:
247 _logger.debug('We did not have enough pairs. requested=%s had=%s' %(psize, numpairs))
248 self.data['size'] = str(size)
222249
223 self.data['size'] = numpairs
224
225 random.shuffle(self.grid)
226 _logger.debug(' grid: %s', self.grid)
250 if self.data['divided'] == '1':
251 random.shuffle(temp1)
252 random.shuffle(temp2)
253 temp1.extend(temp2)
254 else:
255 temp1.extend(temp2)
256 random.shuffle(temp1)
257 self.grid = temp1
258 _logger.debug(' grid( size=%s ): %s' %(self.data['size'], self.grid))
227259
260
228261
229 def gettile(self, tilenum):
230 ''' gets the information of an object associated with a tile number '''
231 img = None
232 snd = None
233 char = None
234 pairkey, moch, state = self.grid[tilenum]
235 if moch == 0:
236 if self.pairs[pairkey].props.aimg != None:
237 img = os.path.join(IMAGES_PATH, self.pairs[pairkey].props.aimg)
238 if self.pairs[pairkey].props.asnd != None:
239 snd = os.path.join(SOUNDS_PATH, self.pairs[pairkey].props.asnd)
240 char = self.pairs[pairkey].props.achar
241 if moch == 1:
242 if self.pairs[pairkey].props.bimg != None:
243 img = os.path.join(IMAGES_PATH, self.pairs[pairkey].props.bimg)
244 if self.pairs[pairkey].props.bsnd != None:
245 snd = os.path.join(SOUNDS_PATH, self.pairs[pairkey].props.bsnd)
246 char = self.pairs[pairkey].props.bchar
247 color = self.pairs[pairkey].props.color
248 return (img, snd, char, color)
262if __name__ == '__main__':
263 model = Model(os.path.dirname(__file__))
264 model.read('drumgit')
265
266 print 'name=%s scoresnd=%s winsnd=%s div=%s' %(model.data['name'], model.data['scoresnd'],
267 model.data['winsnd'], model.data['divided'])
249268
269 model.def_grid(4)
270 print 'grid %s'%model.grid #['size']
250271
251 def same(self, a, b):
252 ''' checks wether two tiles are matching '''
253 pairkeya, moch, state = self.grid[a]
254 pairkeyb, moch, state = self.grid[b]
255 return (pairkeya == pairkeyb)
272 print 'Test set state of tile 7:'
273 tilenum = 7
274 model.grid[tilenum]['state'] = '1'
275 print ' %s' %model.grid[tilenum]
256276
277 print 'Test sound:'
278 snd = model.grid[tilenum].get('snd', None)
279 if snd == None:
280 print ' no sound'
281 else:
282 print ' play sound=%s'%snd
257283
284 print 'Test the same function: 0 1'
285 if model.grid[0]['pairkey'] == model.grid[1]['pairkey']:
286 print ' they are the same'
287 else:
288 print ' they are NOT the same'
289
290 for tile in model.grid:
291 id = model.grid.index(tile)
292 if tile.get('img', None):
293 print 'we got an image=%s '%tile['img']
294 elif tile.get('char', None):
295 print 'we got an char=%s'%tile.get('char')
296 else:
297 print 'we got no pic so prepare for sound game'
298
299 print '\n_______________________________\n'
300
301 '''
302 if model.read('addition') == 0:
303 print '%s' %model.pairs[0]._properties
304 print 'name=%s' %model.data['name']
305 print 'scoresnd=%s' %model.data['scoresnd']
306 print 'winsnd=%s' %model.data['winsnd']
307 print 'div=%d' %model.data['divided']
258308
309 model.def_grid(12)
310 for tile in model.grid:
311 id = model.grid.index(tile)
312 if tile.get('img', None):
313 print 'we got an image=%s '%tile.get('img')
314 elif tile.get('char', None):
315 print 'we got an char=%s'%tile.get('char')
316 else:
317 print 'we got no img so prepare for sound game'
259318
260if __name__ == '__main__':
261 model = Model(GAME_PATH, os.path.dirname(__file__))
262 model.read('drumgit.mem')
263 print '%s' %model.pairs[0]._properties
264 print 'name=%s' %model.data['game_name']
265 print 'scoresnd=%s' %model.data['scoresnd']
266 print 'winsnd=%s' %model.data['winsnd']
267 print 'div=%s' %model.data['divided']
268 model.def_grid(8)
269 print 'grid size=%d'%model.data['size']
270 print model.grid
319 else:
320 print 'error during reading of the game'
271321
272 i=0
273 while i < model.data['size']:
274 pairkey, moch, state = model.grid[i]
275 if moch == 0:
276 if model.pairs[pairkey].props.aimg != None:
277 print model.pairs[pairkey].props.aimg
278 if moch == 1:
279 if model.pairs[pairkey].props.bimg != None:
280 print model.pairs[pairkey].props.bimg
281 i+=1
282322
283
284 '''
285 print '\n_______________________________\n'
323 print '\n_______________________________\n'
324 if model.read('numbers') == 0:
325 print '%s' %model.pairs[0]._properties
326 print 'name=%s' %model.data['name']
327 print 'scoresnd=%s' %model.data['scoresnd']
328 print 'winsnd=%s' %model.data['winsnd']
329 print 'div=%d' %model.data['divided']
330 print 'face1=%s' %model.data['face1']
331 print 'face2=%s' %model.data['face2']
286332
287 model.read('addition.mem')
288 print '%s' %model.pairs[0]._properties
289 print 'name=%s' %model.data['game_name']
290 print 'scoresnd=%s' %model.data['scoresnd']
291 print 'winsnd=%s' %model.data['winsnd']
292 print 'div=%s' %model.data['divided']
293
294 model.def_grid(12)
295 print model.grid
296 print model.gettile(0)
297 print model.gettile(1)
298 model.save('/tmp/mod.txt')
333 model.def_grid(12)
334 for tile in model.grid:
335 id = model.grid.index(tile)
336 if tile.get('img', None):
337 print 'we got an image=%s '%tile.get('img')
338 elif tile.get('char', None):
339 print 'we got an char=%s'%tile.get('char')
340 else:
341 print 'we got no img so prepare for sound game'
342
343 else:
344 print 'error during reading of the game'
299345 '''
  
4545 self.show()
4646
4747 def add_buddy(self, widget, buddy, score):
48 ### FIXME: this breaks when the body is empty
4849 nick = buddy.props.nick
4950 stroke_color, fill_color = buddy.props.color.split(',')
5051 player = PlayerScoreboard(nick, fill_color, stroke_color, score)
6060
6161 def rem_buddy(self, widget, buddy):
6262 self.vbox.remove(self.players[buddy])
63 del self.players[id]
63 del self.players[buddy] ### fix for self.players[id]
6464
6565 def set_selected(self, widget, buddy):
6666 if self.current_buddy <> None: