TStand90 / roguelike_tutorial_revised

The python libtcod roguelike tutorial, with good coding practices kept in mind from the beginning.
97 stars 28 forks source link

code does not set previous.ai = current.ai at any place #5

Open kd8qdz opened 6 years ago

kd8qdz commented 6 years ago

causing a crash when the confuse spell expires.

mgedmin commented 5 years ago

That is no longer a problem: http://rogueliketutorials.com/tutorials/tcod/part-9/ sets previous_ai in the ConfusedMonster.__init__:

class ConfusedMonster:
    def __init__(self, previous_ai, number_of_turns=10):
        self.previous_ai = previous_ai
        self.number_of_turns = number_of_turns

and then when the component is created, the old entity.ai is passed as the argument

            confused_ai = ConfusedMonster(entity.ai, 10)
            confused_ai.owner = entity
            entity.ai = confused_ai