Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWalter Bender <walter@walter-laptop.(none)>2009-12-05 16:37:22 (GMT)
committer Walter Bender <walter@walter-laptop.(none)>2009-12-05 16:37:22 (GMT)
commite36e067ab3559cfc06689fc7d273eb606800b3f4 (patch)
tree06bbe5a9884bef69fd0a169819ecb42e611d5650
parent708687fb37db5d61ddcffc16199fc8130d07b2d1 (diff)
using constants
-rw-r--r--NEWS5
-rw-r--r--VisualMatchActivity.py11
-rw-r--r--card.py10
-rw-r--r--constants.py8
-rw-r--r--grid.py17
-rw-r--r--images/card-108.svg22
-rw-r--r--po/VisualMatch.pot78
-rwxr-xr-xvisualmatch.py1
8 files changed, 85 insertions, 67 deletions
diff --git a/NEWS b/NEWS
index 5d5da22..8a1e5eb 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,8 @@
+9
+
+* added glue for launching outside of Sugar
+* save "low score" to Journal
+
8
* fixed bug in new game labels
diff --git a/VisualMatchActivity.py b/VisualMatchActivity.py
index 6f34ab9..b37189e 100644
--- a/VisualMatchActivity.py
+++ b/VisualMatchActivity.py
@@ -43,9 +43,11 @@ from gettext import gettext as _
import locale
import os.path
+from constants import *
from sprites import *
import window
+
SERVICE = 'org.sugarlabs.VisualMatchActivity'
IFACE = SERVICE
PATH = '/org/augarlabs/VisualMatchActivity'
@@ -88,7 +90,8 @@ class VisualMatchActivity(activity.Activity):
toolbar_box.toolbar.insert(separator, -1)
# Label for showing deck status
- self.deck_label = gtk.Label("%d %s" % (96,_("cards remaining")))
+ self.deck_label = gtk.Label("%d %s" % (DECKSIZE-DEAL,
+ _("cards remaining")))
self.deck_label.show()
deck_toolitem = gtk.ToolItem()
deck_toolitem.add(self.deck_label)
@@ -253,8 +256,8 @@ class ProjectToolbar(gtk.Toolbar):
separator.show()
# Label for showing deck status
- self.activity.deck_label = gtk.Label(\
- _("%d cards remain in the deck") % (96))
+ self.activity.deck_label = gtk.Label("%d %s" % (DECKSIZE-DEAL,
+ _("cards remain in the deck")))
self.activity.deck_label.show()
self.activity.deck_toolitem = gtk.ToolItem()
self.activity.deck_toolitem.add(self.activity.deck_label)
@@ -267,7 +270,7 @@ class ProjectToolbar(gtk.Toolbar):
separator.show()
# Label for showing match status
- self.activity.match_label = gtk.Label(_("%d matches") % (0))
+ self.activity.match_label = gtk.Label("%d %s" % (0,_("matches")))
self.activity.match_label.show()
self.activity.match_toolitem = gtk.ToolItem()
self.activity.match_toolitem.add(self.activity.match_label)
diff --git a/card.py b/card.py
index f8a8815..f13462f 100644
--- a/card.py
+++ b/card.py
@@ -50,6 +50,16 @@ class Card:
tw.card_w*tw.scale,
tw.card_h*tw.scale))
self.index = SELECTMASK
+ elif shape == PLAYMASK:
+ self.spr = sprNew(tw,0,0,self.load_image(tw.path+"play",
+ tw.card_w*tw.scale,
+ tw.card_h*tw.scale))
+ self.index = PLAYMASK
+ elif shape == MATCHMASK:
+ self.spr = sprNew(tw,0,0,self.load_image(tw.path+"match",
+ tw.card_w*tw.scale,
+ tw.card_h*tw.scale))
+ self.index = MATCHMASK
else:
self.shape = shape
self.color = color
diff --git a/constants.py b/constants.py
index 3e5b37f..2e456f1 100644
--- a/constants.py
+++ b/constants.py
@@ -19,7 +19,13 @@
#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
#THE SOFTWARE.
-DECK = 108
+SHAPES=3
+COLORS=4
+NUMBER=3
+SHADES=3
+DECKSIZE = SHAPES*COLORS*NUMBER*SHADES
+DEAL=12
+EXTRAS=3
SELECTMASK = -1
PLAYMASK = -2
MATCHMASK = -3
diff --git a/grid.py b/grid.py
index 69073e8..00f3391 100644
--- a/grid.py
+++ b/grid.py
@@ -43,7 +43,7 @@ class Grid:
# how many cards are in the deck?
self.count = 0
# how many cards are on the playing field
- self.cards = 12
+ self.cards = 0
# card spacing
self.left = int((tw.width-(tw.card_w*5.5*tw.scale))/2)
self.xinc = int(tw.card_w*1.5*tw.scale)
@@ -62,7 +62,7 @@ class Grid:
def deal(self, tw):
# layout the initial 12 cards from the deck
# find upper left corner of grid
- self.cards = 12
+ self.cards = 0
self.grid = []
x = self.left
y = self.top
@@ -71,21 +71,22 @@ class Grid:
self.grid.append(self.deck[self.index])
self.draw_a_card(x,y)
x += self.xinc
+ self.cards += 1
self.grid.append(None) # leave a space for the extra cards
x = self.left
y += self.yinc
def deal_3_extra_cards(self, tw):
# if there are still cards in the deck and only 12 cards in the grid
- if self.index < self.count and self.cards == 12:
+ if self.index < self.count and self.cards == DEAL:
# add 3 extra cards to the playing field
- self.cards = 15
for r in range(0,3):
i = self.grid.index(None)
self.grid[i] = self.deck[self.index]
x = self.left+self.xinc*(i%5)
y = self.top+self.yinc*int(i/5)
self.draw_a_card(x,y)
+ self.cards += 1
# shuffle the deck
def shuffle(self):
@@ -93,9 +94,9 @@ class Grid:
for c in self.deck:
self.deck[c].hide_card()
# randomize the deck
- for n in range(0,532):
- i = random.randrange(108)
- j = random.randrange(108)
+ for n in range(0,DECKSIZE*4):
+ i = random.randrange(DECKSIZE)
+ j = random.randrange(DECKSIZE)
self.swap_cards(i,j)
# reset the index to the beginning of the deck after a shuffle
self.index = 0
@@ -121,7 +122,7 @@ class Grid:
# only add new cards if we are down to 12 cards
i = int(5*(a.y-self.top)/self.yinc) + \
int((a.x-self.left)/self.xinc)
- if self.cards == 12:
+ if self.cards == DEAL:
if self.index < self.count:
# save card in grid position of card we are replacing
self.grid[i] = self.deck[self.index]
diff --git a/images/card-108.svg b/images/card-108.svg
deleted file mode 100644
index ca84b48..0000000
--- a/images/card-108.svg
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Emacs -->
-<svg
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- version="1.0"
- width="75"
- height="125">
-<rect width="74.5" height="124.5" rx="11" ry="9" x="0.25" y="0.25"
-style="fill:#E4AAE4;fill-opacity:1;stroke:#000000;stroke-width:0.5" />
-<g>
-<path d="m 28.3575,70.160499 -5.861,5.861 -5.861,-5.866001 -4.102,-4.1 c -0.747,-0.747999 -1.212,-1.784999 -1.212,-2.93 0,-2.288998 1.854,-4.145998 4.146,-4.145998 1.143,0 2.18,0.465 2.93,1.214 l 4.099,4.101999 14.102,-14.102998 c 0.754,-0.749 1.787,-1.214 2.934,-1.214 2.289,0 4.146,1.856001 4.146,4.145001 0,1.146 -0.467,2.18 -1.217,2.932 l -14.104,14.104997 z"
- transform="translate(10,-38.5)"
- style="fill:#780078;stroke:#780078;stroke-width:1.8;" />
-<path d="m 28.3575,70.160499 -5.861,5.861 -5.861,-5.866001 -4.102,-4.1 c -0.747,-0.747999 -1.212,-1.784999 -1.212,-2.93 0,-2.288998 1.854,-4.145998 4.146,-4.145998 1.143,0 2.18,0.465 2.93,1.214 l 4.099,4.101999 14.102,-14.102998 c 0.754,-0.749 1.787,-1.214 2.934,-1.214 2.289,0 4.146,1.856001 4.146,4.145001 0,1.146 -0.467,2.18 -1.217,2.932 l -14.104,14.104997 z"
- transform="translate(10,1.5)"
- style="fill:#780078;stroke:#780078;stroke-width:1.8;" />
-<path d="m 28.3575,70.160499 -5.861,5.861 -5.861,-5.866001 -4.102,-4.1 c -0.747,-0.747999 -1.212,-1.784999 -1.212,-2.93 0,-2.288998 1.854,-4.145998 4.146,-4.145998 1.143,0 2.18,0.465 2.93,1.214 l 4.099,4.101999 14.102,-14.102998 c 0.754,-0.749 1.787,-1.214 2.934,-1.214 2.289,0 4.146,1.856001 4.146,4.145001 0,1.146 -0.467,2.18 -1.217,2.932 l -14.104,14.104997 z"
- transform="translate(10,41.5)"
- style="fill:#780078;stroke:#780078;stroke-width:1.8;" />
-</g>
-</svg>
diff --git a/po/VisualMatch.pot b/po/VisualMatch.pot
index 100624c..156d2a0 100644
--- a/po/VisualMatch.pot
+++ b/po/VisualMatch.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2009-12-04 01:13+0000\n"
+"POT-Creation-Date: 2009-12-04 16:41+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -16,62 +16,82 @@ msgstr ""
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
-#: activity/activity.info:2
+#: activity/activity.info:2 /home/walter/Desktop/set/window.py:236
+#: /home/walter/Desktop/set/visualmatch.py:42
+#: /home/walter/Desktop/set/visualmatch.py:90
+#: /home/walter/Desktop/set/visualmatch.py:93
msgid "Visual Match"
msgstr ""
-#: /home/walter/Desktop/set/window.py:174
-#: /home/walter/Desktop/set/VisualMatchActivity.py:91
-#: /home/walter/Desktop/set/VisualMatchActivity.py:203
-#, python-format
-msgid "%d cards remaining"
+#: /home/walter/Desktop/set/window.py:167
+#: /home/walter/Desktop/set/visualmatch.py:95
+#: /home/walter/Desktop/set/VisualMatchActivity.py:202
+msgid "cards remaining"
msgstr ""
-#: /home/walter/Desktop/set/window.py:181
+#: /home/walter/Desktop/set/window.py:174
msgid "Game over"
msgstr ""
-#: /home/walter/Desktop/set/window.py:184
+#: /home/walter/Desktop/set/window.py:174
msgid "seconds"
msgstr ""
-#: /home/walter/Desktop/set/window.py:189
-msgid "Match"
+#: /home/walter/Desktop/set/window.py:179
+#: /home/walter/Desktop/set/window.py:181
+msgid "match"
msgstr ""
-#: /home/walter/Desktop/set/window.py:192
-#, python-format
-msgid "%d match"
+#: /home/walter/Desktop/set/window.py:183
+msgid "matches"
msgstr ""
-#: /home/walter/Desktop/set/window.py:195
-#: /home/walter/Desktop/set/VisualMatchActivity.py:102
-#: /home/walter/Desktop/set/VisualMatchActivity.py:260
-#, python-format
-msgid "%d matches"
+#: /home/walter/Desktop/set/window.py:189
+msgid "no match"
msgstr ""
-#: /home/walter/Desktop/set/window.py:201
-msgid "No match"
+#: /home/walter/Desktop/set/visualmatch.py:43
+msgid "Click on cards to create sets of three."
msgstr ""
+#: /home/walter/Desktop/set/visualmatch.py:47
#: /home/walter/Desktop/set/VisualMatchActivity.py:72
-#: /home/walter/Desktop/set/VisualMatchActivity.py:224
+#: /home/walter/Desktop/set/VisualMatchActivity.py:222
msgid "New game"
msgstr ""
+#: /home/walter/Desktop/set/visualmatch.py:51
+msgid "Find a match"
+msgstr ""
+
+#: /home/walter/Desktop/set/visualmatch.py:90
+#: /home/walter/Desktop/set/VisualMatchActivity.py:196
+msgid "Keep looking"
+msgstr ""
+
#: /home/walter/Desktop/set/VisualMatchActivity.py:80
-#: /home/walter/Desktop/set/VisualMatchActivity.py:233
+#: /home/walter/Desktop/set/VisualMatchActivity.py:231
msgid "Is there a match?"
msgstr ""
+#: /home/walter/Desktop/set/VisualMatchActivity.py:91
+#, python-format
+msgid "%d cards remaining"
+msgstr ""
+
+#: /home/walter/Desktop/set/VisualMatchActivity.py:102
+#: /home/walter/Desktop/set/VisualMatchActivity.py:258
+#, python-format
+msgid "%d matches"
+msgstr ""
+
#: /home/walter/Desktop/set/VisualMatchActivity.py:113
-#: /home/walter/Desktop/set/VisualMatchActivity.py:273
+#: /home/walter/Desktop/set/VisualMatchActivity.py:271
msgid "-"
msgstr ""
#: /home/walter/Desktop/set/VisualMatchActivity.py:124
-#: /home/walter/Desktop/set/VisualMatchActivity.py:286
+#: /home/walter/Desktop/set/VisualMatchActivity.py:284
msgid "Find a match."
msgstr ""
@@ -83,15 +103,11 @@ msgstr ""
msgid "Project"
msgstr ""
-#: /home/walter/Desktop/set/VisualMatchActivity.py:199
-msgid "Keep looking"
-msgstr ""
-
-#: /home/walter/Desktop/set/VisualMatchActivity.py:201
+#: /home/walter/Desktop/set/VisualMatchActivity.py:198
msgid "No matches."
msgstr ""
-#: /home/walter/Desktop/set/VisualMatchActivity.py:247
+#: /home/walter/Desktop/set/VisualMatchActivity.py:245
#, python-format
msgid "%d cards remain in the deck"
msgstr ""
diff --git a/visualmatch.py b/visualmatch.py
index 44902d4..270c9fb 100755
--- a/visualmatch.py
+++ b/visualmatch.py
@@ -89,7 +89,6 @@ class VisualMatchMain:
self.tw.low_score = int(s[1])
print "low score is: %d" % (self.tw.low_score)
except:
- print "low score is: %d" % (self.tw.low_score)
self.tw.low_score = -1
def save_score(self):