Welcome, Guest. Please login or register.

Pages: [1]
Print
Author Topic: Q about console class and command handling implementation.  (Read 3346 times)
przemo_li
Community member

Posts: 15


View Profile Email
« on: March 16, 2010, 08:28:35 AM »

How console class works ?
Why commands are build into class code (and not as separate class) ?
Look at save function. Is return statement bug (cause it return result that may be uninitialized) ?
Why re (and not simple if x in dict:) ? And just cut name of command before calling function (so "save" have no need for doing the same re match again).
« Last Edit: March 16, 2010, 08:34:18 AM by przemo_li » Logged
b0rland
Community member

Posts: 105



View Profile Email
« Reply #1 on: March 16, 2010, 09:56:27 AM »

A general note. Since the project is in its early growing stage, the architecture is far from stable. This literally means: don't be surprised if you see any weird or crappy code. We're on the road to improving things and there's been a lot of cleanup done lately. But there's quite a lot of new code that hasn't been reviewed very closely. So all the improvement ideas are welcome. And if you feel you have the time and ability to fix things yourself, you can send in the patches. Those are welcome too Smiley

More to the point of console class. Yes, regexp manipulation isn't exactly perfect there, and your way is better. Do you think you can make a patch for that?

As for moving the commands into separate class(es), that might happen soon enough if we wish to achieve flexibility and ease of adding new commands. But I'd rather not hurry that up, at least until we have the stats and combat system in place. By that time we'll have a big list of commands we want the console to support. Then we can review the whole thing again and think of a better and more extensible architecture. Something along the lines of various classes registering command handlers with console and being called back by it when the command is executed.
Logged
przemo_li
Community member

Posts: 15


View Profile Email
« Reply #2 on: March 17, 2010, 06:53:49 PM »

My ideas are:
1) add command specific help: if "help something" is called help lists only "something" help

1) remove programming specific help form "commands", they duplicate "help", and say only save -> "implements save", etc.
2) remove stand alone help strings and use __doc__ instead
3) change re mathing to dict's native "if x in dict:", and use exceptions to show help

And I thing about adding ticket about reusing console commands (save and load) in game menu and|or removing any other implementations

What do you think ?
Logged
b0rland
Community member

Posts: 105



View Profile Email
« Reply #3 on: March 19, 2010, 09:12:48 AM »

Sounds very reasonable.
As for reusing console commands, I wouldn't do that directly. Rather I think both console commands and main menu postbacks should be basically one-line functions just calling a certain method from the controller (or from the class that implements actual saving/loading).
Logged
przemo_li
Community member

Posts: 15


View Profile Email
« Reply #4 on: March 19, 2010, 10:46:47 PM »

Created ticket and new thread dedicated my ideas about this code.
http://forums.parpg.net/index.php?topic=688.0
Logged
Pages: [1]
Print
Jump to: