-
Notifications
You must be signed in to change notification settings - Fork 11
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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]
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
There was a problem hiding this comment.
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
Later, when you need to randomly pick one of those? A hash can turn into an array
Try it out: http://rubyfiddle.com/riddles/d041c