For clarity i'd make another function (still pseudo):
Code:
function IsCountered(action, defence): boolean
result = true
if action = attack then
if (defence = magic) or (defence = attack) then
result = false
else if action = magic then
if (defence = magic) or (defence = block) then
result = false
else if (action = block) and (defence = attack) then
result = false
Main app:
player_attack_blocked = IsCountered(player_attack, mob_attack)
mob_attack_blocked = IsCountered(mob_attack, player_attack)
if not player_attack_blocked then
hit mob
if not mob_attack_blocked then
hit player
if player_attack_blocked and mob_attack_blocked then
draw
Bookmarks