Dogeku 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/README.md +39 -0
  4. data/app/Historique/Action.rb +29 -0
  5. data/app/Historique/ChangerCase.rb +44 -0
  6. data/app/Historique/HistoriqueAction.rb +114 -0
  7. data/app/components/CaseDessin.rb +325 -0
  8. data/app/components/GrilleDessin.rb +235 -0
  9. data/app/components/Header.rb +194 -0
  10. data/app/config/app.yml +0 -0
  11. data/app/config/database.yml +2 -0
  12. data/app/controller/ApprentissageControleur.rb +75 -0
  13. data/app/controller/ChargerControleur.rb +41 -0
  14. data/app/controller/JeuLibreControleur.rb +244 -0
  15. data/app/controller/MenuControleur.rb +57 -0
  16. data/app/controller/NiveauControleur.rb +54 -0
  17. data/app/controller/NouvellePartieControleur.rb +34 -0
  18. data/app/controller/PrincipaleControleur.rb +30 -0
  19. data/app/controller/PseudoControleur.rb +95 -0
  20. data/app/controller/ReglagesControleur.rb +86 -0
  21. data/app/controller/ReglesControleur.rb +34 -0
  22. data/app/controller/ScoresControleur.rb +42 -0
  23. data/app/controller/StatistiquesControleur.rb +64 -0
  24. data/app/core/Conf.rb +26 -0
  25. data/app/core/Controller.rb +180 -0
  26. data/app/core/Core.rb +186 -0
  27. data/app/core/Model.rb +159 -0
  28. data/app/core/View.rb +56 -0
  29. data/app/db/main.sqlite3 +0 -0
  30. data/app/model/Configuration.rb +180 -0
  31. data/app/model/Grille.rb +180 -0
  32. data/app/model/Jeu.rb +74 -0
  33. data/app/model/Score.rb +100 -0
  34. data/app/model/Utilisateur.rb +113 -0
  35. data/app/utils/DSubset.rb +98 -0
  36. data/app/utils/Generateur.rb +171 -0
  37. data/app/utils/HPTriple.rb +75 -0
  38. data/app/utils/Peche.rb +46 -0
  39. data/app/utils/SCandidate.rb +86 -0
  40. data/app/utils/SCell.rb +73 -0
  41. data/app/utils/Technique.rb +202 -0
  42. data/app/utils/TechniqueUsine.rb +25 -0
  43. data/app/utils/XWing.rb +203 -0
  44. data/app/view/Fenetre.rb +424 -0
  45. data/app/view/FenetreApprentissage.rb +272 -0
  46. data/app/view/FenetreCharger.rb +31 -0
  47. data/app/view/FenetreJeuLibre.rb +468 -0
  48. data/app/view/FenetreMenu.rb +198 -0
  49. data/app/view/FenetreNiveau.rb +105 -0
  50. data/app/view/FenetreNouvellePartie.rb +92 -0
  51. data/app/view/FenetrePrincipale.rb +45 -0
  52. data/app/view/FenetrePseudo.rb +115 -0
  53. data/app/view/FenetreReglages.rb +209 -0
  54. data/app/view/FenetreRegles.rb +111 -0
  55. data/app/view/FenetreScores.rb +120 -0
  56. data/app/view/FenetreStatistiques.rb +134 -0
  57. data/assets/css/style.css +69 -0
  58. data/assets/img/eraser.png +0 -0
  59. data/assets/img/fond.jpg +0 -0
  60. data/assets/img/iconApp.png +0 -0
  61. data/assets/img/logoS.jpeg +0 -0
  62. data/assets/img/sudokuIntro.jpg +0 -0
  63. data/assets/img/user.png +0 -0
  64. data/bin/dogeku +19 -0
  65. data/doc/Action.html +309 -0
  66. data/doc/ApprentissageControleur.html +568 -0
  67. data/doc/CaseDessin.html +2405 -0
  68. data/doc/ChangerCase.html +405 -0
  69. data/doc/ChargerControleur.html +342 -0
  70. data/doc/Conf.html +378 -0
  71. data/doc/Configuration.html +1115 -0
  72. data/doc/Controller.html +1008 -0
  73. data/doc/Core.html +1191 -0
  74. data/doc/DSubset.html +647 -0
  75. data/doc/Fenetre.html +2631 -0
  76. data/doc/FenetreApprentissage.html +1175 -0
  77. data/doc/FenetreCharger.html +343 -0
  78. data/doc/FenetreJeuLibre.html +1859 -0
  79. data/doc/FenetreMenu.html +900 -0
  80. data/doc/FenetreNiveau.html +626 -0
  81. data/doc/FenetreNouvellePartie.html +602 -0
  82. data/doc/FenetrePrincipale.html +371 -0
  83. data/doc/FenetrePseudo.html +695 -0
  84. data/doc/FenetreReglages.html +946 -0
  85. data/doc/FenetreRegles.html +636 -0
  86. data/doc/FenetreScores.html +650 -0
  87. data/doc/FenetreStatistiques.html +672 -0
  88. data/doc/Generateur.html +1015 -0
  89. data/doc/Grille.html +1348 -0
  90. data/doc/GrilleDessin.html +1281 -0
  91. data/doc/HPTriple.html +593 -0
  92. data/doc/Header.html +1253 -0
  93. data/doc/HistoriqueAction.html +792 -0
  94. data/doc/Jeu.html +923 -0
  95. data/doc/JeuLibreControleur.html +1445 -0
  96. data/doc/MenuControleur.html +522 -0
  97. data/doc/Model.html +996 -0
  98. data/doc/NiveauControleur.html +451 -0
  99. data/doc/NouvellePartieControleur.html +330 -0
  100. data/doc/Peche.html +396 -0
  101. data/doc/PrincipaleControleur.html +320 -0
  102. data/doc/PseudoControleur.html +695 -0
  103. data/doc/ReglagesControleur.html +747 -0
  104. data/doc/ReglesControleur.html +330 -0
  105. data/doc/SCandidate.html +617 -0
  106. data/doc/SCell.html +587 -0
  107. data/doc/Score.html +926 -0
  108. data/doc/ScoresControleur.html +346 -0
  109. data/doc/StatistiquesControleur.html +390 -0
  110. data/doc/Technique.html +543 -0
  111. data/doc/TechniqueUsine.html +252 -0
  112. data/doc/Utilisateur.html +806 -0
  113. data/doc/View.html +844 -0
  114. data/doc/XWing.html +1031 -0
  115. data/doc/_index.html +478 -0
  116. data/doc/class_list.html +51 -0
  117. data/doc/css/common.css +1 -0
  118. data/doc/css/full_list.css +58 -0
  119. data/doc/css/style.css +492 -0
  120. data/doc/file.README.html +141 -0
  121. data/doc/file_list.html +56 -0
  122. data/doc/frames.html +17 -0
  123. data/doc/index.html +141 -0
  124. data/doc/js/app.js +243 -0
  125. data/doc/js/full_list.js +216 -0
  126. data/doc/js/jquery.js +4 -0
  127. data/doc/method_list.html +2523 -0
  128. data/doc/top-level-namespace.html +112 -0
  129. data/test/Generateur/grilleCorrecte.rb +198 -0
  130. data/test/Model/scoreCorrecte.rb +55 -0
  131. data/test/Model/utilisateurCorrecte.rb +68 -0
  132. data/test/test_helper.rb +2 -0
  133. data/test/unitTest.rb +72 -0
  134. metadata +187 -0
