-
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?
Conversation
@@ -6,6 +6,15 @@ | |||
puts "What is your second fighter's name?" | |||
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)) do |
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.
This would be extremely difficult to full off -- you'd need to have a block on initialize ("new").
But, instead, I think you want "tap" here .... think of tap like this:
class Thermometer
attr_accessor :temp
end
gauge = Thermometer.new.tap{|t| t.temp = 95}
# OR
gauge = Thermometer.new.tap do |t|
t.temp = 95
end
gauge.temp
=> 95
tldr: match = Match.new(Fighter.new(fighter_a), Fighter.new(fighter_b)).tap |match| do
Not sure what you meant by "Move ranking" -- can you expand? |
Almost done on the Panda level but running into an undefined local variable for "fighter_a". Yeah I am a little confused with the Tiger level question:
|
In https://github.com/RubyoffRails/Episode2/blob/master/lib/turn.rb there's this code: def determine_winner
[@move_a, @move_b].sample
end This just gets a random move between a and b. Instead, it should determine based on the move's ranking: class Move
attr_reader :type, :ranking
def initialize(type)
@type = type
@ranking = rand(100)
end
end So the ranking is just random. Instead, decide on what |
Okay things are a little more clear. What would be a good way to generate a random move now? |
|
||
match = Match.new(Fighter.new(@fighter_a), Fighter.new(@fighter_b)) do | ||
3.times.map do | ||
match = Match.new |
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.
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,.
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.
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 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
- 3.times.map do
match = Match.new
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?
Reply to this email directly or view it on GitHub:
https://github.com/RubyoffRails/Episode2/pull/13/files#r8322165
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'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?
leg_sweep = 60 | ||
end | ||
|
||
def moves |
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
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
Submitting a pull request would not even be a good avenue because I do not believe I understood this assignment. However, it gives the ability for you to see what I have so far. What do I need to go over if these are my questions: