~ubuntu-branches/ubuntu/lucid/gbrainy/lucid

« back to all changes in this revision

Viewing changes to src/MemoryGames/MemoryWords.cs

  • Committer: Bazaar Package Importer
  • Author(s): Robert Ancell
  • Date: 2010-01-12 11:21:24 UTC
  • mfrom: (13.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20100112112124-o4ztomxa0xfh2ulj
Tags: 1.30-1ubuntu1
* debian/control:
  - Revert build-depends to lucid versions

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 2007-2008 Jordi Mas i Hernàndez <jmas@softcatala.org>
3
 
 *
4
 
 * This program is free software; you can redistribute it and/or
5
 
 * modify it under the terms of the GNU General Public License as
6
 
 * published by the Free Software Foundation; either version 2 of the
7
 
 * License, or (at your option) any later version.
8
 
 *
9
 
 * This program is distributed in the hope that it will be useful,
10
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 
 * General Public License for more details.
13
 
 *
14
 
 * You should have received a copy of the GNU General Public
15
 
 * License along with this program; if not, write to the
16
 
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
 
 * Boston, MA 02111-1307, USA.
18
 
 */
19
 
 
20
 
using System;
21
 
using Cairo;
22
 
using Mono.Unix;
23
 
using System.Collections.Generic;
24
 
 
25
 
public class MemoryWords : Memory
26
 
{
27
 
        private ArrayListIndicesRandom words_order;
28
 
        private List <string> words;
29
 
        private const int total_words = 35;
30
 
        private int showed;
31
 
        private int answer;
32
 
 
33
 
        public override string Name {
34
 
                get {return Catalog.GetString ("Memorize words");}
35
 
        }
36
 
 
37
 
        public override string MemoryQuestion {
38
 
                get { 
39
 
                        return String.Format (Catalog.GetString ("There is a missing word from the previous list. Which one is the missing word?"));}
40
 
        }
41
 
 
42
 
        public override void Initialize ()
43
 
        {
44
 
                int tmp;
45
 
                words = new List <string> (total_words);
46
 
 
47
 
                // Body parts
48
 
                words.Add (Catalog.GetString ("wrist"));
49
 
                words.Add (Catalog.GetString ("elbow"));
50
 
                words.Add (Catalog.GetString ("armpit"));
51
 
                words.Add (Catalog.GetString ("hand"));
52
 
                words.Add (Catalog.GetString ("chest"));
53
 
                        
54
 
                //Fishes
55
 
                words.Add (Catalog.GetString ("sardine"));
56
 
                words.Add (Catalog.GetString ("trout"));
57
 
                words.Add (Catalog.GetString ("monkfish"));
58
 
                words.Add (Catalog.GetString ("cod"));
59
 
                words.Add (Catalog.GetString ("salmon"));
60
 
 
61
 
                // Vegetables
62
 
                words.Add (Catalog.GetString ("potato"));
63
 
                words.Add (Catalog.GetString ("ginger"));                       
64
 
                words.Add (Catalog.GetString ("pepper"));
65
 
                words.Add (Catalog.GetString ("garlic"));
66
 
                words.Add (Catalog.GetString ("pumpkin"));
67
 
 
68
 
                // Bicycle
69
 
                words.Add (Catalog.GetString ("brake"));
70
 
                words.Add (Catalog.GetString ("pedal"));
71
 
                words.Add (Catalog.GetString ("chain"));                        
72
 
                words.Add (Catalog.GetString ("wheel"));
73
 
                words.Add (Catalog.GetString ("handlebar"));
74
 
 
75
 
                // Music
76
 
                words.Add (Catalog.GetString ("drummer"));
77
 
                words.Add (Catalog.GetString ("speaker"));
78
 
                words.Add (Catalog.GetString ("lyrics"));
79
 
                words.Add (Catalog.GetString ("beat"));                 
80
 
                words.Add (Catalog.GetString ("song"));
81
 
 
82
 
                // Weather
83
 
                words.Add (Catalog.GetString ("cloud"));
84
 
                words.Add (Catalog.GetString ("rain"));
85
 
                words.Add (Catalog.GetString ("storm"));
86
 
                words.Add (Catalog.GetString ("fog"));
87
 
                words.Add (Catalog.GetString ("rainbow"));
88
 
 
89
 
                // Animals
90
 
                words.Add (Catalog.GetString ("rabbit"));
91
 
                words.Add (Catalog.GetString ("mouse"));
92
 
                words.Add (Catalog.GetString ("monkey"));
93
 
                words.Add (Catalog.GetString ("bear"));
94
 
                words.Add (Catalog.GetString ("wolf"));
95
 
 
96
 
                switch (CurrentDifficulty) {
97
 
                case Difficulty.Easy:
98
 
                        showed = 6;
99
 
                        break;
100
 
                case Difficulty.Medium:
101
 
                        showed = 9;
102
 
                        break;
103
 
                case Difficulty.Master:
104
 
                        showed = 12;
105
 
                        break;
106
 
                }
107
 
 
108
 
                words_order = new ArrayListIndicesRandom (total_words);
109
 
                words_order.Initialize ();
110
 
                answer = random.Next (showed);
111
 
                tmp = words_order [answer];
112
 
                right_answer = words [tmp];
113
 
                base.Initialize ();
114
 
        }
115
 
        
116
 
        public override void DrawPossibleAnswers (CairoContextEx gr, int area_width, int area_height)
117
 
        {
118
 
                double x= DrawAreaX + 0.125, y = DrawAreaY + 0.1;
119
 
                int cnt = 0;
120
 
 
121
 
                for (int i = 0; i < showed; i++)
122
 
                {
123
 
                        if (i == answer)
124
 
                                continue;
125
 
 
126
 
                        gr.MoveTo (x, y);
127
 
                        gr.ShowPangoText (words[words_order[i]]);
128
 
                        gr.Stroke ();
129
 
 
130
 
                        if ((cnt + 1) % 3 == 0) {
131
 
                                y += 0.2;
132
 
                                x = DrawAreaX + 0.125;
133
 
                        } else {
134
 
                                x+= 0.25;
135
 
                        }
136
 
                        cnt++;
137
 
                }
138
 
        }
139
 
        
140
 
        public override void DrawObjectToMemorize (CairoContextEx gr, int area_width, int area_height)
141
 
        {
142
 
                base.DrawObjectToMemorize (gr, area_width, area_height);
143
 
                DrawObject (gr, area_width, area_height);
144
 
        }
145
 
        
146
 
        private void DrawObject (CairoContextEx gr, int area_width, int area_height)
147
 
        {
148
 
                double x= DrawAreaX + 0.125, y = DrawAreaY + 0.1;
149
 
                for (int i = 0; i < showed; i++)
150
 
                {
151
 
                        gr.MoveTo (x, y);
152
 
                        gr.ShowPangoText (words[words_order[i]]);
153
 
                        gr.Stroke ();
154
 
                        
155
 
                        if ((i + 1) % 3 == 0) {
156
 
                                y += 0.2;
157
 
                                x = DrawAreaX + 0.125;
158
 
                        } else {
159
 
                                x+= 0.25;
160
 
                        }
161
 
                }
162
 
        }
163
 
}
164
 
 
165