Module: GamesAndRpgParadise::GUI::Gtk::Mastermind::MastermindModule
- Includes:
- Gtk::BaseModule
- Included in:
- Mastermind
- Defined in:
- lib/games_and_rpg_paradise/games/mastermind/shared_code/mastermind_module.rb
Constant Summary collapse
- NAMESPACE =
#
NAMESPACE
#
inspect
- WIDTH =
#
WIDTH
#
22
- HEIGHT =
#
HEIGHT
#
22
- VERIFY_TEXT =
#
VERIFY_TEXT
#
'_Verify'
- MAX_N_ROWS =
#
MAX_N_ROWS
#
10
Instance Attribute Summary collapse
-
#array_circles ⇒ Object
Returns the value of attribute array_circles.
Class Method Summary collapse
-
.run(i = ARGV) ⇒ Object
# === GamesAndRpgParadise::GUI::Gtk::Mastermind::MastermindModule.run ========================================================================= #.
Instance Method Summary collapse
-
#array_solution? ⇒ Boolean
(also: #array_solution)
# === array_solution? ========================================================================= #.
-
#check_game_status ⇒ Object
# === check_game_status.
-
#compare_with_solution ⇒ Object
# === compare_with_solution.
-
#connect_skeleton ⇒ Object
# === connect_skeleton ========================================================================= #.
-
#create_boxes ⇒ Object
# === create_boxes.
-
#create_buttons ⇒ Object
# === create_buttons (buttons tag) ========================================================================= #.
-
#create_main_table ⇒ Object
# === create_main_table ========================================================================= #.
-
#create_skeleton ⇒ Object
# === create_skeleton ========================================================================= #.
-
#create_the_hbox_with_the_solution ⇒ Object
# === create_the_hbox_with_the_solution ========================================================================= #.
-
#disable_verify_button ⇒ Object
# === disable_verify_button.
-
#hide_all_small_images_and_reset_weight ⇒ Object
# === hide_all_small_images_and_reset_weight ========================================================================= #.
-
#initialize(run_already = true) ⇒ Object
# === initialize ========================================================================= #.
-
#initialize_variables ⇒ Object
# === initialize_variables.
-
#invoke_random_pattern ⇒ Object
# === invoke_random_pattern.
-
#lose_game ⇒ Object
# === lose_game.
-
#padding? ⇒ Boolean
# === padding? ========================================================================= #.
-
#properly_reveal_the_first_image ⇒ Object
# === properly_reveal_the_first_image ========================================================================= #.
-
#reset ⇒ Object
# === reset ========================================================================= #.
-
#restart_the_game ⇒ Object
# === restart_the_game.
-
#reveal_game ⇒ Object
# === reveal_game ========================================================================= #.
-
#run ⇒ Object
# === run ========================================================================= #.
-
#show_the_solution(shall_we_disable_verify_button = true) ⇒ Object
# === show_the_solution.
-
#verify_what_the_player_did ⇒ Object
# === verify_what_the_player_did.
Instance Attribute Details
#array_circles ⇒ Object
Returns the value of attribute array_circles.
60 61 62 |
# File 'lib/games_and_rpg_paradise/games/mastermind/shared_code/mastermind_module.rb', line 60 def array_circles @array_circles end |
Class Method Details
.run(i = ARGV) ⇒ Object
#
GamesAndRpgParadise::GUI::Gtk::Mastermind::MastermindModule.run
#
549 550 551 552 553 554 555 556 557 |
# File 'lib/games_and_rpg_paradise/games/mastermind/shared_code/mastermind_module.rb', line 549 def self.run(i = ARGV) require 'gtk_paradise/run' _ = ::GamesAndRpgParadise::GUI::Gtk::Mastermind::Mastermind.new(i) r = ::Gtk.run r << _ r.set_size_request(_.width?, _.height?) r. r.top_left_then_run end |
Instance Method Details
#array_solution? ⇒ Boolean Also known as: array_solution
#
array_solution?
#
139 140 141 |
# File 'lib/games_and_rpg_paradise/games/mastermind/shared_code/mastermind_module.rb', line 139 def array_solution? @array_solution end |
#check_game_status ⇒ Object
#
check_game_status
Does the main part of the game logic.
#
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
# File 'lib/games_and_rpg_paradise/games/mastermind/shared_code/mastermind_module.rb', line 235 def check_game_status unless @game_over # If you won the game then we will disable the row case @players_last_choice when @array_solution e sfancy('This game has been won!') @button_verify.label = 'Won!' @array_circles[0+(4 * (@active_row-1))].set_sensitive(false) @array_circles[1+(4 * (@active_row-1))].set_sensitive(false) @array_circles[2+(4 * (@active_row-1))].set_sensitive(false) @array_circles[3+(4 * (@active_row-1))].set_sensitive(false) @array_black_white_box[@active_row-1].set_boxes(@n_black_dots,@n_white_dots) # else we will set the new row true, and the old one false. else @array_circles[0+(4 * (@active_row-1))].set_sensitive(false) @array_circles[1+(4 * (@active_row-1))].set_sensitive(false) @array_circles[2+(4 * (@active_row-1))].set_sensitive(false) @array_circles[3+(4 * (@active_row-1))].set_sensitive(false) @array_black_white_box[@active_row-1].set_boxes(@n_black_dots,@n_white_dots) # Only if the counter is smaller or queal to MAX_N_ROWS # will we continue if @active_row < MAX_N_ROWS @active_row += 1 max_number = 3+(4 * (@active_row-1)) if max_number >= (MAX_N_ROWS*4) lose_game else @array_icon_and_label[@active_row-2].hide_img # zeig das an @array_icon_and_label[@active_row-2].change_markup_to(:normal) @array_icon_and_label[@active_row-1].reveal_img # zeig das an @array_icon_and_label[@active_row-1].change_markup_to(:bold) @array_circles[0+(4 * (@active_row-1))].set_sensitive(true) @array_circles[1+(4 * (@active_row-1))].set_sensitive(true) @array_circles[2+(4 * (@active_row-1))].set_sensitive(true) @array_circles[3+(4 * (@active_row-1))].set_sensitive(true) end end end end end |
#compare_with_solution ⇒ Object
#
compare_with_solution
Simply compares @players_last_choice with our solution.
#
217 218 219 220 221 222 223 224 225 226 227 228 |
# File 'lib/games_and_rpg_paradise/games/mastermind/shared_code/mastermind_module.rb', line 217 def compare_with_solution @n_black_dots = 0 @n_white_dots = 0 @n_black_dots += 1 if @players_last_choice[0] == @array_solution[0] @n_black_dots += 1 if @players_last_choice[1] == @array_solution[1] @n_black_dots += 1 if @players_last_choice[2] == @array_solution[2] @n_black_dots += 1 if @players_last_choice[3] == @array_solution[3] @players_last_choice.each { |choice| @n_white_dots += 1 if @array_solution.include?(choice) } @n_white_dots -= @n_black_dots if @n_black_dots > 0 end |
#connect_skeleton ⇒ Object
#
connect_skeleton
#
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 |
# File 'lib/games_and_rpg_paradise/games/mastermind/shared_code/mastermind_module.rb', line 402 def connect_skeleton vbox = gtk_vbox vbox.maximal(@main_table, 1) vbox.modify_background(:normal, :beige) vbox.show # ======================================================================= # # Die mittlere vbox # ======================================================================= # vbox2 = create_vbox vbox2 << @button_restart vbox2 << @button_reveal vbox2 << @vbox_label_showing_solution vbox2 << @hbox_with_the_solution vbox2 << @button_verify vbox2.show maximal(vbox,2) _ = create_vseparator _.show minimal(_,1) maximal(vbox2, 2) show @hbox_with_the_solution.hide end |
#create_boxes ⇒ Object
#
create_boxes
#
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/games_and_rpg_paradise/games/mastermind/shared_code/mastermind_module.rb', line 110 def create_boxes @vbox_label_showing_solution = create_vbox @label_showing_solution = gtk_label('') @label_showing_solution.show @vbox_label_showing_solution.maximal(@label_showing_solution, 0) @array_for_box_with_images_showing_solution << Circle.new(@array_solution[0]) @array_for_box_with_images_showing_solution << Circle.new(@array_solution[1]) @array_for_box_with_images_showing_solution << Circle.new(@array_solution[2]) @array_for_box_with_images_showing_solution << Circle.new(@array_solution[3]) @vbox_label_showing_solution.show_all end |
#create_buttons ⇒ Object
#
create_buttons (buttons tag)
#
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
# File 'lib/games_and_rpg_paradise/games/mastermind/shared_code/mastermind_module.rb', line 172 def @button_restart = ('_Restart') @button_restart.bblack2 @button_restart.make_bold @button_restart.on_clicked { restart_the_game } @button_restart.relief_none @button_restart.show @button_reveal = ('_Reveal') @button_reveal.bblack2 @button_reveal.make_bold @button_reveal.on_clicked { reveal_game } @button_reveal.relief_none @button_reveal.show # Create the verify-button next. @button_verify = (VERIFY_TEXT) @button_verify.bblack2 @button_verify.on_clicked { verify_what_the_player_did check_game_status } @button_verify.relief_none @button_verify.show end |
#create_main_table ⇒ Object
#
create_main_table
#
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 |
# File 'lib/games_and_rpg_paradise/games/mastermind/shared_code/mastermind_module.rb', line 279 def create_main_table @main_table = gtk_table(6, MAX_N_ROWS, true) @main_table.modify_background( :normal, :mediumaquamarine ) @main_table.set_column_spacings(2) @main_table.set_row_spacings(1) @main_table.set_border_width(2) cntr = 1 @main_table.attach_defaults(@array_icon_and_label[9] = IconAndLabel.new('10'),0,1, cntr-1, cntr) @main_table.attach_defaults(@array_circles[36] = Circle.new('',self),1,2, cntr-1, cntr) @main_table.attach_defaults(@array_circles[37] = Circle.new('',self),2,3, cntr-1, cntr) @main_table.attach_defaults(@array_circles[38] = Circle.new('',self),3,4, cntr-1, cntr) @main_table.attach_defaults(@array_circles[39] = Circle.new('',self),4,5, cntr-1, cntr) @main_table.attach_defaults(@array_black_white_box[9] = BlackWhiteBox.new(),5,6, cntr-1, cntr) cntr += 1 @main_table.attach_defaults(@array_icon_and_label[8] = IconAndLabel.new('9'),0,1, cntr-1, cntr) @main_table.attach_defaults(@array_circles[32] = Circle.new('',self),1,2, cntr-1, cntr) @main_table.attach_defaults(@array_circles[33] = Circle.new('',self),2,3, cntr-1, cntr) @main_table.attach_defaults(@array_circles[34] = Circle.new('',self),3,4, cntr-1, cntr) @main_table.attach_defaults(@array_circles[35] = Circle.new('',self),4,5, cntr-1, cntr) @main_table.attach_defaults(@array_black_white_box[8] = BlackWhiteBox.new(),5,6, cntr-1, cntr) cntr += 1 @main_table.attach_defaults(@array_icon_and_label[7] = IconAndLabel.new('8'),0,1, cntr-1, cntr) @main_table.attach_defaults(@array_circles[28] = Circle.new('',self),1,2, cntr-1, cntr) @main_table.attach_defaults(@array_circles[29] = Circle.new('',self),2,3, cntr-1, cntr) @main_table.attach_defaults(@array_circles[30] = Circle.new('',self),3,4, cntr-1, cntr) @main_table.attach_defaults(@array_circles[31] = Circle.new('',self),4,5, cntr-1, cntr) @main_table.attach_defaults(@array_black_white_box[7] = BlackWhiteBox.new(),5,6, cntr-1, cntr) cntr += 1 @main_table.attach_defaults(@array_icon_and_label[6] = IconAndLabel.new('7'),0,1, cntr-1, cntr) @main_table.attach_defaults(@array_circles[24] = Circle.new('',self),1,2, cntr-1, cntr) @main_table.attach_defaults(@array_circles[25] = Circle.new('',self),2,3, cntr-1, cntr) @main_table.attach_defaults(@array_circles[26] = Circle.new('',self),3,4, cntr-1, cntr) @main_table.attach_defaults(@array_circles[27] = Circle.new('',self),4,5, cntr-1, cntr) @main_table.attach_defaults(@array_black_white_box[6] = BlackWhiteBox.new(),5,6, cntr-1, cntr) cntr += 1 @main_table.attach_defaults(@array_icon_and_label[5] =IconAndLabel.new('6'),0,1, cntr-1, cntr) @main_table.attach_defaults(@array_circles[20] = Circle.new('',self),1,2, cntr-1, cntr) @main_table.attach_defaults(@array_circles[21] = Circle.new('',self),2,3, cntr-1, cntr) @main_table.attach_defaults(@array_circles[22] = Circle.new('',self),3,4, cntr-1, cntr) @main_table.attach_defaults(@array_circles[23] = Circle.new('',self),4,5, cntr-1, cntr) @main_table.attach_defaults(@array_black_white_box[5] = BlackWhiteBox.new(),5,6, cntr-1, cntr) cntr += 1 @main_table.attach_defaults(@array_icon_and_label[4] = IconAndLabel.new('5'),0,1, cntr-1, cntr) @main_table.attach_defaults(@array_circles[16] = Circle.new('',self),1,2, cntr-1, cntr) @main_table.attach_defaults(@array_circles[17] = Circle.new('',self),2,3, cntr-1, cntr) @main_table.attach_defaults(@array_circles[18] = Circle.new('',self),3,4, cntr-1, cntr) @main_table.attach_defaults(@array_circles[19] = Circle.new('',self),4,5, cntr-1, cntr) @main_table.attach_defaults(@array_black_white_box[4] = BlackWhiteBox.new(),5,6, cntr-1, cntr) cntr += 1 @main_table.attach_defaults(@array_icon_and_label[3] = IconAndLabel.new('4'),0,1, cntr-1, cntr) @main_table.attach_defaults(@array_circles[12] = Circle.new('',self),1,2, cntr-1, cntr) @main_table.attach_defaults(@array_circles[13] = Circle.new('',self),2,3, cntr-1, cntr) @main_table.attach_defaults(@array_circles[14] = Circle.new('',self),3,4, cntr-1, cntr) @main_table.attach_defaults(@array_circles[15] = Circle.new('',self),4,5, cntr-1, cntr) @main_table.attach_defaults(@array_black_white_box[3] = BlackWhiteBox.new(),5,6, cntr-1, cntr) cntr += 1 @main_table.attach_defaults(@array_icon_and_label[2] = IconAndLabel.new('3'),0,1, cntr-1, cntr) @main_table.attach_defaults(@array_circles[8] = Circle.new('',self),1,2, cntr-1, cntr) @main_table.attach_defaults(@array_circles[9] = Circle.new('',self),2,3, cntr-1, cntr) @main_table.attach_defaults(@array_circles[10] = Circle.new('',self),3,4, cntr-1, cntr) @main_table.attach_defaults(@array_circles[11] = Circle.new('',self),4,5, cntr-1, cntr) @main_table.attach_defaults(@array_black_white_box[2] = BlackWhiteBox.new(),5,6, cntr-1, cntr) cntr += 1 @main_table.attach_defaults(@array_icon_and_label[1] = IconAndLabel.new('2'),0,1, cntr-1, cntr) @main_table.attach_defaults(@array_circles[4] = Circle.new('',self),1,2, cntr-1, cntr) @main_table.attach_defaults(@array_circles[5] = Circle.new('',self),2,3, cntr-1, cntr) @main_table.attach_defaults(@array_circles[6] = Circle.new('',self),3,4, cntr-1, cntr) @main_table.attach_defaults(@array_circles[7] = Circle.new('',self),4,5, cntr-1, cntr) @main_table.attach_defaults(@array_black_white_box[1] = BlackWhiteBox.new(),5,6, cntr-1, cntr) cntr += 1 @main_table.attach_defaults(@array_icon_and_label[0] = IconAndLabel.new('1'),0,1, cntr-1, cntr) @main_table.attach_defaults(@array_circles[0] = Circle.new('',self,true),1,2, cntr-1, cntr) @main_table.attach_defaults(@array_circles[1] = Circle.new('',self,true),2,3, cntr-1, cntr) @main_table.attach_defaults(@array_circles[2] = Circle.new('',self,true),3,4, cntr-1, cntr) @main_table.attach_defaults(@array_circles[3] = Circle.new('',self,true),4,5, cntr-1, cntr) @main_table.attach_defaults(@array_black_white_box[0] = BlackWhiteBox.new(),5,6, cntr-1, cntr) @main_table.show_all hide_all_small_images_and_reset_weight end |
#create_skeleton ⇒ Object
#
create_skeleton
#
376 377 378 379 380 381 |
# File 'lib/games_and_rpg_paradise/games/mastermind/shared_code/mastermind_module.rb', line 376 def create_skeleton create_boxes # creates all boxes create_main_table create_the_hbox_with_the_solution end |
#create_the_hbox_with_the_solution ⇒ Object
#
create_the_hbox_with_the_solution
#
386 387 388 389 390 391 392 393 394 395 396 397 |
# File 'lib/games_and_rpg_paradise/games/mastermind/shared_code/mastermind_module.rb', line 386 def create_the_hbox_with_the_solution @hbox_with_the_solution = create_hbox @circle1 = Circle.new(@array_solution[0]) @circle2 = Circle.new(@array_solution[1]) @circle3 = Circle.new(@array_solution[2]) @circle4 = Circle.new(@array_solution[3]) @hbox_with_the_solution << @circle1 @hbox_with_the_solution << @circle2 @hbox_with_the_solution << @circle3 @hbox_with_the_solution << @circle4 @hbox_with_the_solution.hide end |
#disable_verify_button ⇒ Object
#
disable_verify_button
This method disables our verify button.
#
148 149 150 |
# File 'lib/games_and_rpg_paradise/games/mastermind/shared_code/mastermind_module.rb', line 148 def @button_verify.set_sensitive(false) end |
#hide_all_small_images_and_reset_weight ⇒ Object
#
hide_all_small_images_and_reset_weight
#
162 163 164 165 166 167 |
# File 'lib/games_and_rpg_paradise/games/mastermind/shared_code/mastermind_module.rb', line 162 def hide_all_small_images_and_reset_weight @array_icon_and_label.each { |entry| entry.hide_img entry.change_markup_to(:normal) } end |
#initialize(run_already = true) ⇒ Object
#
initialize
#
65 66 67 68 69 70 71 |
# File 'lib/games_and_rpg_paradise/games/mastermind/shared_code/mastermind_module.rb', line 65 def initialize( run_already = true ) super(:horizontal) reset run if run_already end |
#initialize_variables ⇒ Object
#
initialize_variables
Init our vars.
#
92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/games_and_rpg_paradise/games/mastermind/shared_code/mastermind_module.rb', line 92 def initialize_variables @active_row = 1 # die erste reihe, default. @n_black_dots = 0 # rechts - wie viele schwarze @n_white_dots = 0 # rechts - wie viele weisse @array_solution = [] # has our solution @array_circles = [] # stores the little circles :> @array_icon_and_label = [] @array_black_white_box = [] @game_over = false @players_last_choice = [] # stores players last choice @array_for_box_with_images_showing_solution = [] end |
#invoke_random_pattern ⇒ Object
#
invoke_random_pattern
Will fill up our @array_solution.
#
131 132 133 134 |
# File 'lib/games_and_rpg_paradise/games/mastermind/shared_code/mastermind_module.rb', line 131 def invoke_random_pattern @array_solution = [] # set new Array 4.times { @array_solution << ARRAY_COLOURS.sample } end |
#lose_game ⇒ Object
#
lose_game
Set stuff when you lose the game.
#
207 208 209 210 |
# File 'lib/games_and_rpg_paradise/games/mastermind/shared_code/mastermind_module.rb', line 207 def lose_game @button_verify.label = 'Lost the game!' @game_over = true end |
#padding? ⇒ Boolean
#
padding?
#
155 156 157 |
# File 'lib/games_and_rpg_paradise/games/mastermind/shared_code/mastermind_module.rb', line 155 def padding? 12 end |
#properly_reveal_the_first_image ⇒ Object
#
properly_reveal_the_first_image
#
446 447 448 449 450 |
# File 'lib/games_and_rpg_paradise/games/mastermind/shared_code/mastermind_module.rb', line 446 def properly_reveal_the_first_image # now, reveal the first image @array_icon_and_label[0].reveal_img @array_icon_and_label[0].change_markup_to(:bold) end |
#reset ⇒ Object
#
reset
#
76 77 78 79 80 81 82 83 84 85 |
# File 'lib/games_and_rpg_paradise/games/mastermind/shared_code/mastermind_module.rb', line 76 def reset reset_the_internal_variables # ======================================================================= # # === @configuration # ======================================================================= # @configuration = [true, __dir__, NAMESPACE] title_width_height('Mastermind', WIDTH, HEIGHT) initialize_variables use_gtk_paradise_project_css_file end |
#restart_the_game ⇒ Object
#
restart_the_game
This method does all the necessary stuff to allow a new game again.
#
504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 |
# File 'lib/games_and_rpg_paradise/games/mastermind/shared_code/mastermind_module.rb', line 504 def restart_the_game invoke_random_pattern @label_showing_solution.set_text('') # empty label @active_row = 1 # start at 1 row again. @button_verify.bblack1 @button_verify.label = VERIFY_TEXT @button_verify.make_bold @button_verify.fancy_tooltips = 'By clicking on this button you can check whether your '\ 'guessed colours on the left-hand side are correct. A '\ 'white dot means that the colour is there, but not at '\ 'the correct position. A black dot means that the colour '\ 'is there and the dot is at the correct position as well.' # ======================================================================= # # Finally iterate over the circles. # ======================================================================= # @array_circles.each { |circle| circle.set_sensitive(false) circle.set_blank } @array_black_white_box.each { |box| box.set_boxes(0,0) } @array_circles[0].is_sensitive @array_circles[1].is_sensitive @array_circles[2].is_sensitive @array_circles[3].is_sensitive hide_all_small_images_and_reset_weight @array_for_box_with_images_showing_solution.each { |circle| circle.set_blank } @array_icon_and_label[0].reveal_img # zeig das an @array_icon_and_label[0].change_markup_to(:bold) # ======================================================================= # # Add the verify-button next. # ======================================================================= # @button_verify.set_sensitive(true) # react again @hbox_with_the_solution.hide @game_over = false # last but not least, the most important thing :> end |
#reveal_game ⇒ Object
#
reveal_game
#
455 456 457 |
# File 'lib/games_and_rpg_paradise/games/mastermind/shared_code/mastermind_module.rb', line 455 def reveal_game show_the_solution(false) end |
#run ⇒ Object
#
run
#
562 563 564 565 566 567 568 569 570 |
# File 'lib/games_and_rpg_paradise/games/mastermind/shared_code/mastermind_module.rb', line 562 def run invoke_random_pattern # ======================================================================= # # Now we will turn to the creation-part, then the connection-part. # ======================================================================= # create_skeleton_then_connect_skeleton properly_reveal_the_first_image restart_the_game end |
#show_the_solution(shall_we_disable_verify_button = true) ⇒ Object
#
show_the_solution
When will we call this solution thing? If we reached the last row.
#
465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 |
# File 'lib/games_and_rpg_paradise/games/mastermind/shared_code/mastermind_module.rb', line 465 def show_the_solution( = true ) # ======================================================================= # # We could use a smaller font as well. # @label_showing_solution.set_font(:hack_18) # ======================================================================= # @label_showing_solution.set_text( @array_solution[0].capitalize+', '+"\n"+ @array_solution[1].capitalize+', '+"\n"+ @array_solution[2].capitalize+', '+"\n"+ @array_solution[3].capitalize ) @circle1.use_this_colour = @array_solution[0] @circle2.use_this_colour = @array_solution[1] @circle3.use_this_colour = @array_solution[2] @circle4.use_this_colour = @array_solution[3] @hbox_with_the_solution.show_all #@array_for_box_with_images_showing_solution.each { |img| # img.attach_image #} # @box_for_images_showing_solution.show_all # @box_for_images_showing_solution = gtk_hbox # carries images # @box_for_images_showing_solution.set_size_request(50, 50) # # @array_for_box_with_images_showing_solution.each { |circle| # @box_for_images_showing_solution.minimal(circle) # } # @vbox_label_showing_solution.maximal(@box_for_images_showing_solution, 0) if end |
#verify_what_the_player_did ⇒ Object
#
verify_what_the_player_did
Fills up our array.
#
431 432 433 434 435 436 437 438 439 440 441 |
# File 'lib/games_and_rpg_paradise/games/mastermind/shared_code/mastermind_module.rb', line 431 def verify_what_the_player_did unless @game_over == true @players_last_choice = [] @players_last_choice << @array_circles[0+(4 * (@active_row-1))].colour? # 0 4 8 @players_last_choice << @array_circles[1+(4 * (@active_row-1))].colour? # 1 5 9 @players_last_choice << @array_circles[2+(4 * (@active_row-1))].colour? # 2 6 10 @players_last_choice << @array_circles[3+(4 * (@active_row-1))].colour? # 3 7 11 15 19 23 27 31 35 39 compare_with_solution end show_the_solution if @active_row == MAX_N_ROWS end |