Great indeed. A bit of funky grammar, but meh.7 these are great lens
You need a stack. That's basically what you're describing with the array thing, but if PHP has a built-in stack library, that'd simplify things.19 so.....I finally made it so that cards can be effected by local effects (global effects are not yet tested).
However I taught of a nice problem that may very well occur.
Currently effects that will trigger other effects (which may or may not trigger other effects), will break everything and their dogs >_<
The reason is because I currently store the effect that is being executed in the card_interpreter object (to get around php being annoying), these values will get overwritten as soon as another effect gets executed (which also happens when effects chain together).
I know how to work around it, make an array that contains a list and let each time an effect gets executed add the needed data to this array. I do fear it will get messy very fast though and remove it from the list when it is done. That way the last entry in the list is the effect that is currently being executed (which also means I can have access to the parent effect of the effect that trigged the last effect in the list)
I won't change my code yet as implementing that will be a bitch I fear >_<
Unless I am missing something php only has arrays and objects as things that can store multiple kinds of data. However php is very nice and if you do the following25
You need a stack. That's basically what you're describing with the array thing, but if PHP has a built-in stack library, that'd simplify things.
Whenever something triggers or is cast, push it onto the stack. When it resolves, pop it back off.
$someArray=array("test","test2","test3");
unset($someArray[1]);//remove the second entry
echo $someArray[1]); //will crash due to the fact that it isn't set, in other words php doesn't automatically shift values, unlike some other languages.
How object-oriented is PHP? If you can do the same kinds of things that you do in Java, then you could define your own Stack class with the following fields and methods (I'm using Java type declaration syntax here because it's what I'm familiar with):26
Unless I am missing something php only has arrays and objects as things that can store multiple kinds of data. However php is very nice and if you do the following
PHP:$someArray=array("test","test2","test3"); unset($someArray[1]);//remove the second entry echo $someArray[1]); //will crash due to the fact that it isn't set, in other words php doesn't automatically shift values, unlike some other languages.
Adding things to the end of an array is easy just write $someArray[]="someValue". Its the getting the last one in the array that I am not sure about (Thus without using count() ). Then again, php even has a function build in to flip a string thus I am sure there is a way to get the last value in an array without using count