Recall Battling fighters and Lucky battling fighters, question 7ec8 and question 8d24 respectively. In question 8d24 you were asked to rewrite your Fighter class as LuckyFighter to incorporate the notion of luck.
This design choice forces all fighters to have the luck attribute, and to be equipped with a strategy for using luck in battles. We cannot easily mix fighters with luck with fighters without luck.
Your task now is to define LuckyFighter as a subclass of Fighter, extending a Fighter
with the luck and strategy attributes. You should design your classes so that it is possible to
create a Fighter and a LuckyFighter, and schedule a battle between them directly.
If Joe is a Fighter and Alex a LuckyFighter then a battle might look something like this:
At start of battle, stats are:
Joe - Human Warrior - skill: 16; stamina: 12
Alex - Defensive Elf Lord - skill: 18; stamina: 6; luck: 11
------------------------------
Joe hits Alex, stats are:
Alex tries to resist the damage...
Alex tests luck...
Alex is lucky!
The damage is partially resisted!
Joe - Human Warrior - skill: 16; stamina: 12
Alex - Defensive Elf Lord - skill: 18; stamina: 5; luck: 10
------------------------------
Joe draws with Alex
------------------------------
Alex hits Joe, stats are:
Joe - Human Warrior - skill: 16; stamina: 10
Alex - Defensive Elf Lord - skill: 18; stamina: 5; luck: 10
------------------------------
Alex hits Joe, stats are:
Joe - Human Warrior - skill: 16; stamina: 8
Alex - Defensive Elf Lord - skill: 18; stamina: 5; luck: 10
------------------------------
Alex hits Joe, stats are:
Joe - Human Warrior - skill: 16; stamina: 6
Alex - Defensive Elf Lord - skill: 18; stamina: 5; luck: 10
------------------------------
Joe hits Alex, stats are:
Alex tries to resist the damage...
Alex tests luck...
Alex is lucky!
The damage is partially resisted!
Joe - Human Warrior - skill: 16; stamina: 6
Alex - Defensive Elf Lord - skill: 18; stamina: 4; luck: 9
------------------------------
Alex hits Joe, stats are:
Joe - Human Warrior - skill: 16; stamina: 4
Alex - Defensive Elf Lord - skill: 18; stamina: 4; luck: 9
------------------------------
Alex hits Joe, stats are:
Joe - Human Warrior - skill: 16; stamina: 2
Alex - Defensive Elf Lord - skill: 18; stamina: 4; luck: 9
------------------------------
Joe hits Alex, stats are:
Alex tries to resist the damage...
Alex tests luck...
Alex is lucky!
The damage is partially resisted!
Joe - Human Warrior - skill: 16; stamina: 2
Alex - Defensive Elf Lord - skill: 18; stamina: 3; luck: 8
------------------------------
Alex hits Joe, stats are:
Joe - Human Warrior - skill: 16; stamina: 0
Alex - Defensive Elf Lord - skill: 18; stamina: 3; luck: 8
------------------------------
End of battle, Alex - Defensive Elf Lord - skill: 18; stamina: 3; luck: 8 wins!