Scenario Functions? Really?

Zechnophobe

Strategy Lich
Joined
Sep 1, 2006
Messages
1,867
Location
Goleta, California
Was just perusing the folders to see how the scenarios are set up, and noticed that there is a Scenario's Function python document... that contains all the functions for all the scenarios. I hate to say it, but I think this is part of the reason they are fairly buggy. It's extremely hard to figure out from the code what your scenario is doing, when the various scenario effects are all spliced together into big cludgy functions.

Make each scenario a class, and have each implement the same list of event functions. Then when the game starts, check just once if the current game is a scenario, and then assign to a variable a reference to the correct class.
 
I'd say this is very much a personal programmer's preference. Having each scenario as a separate class, maybe even a separate file, will not necessarily improve the code.

Without wanting to put myself in the place of the actual author, I can for example imagine that it's nice to have all the doTurnScenarioXYZ functions near each other, so that when you're coding the next one, you can have the previous one on screen for reference.
 
Think of it this way Falc, what if there are 4 different people trying to create scenarios? The current system would require that each person splice their code in with each other. It's a versioning nightmare because everyone is directly editing the same document.

My version has each person working out of a different document, meaning that the ScenarioFunctions.py never need be recompiled. When people talk about the open-closed principle of programming, this is pretty much it. The only thing we aren't getting around is that we still need to edit in the import and assignment of each type of Scenario (Something we could get around by dynamically checking for scenarios... but I think that's a bit over the top for this).

Also, for being able to compare code, realize that a single 'do turn' for a scenario is often more than a page anyway, and scrolling up and down is more work than just tabbing between windows. Sure, you could have two versions of the same document open more than once, but why not just have two different documents open. Then you are a window away from all other scenarios. Lastly, it is more likely you'll need to check up on code pertaining to the scenario you are editing than on other scenarios, and we have made that easy for the coder to parse.
 
Back
Top Bottom