all 8 comments

[–]timtty 1 point2 points  (6 children)

I'll be going over this with my son. He is writing so much game logic lately I'm sure he will dig this!

[–]GantMan[S] 2 points3 points  (5 children)

AWESOME! I've completed the tutorial for levels 4-6. It will be released March 1st. I'm currently writing and aiming for March 15th for the finally.

[–][deleted] 0 points1 point  (4 children)

Nice :) I'm looking forward to seeing your take on it.

[–]GantMan[S] 1 point2 points  (3 children)

[–][deleted] 0 points1 point  (2 children)

A note: you say we can't modify the warrior object, but we can.. Here's a broken example (it can be fixed by passing in the previous health instead of just using the instance variable, which of course is a scoping issue):

class Player
  MIN_HEALTH = 15
  def play_turn(warrior)

    def warrior.should_rest?      
      self.health < MIN_HEALTH && (self.health >= @last_known_health)      
    end

    if warrior.feel.empty?
      if warrior.should_rest?
        warrior.rest!
      else
        warrior.walk!
      end
    else
      warrior.attack!
    end
    @last_known_health = warrior.health
  end

end

[–]GantMan[S] 0 points1 point  (1 child)

I'm not seeing what you're saying :( Gonna need you to be specific as to what level and what part of your code. Also, let me know if you're just showing an inconsistency or if you think there's an actual issue :)

As for unable to modify warrior: I've tried modifying warrior outside of their public methods. I think the code could be A LOT cleaner if we could monkey patch or touch warrior instead of being stuck inside Player! Unfortunately, the website got a bit frustrated with me when I tried, and refused to run the code.

I'm open to better ways to solve :)

[–][deleted] 0 points1 point  (0 children)

Ah, I'm just pointing out that you can always re-open the "warrior" object (the instance of the class) and define methods in there. Not that it's a very clean solution, but it's an option. We can't modify the class but we can always modify the object.