-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbattle.py
More file actions
46 lines (32 loc) · 1.08 KB
/
battle.py
File metadata and controls
46 lines (32 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python3
from ex0 import CreatureFactory, FlameFactory, AquaFactory
def test_factory(factory: CreatureFactory) -> None:
"""Test a factory by creating and using both family creatures."""
print("Testing factory")
base1 = factory.create_base()
print(base1.describe())
print(base1.attack())
evolved1 = factory.create_evolved()
print(evolved1.describe())
print(evolved1.attack())
print()
def battle(factory1: CreatureFactory, factory2: CreatureFactory) -> None:
"""Make the base creatures of two factories fight."""
print("Testing battle")
base1 = factory1.create_base()
base2 = factory2.create_base()
print(f"{base1.describe()}")
print(" vs.")
print(f"{base2.describe()}")
print(" fight!")
print(f"{base1.attack()}")
print(f"{base2.attack()}")
def main() -> None:
"""Run the test scenario for both factories and their battle from ex0."""
flame = FlameFactory()
aqua = AquaFactory()
test_factory(flame)
test_factory(aqua)
battle(flame, aqua)
if __name__ == "__main__":
main()