@@ -0,0 +1,95 @@
1
+ # => Author:: Valentin, DanAurea
2
+ # => Version:: 0.1
3
+ # => Copyright:: © 2016
4
+ # => License:: Distributes under the same terms as Ruby
5
+ #
6
+
7
+ ##
8
+ ## Classe permettant de créer un contrôleur pour la vue FenetrePseudo
9
+ ##
10
+ class PseudoControleur < Controller
11
+
12
+ ##
13
+ ## Initialize
14
+ ##
15
+ def initialize()
16
+ #charge le modèle utilisateur
17
+ loadModel("Utilisateur")
18
+
19
+ #paramètres fenêtre
20
+ @title = "Sudoku - Pseudo"
21
+ @width = 600
22
+ @height = 550
23
+ @resizable = false
24
+ @position= "CENTER_ALWAYS"
25
+
26
+ end
27
+
28
+ ##
29
+ ## Action après clic sur le bouton valider pour choix du pseudo
30
+ ##
31
+ ## @param message Message popup
32
+ ## @param entreePseudo Widget pseudo
33
+ ##
34
+ ## @return boolean
35
+ ##
36
+ def actionValider(message, entreePseudo)
37
+ messageQuestion = Fenetre::creerPopup(message, "YES_NO")
38
+ reponse = messageQuestion.run()
39
+ action = false
40
+
41
+ if(reponse == Gtk::ResponseType::YES)
42
+ ## Ajoute l'entête de la fenêtre avec le profil utilisateur
43
+ ## puis change de page
44
+ Header.profil(entreePseudo.text)
45
+
46
+ Core::changeTo("Menu", "pseudo": entreePseudo.text)
47
+ action = true
48
+ else
49
+ entreePseudo.text=""
50
+ action = false
51
+ end
52
+
53
+ messageQuestion.destroy()
54
+ return action
55
+ end
56
+
57
+ ##
58
+ ## Action du bouton valider (vérification pseudo)
59
+ ##
60
+ ## @param entreePseudo Widget pseudo
61
+ ##
62
+ def actionBoutonValider(entreePseudo)
63
+ if(entreePseudo.text == "")
64
+ messageErreur = Fenetre::creerPopup("Vous devez entrer un pseudo valide pour continuer!", "CLOSE")
65
+ messageErreur.run()
66
+ messageErreur.destroy()
67
+ elsif self.pseudoExiste(entreePseudo.text)
68
+ actionValider("Ce pseudo existe déjà, êtes vous '#{entreePseudo.text}'?", entreePseudo)
69
+ else
70
+ if actionValider("Pseudo inconnu, créer un nouveau profil?", entreePseudo)
71
+ @Utilisateur.creerUtilisateur(entreePseudo.text)
72
+ end
73
+ end
74
+ end
75
+
76
+ ##
77
+ ## Permet de savoir si le pseudo existe déjà dans la base
78
+ ##
79
+ ## @param pseudo Pseudo voulu par l'utilisateur
80
+ ##
81
+ ## @return boolean
82
+ ##
83
+ def pseudoExiste(pseudo)
84
+ return @Utilisateur.rechercherUtilisateur(pseudo)
85
+ end
86
+
87
+ ##
88
+ ## Méthode à définir dans tous les cas !
89
+ ##
90
+ ## @return self
91
+ ##
92
+ def run()
93
+ return self
94
+ end
95
+ end
@@ -0,0 +1,86 @@
1
+ # => Author:: Valentin, DanAurea
2
+ # => Version:: 0.1
3
+ # => Copyright:: © 2016
4
+ # => License:: Distributes under the same terms as Ruby
5
+ #
6
+
7
+ ##
8
+ ## Classe permettant de créer un contrôleur pour la vue FenetreReglages
9
+ ##
10
+ class ReglagesControleur < Controller
11
+
12
+ ##
13
+ ## Initialize
14
+ ##
15
+ def initialize()
16
+ #charge le modèle utilisateur
17
+ loadModel("Utilisateur")
18
+ loadModel("Configuration")
19
+
20
+ #paramètres fenêtre
21
+ @title = "Sudoku - Réglages"
22
+ @width = 600
23
+ @height = 550
24
+ @resizable = false
25
+ @position = "CENTER_ALWAYS"
26
+
27
+ end
28
+
29
+
30
+ ##
31
+ ## Enregistre les paramètres en base de données
32
+ ##
33
+ ## @param pseudo Pseudo de l'utilisateur
34
+ ## @param config Configuration de l'utilisateur
35
+ ##
36
+ ## @return self
37
+ ##
38
+ def enregistrerReglages(pseudo, config)
39
+ @Configuration.enregistrer(pseudo, config)
40
+ return self
41
+ end
42
+
43
+
44
+ ##
45
+ ## Réinitialise l'utilisateur avec les configurations par défaut
46
+ ##
47
+ ## @return { description_of_the_return_value }
48
+ ##
49
+ def resetUtilisateur()
50
+ @Utilisateur.reinitialiserUtilisateur(@content["pseudo"])
51
+ end
52
+
53
+ ##
54
+ ## Convertit un gdk color en composantes sous forme d'une chaîne séparée par une virgule
55
+ ##
56
+ ## @param gdkColor GDK::Color
57
+ ##
58
+ ## @return Les composantes sous forme de chaîne
59
+ ##
60
+ def couleur(gdkColor)
61
+ return @Configuration.couleur(gdkColor)
62
+ end
63
+
64
+
65
+ ##
66
+ ## Crée un Gdk::Color à partir d'une chaîne
67
+ ##
68
+ ## @param composantes Composantes ("r,g,b")
69
+ ##
70
+ ## @return Gdk::Color
71
+ ##
72
+ def creerCouleur(composantes)
73
+ return @Configuration.creerCouleur(composantes)
74
+ end
75
+
76
+ ##
77
+ ## Méthode à définir dans tous les cas !
78
+ ##
79
+ ## @return self
80
+ ##
81
+ def run()
82
+ @content["config"] = @Configuration.getConfiguration(@content["pseudo"])
83
+
84
+ return self
85
+ end
86
+ end
@@ -0,0 +1,34 @@
1
+ # => Author:: Valentin, DanAurea
2
+ # => Version:: 0.1
3
+ # => Copyright:: © 2016
4
+ # => License:: Distributes under the same terms as Ruby
5
+ #
6
+
7
+ ##
8
+ ## Classe permettant de créer un contrôleur pour la vue FenetreRegles
9
+ ##
10
+ class ReglesControleur < Controller
11
+
12
+ ##
13
+ ## Initialize
14
+ ##
15
+ def initialize()
16
+ #charge le modèle utilisateur
17
+ loadModel("Utilisateur")
18
+ #paramètres fenêtre
19
+ @title = "Sudoku - Règles"
20
+ @width = 600
21
+ @height = 550
22
+ @resizable = false
23
+ @position= "CENTER_ALWAYS"
24
+ end
25
+
26
+ ##
27
+ ## Méthode à définir dans tous les cas !
28
+ ##
29
+ ## @return self
30
+ ##
31
+ def run()
32
+ return self
33
+ end
34
+ end
@@ -0,0 +1,42 @@
1
+ # => Author:: Valentin, DanAurea
2
+ # => Version:: 0.1
3
+ # => Copyright:: © 2016
4
+ # => License:: Distributes under the same terms as Ruby
5
+ #
6
+
7
+ ##
8
+ ## Classe permettant de créer un contrôleur pour la vue FenetreScores
9
+ ##
10
+ class ScoresControleur < Controller
11
+
12
+ ##
13
+ ## Initialize
14
+ ##
15
+ def initialize()
16
+ #charge le modèle utilisateur
17
+ loadModel('Score')
18
+ #paramètres fenêtre
19
+ @title = "Sudoku - Scores"
20
+ @width = 600
21
+ @height = 550
22
+ @resizable = false
23
+ @position= "CENTER_ALWAYS"
24
+ end
25
+
26
+ ##
27
+ ## Méthode à définir dans tous les cas !
28
+ ##
29
+ ## @return self
30
+ ##
31
+ def run()
32
+ meilleursScores = @Score.meilleursScores(10)
33
+
34
+ @content["meilleursScores"] = []
35
+
36
+ meilleursScores.each do |score|
37
+ @content["meilleursScores"] << [score["pseudo"], score["score"]]
38
+ end
39
+
40
+ return self
41
+ end
42
+ end
@@ -0,0 +1,64 @@
1
+ # => Author:: Valentin, DanAurea
2
+ # => Version:: 0.1
3
+ # => Copyright:: © 2016
4
+ # => License:: Distributes under the same terms as Ruby
5
+
6
+
7
+ ##
8
+ ## Classe permettant de créer un contrôleur pour la vue FenetreStatistiques
9
+ ##
10
+ class StatistiquesControleur < Controller
11
+
12
+ ##
13
+ ## Initialize
14
+ ##
15
+ def initialize()
16
+ #charge le modèle utilisateur
17
+ loadModel("Score")
18
+ loadModel("Jeu")
19
+ #paramètres fenêtre
20
+ @title = "Sudoku - Statistiques"
21
+ @width = 600
22
+ @height = 550
23
+ @resizable = false
24
+ @position= "CENTER_ALWAYS"
25
+ end
26
+
27
+ ##
28
+ ## Méthode à définir dans tous les cas !
29
+ ##
30
+ ## @return self
31
+ ##
32
+ def run()
33
+ scores = @Score.scoreUtilisateur(@content["pseudo"])
34
+
35
+ nombreParties = Array.new(3, 0)
36
+ moyennes = Array.new(3, 0)
37
+ meilleursScores = Array.new(3, 0)
38
+
39
+ ## Calcule la moyenne des scores de l'utilisateur
40
+ scores.each do |ligne|
41
+ niveau = ligne["niveau"]
42
+ score = ligne["score"]
43
+
44
+ moyennes[niveau] += score
45
+ nombreParties[niveau] += 1
46
+
47
+ if(meilleursScores[niveau] < score)
48
+ meilleursScores[niveau] = score
49
+ end
50
+ end
51
+
52
+ (0...moyennes.length).each do |i|
53
+ if(nombreParties[i] > 0)
54
+ moyennes[i] /= nombreParties[i]
55
+ end
56
+ end
57
+
58
+ @content["moyennes"] = moyennes
59
+ @content["meilleursScores"] = meilleursScores
60
+ @content["nombreParties"] = nombreParties
61
+
62
+ return self
63
+ end
64
+ end
data/app/core/Conf.rb ADDED
@@ -0,0 +1,26 @@
1
+ require "yaml"
2
+
3
+ # => Author:: DanAurea
4
+ # => Version:: 0.1
5
+ # => Copyright:: © 2016
6
+ # => License:: Distributes under the same terms as Ruby
7
+
8
+ ##
9
+ ## Classe permettant de gérer le core (configuration unique)
10
+ ##
11
+
12
+ class Conf
13
+ include Singleton
14
+
15
+ attr_reader :app, :db
16
+
17
+ ##
18
+ ## Initialisation
19
+ ##
20
+ def initialize ()
21
+ ## TODO: Add some exceptions handling
22
+ @app = YAML.load_file(Core::ROOT + "config/app.yml")
23
+ @db = YAML.load_file(Core::ROOT + "config/database.yml")
24
+ end
25
+
26
+ end
@@ -0,0 +1,180 @@
1
+ # => Author:: DanAurea
2
+ # => Version:: 0.1
3
+ # => Copyright:: © 2016
4
+ # => License:: Distributes under the same terms as Ruby
5
+
6
+ ##
7
+ ## Controls the data flow into an item object and updates the view whenever data changes.
8
+ ##
9
+ class Controller
10
+ ##
11
+ ## Initialisation
12
+ ##
13
+ def initialize ()
14
+
15
+ @title = "MyApp"
16
+ @width = 900
17
+ @height = 500
18
+ @borderWidth = 0
19
+ @resizable = true
20
+ @position = "CENTER"
21
+
22
+ ## Create content variable sent from controller to view called
23
+ @content = Hash.new(0)
24
+
25
+ if Core::DEBUG
26
+ puts "Main controller instanciation"
27
+ end
28
+
29
+ end
30
+
31
+ ##
32
+ ## Invoke methods when inherited
33
+ ##
34
+ ## @param subclass The subclass
35
+ ##
36
+ ## @return Itself
37
+ ##
38
+ def self.inherited(subclass)
39
+ super
40
+
41
+ return self
42
+ end
43
+
44
+ ##
45
+ ## Loads a file.
46
+ ##
47
+ ## @param filePath The file path
48
+ ## @param debugInfo The debug information
49
+ ##
50
+ ## @return Itself
51
+ ##
52
+ def loadFile(filePath, debugInfo)
53
+ begin
54
+ require filePath
55
+ rescue LoadError
56
+
57
+ if Core::DEBUG
58
+ puts debugInfo + ": " + File.basename(filePath) + " not found in " + Core::ROOT + debugInfo.downcase
59
+ end
60
+
61
+ exit(1)
62
+ end
63
+
64
+ return self
65
+ end
66
+
67
+ ##
68
+ ## Render view called by controller
69
+ ##
70
+ ## @param name The view to render
71
+ ##
72
+ def render(name, **args)
73
+
74
+ if Core::DEBUG
75
+ puts "Loading view..."
76
+ end
77
+
78
+ name = Core::VIEW + name
79
+
80
+ filePath = Core::viewPath(name)
81
+
82
+ self.loadFile(filePath, "View")
83
+
84
+ ## Will retrieve class constant name for dynamic instanciation
85
+ viewName = Object.const_get(name)
86
+
87
+ view = viewName.new()
88
+
89
+ ## Force children controller and view
90
+ ## to run parent initialize if overriden.
91
+ Core::forceParentInit(self)
92
+ Core::forceParentInit(view)
93
+
94
+ ## Set values sent from previous view in
95
+ ## content of current view.
96
+ args.each{
97
+ |key, value|
98
+ @content[key.to_s] = value
99
+ }
100
+
101
+ self.setProperties(view)
102
+
103
+ ## Collect content from controller and send it to view
104
+ view.controller = self
105
+ view.controller.run()
106
+ view.content = @content.clone()
107
+
108
+ ## Refer controller methods in view for easier
109
+ ## call.
110
+ self.class.instance_methods(false).each() do |method|
111
+ if !view.class.method_defined?(method)
112
+ view.define_singleton_method(method) do |*arguments|
113
+ self.controller.send(method, *arguments)
114
+ end
115
+ end
116
+ end
117
+
118
+ ## Will render view with content retrieved in controller
119
+ view.setInstanceVars()
120
+ view.run()
121
+
122
+ Fenetre::css(:priorite => "PRIORITY_APPLICATION")
123
+
124
+ ## Display content builded in view with Gtk
125
+ view.window.show_all
126
+ end
127
+
128
+ ##
129
+ ## Sets the properties of window
130
+ ##
131
+ def setProperties(view)
132
+ ## Set window properties
133
+
134
+ view.headerBar.title = @title
135
+ view.window.set_titlebar (view.headerBar)
136
+ view.window.set_size_request(@width, @height)
137
+ view.window.border_width = @borderWidth
138
+ view.window.set_resizable(@resizable)
139
+ view.window.set_window_position(Object.const_get("Gtk::WindowPosition::" + @position))
140
+
141
+ end
142
+
143
+ ##
144
+ ## Loads a model.
145
+ ##
146
+ ## @param name The model to load
147
+ ##
148
+ ## @return Model instance
149
+ ##
150
+ def loadModel(name)
151
+
152
+ filePath = Core::modelPath(name)
153
+
154
+ self.loadFile(filePath, "Model")
155
+
156
+ ## Will retrieve class constant name for dynamic instanciation
157
+ modelName = Object.const_get(name)
158
+
159
+ ## Make an only one instance of model (Singleton pattern)
160
+ ## to ensure date integrity.
161
+ model = modelName.instance()
162
+
163
+ self.instance_variable_set("@" + name, model)
164
+
165
+ return model
166
+
167
+ end
168
+
169
+ ## Invoke all method in controller for collecting contents to send on view.
170
+ ##
171
+ ## @return itself
172
+ ##
173
+ def run()
174
+ if Core::DEBUG
175
+ raise "Controller #{self.class.name} can't collect content because run method is not redefined."
176
+ end
177
+ return self
178
+ end
179
+
180
+ end