Re: developing a singular verses plural grammar system in your game

You can do this with something like jinja2 or any of the simpler templated languages, which offer a way to embed variables, etc, into strings.

But in practice, how most of the mud codebases I've looked at solve this is by having you define 3 strings: "You cast magic missile on other", "Player casts magic missile on you", "Player a casts magic missile on player b".  You give these to a function that dispatches to everyone in the room plus the source and target and/or targets of the action, and it figures out which variant to show.  You're not going to do much better than this, because if you try to work it out with variables and flags you're going to discover that it's not so easy.  If you integrated with Jinja2 or another templating library, the function could just be:

send_to(room, source, target,
    "You cast magic missile on {{target}}",
    "{{source}} casts magic missile on you",
    "{{source}} casts magic missile on {{target}}")

Where the variables are provided by the templating engine, and in fact are even able to be objects, i.e. you'd also have source.hp, etc, for free.



-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Zarvox via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : redfox via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : visualstudio via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : chrisnorman7 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : chrisnorman7 via Audiogames-reflector

Reply via email to