Hi Jason, I forgot to mention that I use a
class library. I was hoping to be able to implement dragging within the class itself, but no luck. I put that on the back-burner for now while I just power through with implementing other features.
Game Phases
Draw Phase, Set Phase, etc. It results in a lot of if/then statements because certain actions can only be done during a certain phase.
Card Effects
Since my last message, for card effects I decided to ask my friend (he comes up with all the card info) to compile a master list of effect 'keywords' that exist in the game with a list of 'arguments' that the keywords affect. I wonder if this was what you meant by "rules" and "conditions".
For example, the keyword for a card whose effect is to "increase the strength of type X cards by amount Y" would be
increase. In the cards database (text file), my friend would put under 'keyword': 'increase' and under 'arguments': 'X,strength,Y'. I will write the functionality for increase.
Whenever the card's effect is activated in-game, call the function
run(keyword, arguments), which takes card.keyword and card.arguments and does an if/then matching for all the function-keywords to execute them manually.
Code: Select all
function run(keyword, arguments)
if keyword == 'increase' then
increase(arguments[1], arguments[2], arguments[3])
elseif keyword == ... then
...
end
end
For more complicated effects, the keyword is likely going to be something whose one argument is another keyword which would be called with
run. For example, if a card only activates
increase during a certain phase, instead of
increase its keyword would be something like
checkphase, which takes 'arguments' = 'phase,keyword,{arguments}...'.
Code: Select all
function run(keyword,arguments)
if keyword == 'checkphase' then
checkphase(arguments[1], arguments[2], arguments[3], arguments[4], arguments[5])
elseif keyword == 'increase' then
...
elseif
...
end
end
function checkphase(phase, keyword, argument1, argument2, ...)
if gamePhase == phase then
run(keyword, argument1, argument2, ...)
end
end
It's going to be time-consuming since I'd need to know all possible card effects and manually list the arguments, but it's the solution I have so far.
Player 2
I completely agree. I figured programming an AI would be whole endeavor in itself and it doesn't seem better than player vs. player to test my game's code so why bother. I am so far from finishing the basic game though, so I probably won't be looking into the Discord API for a long while haha.
Best of luck!