pc 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/Gemfile +6 -0
- data/HISTORY.md +15 -0
- data/LICENSE.txt +22 -0
- data/README.md +33 -0
- data/Rakefile +1 -0
- data/bin/tarzan +21 -0
- data/lib/pc.rb +1 -0
- data/lib/pc/game.rb +50 -0
- data/lib/pc/games/odds_and_evens.rb +22 -0
- data/lib/pc/games/rock_paper_scissors.rb +23 -0
- data/lib/pc/interface.rb +13 -0
- data/lib/pc/interfaces/campfire.rb +39 -0
- data/lib/pc/interfaces/desktop.rb +17 -0
- data/lib/pc/interfaces/desktop/window.rb +91 -0
- data/lib/pc/interfaces/shell.rb +34 -0
- data/lib/pc/loop.rb +31 -0
- data/lib/pc/players/human.rb +1 -0
- data/lib/pc/players/random.rb +1 -0
- data/lib/pc/players/smart.rb +6 -0
- data/lib/pc/tournament.rb +32 -0
- data/lib/pc/version.rb +3 -0
- data/pc.gemspec +27 -0
- data/spec/tarzan/games/odds_and_evens_spec.rb +19 -0
- data/spec/tarzan/games/rock_paper_scissors_spec.rb +24 -0
- metadata +142 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8a2fea4f3614c7570e83780e38056f2b76da1717b296fd7c7bb7c35cf3117ec3
|
4
|
+
data.tar.gz: e4c4cff0c80bf71edb0c16b28dad145ff91c6d02fceb139a942845fec0d03d63
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 27c00563d967c8d4afa5f7a3a246ddcea54f8319694c0ffc210a8e3aedafa26a173331268b71a29b3d3313f67f1550ea43a6f1a73215e400a08b909ce256471c
|
7
|
+
data.tar.gz: 382d917448450fceced47a1a82462f88e1ab25f77e079903814f07dc6f09d442343b8934cf1e6cc29645e38e7b6a4ffa154e9f8a3b25d0210f75576c5c9660fc
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/HISTORY.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
v0.0.4 - 2014/02/09
|
2
|
+
|
3
|
+
* Rewritten with Module, no Singleton class
|
4
|
+
* More compact files for each game and interface
|
5
|
+
* Room for separate player modules (Human, Random, Smart)
|
6
|
+
|
7
|
+
v0.0.3 - 2014/02/05
|
8
|
+
|
9
|
+
* Add Odd Or Evens game
|
10
|
+
* Separate interface, game and moves into modules
|
11
|
+
* Integrate Campfire with Nico gem
|
12
|
+
|
13
|
+
v0.0.2 - 2014/02/05
|
14
|
+
|
15
|
+
* Shell-only Rock Paper Scissors game
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 claudiob
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# Pc
|
2
|
+
|
3
|
+
King of the Game Jungle
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'pc'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install pc
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
From the command line run:
|
22
|
+
|
23
|
+
$ pc
|
24
|
+
|
25
|
+
To use Campfire as an interface, define the following environment variables: `CAMPFIRE_SUBDOMAIN`, `CAMPFIRE_ROOM_ID` and `CAMPFIRE_TOKEN`.
|
26
|
+
|
27
|
+
## Contributing
|
28
|
+
|
29
|
+
1. Fork it ( http://github.com/claudiob/pc/fork )
|
30
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
31
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
32
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
33
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/tarzan
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'pc'
|
5
|
+
rescue LoadError
|
6
|
+
require 'rubygems'
|
7
|
+
require 'pc'
|
8
|
+
end
|
9
|
+
|
10
|
+
puts %{Pick [S]hell, [C]ampfire, or [D]esktop: }
|
11
|
+
interface = case gets.strip
|
12
|
+
when 'S'
|
13
|
+
require 'pc/interfaces/shell'
|
14
|
+
Pc::Tournament.run Pc::Shell
|
15
|
+
when 'C'
|
16
|
+
require 'pc/interfaces/campfire'
|
17
|
+
Pc::Tournament.run Pc::Campfire, subdomain: ENV['CAMPFIRE_SUBDOMAIN'], room_id: ENV['CAMPFIRE_ROOM_ID'], token: ENV['CAMPFIRE_TOKEN']
|
18
|
+
when 'D'
|
19
|
+
require 'pc/interfaces/desktop'
|
20
|
+
Pc::Tournament.run Pc::Desktop
|
21
|
+
end
|
data/lib/pc.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'pc/tournament'
|
data/lib/pc/game.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'pc/loop'
|
2
|
+
|
3
|
+
module Pc
|
4
|
+
module Game
|
5
|
+
include Loop
|
6
|
+
|
7
|
+
def self.included(base)
|
8
|
+
base.extend base
|
9
|
+
end
|
10
|
+
|
11
|
+
def welcome
|
12
|
+
say %{Rules: #{rules}}, next: ->{prompt_move}
|
13
|
+
end
|
14
|
+
|
15
|
+
def rules
|
16
|
+
'[no rules defined]'
|
17
|
+
end
|
18
|
+
|
19
|
+
def moves
|
20
|
+
{}
|
21
|
+
end
|
22
|
+
|
23
|
+
def prompt_move
|
24
|
+
ask %{Choose a move}, Hash[*moves.map{|k, v| [k, ->{choose v}]}.flatten]
|
25
|
+
end
|
26
|
+
|
27
|
+
def choose(choice)
|
28
|
+
@move_p1 = choice
|
29
|
+
@move_p2 = random_move
|
30
|
+
say %{You played #{@move_p1} - I played #{@move_p2}}, next: ->{show_outcome}
|
31
|
+
end
|
32
|
+
|
33
|
+
def random_move
|
34
|
+
moves.values.sample
|
35
|
+
end
|
36
|
+
|
37
|
+
def show_outcome
|
38
|
+
outcome = case compare_moves(@move_p1, @move_p2)
|
39
|
+
when 1 then %{You win!}
|
40
|
+
when -1 then %{You lose!}
|
41
|
+
when 0 then %{It’s a tie!}
|
42
|
+
end
|
43
|
+
say outcome, next: ->{exit}
|
44
|
+
end
|
45
|
+
|
46
|
+
def compare_moves(move_a, move_b)
|
47
|
+
move_a <=> move_b
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'pc/game'
|
2
|
+
|
3
|
+
module Pc
|
4
|
+
module OddsAndEvens
|
5
|
+
include Game
|
6
|
+
|
7
|
+
def rules
|
8
|
+
'Odd sum wins, even sum loses'
|
9
|
+
end
|
10
|
+
|
11
|
+
def moves
|
12
|
+
{'1' => 1, '2' => 2, '3' => 3, '4' => 4, '5' => 5}
|
13
|
+
end
|
14
|
+
|
15
|
+
def compare_moves(move_a, move_b)
|
16
|
+
case move_a + move_b # might need finger_offset
|
17
|
+
when ->(sum) { sum.odd? } then 1
|
18
|
+
when ->(sum) { sum.even? } then -1
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'pc/game'
|
2
|
+
|
3
|
+
module Pc
|
4
|
+
module RockPaperScissors
|
5
|
+
include Game
|
6
|
+
|
7
|
+
def rules
|
8
|
+
'Rock beats Scissors beats Paper beats Rock'
|
9
|
+
end
|
10
|
+
|
11
|
+
def moves
|
12
|
+
{rock: 'R', paper: 'P', scissors: 'S'}
|
13
|
+
end
|
14
|
+
|
15
|
+
def compare_moves(move_a, move_b)
|
16
|
+
case "#{move_a}#{move_b}"
|
17
|
+
when 'RS', 'SP', 'PR' then 1
|
18
|
+
when 'RP', 'SR', 'PS' then -1
|
19
|
+
else 0
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/pc/interface.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'pc/interface'
|
2
|
+
require 'nico'
|
3
|
+
require 'net/http'
|
4
|
+
|
5
|
+
module Pc
|
6
|
+
module Campfire
|
7
|
+
include Interface
|
8
|
+
|
9
|
+
def run(options = {})
|
10
|
+
@room ||= Nico::Room.new options
|
11
|
+
while action = (@actions ||= []).shift
|
12
|
+
say action[:message]
|
13
|
+
choose(action[:choices]).call
|
14
|
+
run
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def enqueue(message, choices = {})
|
19
|
+
(@actions ||= []).push message: message, choices: choices
|
20
|
+
end
|
21
|
+
|
22
|
+
def say(message)
|
23
|
+
@room.say message
|
24
|
+
end
|
25
|
+
|
26
|
+
def choose(choices = {})
|
27
|
+
if choices[:next]
|
28
|
+
sleep 0.2
|
29
|
+
choices[:next]
|
30
|
+
else
|
31
|
+
say %{Pick one: #{choices.keys.join ' - '} }
|
32
|
+
@room.each_message do |message|
|
33
|
+
choice = choices.select{|k,v| k.to_s == message}.values.first
|
34
|
+
return choice if choice
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'pc/interface'
|
2
|
+
require 'pc/interfaces/desktop/window'
|
3
|
+
|
4
|
+
module Pc
|
5
|
+
module Desktop
|
6
|
+
include Interface
|
7
|
+
|
8
|
+
def run(options = {})
|
9
|
+
Window.instance.show
|
10
|
+
end
|
11
|
+
|
12
|
+
def enqueue(message, choices = {})
|
13
|
+
Window.instance.set_alert message
|
14
|
+
Window.instance.set_buttons choices
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
require 'gosu'
|
3
|
+
|
4
|
+
module Pc
|
5
|
+
class Window < Gosu::Window
|
6
|
+
include Singleton
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
super 640, 480, is_fullscreen
|
10
|
+
self.caption = 'Game Hall'
|
11
|
+
@font = Gosu::Font.new self, Gosu::default_font_name, 20
|
12
|
+
end
|
13
|
+
|
14
|
+
def set_alert(message)
|
15
|
+
@alert = message
|
16
|
+
end
|
17
|
+
|
18
|
+
def set_buttons(choices = {})
|
19
|
+
@buttons = choices.map.with_index do |(key, value), index|
|
20
|
+
{timeout: Time.now + 1.2, label: key, action: value, x1: 100, x2: 200, y1: 30+index*30, y2: 50+index*30}
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# This method is called once every #update_interval milliseconds while the window is being shown.
|
25
|
+
def update
|
26
|
+
@buttons.each do |button, index|
|
27
|
+
if button[:timeout] < Time.now && button[:label] == :next
|
28
|
+
@buttons = nil
|
29
|
+
button[:action].call
|
30
|
+
break
|
31
|
+
end
|
32
|
+
end if @buttons
|
33
|
+
end
|
34
|
+
|
35
|
+
def draw_text(text)
|
36
|
+
@font.draw @alert, 200, 450, 2 # TO DO: center the text
|
37
|
+
end
|
38
|
+
|
39
|
+
def draw_rectangle(button)
|
40
|
+
c1, c2 = [Gosu::Color.new(0xFF1EB1FA), Gosu::Color.new(0xFF1D4DB5)]
|
41
|
+
x1, x2, y1, y2 = [button[:x1], button[:x2], button[:y1], button[:y2]]
|
42
|
+
z_index = 0
|
43
|
+
draw_quad x1, y1, c1, x2, y1, c1, x1, y2, c2, x2, y2, c2, z_index
|
44
|
+
end
|
45
|
+
|
46
|
+
def draw_buttons(buttons)
|
47
|
+
buttons.reject{|button| button[:label] == :next}.each do |button|
|
48
|
+
draw_rectangle button
|
49
|
+
@font.draw button[:label], button[:x1], button[:y1], 2
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# This method is called after every update and whenever the OS wants the window to repaint itself.
|
54
|
+
def draw
|
55
|
+
draw_text @alert if @alert
|
56
|
+
draw_buttons @buttons if @buttons
|
57
|
+
end
|
58
|
+
|
59
|
+
# This method is called whenever a key is pressed down
|
60
|
+
def button_down(id)
|
61
|
+
case id
|
62
|
+
when Gosu::KbEscape then close
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# This method is called whenever a key is pressed up
|
67
|
+
def button_up(id)
|
68
|
+
case id
|
69
|
+
when Gosu::MsLeft
|
70
|
+
@buttons.each do |button, index|
|
71
|
+
if button[:y1] < mouse_y && mouse_y < button[:y2] && button[:x1] < mouse_x && mouse_x < button[:x2]
|
72
|
+
@buttons = nil
|
73
|
+
button[:action].call
|
74
|
+
break
|
75
|
+
end
|
76
|
+
end if @buttons
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
private
|
81
|
+
|
82
|
+
def is_fullscreen
|
83
|
+
false
|
84
|
+
end
|
85
|
+
|
86
|
+
# [from Gosu::Window] Whether the system cursor should be shown
|
87
|
+
def needs_cursor?
|
88
|
+
true
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'pc/interface'
|
2
|
+
|
3
|
+
module Pc
|
4
|
+
module Shell
|
5
|
+
include Interface
|
6
|
+
|
7
|
+
def run(options = {})
|
8
|
+
while action = (@actions ||= []).shift
|
9
|
+
say action[:message]
|
10
|
+
choose(action[:choices]).call
|
11
|
+
run
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def enqueue(message, choices = {})
|
16
|
+
(@actions ||= []).push message: message, choices: choices
|
17
|
+
end
|
18
|
+
|
19
|
+
def say(message)
|
20
|
+
puts message
|
21
|
+
end
|
22
|
+
|
23
|
+
def choose(choices = {})
|
24
|
+
if choices[:next]
|
25
|
+
sleep 0.2
|
26
|
+
choices[:next]
|
27
|
+
else
|
28
|
+
say %{Pick one: #{choices.keys.join ' - '} }
|
29
|
+
choice = gets.strip
|
30
|
+
choices.select{|k,v| k.to_s == choice}.values.first || prompt(choices)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/pc/loop.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
module Pc
|
2
|
+
module Loop
|
3
|
+
def self.included(base)
|
4
|
+
base.extend base
|
5
|
+
end
|
6
|
+
|
7
|
+
def run(interface, options = {})
|
8
|
+
@interface ||= interface
|
9
|
+
@options ||= options
|
10
|
+
welcome
|
11
|
+
catch(:exit) { @interface.run @options }
|
12
|
+
end
|
13
|
+
|
14
|
+
def welcome
|
15
|
+
say %{Welcome}, next: ->{goodbye}
|
16
|
+
end
|
17
|
+
|
18
|
+
def goodbye
|
19
|
+
say %{Goodbye}, next: ->{exit}
|
20
|
+
end
|
21
|
+
|
22
|
+
def exit
|
23
|
+
throw :exit
|
24
|
+
end
|
25
|
+
|
26
|
+
def say(message, choices = {})
|
27
|
+
@interface.enqueue message, choices
|
28
|
+
end
|
29
|
+
alias :ask :say
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
# This will include prompt for a human player
|
@@ -0,0 +1 @@
|
|
1
|
+
# This will always make a random choice
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'pc/loop'
|
2
|
+
|
3
|
+
module Pc
|
4
|
+
module Tournament
|
5
|
+
include Loop
|
6
|
+
|
7
|
+
def welcome
|
8
|
+
say %{Welcome}, next: ->{select_game}
|
9
|
+
end
|
10
|
+
|
11
|
+
def select_game
|
12
|
+
ask %{Pick a game}, loaded_games
|
13
|
+
end
|
14
|
+
|
15
|
+
def loaded_games
|
16
|
+
Dir[File.dirname(__FILE__) + '/games/*.rb'].each {|file| require file }
|
17
|
+
|
18
|
+
{exit: -> {goodbye}}.tap do |games|
|
19
|
+
ObjectSpace.each_object(Game) do |game|
|
20
|
+
unless game == Pc::Game
|
21
|
+
games[game.to_s] = ->{play game}
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def play(game)
|
28
|
+
game.run @interface, @options
|
29
|
+
say %{Get ready for the next one}, next: ->{select_game}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/pc/version.rb
ADDED
data/pc.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'pc/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'pc'
|
8
|
+
spec.version = Pc::VERSION
|
9
|
+
spec.authors = ['claudiob']
|
10
|
+
spec.email = ['claudiob@gmail.com']
|
11
|
+
spec.summary = %q{King of the Game Jungle.}
|
12
|
+
spec.description = %q{Step-by-step tutorial to modular games in Ruby}
|
13
|
+
spec.homepage = 'https://github.com/claudiob/pc'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_dependency 'nico', '>= 0.1.1' # Campfire integration
|
22
|
+
spec.add_dependency 'gosu' # 2D graphic engine for OS X
|
23
|
+
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.5'
|
25
|
+
spec.add_development_dependency 'rake', '~> 0'
|
26
|
+
spec.add_development_dependency 'rspec'
|
27
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'pc/games/odds_and_evens'
|
2
|
+
|
3
|
+
module Pc
|
4
|
+
describe 'OddsAndEvens.compare_moves' do
|
5
|
+
context 'given a first hand of 3 fingers' do
|
6
|
+
let (:move_a) { 3 }
|
7
|
+
|
8
|
+
context 'versus a second hand of 4 fingers' do
|
9
|
+
let (:move_b) { 4 }
|
10
|
+
it { expect(OddsAndEvens.compare_moves move_a, move_b).to eq 1}
|
11
|
+
end
|
12
|
+
|
13
|
+
context 'versus a second hand of 5 fingers' do
|
14
|
+
let (:move_b) { 5 }
|
15
|
+
it { expect(OddsAndEvens.compare_moves move_a, move_b).to eq -1}
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'pc/games/rock_paper_scissors'
|
2
|
+
|
3
|
+
module Pc
|
4
|
+
describe 'RockPaperScissors.compare_moves' do
|
5
|
+
context 'given a first hand of Rock' do
|
6
|
+
let (:move_a) { 'R' }
|
7
|
+
|
8
|
+
context 'versus a second hand of Scissors' do
|
9
|
+
let (:move_b) { 'S' }
|
10
|
+
it { expect(RockPaperScissors.compare_moves move_a, move_b).to eq 1}
|
11
|
+
end
|
12
|
+
|
13
|
+
context 'versus a second hand of Paper' do
|
14
|
+
let (:move_b) { 'P' }
|
15
|
+
it { expect(RockPaperScissors.compare_moves move_a, move_b).to eq -1}
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'versus a second hand of Rock' do
|
19
|
+
let (:move_b) { 'R' }
|
20
|
+
it { expect(RockPaperScissors.compare_moves move_a, move_b).to eq 0}
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pc
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- claudiob
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-06-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: nico
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.1.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.1.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: gosu
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.5'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.5'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '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'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Step-by-step tutorial to modular games in Ruby
|
84
|
+
email:
|
85
|
+
- claudiob@gmail.com
|
86
|
+
executables:
|
87
|
+
- tarzan
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- ".gitignore"
|
92
|
+
- ".rspec"
|
93
|
+
- Gemfile
|
94
|
+
- HISTORY.md
|
95
|
+
- LICENSE.txt
|
96
|
+
- README.md
|
97
|
+
- Rakefile
|
98
|
+
- bin/tarzan
|
99
|
+
- lib/pc.rb
|
100
|
+
- lib/pc/game.rb
|
101
|
+
- lib/pc/games/odds_and_evens.rb
|
102
|
+
- lib/pc/games/rock_paper_scissors.rb
|
103
|
+
- lib/pc/interface.rb
|
104
|
+
- lib/pc/interfaces/campfire.rb
|
105
|
+
- lib/pc/interfaces/desktop.rb
|
106
|
+
- lib/pc/interfaces/desktop/window.rb
|
107
|
+
- lib/pc/interfaces/shell.rb
|
108
|
+
- lib/pc/loop.rb
|
109
|
+
- lib/pc/players/human.rb
|
110
|
+
- lib/pc/players/random.rb
|
111
|
+
- lib/pc/players/smart.rb
|
112
|
+
- lib/pc/tournament.rb
|
113
|
+
- lib/pc/version.rb
|
114
|
+
- pc.gemspec
|
115
|
+
- spec/tarzan/games/odds_and_evens_spec.rb
|
116
|
+
- spec/tarzan/games/rock_paper_scissors_spec.rb
|
117
|
+
homepage: https://github.com/claudiob/pc
|
118
|
+
licenses:
|
119
|
+
- MIT
|
120
|
+
metadata: {}
|
121
|
+
post_install_message:
|
122
|
+
rdoc_options: []
|
123
|
+
require_paths:
|
124
|
+
- lib
|
125
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0'
|
130
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
135
|
+
requirements: []
|
136
|
+
rubygems_version: 3.0.3
|
137
|
+
signing_key:
|
138
|
+
specification_version: 4
|
139
|
+
summary: King of the Game Jungle.
|
140
|
+
test_files:
|
141
|
+
- spec/tarzan/games/odds_and_evens_spec.rb
|
142
|
+
- spec/tarzan/games/rock_paper_scissors_spec.rb
|