简体   繁体   中英

Adding /Editing / Deleting existing code using an install script in PHP

I have wanted to create a PBBG creator. (Primarily text based games) However, I couldn't think of a system that efficiently allowed people to have the base code, then install modules into the game adding new features.

For example, the base code would consist of a simple home page and bare bones admin panel. Then you would install a registration module which would add new code and new database tables and a login module that would use the registration module's tables. Then from there you could install a Stats Module adding Health, Mana, etc., that would add more columns in the database for users. This would go on till you had a fully operating game made up of several different modules made by several different people.

What I want to know is if this idea is a good one. What are some issues that might appear? And how would I go about making it easy to add, edit, and delete code. Like if a Combat Module had a Module that modified the combat system, how would I go about determining what to change from an install script?

Also, are there any other open source projects using this system I can study to grasp the idea better.

I hope I explained everything well enough, if not please let me know so I can correct that. :)

Thanks!

It seems like you're describing code generation . If your question, then, is whether this is a good idea or not, code generation is a widely accepted "pattern" and should not be considered harmful.

Modifying existing generated code would increase complexity significantly, so what you probably want is some sort of intermediate representation of the code between when the user configures the PBBG and when it is generated. The intermediate representation should be a easily-modifiable full description of the system - modifying this would be a lot easier than writing a script to parse existing code and edit that.

Hope this helps, and good luck!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM