Class: Cliptic::Main::Player::Game
- Inherits:
-
Object
- Object
- Cliptic::Main::Player::Game
- Defined in:
- lib/cliptic/main.rb
Constant Summary
Constants included from Database
Database::Dir_Path, Database::File_Path
Instance Attribute Summary collapse
-
#board ⇒ Object
readonly
Returns the value of attribute board.
-
#bot_b ⇒ Object
readonly
Returns the value of attribute bot_b.
-
#continue ⇒ Object
Returns the value of attribute continue.
-
#ctrls ⇒ Object
readonly
Returns the value of attribute ctrls.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#mode ⇒ Object
Returns the value of attribute mode.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
-
#timer ⇒ Object
readonly
Returns the value of attribute timer.
-
#top_b ⇒ Object
readonly
Returns the value of attribute top_b.
-
#unsaved ⇒ Object
Returns the value of attribute unsaved.
Instance Method Summary collapse
- #exit ⇒ Object
- #game_over ⇒ Object
-
#initialize(date: Date.today) ⇒ Game
constructor
A new instance of Game.
- #pause ⇒ Object
- #play ⇒ Object
- #redraw ⇒ Object
- #reset ⇒ Object
- #reset_menu ⇒ Object
- #reveal ⇒ Object
- #save ⇒ Object
- #unpause ⇒ Object
- #user_input ⇒ Object
Constructor Details
#initialize(date: Date.today) ⇒ Game
Returns a new instance of Game.
609 610 611 612 613 614 615 616 617 618 |
# File 'lib/cliptic/main.rb', line 609 def initialize(date:Date.today) @date = date init_windows @timer = Timer.new(time:state.time, bar:top_b, callback:->{board.update}) @ctrls = Controller.new(game:self) @unsaved = false @continue = true draw end |
Instance Attribute Details
#board ⇒ Object (readonly)
Returns the value of attribute board.
606 607 608 |
# File 'lib/cliptic/main.rb', line 606 def board @board end |
#bot_b ⇒ Object (readonly)
Returns the value of attribute bot_b.
606 607 608 |
# File 'lib/cliptic/main.rb', line 606 def bot_b @bot_b end |
#continue ⇒ Object
Returns the value of attribute continue.
608 609 610 |
# File 'lib/cliptic/main.rb', line 608 def continue @continue end |
#ctrls ⇒ Object (readonly)
Returns the value of attribute ctrls.
606 607 608 |
# File 'lib/cliptic/main.rb', line 606 def ctrls @ctrls end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
606 607 608 |
# File 'lib/cliptic/main.rb', line 606 def date @date end |
#mode ⇒ Object
Returns the value of attribute mode.
608 609 610 |
# File 'lib/cliptic/main.rb', line 608 def mode @mode end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
606 607 608 |
# File 'lib/cliptic/main.rb', line 606 def state @state end |
#timer ⇒ Object (readonly)
Returns the value of attribute timer.
606 607 608 |
# File 'lib/cliptic/main.rb', line 606 def timer @timer end |
#top_b ⇒ Object (readonly)
Returns the value of attribute top_b.
606 607 608 |
# File 'lib/cliptic/main.rb', line 606 def top_b @top_b end |
#unsaved ⇒ Object
Returns the value of attribute unsaved.
608 609 610 |
# File 'lib/cliptic/main.rb', line 608 def unsaved @unsaved end |
Instance Method Details
#exit ⇒ Object
675 676 677 678 |
# File 'lib/cliptic/main.rb', line 675 def exit @continue = false Screen.clear end |
#game_over ⇒ Object
670 671 672 673 674 |
# File 'lib/cliptic/main.rb', line 670 def game_over save if $config[:auto_save] timer.stop completed if board.puzzle.complete? end |
#pause ⇒ Object
644 645 646 647 |
# File 'lib/cliptic/main.rb', line 644 def pause timer.stop Menus::Pause.new(game:self).choose_opt end |
#play ⇒ Object
619 620 621 622 623 624 625 626 |
# File 'lib/cliptic/main.rb', line 619 def play if state.done else add_to_recents game_and_timer_threads.map(&:join) end end |
#redraw ⇒ Object
627 628 629 630 631 632 |
# File 'lib/cliptic/main.rb', line 627 def redraw save Screen.clear init_windows draw end |
#reset ⇒ Object
661 662 663 664 665 |
# File 'lib/cliptic/main.rb', line 661 def reset state.delete if state.exists? board.clear_all_cells timer.reset end |
#reset_menu ⇒ Object
657 658 659 660 |
# File 'lib/cliptic/main.rb', line 657 def timer.stop Reset_Progress.new(game:self) end |
#reveal ⇒ Object
666 667 668 669 |
# File 'lib/cliptic/main.rb', line 666 def reveal state.reveals+= 1 board.reveal_clue end |
#save ⇒ Object
652 653 654 655 656 |
# File 'lib/cliptic/main.rb', line 652 def save state.save(game:self) bot_b.time_str(t:5, x:10, str:"Saved!") self.unsaved = false end |
#unpause ⇒ Object
648 649 650 651 |
# File 'lib/cliptic/main.rb', line 648 def unpause timer.start board.redraw end |
#user_input ⇒ Object
641 642 643 |
# File 'lib/cliptic/main.rb', line 641 def user_input board.grid.getch end |