top of page

Code Detail (Card Effects)

For the card effects of C​loud Citadel, I've plan to use decorator design pattern to implement the card effects as all the card effects will share some variables such as range, damage and others variable. Thus, using decorator pattern can make the child classes inherit from a same base class which also having their execute function to use different effects. 

​

EffectParent.png

Parent Class

The parent class will have commonly shared variables that can be used by the child classes such as damage, range, grid and card reference. The Activate Effect and Range function can be overridden by the child classes as each card have their own effect that can be used. The Destroy Range function is implemented directly as it is universally shared which will destroy all the range spawn. 

Strike.png

Strike Child Class

The strike child class has the effect to attack the enemy in front of the player. From effect range function, the range prefab will spawn at the position of grid in front of player using get world position of grid. When its effect is activated, it will check if there is any unit standing at the targeted grid. If there is unit standing, the damage will be dealt to the enemy. 

Slam1.png
Slam2.png
Slam3.png

Slam Child Class

The slam child class has the effect to hit the enemy in front of player and knock back the enemy one space. Since its range is also 1, the effect range will be same as Strike.  The activate effect function of slam will first check if the there is enemy available at the targeted grid in order to execute the effect. It will deal damage to the enemy first. After that, it will check if the space at back of enemy is available or not, if it is available, it will knock the enemy back to that space by setting the enemy path to that grid. As Slam consume Action Points, it will also deduct the player AP at last. 

 

Above are some of the examples of child classes that shares the same parent class but can execute various different effects based on what is overridden inside ActivateEffect function.

© 2019 by Poh Hao Bing. 

bottom of page