Card game : apply the good effect at the right sequence

Hi everybody
first sorry for my broken english,

I want to create a card game with python and i have some question about the game sequence.

I have created this class :

Class card with all necessary variables : name, life, initiative…, texteffects, effects

texteffects is in this class just a text description of the effect that card can have on the game sequence, effects is the name of the object defined in an other class : the class of the effect

so, each effect has his own class with the algorithmic definition of the effect

effect have an owner (the player who own (control) the card), sometimes a target (most of the time an opponement), a trigger (which time this effect would activating, testing), a duration (once per turn, once per game, permanent). Effect have a method in order to activate it or reset it

so i have a game sequence for example attack sequence with 5 steps : (this sequence is a class too, class attack and each sequence is a method of class object attack)

1 before attack

2 attack_roll

3 attack : hit

4 attack : miss

5 after attack

I want to test if one of my cards in game have a trigger on this sequence and if yes launch the method activate for example and the desactivate method at the end of the effect (with duration variable for example)

So true example :

Warrior1=cards(« Alexander »,8,4, « Kat : Your attacks deal +1 damage against warriors with more life than you. »,kat)

Object kat instance of Kat (the effects)


Warrior2=cards(« Leo »,9,2, « Mol : Once per round, after you deal damage to an enemy warrior, gain 1 life. »,mol)

Object kat instance of Kat (the effects)



attack1.before_attack() is there effect at this step => in this case no so Pass

attack1.attack_roll() is there effect at this step => in this case no so Pass

attack1.attack_hit() YES there is an effect happened : kat effect can activate here (we supose that attack hit) so i want to launch the activate method of Kat on kat who own warrior1. Activate method so answer true cause the condition is met : warrior2 have more life than warrior1)

I stop the example here but the sequence go on. My question is how can I dynamically call the method activate in the good sequence.

Probably obsviously for you but not for me If you can help me, I’ll be grateful ! and you can give me advice on the global approach of the project, maybe is not the good way to code it !

Thanks for help

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.