1. Dragon (version alpha)
1.1. About
Assignment: Dragon (version alpha)
Complexity: medium
Lines of code: 100 lines
Time: 89 min, then 144 min live coding with instructor
Warning: Don't delete code, assignment will be continued

Figure 1.15. Firkraag dragon from game Baldur's Gate II: Shadows of Amn
1.2. English
Create class representing Dragon
- Dragon has (attributes):
name
position on the screen
texture file name, default img/dragon/alive.png
health points, default random int in range from 50 to 100
- Dragon can (methods):
have position set to any place on the screen
make damage in range from 5 to 20
take damage
move in any direction by specified value
- Assume left-top screen corner as an initial coordinates position:
going right add to x
going left subtract from x
going up subtract from y
going down add to y
- When health points drop to, and below zero:
Dragon is dead
Set object status to dead
Print XXX is dead, where XXX is the name of the dragon
Change texture file name to img/dragon/dead.png
Print position where dragon died
Print how much gold Dragon dropped (random in range from 1 to 100)
Dragon cannot take any more damage
Dragon cannot make any more damage
Dragon cannot move or have position set
- Run the game:
Create dragon at x=50, y=120 position and name it "Wawelski"
Set new position to x=10, y=20
Move dragon left by 10 and down by 20
Move dragon left by 10 and right by 15
Move dragon right by 15 and up by 5
Move dragon down by 5
Dragon makes damage
Make 10 points damage to the dragon
Make 5 points damage to the dragon
Make 3 points damage to the dragon
Make 2 points damage to the dragon
Make 15 points damage to the dragon
Make 25 points damage to the dragon
Make 75 points damage to the dragon
- Non-functional requirements:
This assignment is a simulation of development process
Trainer acts as Product Owner with little technical knowledge
You are the software engineer who need to decide and live with consequences of your choices
Task is a narrative story telling to demonstrate OOP and good engineering practices
Calculated last position of the game should be x=20, y=40
You can introduce new fields, methods, functions, variables, constants, classes, objects, whatever you want
Don't use modules form outside the Python Standard Library
Task is business requirement specification, not a technical documentation, i.e., "what Dragon has to do, not how to do it"
You don't have to keep order of specification while writing code
This is alpha version, so no new functionality like negative position checking etc.
l. You can create tests, i.e.: unittest, doctest k. Do not read solution or any future iterations of this exercise;
if you read future tasks, you will spoil fun and learning
1.3. Polish
Stwórz klasę reprezentującą Smoka
- Smok ma (atrybuty):
nazwę
pozycję na ekranie
nazwę pliku tekstury, domyślnie img/dragon/alive.png
punkty życia, domyślnie losowy int z zakresu od 50 do 100
- Smok może (metody):
być ustawiony w dowolne miejsce ekranu
zadawać komuś losowe obrażenia z przedziału od 5 do 20
otrzymywać obrażenia
być przesuwany o zadaną liczbę punktów w którymś z kierunków
- Przyjmij górny lewy róg ekranu za punkt początkowy:
idąc w prawo dodajesz x
idąc w lewo odejmujesz x
idąc w górę odejmujesz y
idąc w dół dodajesz y
- Kiedy punkty życia Smoka spadną do lub poniżej zera:
Smok jest martwy
Ustaw status obiektu na dead
Wypisz napis XXX is dead gdzie XXX to nazwa smoka
Zmień nazwę pliku tekstury na img/dragon/dead.png
Wypisz, pozycję gdzie smok zginął
Wypisz, ile złota smok wyrzucił (losowa 1-100)
Nie można zadawać mu obrażeń
Smok nie może zadawać obrażeń
Smok nie może się poruszać
- Przeprowadź grę:
Stwórz smoka w pozycji x=50, y=120 i nazwij go "Wawelski"
Ustaw nową pozycję na x=10, y=20
Przesuń smoka w lewo o 10 i w dół o 20
Przesuń smoka w lewo o 10 i w prawo o 15
Przesuń smoka w prawo o 15 i w górę o 5
Przesuń smoka w dół o 5
Smok zadaje obrażenia
Zadaj 10 obrażeń smokowi
Zadaj 5 obrażeń smokowi
Zadaj 3 obrażeń smokowi
Zadaj 2 obrażeń smokowi
Zadaj 15 obrażeń smokowi
Zadaj 25 obrażeń smokowi
Zadaj 75 obrażeń smokowi
- Wymagania niefunkcjonalne:
Zadanie jest symulacją procesu developmentu
Trener zachowuje się jak Product Owner z niewielką techniczną wiedzą
Ty jesteś inżynierem oprogramowania, który musi podejmować decyzje i ponosić ich konsekwencje
Zadanie jest tylko narracją do demonstracji OOP i dobrych praktyk programowania
Wyliczona pozycja Smoka na końcu gry powinna być x=20, y=40
Możesz wprowadzać dodatkowe pola, metody, funkcje, zmienne, stałe, klasy, obiekty, co tylko chcesz
Nie korzystaj z modułów spoza standardowej biblioteki
Zadanie jest specyfikacją wymagań biznesowych, a nie dokumentacją techniczną, tj. "co Smok ma robić, a nie jak to ma robić"
Nie musisz trzymać się kolejności punktów i podpunktów w zadaniu
Jest to wersja alpha więc bez dodatkowych funkcjonalności (np. sprawdzanie koordynatów, wychodzenia poza planszę itp.)
Możesz stworzyć testy, np. unittest lub doctest
Nie przeglądaj rozwiązań ani treści kolejnych części zadania; jeżeli zaglądniesz w przód, to zepsujesz sobie zabawę i naukę
1.4. Solution
EN: Note, that this will spoil your fun and learning
PL: Zwróć uwagę, że to zepsuje Twoją zabawę i naukę