Skip to content

Commit

Permalink
RASENN feat. kne
Browse files Browse the repository at this point in the history
  • Loading branch information
threetreeslight committed Jul 24, 2019
1 parent 5190730 commit 099106e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion game.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def assert(demes)
return "win"
else
deme = demes.combination(2).select{|a,b| a == b}.flatten
nokorideme = demes - deme
nokorideme = (demes - deme).first

if nokorideme == 1
return "deme1"
Expand Down
20 changes: 14 additions & 6 deletions spec/game_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,29 @@
require_relative "../game.rb"

describe Game do
let(:game){ Game.new }

describe "#assert" do
context "ひふみ" do
it do
game = Game.new
hifumi = [3,2,1]
expect(game.assert(hifumi)).to eq "lose"
demes = [3,2,1]
expect(game.assert(demes)).to eq "lose"
end
end

context "しごろ" do
it do
game = Game.new
shigoro = [6,5,4]
expect(game.assert(shigoro)).to eq "win"
demes = [6,5,4]
expect(game.assert(demes)).to eq "win"
end
end

context "でめ" do
it do
demes = [2,2,1]
expect(game.assert(demes)).to eq "deme1"
end
end

end
end

0 comments on commit 099106e

Please sign in to comment.