wornBy: wearer
| strengthEffect intelligenceEffect |
super wornBy: wearer.
strengthEffect := Effect new.
strengthEffect
overrides: #strength;
effectBlock: [:baseValue | baseValue - 3];
duration: 5.
wearer addEffect: strengthEffect.
intelligenceEffect := Effect new.
intelligenceEffect
overrides: #intelligence;
effectBlock: [:baseValue | baseValue + 3];
duration: 5.
wearer addEffect: intelligenceEffect.
strength: baseStrength
^baseStrength + (self effectTarget intelligence * self effectPercentage / 100)
castOn: targetSo here we've got an effect which is hard-coded to connect strength to intelligence, but by a configurable amount. (Note that the effect's effectTarget property is set by the proxy as part of the addEffect: process).
| strengthEffect |
strengthEffect := StrengthIntelligenceLinkage new.
strengthEffect effectPercentage: 50.
target addEffect: strengthEffect
castOn: targetHere you'll note that the block being passed into the effect object contains a reference to the target variable - something that is in scope within the context of the spell's castOn: method, not a variable that the effect class itself is aware of. But the block executes happily because it remembers what context it was defined in.
| strengthEffect |
strengthEffect := Effect new.
strengthEffect overrides: #strength.
strengthEffect action:
[:baseStrength | baseStrength + (target intelligence * 0.5)]
Less facetiously, your suggestion might not sit will with Shasarak, because to implement your proposal one needs to know an awful lot again about what one can modify, which is exactly what he has been trying to avoid. So your suggestion would sit well in my camp, but really doesn't address Shasarak's goals here. I'm still curious to know how he'd handle all this in practice.
My opinions are also democratically elected.