|laziness, impatience, and hubris|
Modules: Building blocks for the Daft Adventureby Tiefling (Monk)
|on Jun 12, 2001 at 15:20 UTC||Need Help??|
Tiefling has asked for the wisdom of the Perl Monks concerning the following question:
Following my earlier request for assistance, I'm beginning to see the joined-up way of working that I need. It is my intention to produce modules performing the general functions of the RPG. (If possible, I'd like them to be called RPG, RPG::DND, etc.) Once I have the answer to this query, I'll go away and produce the RPG::Dice module which converts any die roll, expressed as a string ('3d6' for 'the sum of three normal dice', for example) to the appropriate set of rand calls and sends back an appropriate roll. (A side-effect of this will probably be simpler calls for specific things - such as a dice($n) call to roll an n-sided die.) This module will, naturally, be posted here at PerlMonks.
All well and good. The small problem here is that every discussion of modules which I've encountered either jumps in the deep end or assumes prior knowledge which I haven't got. So, I'm going to ask for help with a trivial case:
In Dungeons and Dragons Third Edition, all ability score modifiers are drawn from a single table. This table's values are trivial: given a score of n, the modifier is (n/2)-5. (ie: 8-9: -1; 10-11: 0; 12-13: +1). In the first shot at the character generator, I stupidly plugged these values into a list. Simpler, cleaner, and more transferable, I now realise, to call a function modifier($n) for an arbitrary value of $n. So:
(I hope that does what I said it did - I just wrote it on the fly.) The question is, how can I turn that into an element of the (as yet unwritten) Module RPG::DND, and how will the function then be called?
Thanks very much,
Tiefling, Known Lazy Bastard