Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A lot of questions. need to go over it again #13

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/match.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ def initialize(opponent_a, opponent_b)
@opponent_a = opponent_a
@opponent_b = opponent_b
@turns = build_turns
@fighter_a = fighter_a
@fighter_b = fighter_b
end

def opponents
Expand Down
54 changes: 51 additions & 3 deletions superfight.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,58 @@


puts "What is your first fighter's name?"
fighter_a = $stdin.gets
@fighter_a = $stdin.gets
puts "What is your second fighter's name?"
fighter_b = $stdin.gets
@fighter_b = $stdin.gets

match = Match.new(Fighter.new(fighter_a), Fighter.new(fighter_b))
match = Match.new(Fighter.new(@fighter_a), Fighter.new(@fighter_b)).tap do
13.times.map do
match = Match.new
if @fighter_a.strike == turn.winner
puts "Fighter A -- #{@fighter_a.name} -- won"
else
puts "Fighter B -- #{@fighter_b.name} -- won"
end
end
end

puts "The winner of match is ....... #{match.winner.name}"

# Moving away from random winners

class Move

attr_reader :strike, :block, :leg_sweep

def initialize
@strike = strike
@block = block
@leg_sweep = leg_sweep
end

def values
strike = 50
block = 40
leg_sweep = 60
end

def moves
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can tell you're lost here.

So, first question: why are you not using the provided Move class? lib/move.rb

second, if you have some possible moves, it should look like

def possible_moves
  {strike: 50, block: 40, leg_sweep: 60}
end

Later, when you need to randomly pick one of those? A hash can turn into an array

Hash[possible_moves.to_a.sample(1)]

Try it out: http://rubyfiddle.com/riddles/d041c

move = Move.new
# test
move.values{strike: 50, block: 40, leg_sweep: 60}
puts moves.values.to_i

end
end

match = Match.new(Fighter.new(@fighter_a), Fighter.new(@fighter_b)) do
13.times.map do
match = Match.new
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A match should contain 13 rounds. Each round has a move by each player

Remember, when you puts "Fighter A -- #{@fighter_a.name} -- won" -- that should be a replay of the game's results. Not looping through and doing it,.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. what do you mean by replay instead of looping? do you mean that there should be a line where there is a rematch instead of spitting out the same result?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean that that I should be able to view the results, and then pass the match object to you, and then you view the same results. 

It means you have to store the rounds in an array for the match.

On Thu, Dec 12, 2013 at 7:41 PM, Mike Adeleke [email protected]
wrote:

  • def initialize
  •    @strike = strike
    
  •    @block = block
    
  •    @leg_sweep = leg_sweep
    
  • end
  • def moves
  •    strike = 50
    
  •    block = 40
    
  •    leg_sweep = 60
    
  • end
    +end

+match = Match.new(Fighter.new(@fighter_a), Fighter.new(@fighter_b)) do

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking, maybe I should make a new method called "rounds" that has an array. I also now have a "moves" method. I can call "values" on moves and pass in the values. Is that what you were thinking?

if @fighter_a.moves > @fighter_b.moves
puts "Fighter A -- #{@fighter_a.name} -- won"
else
puts "Fighter B -- #{@fighter_b.name} -- won"
end
end
end