[gbrainy/gbrainy_15x] Logic puzzle trains
- From: Jordi Mas <jmas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gbrainy/gbrainy_15x] Logic puzzle trains
- Date: Sun, 25 Apr 2010 13:00:09 +0000 (UTC)
commit 738cd3370e5dd6d71ca04be0073e27c05a78920f
Author: Jordi Mas <jmas softcatala org>
Date: Sun Apr 25 15:01:04 2010 +0200
Logic puzzle trains
data/Makefile.am | 6 +-
data/game-graphics/train_left.svg | 167 +++++++++++++++++++++++++++++
data/game-graphics/train_right.svg | 167 +++++++++++++++++++++++++++++
po/POTFILES.in | 1 +
src/Games/GameList.cs | 1 +
src/Games/Logic/PuzzleTrains.cs | 202 ++++++++++++++++++++++++++++++++++++
src/Games/Makefile.am | 6 +-
7 files changed, 544 insertions(+), 6 deletions(-)
---
diff --git a/data/Makefile.am b/data/Makefile.am
index 9545214..2e02710 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -44,10 +44,6 @@ tango_icons = \
analogies_DATA = \
verbal_analogies.xml
-game_graphics = \
- game-graphics/present.svg \
- game-graphics/handshake.svg
-
install-data-local:
@-$(mkinstalldirs) $(DESTDIR)$(hicolordir)/scalable/apps
$(INSTALL_DATA) $(srcdir)/app-graphics/gbrainy.svg $(DESTDIR)$(hicolordir)/scalable/apps/gbrainy.svg
@@ -82,4 +78,4 @@ noinst_DATA =
DISTCLEANFILES = $(desktop_files)
-EXTRA_DIST = $(pixmap_DATA) $(tango_icons) $(game_graphics) $(man_MANS) $(analogies_DATA) $(desktop_in_files) gbrainy.pc.in
+EXTRA_DIST = $(pixmap_DATA) $(tango_icons) $(man_MANS) $(analogies_DATA) $(desktop_in_files) gbrainy.pc.in
diff --git a/data/game-graphics/train_left.svg b/data/game-graphics/train_left.svg
new file mode 100644
index 0000000..4820e63
--- /dev/null
+++ b/data/game-graphics/train_left.svg
@@ -0,0 +1,167 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ height="297mm"
+ id="svg1"
+ inkscape:version="0.47pre4 r22446"
+ sodipodi:docname="train_right.svg"
+ sodipodi:version="0.32"
+ width="210mm"
+ version="1.1">
+ <metadata
+ id="metadata3">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:title></dc:title>
+ <dc:description />
+ <dc:subject>
+ <rdf:Bag>
+ <rdf:li />
+ <rdf:li>roadsign</rdf:li>
+ <rdf:li>transportation</rdf:li>
+ </rdf:Bag>
+ </dc:subject>
+ <dc:publisher>
+ <cc:Agent
+ rdf:about="http://www.openclipart.org">
+ <dc:title>John Cliff</dc:title>
+ </cc:Agent>
+ </dc:publisher>
+ <dc:creator>
+ <cc:Agent>
+ <dc:title>John Cliff</dc:title>
+ </cc:Agent>
+ </dc:creator>
+ <dc:rights>
+ <cc:Agent>
+ <dc:title>John Cliff</dc:title>
+ </cc:Agent>
+ </dc:rights>
+ <dc:date />
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <cc:license
+ rdf:resource="http://web.resource.org/cc/PublicDomain" />
+ <dc:language>en</dc:language>
+ </cc:Work>
+ <cc:License
+ rdf:about="http://web.resource.org/cc/PublicDomain">
+ <cc:permits
+ rdf:resource="http://web.resource.org/cc/Reproduction" />
+ <cc:permits
+ rdf:resource="http://web.resource.org/cc/Distribution" />
+ <cc:permits
+ rdf:resource="http://web.resource.org/cc/DerivativeWorks" />
+ </cc:License>
+ </rdf:RDF>
+ </metadata>
+ <defs
+ id="defs3">
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ id="perspective19" />
+ </defs>
+ <sodipodi:namedview
+ bordercolor="#666666"
+ borderopacity="1.0"
+ id="base"
+ inkscape:cx="450.97554"
+ inkscape:cy="505.22162"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:window-height="694"
+ inkscape:window-width="1152"
+ inkscape:window-x="0"
+ inkscape:window-y="52"
+ inkscape:zoom="1.2279697"
+ pagecolor="#ffffff"
+ showgrid="false"
+ snaptogrid="false"
+ snaptoguides="false"
+ inkscape:window-maximized="1"
+ inkscape:current-layer="svg1" />
+ <path
+ transform="matrix(-1,0,0,1,827.37312,29.316683)"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:3pt;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ sodipodi:type="arc"
+ sodipodi:ry="22.394464"
+ sodipodi:rx="22.394464"
+ sodipodi:cy="592.76672"
+ sodipodi:cx="353.73074"
+ id="path644"
+ d="m 376.12521,592.76672 a 22.394464,22.394464 0 1 1 -44.78893,0 22.394464,22.394464 0 1 1 44.78893,0 z" />
+ <path
+ transform="matrix(-1,0,0,1,772.4049,29.316683)"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:3pt;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ sodipodi:type="arc"
+ sodipodi:ry="22.394464"
+ sodipodi:rx="22.394464"
+ sodipodi:cy="592.76672"
+ sodipodi:cx="353.73074"
+ id="path645"
+ d="m 376.12521,592.76672 a 22.394464,22.394464 0 1 1 -44.78893,0 22.394464,22.394464 0 1 1 44.78893,0 z" />
+ <path
+ transform="matrix(-1,0,0,1,717.43672,29.316683)"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:3pt;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ sodipodi:type="arc"
+ sodipodi:ry="22.394464"
+ sodipodi:rx="22.394464"
+ sodipodi:cy="592.76672"
+ sodipodi:cx="353.73074"
+ id="path646"
+ d="m 376.12521,592.76672 a 22.394464,22.394464 0 1 1 -44.78893,0 22.394464,22.394464 0 1 1 44.78893,0 z" />
+ <path
+ transform="matrix(-0.625,0,0,0.625,542.28912,260.00208)"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:3pt;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ sodipodi:type="arc"
+ sodipodi:ry="22.394464"
+ sodipodi:rx="22.394464"
+ sodipodi:cy="592.76672"
+ sodipodi:cx="353.73074"
+ id="path647"
+ d="m 376.12521,592.76672 a 22.394464,22.394464 0 1 1 -44.78893,0 22.394464,22.394464 0 1 1 44.78893,0 z" />
+ <path
+ style="font-size:12px;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:2.92460003pt"
+ sodipodi:nodetypes="ccccccccccccccccccccccccccccccc"
+ id="path650"
+ d="m 482.5604,577.21377 21.61989,-0.0146 0,36.74077 -231.57911,0 0,-19.86508 10.68827,0.0154 0,-47.33376 13.61481,0 0.10339,-8.39795 -3.861,-4.19897 0.0199,-3.18104 13.50351,0 13.69437,0 0.0199,2.86294 -3.73375,4.07173 -0.21472,8.84329 59.99435,0 0.0996,-6.61657 c -0.0773,-3.44928 3.21931,-9.28286 6.65093,-9.13319 l 6.93629,-0.0282 6.65094,-0.099 c 3.48175,-0.0121 7.00849,4.33945 6.93629,9.00594 l 0.0996,6.87106 43.91504,0 0.0173,-15.83531 46.17359,-0.09 0.0173,15.92528 -11.38955,0 c -2.37609,0.0393 -4.4977,2.75072 -4.4562,5.0804 l 0.12452,20.72188 c 0.0519,2.44234 2.01243,4.75743 4.35468,4.65493 z" />
+ <path
+ transform="matrix(-0.625,0,0,0.625,509.20642,260.00208)"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:3pt;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ sodipodi:type="arc"
+ sodipodi:ry="22.394464"
+ sodipodi:rx="22.394464"
+ sodipodi:cy="592.76672"
+ sodipodi:cx="353.73074"
+ id="path648"
+ d="m 376.12521,592.76672 a 22.394464,22.394464 0 1 1 -44.78893,0 22.394464,22.394464 0 1 1 44.78893,0 z" />
+ <path
+ transform="matrix(-1,0,0,1,717.43672,29.316683)"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:3pt;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ sodipodi:type="arc"
+ sodipodi:ry="22.394464"
+ sodipodi:rx="22.394464"
+ sodipodi:cy="592.76672"
+ sodipodi:cx="353.73074"
+ id="path656"
+ d="m 376.12521,592.76672 a 22.394464,22.394464 0 1 1 -44.78893,0 22.394464,22.394464 0 1 1 44.78893,0 z" />
+ <path
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:3pt;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ sodipodi:nodetypes="cccccccsssssscccc"
+ id="path661"
+ d="m 401.55731,433.78543 c 17.69981,0 32.06249,14.36271 32.0625,32.0625 0,17.6998 -14.36269,32.0625 -32.0625,32.0625 -4.47496,0 -8.72337,-0.93556 -12.59375,-2.59375 -5.63658,6.24159 -13.71538,10.21875 -22.78125,10.21875 -2.26024,0 -4.47201,-0.25614 -6.59375,-0.71875 -4.3931,4.51522 -10.52001,7.34375 -17.3125,7.34375 -6.67254,0 -12.71941,-2.71061 -17.09815,-7.08935 -2.18937,-2.18937 -9.45012,-0.97188 -11.48488,4.45757 -0.41559,1.18246 0.10109,20.44929 -0.88062,20.61468 -0.98172,0.16539 -10.85774,1.30755 -11.63166,0.46468 -0.77391,-0.84287 1.23163,-15.78659 2.37195,-22.33186 2.17071,-12.63948 12.64062,-28.5781 16.07478,-32.74242 3.43415,-4.16431 12.19768,-10.03918 17.67983,-11.1858 4.28307,-11.84848 15.55077,-20.37499 28.875,-20.375 3.67643,0 7.16789,0.75395 10.4375,1.9375 5.87753,-7.34431 14.80632,-12.125 24.9375,-12.125 z" />
+</svg>
diff --git a/data/game-graphics/train_right.svg b/data/game-graphics/train_right.svg
new file mode 100644
index 0000000..eaece55
--- /dev/null
+++ b/data/game-graphics/train_right.svg
@@ -0,0 +1,167 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ height="297mm"
+ id="svg1"
+ inkscape:version="0.47pre4 r22446"
+ sodipodi:docname="train.svg"
+ sodipodi:version="0.32"
+ width="210mm"
+ version="1.1">
+ <metadata
+ id="metadata3">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:title></dc:title>
+ <dc:description />
+ <dc:subject>
+ <rdf:Bag>
+ <rdf:li />
+ <rdf:li>roadsign</rdf:li>
+ <rdf:li>transportation</rdf:li>
+ </rdf:Bag>
+ </dc:subject>
+ <dc:publisher>
+ <cc:Agent
+ rdf:about="http://www.openclipart.org">
+ <dc:title>John Cliff</dc:title>
+ </cc:Agent>
+ </dc:publisher>
+ <dc:creator>
+ <cc:Agent>
+ <dc:title>John Cliff</dc:title>
+ </cc:Agent>
+ </dc:creator>
+ <dc:rights>
+ <cc:Agent>
+ <dc:title>John Cliff</dc:title>
+ </cc:Agent>
+ </dc:rights>
+ <dc:date />
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <cc:license
+ rdf:resource="http://web.resource.org/cc/PublicDomain" />
+ <dc:language>en</dc:language>
+ </cc:Work>
+ <cc:License
+ rdf:about="http://web.resource.org/cc/PublicDomain">
+ <cc:permits
+ rdf:resource="http://web.resource.org/cc/Reproduction" />
+ <cc:permits
+ rdf:resource="http://web.resource.org/cc/Distribution" />
+ <cc:permits
+ rdf:resource="http://web.resource.org/cc/DerivativeWorks" />
+ </cc:License>
+ </rdf:RDF>
+ </metadata>
+ <defs
+ id="defs3">
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ id="perspective19" />
+ </defs>
+ <sodipodi:namedview
+ bordercolor="#666666"
+ borderopacity="1.0"
+ id="base"
+ inkscape:cx="387.72923"
+ inkscape:cy="505.22162"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:window-height="694"
+ inkscape:window-width="1152"
+ inkscape:window-x="0"
+ inkscape:window-y="52"
+ inkscape:zoom="1.2279697"
+ pagecolor="#ffffff"
+ showgrid="false"
+ snaptogrid="false"
+ snaptoguides="false"
+ inkscape:window-maximized="1"
+ inkscape:current-layer="svg1" />
+ <path
+ transform="translate(-50.591654,29.316683)"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:3pt;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ sodipodi:type="arc"
+ sodipodi:ry="22.394464"
+ sodipodi:rx="22.394464"
+ sodipodi:cy="592.76672"
+ sodipodi:cx="353.73074"
+ id="path644"
+ d="m 376.12521,592.76672 a 22.394464,22.394464 0 1 1 -44.78893,0 22.394464,22.394464 0 1 1 44.78893,0 z" />
+ <path
+ transform="translate(4.376571,29.316683)"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:3pt;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ sodipodi:type="arc"
+ sodipodi:ry="22.394464"
+ sodipodi:rx="22.394464"
+ sodipodi:cy="592.76672"
+ sodipodi:cx="353.73074"
+ id="path645"
+ d="m 376.12521,592.76672 a 22.394464,22.394464 0 1 1 -44.78893,0 22.394464,22.394464 0 1 1 44.78893,0 z" />
+ <path
+ transform="translate(59.344751,29.316683)"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:3pt;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ sodipodi:type="arc"
+ sodipodi:ry="22.394464"
+ sodipodi:rx="22.394464"
+ sodipodi:cy="592.76672"
+ sodipodi:cx="353.73074"
+ id="path646"
+ d="m 376.12521,592.76672 a 22.394464,22.394464 0 1 1 -44.78893,0 22.394464,22.394464 0 1 1 44.78893,0 z" />
+ <path
+ transform="matrix(0.625,0,0,0.625,234.49235,260.00208)"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:3pt;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ sodipodi:type="arc"
+ sodipodi:ry="22.394464"
+ sodipodi:rx="22.394464"
+ sodipodi:cy="592.76672"
+ sodipodi:cx="353.73074"
+ id="path647"
+ d="m 376.12521,592.76672 a 22.394464,22.394464 0 1 1 -44.78893,0 22.394464,22.394464 0 1 1 44.78893,0 z" />
+ <path
+ style="font-size:12px;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:2.92460003pt"
+ sodipodi:nodetypes="ccccccccccccccccccccccccccccccc"
+ id="path650"
+ d="m 294.22107,577.21377 -21.61989,-0.0146 0,36.74077 231.57911,0 0,-19.86508 -10.68827,0.0154 0,-47.33376 -13.61481,0 -0.10339,-8.39795 3.861,-4.19897 -0.0199,-3.18104 -13.50351,0 -13.69437,0 -0.0199,2.86294 3.73375,4.07173 0.21472,8.84329 -59.99435,0 -0.0996,-6.61657 c 0.0773,-3.44928 -3.21931,-9.28286 -6.65093,-9.13319 l -6.93629,-0.0282 -6.65094,-0.099 c -3.48175,-0.0121 -7.00849,4.33945 -6.93629,9.00594 l -0.0996,6.87106 -43.91504,0 -0.0173,-15.83531 -46.17359,-0.09 -0.0173,15.92528 11.38955,0 c 2.37609,0.0393 4.4977,2.75072 4.4562,5.0804 l -0.12452,20.72188 c -0.0519,2.44234 -2.01243,4.75743 -4.35468,4.65493 z" />
+ <path
+ transform="matrix(0.625,0,0,0.625,267.57505,260.00208)"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:3pt;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ sodipodi:type="arc"
+ sodipodi:ry="22.394464"
+ sodipodi:rx="22.394464"
+ sodipodi:cy="592.76672"
+ sodipodi:cx="353.73074"
+ id="path648"
+ d="m 376.12521,592.76672 a 22.394464,22.394464 0 1 1 -44.78893,0 22.394464,22.394464 0 1 1 44.78893,0 z" />
+ <path
+ transform="translate(59.344751,29.316683)"
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:3pt;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ sodipodi:type="arc"
+ sodipodi:ry="22.394464"
+ sodipodi:rx="22.394464"
+ sodipodi:cy="592.76672"
+ sodipodi:cx="353.73074"
+ id="path656"
+ d="m 376.12521,592.76672 a 22.394464,22.394464 0 1 1 -44.78893,0 22.394464,22.394464 0 1 1 44.78893,0 z" />
+ <path
+ style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:3pt;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ sodipodi:nodetypes="cccccccsssssscccc"
+ id="path661"
+ d="m 375.22416,433.78543 c -17.69981,0 -32.06249,14.36271 -32.0625,32.0625 0,17.6998 14.36269,32.0625 32.0625,32.0625 4.47496,0 8.72337,-0.93556 12.59375,-2.59375 5.63658,6.24159 13.71538,10.21875 22.78125,10.21875 2.26024,0 4.47201,-0.25614 6.59375,-0.71875 4.3931,4.51522 10.52001,7.34375 17.3125,7.34375 6.67254,0 12.71941,-2.71061 17.09815,-7.08935 2.18937,-2.18937 9.45012,-0.97188 11.48488,4.45757 0.41559,1.18246 -0.10109,20.44929 0.88062,20.61468 0.98172,0.16539 10.85774,1.30755 11.63166,0.46468 0.77391,-0.84287 -1.23163,-15.78659 -2.37195,-22.33186 -2.17071,-12.63948 -12.64062,-28.5781 -16.07478,-32.74242 -3.43415,-4.16431 -12.19768,-10.03918 -17.67983,-11.1858 -4.28307,-11.84848 -15.55077,-20.37499 -28.875,-20.375 -3.67643,0 -7.16789,0.75395 -10.4375,1.9375 -5.87753,-7.34431 -14.80632,-12.125 -24.9375,-12.125 z" />
+</svg>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index e39c826..340b6d6 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -71,6 +71,7 @@ src/Games/Logic/PuzzleSquares.cs
src/Games/Logic/PuzzleSquareSheets.cs
src/Games/Logic/PuzzleTetris.cs
src/Games/Logic/PuzzleTimeNow.cs
+src/Games/Logic/PuzzleTrains.cs
src/Games/Logic/PuzzleTriangles.cs
src/Games/Logic/PuzzleTrianglesWithNumbers.cs
src/Games/Memory/MemoryColouredFigures.cs
diff --git a/src/Games/GameList.cs b/src/Games/GameList.cs
index 3d98cb4..99db23b 100644
--- a/src/Games/GameList.cs
+++ b/src/Games/GameList.cs
@@ -76,6 +76,7 @@ namespace gbrainy.Games
typeof (Puzzle3DCube),
typeof (PuzzlePredicateLogic),
typeof (PuzzleDice),
+ typeof (PuzzleTrains),
};
static Type[] CalculationTrainersInternal = new Type[]
diff --git a/src/Games/Logic/PuzzleTrains.cs b/src/Games/Logic/PuzzleTrains.cs
new file mode 100644
index 0000000..2802a35
--- /dev/null
+++ b/src/Games/Logic/PuzzleTrains.cs
@@ -0,0 +1,202 @@
+/*
+ * Copyright (C) 2010 Jordi Mas i Hernà ndez <jmas softcatala org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+using Cairo;
+using Mono.Unix;
+using System;
+
+using gbrainy.Core.Main;
+using gbrainy.Core.Libraries;
+
+namespace gbrainy.Games.Logic
+{
+ public class PuzzleTrains : Game
+ {
+ enum GameType
+ {
+ Overtake,
+ Meet,
+ Apart,
+ Total
+ }
+
+ string question, answer;
+ GameType gametype;
+
+ public override string Name {
+ get {return Catalog.GetString ("Trains");}
+ }
+
+ public override string Question {
+ get {return question; }
+ }
+
+ public override string Answer {
+ get { return base.Answer + " " + answer;}
+ }
+
+ public override string Tip {
+ get { return Catalog.GetString ("The distance formula is 'distance = rate x time'.");}
+ }
+
+ public override void Initialize ()
+ {
+ int ans;
+ double speed_a, speed_b, rslt;
+
+ gametype = (GameType) random.Next ((int) GameType.Total);
+
+ switch (gametype)
+ {
+ case GameType.Overtake:
+ {
+ double hours;
+
+ do
+ {
+ speed_a = 20 + (5 * random.Next (5));
+ speed_b = 50 + (5 * random.Next (5));
+ hours = 2 * (1 + random.Next (3));
+ rslt = speed_b * hours / (speed_b - speed_a);
+
+ } while (rslt != Math.Truncate (rslt));
+
+ question = String.Format (
+ // Translators:
+ // - {0}, {1} and {2} are always greater than 2
+ // - mph (miles per hour). You must localize this using the right unit of speed for your locale
+ Catalog.GetString ("A train leaves the station traveling at {0} mph. {1} hours later a second train leaves the station traveling in the same direction at {2} mph. How many hours does it take the second train to overtake the first train?")
+ ,speed_a, hours, speed_b);
+
+ answer = String.Format (Catalog.GetString ("You can calculate the answer multiplying the second train speed by the time and dividing it by the difference of speeds."));
+
+ break;
+ }
+ case GameType.Meet:
+ {
+ double distance, hours;
+
+ speed_a = 20 + (5 * random.Next (5));
+ speed_b = 50 + (5 * random.Next (5));
+ hours = 2 + random.Next (5);
+ distance = hours * (speed_b + speed_a);
+ rslt = hours;
+
+ question = String.Format (
+ // Translators:
+ // - {0}, {1} and {3} are always greater than 2
+ // - mph (miles per hour) and miles must be localized this using the right unit of speed for your locale
+ Catalog.GetString ("Two trains separated by {0} miles are heading towards each other on straight parallel tracks. One travels at {1} mph and the other at {2} mph. In how many hours do they meet?"),
+ distance, speed_a, speed_b);
+
+ answer = String.Format (Catalog.GetString ("You can calculate the answer dividing the distance by the sum of both speeds."));
+ break;
+ }
+ case GameType.Apart:
+ {
+ double distance;
+
+ speed_a = 10 + (2 * random.Next (5));
+ speed_b = 20 + (2 * random.Next (5));
+ distance = (speed_a + speed_b) * (2 + random.Next (5));
+
+ // Time in hours
+ rslt = distance / (speed_a + speed_b);
+
+ question = String.Format (
+ // Translators:
+ // - {0}, {1} and {2} are always greater than 2
+ // - mph (miles per hour). You must localize this using the right unit of speed for your locale
+ Catalog.GetString ("Two trains on straight parallel tracks leave from the same point and time traveling in opposite directions at {0} and {1} mph respectively. In how many hours they will be {2} miles apart?"),
+ speed_a, speed_b, distance);
+
+ answer = String.Format (Catalog.GetString ("You can calculate the answer dividing the distance by the sum of both speeds."));
+ break;
+ }
+ default:
+ throw new Exception ("Unexpected value");
+ }
+
+ ans = (int) rslt;
+ right_answer = (ans).ToString ();
+ }
+
+ public override void Draw (CairoContextEx gr, int area_width, int area_height, bool rtl)
+ {
+ string train_right = "train_right.svg";
+ string train_left = "train_left.svg";
+
+ base.Draw (gr, area_width, area_height, rtl);
+
+ switch (gametype)
+ {
+ case GameType.Overtake:
+ gr.DrawImageFromAssembly (train_right, 0, 0.1, 0.5, 0.55);
+ gr.MoveTo (0.1, 0.45);
+ gr.LineTo (0.9, 0.45);
+ gr.Stroke ();
+
+ gr.DrawImageFromAssembly (train_right, 0.5, 0.1, 0.5, 0.55);
+ break;
+
+ case GameType.Meet:
+ gr.DrawImageFromAssembly (train_right, 0, 0.1, 0.5, 0.55);
+ gr.MoveTo (0.1, 0.45);
+ gr.LineTo (0.9, 0.45);
+ gr.Stroke ();
+
+ gr.DrawImageFromAssembly (train_left, 0.55, 0.3, 0.5, 0.55);
+ gr.MoveTo (0.1, 0.65);
+ gr.LineTo (0.9, 0.65);
+ gr.Stroke ();
+ break;
+
+ case GameType.Apart:
+ gr.DrawImageFromAssembly (train_right, 0.35, 0.1, 0.5, 0.55);
+ gr.MoveTo (0.1, 0.45);
+ gr.LineTo (0.9, 0.45);
+ gr.Stroke ();
+
+ gr.DrawImageFromAssembly (train_left, 0.15, 0.3, 0.5, 0.55);
+ gr.MoveTo (0.1, 0.65);
+ gr.LineTo (0.9, 0.65);
+ gr.Stroke ();
+ break;
+ default:
+ throw new Exception ("Unexpected value");
+ }
+ }
+
+ public override bool CheckAnswer (string answer)
+ {
+ string num = string.Empty;
+
+ // Clean the answer from every non-numeric values after the numbers (like 5 hours)
+ for (int c = 0; c < answer.Length; c++)
+ {
+ if (answer[c] < '0' || answer[c] > '9')
+ break;
+
+ num += answer[c];
+ }
+
+ return base.CheckAnswer (num);
+ }
+ }
+}
diff --git a/src/Games/Makefile.am b/src/Games/Makefile.am
index 925a0f1..ef03af9 100644
--- a/src/Games/Makefile.am
+++ b/src/Games/Makefile.am
@@ -45,6 +45,7 @@ CSDISTFILES = \
$(srcdir)/Logic/PuzzleSquareSheets.cs \
$(srcdir)/Logic/PuzzleTetris.cs \
$(srcdir)/Logic/PuzzleTimeNow.cs \
+ $(srcdir)/Logic/PuzzleTrains.cs \
$(srcdir)/Logic/PuzzleTriangles.cs \
$(srcdir)/Logic/PuzzleTrianglesWithNumbers.cs \
$(srcdir)/Logic/PuzzlePredicateLogic.cs \
@@ -75,7 +76,10 @@ CSFILES = $(CSDISTFILES) \
RES = \
$(top_srcdir)/data/game-graphics/present.svg \
$(top_srcdir)/data/game-graphics/handshake.svg \
-$(top_srcdir)/data/game-graphics/dice.svg
+$(top_srcdir)/data/game-graphics/dice.svg \
+$(top_srcdir)/data/game-graphics/train_right.svg \
+$(top_srcdir)/data/game-graphics/train_left.svg
+
REFS = \
-r:System \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]