Re-factoring SpellAbilityAi
I am thinking of re-factoring canPlayAI() at least into a template pattern as there is a lot of duplicated code across the various implementations of SpellAbilityAi. For starters, it will have
1. check specific card AI
2. check AiLogic param
3. check extra cost (checkSacrifice/DiscardCost etc.)
4. check phase restriction logic (eg. instant draw-effects in opponent turn)
5. rest of logic
Having separate methods for each of the above steps to be overridden as required in the specific implementations should reduce the duplicated code and potential bugs (eg. r31202 where the AI will always discard to activate Stern Constable).
Would it be better to modify the abstract SpellAbilityAi.canPlayAI() directly or just extend it into a new class (eg. SpellAbilityAi2)?
1. check specific card AI
2. check AiLogic param
3. check extra cost (checkSacrifice/DiscardCost etc.)
4. check phase restriction logic (eg. instant draw-effects in opponent turn)
5. rest of logic
Having separate methods for each of the above steps to be overridden as required in the specific implementations should reduce the duplicated code and potential bugs (eg. r31202 where the AI will always discard to activate Stern Constable).
Would it be better to modify the abstract SpellAbilityAi.canPlayAI() directly or just extend it into a new class (eg. SpellAbilityAi2)?