Post by satori on Apr 28, 2006 3:41:44 GMT
This is where I am working on logical branching and resolutions.
Most of this will be in psuedo-code, so most any programmer should be able to follow along. I will predeclare funcions in the following format:
<return value> Name(<arg1>, <arg2>, <argn>) ;
As Turbo Pascal and C were my first 'real' languages to learn (Apple/Com64 BASIC don't count)
Basic breakdown:
Main function = Ouresmost controlling script
Pageview = Takes over control when you turn to a new page.
Pageview is the one I want to look at for now, as it's alittle more abstract than the pscode below.
1) Page loads
2) relevant data is stored into the player array, so the player array knows what pages have been visited (cleared on death or book restart)
2) The page has a list of all the actions that occur in the page.
3) Each action is worked though in the order they occur in the page. Before each stage starts, the 'activity button' will change appearance to reflect the type of action you are about to encounter. A simple take 2 EN loss that allows you no preventable choice will simply deduct the EN, which will be shown in the GUI area showing current page progess. Now if the EN drop takes you to 0 or less, you die, but before you are totally killed, you can still read whatever was on the current page and page logs untill you accept death.
4) When you hit the activity button, you will begin that current action phase (combat, trading, items found, items lost)
5) When each action is done, the activity button will change to shown the next action in the page, waiting for you to select it to begin the next action.
6) This repeats untill you fail to compleate all actions on a page, such as dying in combat, taking to mush EN damage in a section, etc... Usually you die or are forced to turn to a specific section.
7) The valid 'turn to page' options will be shown in the lower left corner of the GUI. Please not that in some cases a random number roll will take you directly to a new pagebranch. This will automatically skip any action further down the page's timeline, and only that option will be able to be selected for traversal to the next section. The same may be true for certain items/disciplines, but I'm not sure yet.
8) reload with the new page as specified from the above code.
The majority of the subfunctions (listed in the reply post) will be able to call themselves to handge odd rule combinations. This means once the correct action is started (as listed in the Page's table) they are capable of self resolving complex calls to them selves (recursion) and other functions before sptting out the correct return values.
w functions.
That last part might sound very bizzare, but I'm designing the code in a few levels.
Level 1 is the GUI and PA text incorporation. Basically the wrapper.
Level 2 isPageview, the highest level block of controll code, handling how to navigate each element in a page, as well as keeping track of passive effects. It also contains branchings for function calling to resolves these events.
Level 3 Is the muscle of the functions. This is where stats, items, and other things that have a direct effect on the player are resolved. In most (not all) access is being made directly to the player's MySql table. These funtions also will call eachother, based on the complex result sought.
Exaple of level 3
You can a random, if X is rolled, take X en damage, and then based on that damge, turn to a certain section. The random would be called with branching for possible roll mods (passed to random by Pageview from the page's table.)
Whenever varius level 3s function are calling themselves or others, there is never any values returned , simply effects applied diectly to the tables, 'turn to page' entries add to the possible choice at the end off the page.
Basically lvl3 functions (EXCLUDING meal, inventory , meal, die, and combat) return either 1 or more valid 'turn to page' option, or no valid 'turn to page' options, and simply have a game effect.
Most of this will be in psuedo-code, so most any programmer should be able to follow along. I will predeclare funcions in the following format:
<return value> Name(<arg1>, <arg2>, <argn>) ;
As Turbo Pascal and C were my first 'real' languages to learn (Apple/Com64 BASIC don't count)
Basic breakdown:
Main function = Ouresmost controlling script
Pageview = Takes over control when you turn to a new page.
Pageview is the one I want to look at for now, as it's alittle more abstract than the pscode below.
1) Page loads
2) relevant data is stored into the player array, so the player array knows what pages have been visited (cleared on death or book restart)
2) The page has a list of all the actions that occur in the page.
3) Each action is worked though in the order they occur in the page. Before each stage starts, the 'activity button' will change appearance to reflect the type of action you are about to encounter. A simple take 2 EN loss that allows you no preventable choice will simply deduct the EN, which will be shown in the GUI area showing current page progess. Now if the EN drop takes you to 0 or less, you die, but before you are totally killed, you can still read whatever was on the current page and page logs untill you accept death.
4) When you hit the activity button, you will begin that current action phase (combat, trading, items found, items lost)
5) When each action is done, the activity button will change to shown the next action in the page, waiting for you to select it to begin the next action.
6) This repeats untill you fail to compleate all actions on a page, such as dying in combat, taking to mush EN damage in a section, etc... Usually you die or are forced to turn to a specific section.
7) The valid 'turn to page' options will be shown in the lower left corner of the GUI. Please not that in some cases a random number roll will take you directly to a new pagebranch. This will automatically skip any action further down the page's timeline, and only that option will be able to be selected for traversal to the next section. The same may be true for certain items/disciplines, but I'm not sure yet.
8) reload with the new page as specified from the above code.
The majority of the subfunctions (listed in the reply post) will be able to call themselves to handge odd rule combinations. This means once the correct action is started (as listed in the Page's table) they are capable of self resolving complex calls to them selves (recursion) and other functions before sptting out the correct return values.
w functions.
That last part might sound very bizzare, but I'm designing the code in a few levels.
Level 1 is the GUI and PA text incorporation. Basically the wrapper.
Level 2 isPageview, the highest level block of controll code, handling how to navigate each element in a page, as well as keeping track of passive effects. It also contains branchings for function calling to resolves these events.
Level 3 Is the muscle of the functions. This is where stats, items, and other things that have a direct effect on the player are resolved. In most (not all) access is being made directly to the player's MySql table. These funtions also will call eachother, based on the complex result sought.
Exaple of level 3
You can a random, if X is rolled, take X en damage, and then based on that damge, turn to a certain section. The random would be called with branching for possible roll mods (passed to random by Pageview from the page's table.)
Whenever varius level 3s function are calling themselves or others, there is never any values returned , simply effects applied diectly to the tables, 'turn to page' entries add to the possible choice at the end off the page.
Basically lvl3 functions (EXCLUDING meal, inventory , meal, die, and combat) return either 1 or more valid 'turn to page' option, or no valid 'turn to page' options, and simply have a game effect.