"If this goes on, we’ll simply kill each other, and there will be no winners - we’ll all lose." - reflected Sir Ronald, watching a bleak picture in front of him.
"I have to make an important decision. I know what it’ll cost, but now that’s the only thing that can save us all..."
A long time ago, when he was often in search of trouble and adventure, he went to hunt a witch who had a huge bounty on her head. The bloody creature was able to save her life by persuading the knight to take a gift from her - a vial of vampire blood. This blood poured into the dying man’s mouth could bring him back to life in vampire form.
Is it really the day when he has to use it?..
It seemed to be the only way to win this battle.
Sir Ronald began to lean over the barely living bodies of his knights, who were lying beside him. To each of them he said:
- "Drink. You’ll be given a new life..."
So we have 3 types of units: the Warrior, Knight and Defender. Let's make the battles even more epic and add another type - the Vampire!
Vampire should be the subclass of the Warrior class and have the additional vampirism parameter, which helps him to heal himself. When the Vampire hits the other unit, he restores his health by +50% of the dealt damage (enemy defense makes the dealt damage value lower).
The basic parameters of the Vampire:
health = 40
attack = 4
vampirism = 50%
You should store vampirism attribute as an integer (50 for 50%). It will be needed to make this solution evolutes to fit one of the next challenges of this saga.
chuck = Warrior() bruce = Warrior() carl = Knight() dave = Warrior() mark = Warrior() bob = Defender() mike = Knight() rog = Warrior() lancelot = Defender() eric = Vampire() adam = Vampire() richard = Defender() ogre = Warrior() fight(chuck, bruce) == True fight(dave, carl) == False chuck.is_alive == True bruce.is_alive == False carl.is_alive == True dave.is_alive == False fight(carl, mark) == False carl.is_alive == False fight(bob, mike) == False fight(lancelot, rog) == True fight(eric, richard) == False fight(ogre, adam) == True my_army = Army() my_army.add_units(Defender, 2) my_army.add_units(Vampire, 2) my_army.add_units(Warrior, 1) enemy_army = Army() enemy_army.add_units(Warrior, 2) enemy_army.add_units(Defender, 2) enemy_army.add_units(Vampire, 3) army_3 = Army() army_3.add_units(Warrior, 1) army_3.add_units(Defender, 4) army_4 = Army() army_4.add_units(Vampire, 3) army_4.add_units(Warrior, 2) battle = Battle() battle.fight(my_army, enemy_army) == False battle.fight(army_3, army_4) == True
Input: The warriors and armies.
Output: The result of the battle (True or False).
How it is used: For the computer games development.
Precondition: 4 types of units
CheckiO Extensions allow you to use local files to solve missions. More info in a blog post.
In order to install CheckiO client you'll need installed Python (version at least 3.8)
Install CheckiO Client first:
pip3 install checkio_client
Configure your tool
checkio --domain=py config --key=
Sync solutions into your local folder
(in beta testing) Launch local server so your browser can use it and sync solution between local file end extension on the fly. (doesn't work for safari)
checkio serv -d
Alternatevly, you can install Chrome extension or FF addon
checkio install-plugin --ff
checkio install-plugin --chromium