elthran / RPG-Game

0 stars 1 forks source link

Endurance needs to be brought in #259

Open elthran opened 6 years ago

elthran commented 6 years ago

You should spend 1 Endurance point each time you move anywhere on the world map. If you have no endurance left, you should not be allowed to wander the map. Also, death should cost all of your endurance. Your Endurance should recover once every 10 minutes for now.

elthran commented 6 years ago

It's a bit complicated and I need your help. It should look something like this: coding_pic

What I mean by this is, if you are currently in a town type location and still are (as in you moved from the town bank to the town barracks), your endurance shouldn't change. Or if you moved from the entrance of the cave into the inside of the cave, it shouldn't use endurance.

But if you move from the town into the world map, then it should spend endurance. What might be an easier way is: If you move on the world map (as in between Location1 to Town) it should spend Endurance. But if you are moving within a location, it shouldnt spend endurance. But I can't differentiate that within your code. All moves seem to be treated equally. @klondikemarlen

klondikemarlen commented 6 years ago

I would create a separate class of actions. Make all locations that use endurance be in one @app.route() and all actions that don't use endurance can be spread out wherever.

Whenever you enter a location type that uses endurance (town, cave, map, explorable) it should deduct endurance. Or bounce you back if you have none.

I think the 'current_city' type variable might sort of work.

You would need to make a major hero variable that meant "the last location that you were in that decrements endurance". Whenever this changed you would do a check and decrement endurance.

I would 'hook' this into the 'hero.current_location' code. So that whenever your location changed it would update this variable if relevant. And update endurance OR throw an error.

klondikemarlen commented 6 years ago

So in summary:

  1. you probably need a new variable to track this (hero.local_zone?)
  2. you need an current_location hook.

    in game.py - Hero class

    @validates('current_location')
    def validate_current_location(self, key, location):
        """Updates value of current_city on assignment.
    
        If current_location is a city ... set value of current_city as well.
        If not remove the value of current_city.
        """
        if location.type in ("cave", "town"):
            self.current_city = location
        location_that_change_endurance = ['cave', 'town', 'explorable', 'map']  # etc.
        if location.type in locations_that_change_endurance:
            self.set_local_zone(location)
        return location
  3. Make local_zone throw an error and change endurance.
    def set_local_zone(self, location):
    if not self.endurance:
        raise Exception("You have no endurance so can't move to location {}".format (location.type))
    self.local_zone = location
    self.endurance -= 1