IRC channel logs

2018-05-12.log

back to list of logs

<lyr3>-
***Raimondii is now known as Raimondi
<manumanumanu>ahoy hoy
<lispmacs>does goops have some trick or mechanism to override a method for a single specific instance of a class
<lispmacs>like, if I had instance `monster` of class <orc>, and (move monster) normally had a certain effect, but somebody put a spell on monster causing (move monster) to have a different effect (e.g., moves randomly or can't move, etc.)
<lispmacs>i could see how I could accomplish that with having all methods check first for a slot with an override procedure, maybe that is the way, but maybe there is something cleaner?
<amz3`>lispmacs: isn't the <orc> mutated by the <effect> ?
<amz3`>then the move method can take into account the effects
<amz3`>lispmacs: seemms like you want is to monkeypatch the object? isn'nt it?
<lispmacs>amz3`: so, I was hoping for some way that I could have effects that I didn't have to code into the base class
<amz3`>hmm
<lispmacs>like, currently, to put a spell on orc that slows him down for x period of time
<amz3`>what do the effect do?
<amz3`>hmm
<lispmacs>I have to have code slots in orc
<amz3`>ok
<lispmacs>that keep track of how long the spell is in effect
<amz3`>hmm...
<amz3`>well, first monkeypatching is not the way to go...
<amz3`>I think... it's rarely does
<lispmacs>by the time you get a dozen effects, then you have this monstrously large class
<amz3`>I get it
<amz3`>especially since, each effect can have different consequences on different methods
<amz3`>well, I am thinking about combinators somehow, but not sure how to apply it in the current context
<amz3`>lispmacs: can you list a few spells and their effect, maybe it will be of inspiration?
<lispmacs>i made that up as an example. In my actual game, I have multiple enemy types (soldier, tank, boat, etc) which all can be hit by a "slow down" bullet which causes them to move at half speed
<lispmacs>however, effect is only temporary, a certain number of seconds, depending on exact level of slow bullet tower
<lispmacs>(tower defense game)
<lispmacs>to make it happen, I had to code slots into <enemy> class that keep track of whether or not a enemy has been hit by such a bullet
<lispmacs>and how much longer the effect is supposed to last