Sith-Lord_Jedi_Ewok 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a0d7f680a56b27989cd623343ab8d32695bd6177e33acbe1b6dec73c26707da0
4
+ data.tar.gz: d4ec4d728647ec875bcd33b7b9596eaabc99699f98e1a43ccd417050b9d0ea52
5
+ SHA512:
6
+ metadata.gz: b8ca3054651584f6260ffa9cedada19ba0197a4b01d5b89d133f9ed02891975b94c50181b52a02e614ba3e19b4dbd7eff35b306a94a973f693fd9a47d2613787
7
+ data.tar.gz: 9da437ae9f6337618fa6b10a665080afd90354226bf8c6e70446531c854bf8236d4f4e049b7d7da4a30a05f01e8660f8ea6201c44511fb17bc4f5ede877e2186
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in sith_jedi_ewok.gemspec
6
+ gemspec
7
+
8
+ # gem "rake", "~> 12.0"
9
+ # gem "rspec", "~> 3.9"
10
+ # gem "tty-table"
11
+ # gem "tty-prompt"
12
+ # gem 'colorize', '~> 0.8.1'
13
+ # gem 'artii', '~> 2.1', '>= 2.1.2'
14
+ # gem 'ruby2d', '~> 0.9.2'
@@ -0,0 +1,66 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ Sith-Lord_Jedi_Ewok (0.1.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ artii (2.1.2)
10
+ colorize (0.8.1)
11
+ diff-lcs (1.4.4)
12
+ pastel (0.8.0)
13
+ tty-color (~> 0.5)
14
+ rake (12.3.3)
15
+ rspec (3.9.0)
16
+ rspec-core (~> 3.9.0)
17
+ rspec-expectations (~> 3.9.0)
18
+ rspec-mocks (~> 3.9.0)
19
+ rspec-core (3.9.3)
20
+ rspec-support (~> 3.9.3)
21
+ rspec-expectations (3.9.2)
22
+ diff-lcs (>= 1.2.0, < 2.0)
23
+ rspec-support (~> 3.9.0)
24
+ rspec-mocks (3.9.1)
25
+ diff-lcs (>= 1.2.0, < 2.0)
26
+ rspec-support (~> 3.9.0)
27
+ rspec-support (3.9.3)
28
+ ruby2d (0.9.4)
29
+ strings (0.2.0)
30
+ strings-ansi (~> 0.2)
31
+ unicode-display_width (~> 1.5)
32
+ unicode_utils (~> 1.4)
33
+ strings-ansi (0.2.0)
34
+ tty-color (0.5.2)
35
+ tty-cursor (0.7.1)
36
+ tty-prompt (0.22.0)
37
+ pastel (~> 0.8)
38
+ tty-reader (~> 0.8)
39
+ tty-reader (0.8.0)
40
+ tty-cursor (~> 0.7)
41
+ tty-screen (~> 0.8)
42
+ wisper (~> 2.0)
43
+ tty-screen (0.8.1)
44
+ tty-table (0.12.0)
45
+ pastel (~> 0.8)
46
+ strings (~> 0.2.0)
47
+ tty-screen (~> 0.8)
48
+ unicode-display_width (1.7.0)
49
+ unicode_utils (1.4.0)
50
+ wisper (2.0.1)
51
+
52
+ PLATFORMS
53
+ ruby
54
+
55
+ DEPENDENCIES
56
+ Sith-Lord_Jedi_Ewok!
57
+ artii (~> 2.1, >= 2.1.2)
58
+ colorize (~> 0.8.1)
59
+ rake (~> 12.0)
60
+ rspec (~> 3.9)
61
+ ruby2d (~> 0.9.2)
62
+ tty-prompt (~> 0.22.0)
63
+ tty-table (~> 0.12.0)
64
+
65
+ BUNDLED WITH
66
+ 2.1.4
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 waldowred5
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,40 @@
1
+ # Sith-Lord, Jedi, Ewok
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/sith_jedi_ewok`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'sith_jedi_ewok'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install sith_jedi_ewok
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/sith_jedi_ewok.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rake' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rake", "rake")
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), *%w[.. .. lib])
3
+
4
+ require "bundler/setup"
5
+ require "sith_jedi_ewok"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
@@ -0,0 +1 @@
1
+ --format doc
@@ -0,0 +1,58 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ artii (2.1.2)
5
+ colorize (0.8.1)
6
+ diff-lcs (1.4.4)
7
+ pastel (0.8.0)
8
+ tty-color (~> 0.5)
9
+ rspec (3.9.0)
10
+ rspec-core (~> 3.9.0)
11
+ rspec-expectations (~> 3.9.0)
12
+ rspec-mocks (~> 3.9.0)
13
+ rspec-core (3.9.2)
14
+ rspec-support (~> 3.9.3)
15
+ rspec-expectations (3.9.2)
16
+ diff-lcs (>= 1.2.0, < 2.0)
17
+ rspec-support (~> 3.9.0)
18
+ rspec-mocks (3.9.1)
19
+ diff-lcs (>= 1.2.0, < 2.0)
20
+ rspec-support (~> 3.9.0)
21
+ rspec-support (3.9.3)
22
+ ruby2d (0.9.4)
23
+ strings (0.2.0)
24
+ strings-ansi (~> 0.2)
25
+ unicode-display_width (~> 1.5)
26
+ unicode_utils (~> 1.4)
27
+ strings-ansi (0.2.0)
28
+ tty-color (0.5.2)
29
+ tty-cursor (0.7.1)
30
+ tty-prompt (0.22.0)
31
+ pastel (~> 0.8)
32
+ tty-reader (~> 0.8)
33
+ tty-reader (0.8.0)
34
+ tty-cursor (~> 0.7)
35
+ tty-screen (~> 0.8)
36
+ wisper (~> 2.0)
37
+ tty-screen (0.8.1)
38
+ tty-table (0.12.0)
39
+ pastel (~> 0.8)
40
+ strings (~> 0.2.0)
41
+ tty-screen (~> 0.8)
42
+ unicode-display_width (1.7.0)
43
+ unicode_utils (1.4.0)
44
+ wisper (2.0.1)
45
+
46
+ PLATFORMS
47
+ ruby
48
+
49
+ DEPENDENCIES
50
+ artii (~> 2.1, >= 2.1.2)
51
+ colorize (~> 0.8.1)
52
+ rspec (~> 3.9)
53
+ ruby2d (~> 0.9.2)
54
+ tty-prompt
55
+ tty-table
56
+
57
+ BUNDLED WITH
58
+ 2.1.4
@@ -0,0 +1,61 @@
1
+ require_relative '../models/round'
2
+ require_relative '../models/game'
3
+ require_relative '../views/rounds_view'
4
+ require_relative '../views/games_view'
5
+ require_relative '../views/highscores_view'
6
+ require_relative '../views/rules_view'
7
+ require_relative '../views/options_view'
8
+ require_relative '../views/exit_view'
9
+
10
+ module AppController
11
+ def play_game
12
+ begin
13
+ self.clear_screen
14
+ Sound.new("lib/media/blaster-firing.wav").play
15
+ new_round = Round.new
16
+ request_player_input = RoundsView.input round: new_round, round_number: Round.num_rounds
17
+ new_round.player_input = request_player_input
18
+ new_round.player_selection = new_round.selections request_player_input
19
+ RoundsView.display_results new_round
20
+ new_round.save!
21
+ RoundsView.successful_save
22
+ end until new_round.result == 'lost'
23
+ new_game = Game.new
24
+ GamesView.get_player_name new_game
25
+ new_game.score = Round.count_wins * 100 + Round.count_draws * 25
26
+ self.clear_screen
27
+ GamesView.thanks new_game
28
+ new_game.save!
29
+ GamesView.successful_save
30
+ Round.clear_rounds
31
+ self.play_or_menu
32
+ end
33
+
34
+ def show_highscores
35
+ self.clear_screen
36
+ games = Game.map { |game| [game.player_name, game.score] }
37
+ HighscoresView.show games: games
38
+ self.play_or_menu
39
+ end
40
+
41
+ def show_rules
42
+ self.clear_screen
43
+ RulesView.show
44
+ self.play_or_menu
45
+ end
46
+
47
+ def play_or_menu
48
+ OptionsView.show == false ? nil : self.play_game
49
+ end
50
+
51
+ def clear_screen
52
+ system('clear')
53
+ end
54
+
55
+ def exit?
56
+ self.clear_screen
57
+ ExitView.show
58
+ end
59
+
60
+ module_function :play_game, :show_highscores, :show_rules, :play_or_menu, :clear_screen, :exit?
61
+ end
@@ -0,0 +1,14 @@
1
+ require_relative 'controllers/app_controller'
2
+
3
+ def dispatch(choice)
4
+ case choice
5
+ when 0
6
+ AppController.play_game
7
+ when 1
8
+ AppController.show_rules
9
+ when 2
10
+ AppController.show_highscores
11
+ when 3
12
+ AppController.exit?
13
+ end
14
+ end
@@ -0,0 +1,31 @@
1
+ ---
2
+ - !ruby/object:Game
3
+ id: 1
4
+ player_name: Luke Skywalker
5
+ wins: 4
6
+ draws: 2
7
+ score: 450
8
+ - !ruby/object:Game
9
+ id: 2
10
+ player_name: Wicket
11
+ wins: 1
12
+ draws: 1
13
+ score: 125
14
+ - !ruby/object:Game
15
+ id: 3
16
+ player_name: Obi-Wan Kenobi
17
+ wins: 3
18
+ draws: 2
19
+ score: 350
20
+ - !ruby/object:Game
21
+ id: 4
22
+ player_name: Darth Vader
23
+ wins: 3
24
+ draws: 0
25
+ score: 300
26
+ - !ruby/object:Game
27
+ id: 5
28
+ player_name: ofenqiofiq
29
+ wins: 0
30
+ draws: 0
31
+ score: 0
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,83 @@
1
+ ---
2
+ - - "'[Beep], [beep] [boop], [whistle]' - R2-D2"
3
+ - lib/media/R2D2-yeah.wav
4
+ - - "'ROOOOOOAAAAAAAR.' - Chewbacca"
5
+ - lib/media/chewy_roar.wav
6
+ - - "'What is thy bidding, my master?' - Darth Vader"
7
+ - lib/media/swvader04.wav
8
+ - - "'The Force will be with you. Always.' - Obi-Wan Kenobi"
9
+ - lib/media/force.wav
10
+ - - "'Laugh it up fuzzball.' - Han Solo"
11
+ - lib/media/laughfuzzball.wav
12
+ - - "'Why, you stuck-up, half-witted, scruffy-looking nerf herder!' - Leia Organa"
13
+ - lib/media/nerfherder.wav
14
+ - - "'It's a trap!' - Admiral Ackbar"
15
+ - lib/media/trap.mp3
16
+ - - "'Sir, the possibility of successfully navigating an asteroid field is approximately
17
+ 3,720 to 1.' - C-3PO"
18
+ -
19
+ - - "'Help me, Obi-Wan Kenobi. You're my only hope.' - Leia Organa"
20
+ -
21
+ - - "'I find your lack of faith disturbing.' - Darth Vader"
22
+ -
23
+ - - "'It's the ship that made the Kessel run in less than twelve parsecs.' - Han Solo"
24
+ -
25
+ - - "'Now THIS is podracing' - Anakin Skywalker"
26
+ -
27
+ - - "'I'll never turn to the dark side. You've failed, your highness. I am a Jedi,
28
+ like my father before me.' - Luke Skywalker"
29
+ -
30
+ - - "'There's always a bigger fish.' - Qui-Gon Jinn"
31
+ -
32
+ - - "'You can't stop the change, any more than you can stop the suns from setting.'
33
+ - Shmi Skywalker"
34
+ -
35
+ - - "'In my experience there is no such thing as luck.' - Obi-Wan Kenobi"
36
+ -
37
+ - - "'Stay on target.' - Davish Krail"
38
+ -
39
+ - - "'Let me give you some advice. Assume everyone will betray you, and you will never
40
+ be disappointed.' - Han Solo"
41
+ -
42
+ - - "'Fear is the path to the dark side.' - Yoda"
43
+ -
44
+ - - "'Be mindful of your thoughts Anakin. They’ll betray you.' - Obi-Wan Kenobi"
45
+ -
46
+ - - "'Someday I will be the most powerful Jedi ever.' - Anakin Skywalker"
47
+ -
48
+ - - "'May the force be with you.' - (Every Star Wars character in existence)"
49
+ -
50
+ - - "'Fear is the path to the dark side. Fear leads to anger; anger leads to hate;
51
+ hate leads to suffering. I sense much fear in you.' - Yoda"
52
+ -
53
+ - - "'If you strike me down I shall become more powerful than you can possibly imagine.'
54
+ - Obi-Wan Kenobi"
55
+ -
56
+ - - "'Sometimes we must let go of our pride and do what is requested of us.' - Padmé
57
+ Amidala"
58
+ -
59
+ - - "'Always in motion is the future.' - Yoda"
60
+ -
61
+ - - "'Search your feelings, you know it to be true.' - Darth Vader"
62
+ -
63
+ - - "'Compassion, which I would define as unconditional love, is essential to a Jedi’s
64
+ life. So you might say, that we are encouraged to love.' - Anakin Skywalker"
65
+ -
66
+ - - "'Luke, I am your father.' - Darth Vader"
67
+ -
68
+ - - "'Size matters not. Look at me. Judge me by my size, do you? And well you should
69
+ not. For my ally is the Force, and a powerful ally it is.' - Yoda"
70
+ -
71
+ - - "'Much to learn you still have… my old Padawan.' - Yoda"
72
+ -
73
+ - - "'I have taught you everything I know. And you have become a far greater Jedi
74
+ than I could ever hope to be.' - Obi-Wan Kenobi"
75
+ -
76
+ - - "'Never tell me the odds.' - Han Solo"
77
+ -
78
+ - - "'Master Kenobi, you disappoint me. Yoda holds you in such high esteem. Surely
79
+ you can do better!' - Count Dooku"
80
+ -
81
+ - - "'The ability to destroy a planet is insignificant next to the power of the Force.'
82
+ - Darth Vader"
83
+ -
Binary file
Binary file
Binary file
@@ -0,0 +1,35 @@
1
+ require 'yaml'
2
+
3
+ class Game
4
+ @games = YAML.load(File.read("lib/games.yml")) rescue []
5
+
6
+ class << self
7
+ def map
8
+ @games.map { |game_ary| yield game_ary }
9
+ end
10
+
11
+ def next_id
12
+ @games.length + 1
13
+ end
14
+
15
+ def save(game)
16
+ game.id = next_id
17
+ @games << game
18
+ File.open("lib/games.yml", "w") { |file| file.write(@games.to_yaml) }
19
+ end
20
+ end
21
+
22
+ attr_accessor :id, :player_name, :wins, :draws, :score
23
+
24
+ def initialize
25
+ @id = nil
26
+ @player_name = nil
27
+ @wins = 0
28
+ @draws = 0
29
+ @score = 0
30
+ end
31
+
32
+ def save!
33
+ self.class.save(self)
34
+ end
35
+ end
@@ -0,0 +1,22 @@
1
+ class QuoteGenerator
2
+ # for DEMO purposes only: see below under class method quote_index for more info
3
+ # Use to force each quote + sound to be played one after another instead of being selected at random
4
+ # @fixed_idx = 0 # <-- comment out when switching to PRODUCTION
5
+
6
+ @quotes = YAML.load(File.read("lib/media/quotes.yml"))
7
+
8
+ class << self
9
+ def quote_index
10
+ # @fixed_idx == 6 ? @fixed_idx = 0 : @fixed_idx += 1 # <-- # DEMO
11
+ rand(35) # <-- PRODUCTION
12
+ end
13
+
14
+ def choose_quote(idx)
15
+ @quotes[idx][0]
16
+ end
17
+
18
+ def quote_sound(idx)
19
+ @quotes[idx][1]
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,72 @@
1
+ class Round
2
+ @rounds = []
3
+ @round_result_sounds = {
4
+ "lost" => "lib/media/WilhelmScream.wav",
5
+ "drew" => "lib/media/lightsaberclash.mp3",
6
+ "won!" => "lib/media/lightsaberspin.mp3"
7
+ }
8
+
9
+ class << self
10
+ def num_rounds
11
+ @rounds.length + 1
12
+ end
13
+
14
+ def count_wins
15
+ @rounds.count {|x| x.result == "won!"}
16
+ end
17
+
18
+ def count_draws
19
+ @rounds.count {|x| x.result == "drew"}
20
+ end
21
+
22
+ def clear_rounds
23
+ @rounds.clear
24
+ end
25
+
26
+ def get_sound(result)
27
+ @round_result_sounds[result]
28
+ end
29
+
30
+ def next_id
31
+ @rounds.length + 1
32
+ end
33
+
34
+ def save(round)
35
+ round.id = next_id
36
+ @rounds << round
37
+ end
38
+ end
39
+
40
+ attr_reader :ai_input
41
+ attr_accessor :id, :player_input, :player_selection, :ai_selection, :result
42
+
43
+ def initialize
44
+ @id = nil
45
+ @player_input = nil
46
+ @player_selection = nil
47
+ @ai_input = rand(3)
48
+ @ai_selection = self.selections(@ai_input)
49
+ @result = nil
50
+ end
51
+
52
+ def selections(choice)
53
+ select_from = ["Sith".colorize(:light_red), "Jedi".colorize(:light_cyan), "Ewok".colorize(:light_green)]
54
+ select_from[choice]
55
+ end
56
+
57
+ def determine_result
58
+ math_check = @player_input - @ai_input
59
+ case math_check
60
+ when 0
61
+ @result = "drew"
62
+ when 1, -2
63
+ @result = "won!"
64
+ when -1, 2
65
+ @result = "lost"
66
+ end
67
+ end
68
+
69
+ def save!
70
+ self.class.save(self)
71
+ end
72
+ end
@@ -0,0 +1,30 @@
1
+ require 'ruby2d'
2
+ require 'tty-prompt'
3
+ require 'colorize'
4
+ require 'artii'
5
+ require_relative 'dispatch'
6
+
7
+ if ARGV.empty?
8
+ Sound.new("lib/media/blaster-firing.wav").play
9
+ loop do
10
+ system('clear')
11
+ puts "Welcome to...".colorize(:light_yellow)
12
+ puts Artii::Base.new(:font => 'slant').asciify("Sith - Lord Jedi Ewok").colorize(:light_yellow).bold
13
+ choice = TTY::Prompt.new.select("What would you like to do?".colorize(:light_yellow), help_color: :bright_magenta) do |menu|
14
+ menu.choice "Play Game".colorize(:light_green), 0
15
+ menu.choice "Read Rules".colorize(:light_yellow), 1
16
+ menu.choice "View Leaderboard".colorize(:light_yellow), 2
17
+ menu.choice "Exit".colorize(:light_red), 3
18
+ end
19
+ dispatch choice
20
+ end
21
+ elsif ARGV[0] == "-h" || ARGV[0] == "--help"
22
+ puts "\n--- Help Menu ---"
23
+ puts "\nInstallation:"
24
+ puts " To install this gem, Add this line to your application's Gemfile:"
25
+ puts " gem 'sith_jedi_ewok'"
26
+ puts " and then execute 'bundle install'"
27
+ puts " or install yourself as 'gem install sith_jedi_ewok'"
28
+ puts "\nOptions:"
29
+ puts " -h or --help # get help file\n\n"
30
+ end
@@ -0,0 +1,3 @@
1
+ module SithJediEwok
2
+ VERSION = "0.1.1"
3
+ end
@@ -0,0 +1,15 @@
1
+ require_relative '../models/round'
2
+ require_relative '../models/game'
3
+ require_relative '../views/highscores_view'
4
+
5
+ # Testing help message from Leaderboard prints when scores are empty
6
+ describe HighscoresView do
7
+ let(:games_empty) {[]}
8
+
9
+ it "should display 'no scores' message when no available scores" do
10
+ expect{subject.show games: games_empty}.to output{
11
+ "Leaderboard:".colorize(:light_yellow)
12
+ "\nNo scores on the leaderboard to show!".colorize(:red)
13
+ }.to_stdout
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ require 'colorize'
2
+ require_relative '../models/quote_generator'
3
+
4
+ # Testing Quote Generator
5
+ describe QuoteGenerator do
6
+ it "should return correct quote from external quotes file'" do
7
+ expect(QuoteGenerator.choose_quote(0)).to eq "'[Beep], [beep] [boop], [whistle]' - R2-D2"
8
+ expect(QuoteGenerator.choose_quote(1)).to eq "'ROOOOOOAAAAAAAR.' - Chewbacca"
9
+ end
10
+
11
+ it "should return correct sound byte path from external quotes file'" do
12
+ expect(QuoteGenerator.quote_sound(0)).to eq 'lib/media/R2D2-yeah.wav'
13
+ expect(QuoteGenerator.quote_sound(1)).to eq 'lib/media/chewy_roar.wav'
14
+ end
15
+ end
@@ -0,0 +1,40 @@
1
+ require_relative '../models/round'
2
+
3
+ # Testing game logic in 'round.rb' returns correct results (win, lose, draw) for every player selection option (sith, jedi, ewok)
4
+ describe Round do
5
+ it 'should correctly determine round result when player chooses Sith' do
6
+ subject.player_input = 0
7
+ case subject.ai_input
8
+ when 0
9
+ expect(subject.determine_result).to eq 'drew'
10
+ when 1
11
+ expect(subject.determine_result).to eq 'lost'
12
+ when 2
13
+ expect(subject.determine_result).to eq 'won!'
14
+ end
15
+ end
16
+
17
+ it 'should correctly determine round result when player chooses Jedi' do
18
+ subject.player_input = 1
19
+ case subject.ai_input
20
+ when 0
21
+ expect(subject.determine_result).to eq 'won!'
22
+ when 1
23
+ expect(subject.determine_result).to eq 'drew'
24
+ when 2
25
+ expect(subject.determine_result).to eq 'lost'
26
+ end
27
+ end
28
+
29
+ it 'should correctly determine round result when player chooses Ewok' do
30
+ subject.player_input = 2
31
+ case subject.ai_input
32
+ when 0
33
+ expect(subject.determine_result).to eq 'lost'
34
+ when 1
35
+ expect(subject.determine_result).to eq 'won!'
36
+ when 2
37
+ expect(subject.determine_result).to eq 'drew'
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,12 @@
1
+ module ExitView
2
+ def show
3
+ Sound.new("lib/media/swluke01.wav").play
4
+ to_exit = TTY::Prompt.new.select("Are you sure you want to exit?".colorize(:light_yellow), help: '') do |menu|
5
+ menu.choice "Yes".colorize(:light_green), true
6
+ menu.choice "No".colorize(:light_red), false
7
+ end
8
+ to_exit == true ? exit : to_exit
9
+ end
10
+
11
+ module_function :show
12
+ end
@@ -0,0 +1,21 @@
1
+ module GamesView
2
+ def get_player_name(game)
3
+ begin
4
+ game.player_name = TTY::Prompt.new.ask("\nTo record you score, please enter your name: ".colorize(:light_yellow), help: '') do |name|
5
+ name.validate(/\w/, "Please enter a valid name (no special characters)".colorize(:red))
6
+ end
7
+ end while game.player_name.nil?
8
+ end
9
+
10
+ def thanks(game)
11
+ puts "\nThanks for playing, #{game.player_name}, your score was #{game.score}\n".colorize(:light_yellow)
12
+ sleep(2)
13
+ end
14
+
15
+ def successful_save
16
+ puts "Your score was saved successfully to the Leaderboard!".colorize(:white)
17
+ sleep(2)
18
+ end
19
+
20
+ module_function :get_player_name, :thanks, :successful_save
21
+ end
@@ -0,0 +1,15 @@
1
+ require 'tty-table'
2
+
3
+ module HighscoresView
4
+ def show(games:)
5
+ puts "Leaderboard:".colorize(:light_yellow)
6
+ return puts "\nNo scores on the leaderboard to show!".colorize(:red) if games.empty?
7
+ headers = ['Player'.colorize(:light_blue), 'Score'.colorize(:light_magenta)]
8
+ # top_10 stores the highest 10 scores in YAML, sorted in descending order
9
+ top_10 = games.sort_by{|ary|ary[1]}.reverse[0..9]
10
+ highscores = TTY::Table.new(header: headers, rows: top_10)
11
+ puts highscores.render :unicode, alignments: [:left, :right]
12
+ end
13
+
14
+ module_function :show
15
+ end
@@ -0,0 +1,17 @@
1
+ require_relative '../models/quote_generator'
2
+
3
+ module OptionsView
4
+ def show
5
+ TTY::Prompt.new.keypress("\nPress any key to continue".colorize(:light_magenta))
6
+ quote_idx = QuoteGenerator.quote_index
7
+ puts "\n\n\n#{QuoteGenerator.choose_quote(quote_idx)}\n".colorize(:white).italic
8
+ sound_path = QuoteGenerator.quote_sound(quote_idx) # condensing this for next line
9
+ Sound.new(sound_path).play unless sound_path.nil? # play quote sound from quotes array unless no sound available
10
+ prompt = TTY::Prompt.new.select("\n\nWhat would you like to do?".colorize(:light_yellow), help: '') do |menu|
11
+ menu.choice "Start New Game".colorize(:light_green), true
12
+ menu.choice "Exit to Main Menu".colorize(:light_red), false
13
+ end
14
+ end
15
+
16
+ module_function :show
17
+ end
@@ -0,0 +1,30 @@
1
+ module RoundsView
2
+ def input(round:, round_number:)
3
+ puts "Round: #{round_number}".colorize(:light_yellow)
4
+ TTY::Prompt.new.select("\nPlease choose your desired faction:".colorize(:light_yellow), help: '') do |menu|
5
+ menu.choice "Sith".colorize(:light_red), 0
6
+ menu.choice "Jedi".colorize(:light_cyan), 1
7
+ menu.choice "Ewok".colorize(:light_green), 2
8
+ end
9
+ end
10
+
11
+ def display_results(round)
12
+ print "\nYou chose: ".colorize(:light_yellow)
13
+ sleep(0.5)
14
+ puts round.player_selection
15
+ sleep(0.5)
16
+ print "Your opponent chose: ".colorize(:light_yellow)
17
+ sleep(0.5)
18
+ puts round.ai_selection
19
+ sleep(1)
20
+ puts "\nYou #{round.determine_result}".colorize(:light_yellow)
21
+ Sound.new(Round.get_sound(round.result)).play
22
+ end
23
+
24
+ def successful_save
25
+ puts "\nRound saved successfully".colorize(:grey)
26
+ TTY::Prompt.new.keypress("\nPress any key to continue".colorize(:light_magenta))
27
+ end
28
+
29
+ module_function :input, :display_results, :successful_save
30
+ end
@@ -0,0 +1,18 @@
1
+ module RulesView
2
+ def show
3
+ puts "Rules:".colorize(:light_magenta)
4
+ puts "\nIn a game of 'Sith-lord, Jedi, Ewok', players play a series of rounds.".colorize(:light_yellow)
5
+ puts "The game ends when you are defeated by the computer in any round.".colorize(:light_yellow)
6
+ puts "Before each round, players choose a faction to represent.".colorize(:light_yellow)
7
+ puts "Each faction will win against only ONE other faction.".colorize(:light_yellow)
8
+ puts "\nThe round results for each faction are as follows:".colorize(:light_yellow)
9
+ puts "- ".colorize(:light_yellow) + "Sith".colorize(:light_red) + " enslaves ".colorize(:light_yellow) + "Ewok".colorize(:light_green)
10
+ puts "- ".colorize(:light_yellow) + "Ewok".colorize(:light_green) + " recruits ".colorize(:light_yellow) + "Jedi".colorize(:light_cyan)
11
+ puts "- ".colorize(:light_yellow) + "Jedi".colorize(:light_cyan) + " overpowers ".colorize(:light_yellow) + "Sith".colorize(:light_red)
12
+ puts "\nScoring:".colorize(:light_magenta)
13
+ puts "\nEvery winning round scores 100 points and every draw scores 25 points".colorize(:light_yellow)
14
+ end
15
+
16
+ module_function :show
17
+ end
18
+
@@ -0,0 +1,37 @@
1
+ require_relative 'lib/sith_jedi_ewok/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "Sith-Lord_Jedi_Ewok"
5
+ spec.version = SithJediEwok::VERSION
6
+ spec.authors = ["Daniel Waldow"]
7
+
8
+ spec.summary = %q{Sith-Lord, Jedi is a 'Star Wars' themed 'Scissors, Paper, Rock' simulator.}
9
+ spec.description = %q{'Sith-Lord, Jedi, Ewok' is a game targeting younger audiences who may not have grown up playing 'Scissors, Paper, Rock', but will also more broadly appeal to fans of the Star Wars franchise.}
10
+ spec.homepage = "https://github.com/waldowred5/T1A3-Terminal-App"
11
+ spec.license = "MIT"
12
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
13
+
14
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
15
+
16
+ spec.metadata["homepage_uri"] = spec.homepage
17
+ spec.metadata["source_code_uri"] = "https://github.com/waldowred5/T1A3-Terminal-App"
18
+ # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
19
+
20
+ # Specify which files should be added to the gem when it is released.
21
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
23
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24
+ end
25
+ # spec.bindir = "exe"
26
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+ spec.executables << 'sith_jedi_ewok'
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency "rake", "~> 12.0"
31
+ spec.add_development_dependency "rspec", "~> 3.9"
32
+ spec.add_development_dependency "tty-table", "~> 0.12.0"
33
+ spec.add_development_dependency "tty-prompt", "~> 0.22.0"
34
+ spec.add_development_dependency "colorize", "~> 0.8.1"
35
+ spec.add_development_dependency "artii", "~> 2.1", ">= 2.1.2"
36
+ spec.add_development_dependency "ruby2d", "~> 0.9.2"
37
+ end
metadata ADDED
@@ -0,0 +1,193 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: Sith-Lord_Jedi_Ewok
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Daniel Waldow
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-10-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '12.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '12.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.9'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.9'
41
+ - !ruby/object:Gem::Dependency
42
+ name: tty-table
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.12.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.12.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: tty-prompt
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.22.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.22.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: colorize
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.8.1
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.8.1
83
+ - !ruby/object:Gem::Dependency
84
+ name: artii
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '2.1'
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: 2.1.2
93
+ type: :development
94
+ prerelease: false
95
+ version_requirements: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - "~>"
98
+ - !ruby/object:Gem::Version
99
+ version: '2.1'
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: 2.1.2
103
+ - !ruby/object:Gem::Dependency
104
+ name: ruby2d
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: 0.9.2
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: 0.9.2
117
+ description: "'Sith-Lord, Jedi, Ewok' is a game targeting younger audiences who may
118
+ not have grown up playing 'Scissors, Paper, Rock', but will also more broadly appeal
119
+ to fans of the Star Wars franchise."
120
+ email:
121
+ executables:
122
+ - sith_jedi_ewok
123
+ extensions: []
124
+ extra_rdoc_files: []
125
+ files:
126
+ - ".gitignore"
127
+ - Gemfile
128
+ - Gemfile.lock
129
+ - LICENSE.txt
130
+ - README.md
131
+ - Rakefile
132
+ - bin/rake
133
+ - bin/setup
134
+ - bin/sith_jedi_ewok
135
+ - lib/.rspec
136
+ - lib/Gemfile.lock
137
+ - lib/controllers/app_controller.rb
138
+ - lib/dispatch.rb
139
+ - lib/games.yml
140
+ - lib/media/R2D2-yeah.wav
141
+ - lib/media/WilhelmScream.wav
142
+ - lib/media/blaster-firing.wav
143
+ - lib/media/chewy_roar.wav
144
+ - lib/media/force.wav
145
+ - lib/media/laughfuzzball.wav
146
+ - lib/media/lightsaberclash.mp3
147
+ - lib/media/lightsaberspin.mp3
148
+ - lib/media/nerfherder.wav
149
+ - lib/media/quotes.yml
150
+ - lib/media/swluke01.wav
151
+ - lib/media/swvader04.wav
152
+ - lib/media/trap.mp3
153
+ - lib/models/game.rb
154
+ - lib/models/quote_generator.rb
155
+ - lib/models/round.rb
156
+ - lib/sith_jedi_ewok.rb
157
+ - lib/sith_jedi_ewok/version.rb
158
+ - lib/spec/highscores_spec.rb
159
+ - lib/spec/quote_generator_spec.rb
160
+ - lib/spec/round_spec.rb
161
+ - lib/views/exit_view.rb
162
+ - lib/views/games_view.rb
163
+ - lib/views/highscores_view.rb
164
+ - lib/views/options_view.rb
165
+ - lib/views/rounds_view.rb
166
+ - lib/views/rules_view.rb
167
+ - sith_jedi_ewok.gemspec
168
+ homepage: https://github.com/waldowred5/T1A3-Terminal-App
169
+ licenses:
170
+ - MIT
171
+ metadata:
172
+ homepage_uri: https://github.com/waldowred5/T1A3-Terminal-App
173
+ source_code_uri: https://github.com/waldowred5/T1A3-Terminal-App
174
+ post_install_message:
175
+ rdoc_options: []
176
+ require_paths:
177
+ - lib
178
+ required_ruby_version: !ruby/object:Gem::Requirement
179
+ requirements:
180
+ - - ">="
181
+ - !ruby/object:Gem::Version
182
+ version: 2.3.0
183
+ required_rubygems_version: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ requirements: []
189
+ rubygems_version: 3.1.2
190
+ signing_key:
191
+ specification_version: 4
192
+ summary: Sith-Lord, Jedi is a 'Star Wars' themed 'Scissors, Paper, Rock' simulator.
193
+ test_files: []