On Jul 18, 2012, at 4:46 PM, William Squires <wsqui...@satx.rr.com> wrote:

> For example, an effect could be called "fireball" and do 1d6 HP to a player 
> caught in the blast radius. My 'effect' class has an @property of type 
> NSMutableArray (which holds 'codons' in NSStrings) of the form:
> 
> <keypath><assignment operator><value>
> 
> and the parser will check the <assignment> for '=', '+=', '-=', '*=' and 
> '/=', evaluate the <value> portion, and pass those on to the player object 
> via valueForKey: (to get the property's initial value before the assignment, 
> and setValue:forKey: to set the new value.

This sounds kind of like a rule system, like WebObjects used to include in 
DirectToWeb (D2W), as a feature atop KVC and EOQualifier.

Rather than using strings you need to parse as your model for something like 
this, things will be easier if you use a distinct class.

For example, you could create a class that has a key path and an NSExpression 
used to generate a value based on parameters passed in (such as the original 
value at the key path). Then not only do you not have to do the parsing, you 
also get more features "free" because you can use everything NSExpression 
provides.

  -- Chris

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to