Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

PHP help?


ghost's Avatar
0 0

Well.. since I don't know squat about this, I figured I should just ask someone.

You see, there is this game I'm playing, it's text-based, and our admin is having some problems..

so instead of me just blabbering.. I figured I could ask you.

And the $1,000,000 question:

How to store the combat action results in such a way that their message, and effect are separate, so the effect can be altered later by bloodline / status effects, and can thereafter be merged with the message.

without requiring a separate function to contain all the messages (as is the case now) and maintaining a certain degree of efficiency and speed.

The splitting of message / effect is easy enough by using an array

[php] $actions[count($actions)][0] = 'This is an action message for in the battle log: {effect}'; $actions[count($actions) - 1][1] = 500; [/php]

however, such an "actions" array would have to be indexed for bloodline and status effects to know which parts of the array to alter.

thus creating a third field, or changing the index to be text, rather than numeric.

[php] $actions['damage'][0] = 'Sustained {effect} {element} damage'; $actions['damage'][1] = 500; $actions['damage'][2] = 'wind' [/php]

or

[php] $actions[count($actions)][0] = 'damage'; $actions[count($actions) - 1][1] = 'Sustained {effect} {element} damage'; $actions[count($actions) - 1][2] = 500; $actions[count($actions) - 1][3] = 'wind'; [/php]

Where the second one has the disadvantage of needing a loop, whereas the former would work without needing to loop over all the elements, thus making that preferred.