



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An assignment for implementing new character classes for a turn-based rpg game. The game is a fight between two teams of adventurers, each with different types of characters (fighter, mage, berserker, archmage, and necromancer). The assignment requires the implementation of three new classes (berserker, archmage, and necromancer) using inheritance, while maintaining the existing fighter and mage classes. The document also includes details about the battle system, character statistics, and specific abilities for each class. The goal is to create a functional game engine by adding the new classes to the provided characters.py file.
Typology: Slides
1 / 5
This page cannot be seen from the preview
Don't miss anything!




We play a lot of RPG games nowadays like Final Fantasy, World of Warcrafts or DOTA. In this assignment, you are going to implement the characters for a turn-based RPG.
(If you are not familiar with turn-based RPG, please google or reference to this: https://www.gamasutra.com/blogs/FelipePepe/20170922/305783/The_Art_of_TurnBased_RPGs_I_Menubased_bat tles.php)
The game is a fight between two teams of adventurers formed by different types of characters (the jargon should be “classes” but I do not want to be confused with the “class” in Python). You are given a battle system that can let two teams fight each other until one team won by destroying all the characters in the other team. The good thing is that, the battle system is already implemented for you. You only have to implement some new types of characters. You can choose to run the file battle.py to start the game and try it out.
Game System
Battle System
A typical start of the battle is shown in the next page. And the file “sample gameply.txt” stores the log of a full battle for you to reference to.
Round 1 Team A: Members: | Fighter| Mage|Necromancer| Fighter Hitpoints: | 1200| 800| 800| 1200 Strength: | 100| | | 100 Max. Mana: | | 50| 50| Currnet M: | | 50| 50|
Team B: Members: | ArchMage| Berserker Hitpoints: | 800| 1200 Strength: | | 100 Max. Mana: | 50| Currnet M: | 50|
Team A member 0 Fighter acts Hurt enemy 1 by damage 100. Berserker hurt with remaining hp 1100.
Team A: Members: | Fighter| Mage|Necromancer| Fighter Hitpoints: | 1200| 800| 800| 1200 Strength: | 100| | | 100 Max. Mana: | | 50| 50| Currnet M: | | 50| 50|
Team B: Members: | ArchMage| Berserker Hitpoints: | 800| 1100 Strength: | | 100 Max. Mana: | 50| Currnet M: | 50|
Team B member 0 ArchMage acts Strike enemy 3 with spell Fighter hurt with remaining hp 800.
Round 2 Team A: Members: | Fighter| Mage|Necromancer| Fighter Hitpoints: | 1200| 800| 800| 800 Strength: | 100| | | 100 Max. Mana: | | 50| 50| Currnet M: | | 50| 50|
Team B: Members: | ArchMage| Berserker Hitpoints: | 800| 1100 Strength: | | 100 Max. Mana: | 50| Currnet M: | 30 |
Team A member 0 Fighter acts Hurt enemy 0 by damage 100. ArchMage hurt with remaining hp 700. (and the battle goes on….)
Your job is to implement the three remaining classes with inheritance. You are given three files:
characters.py
This is the major file you have to add your code. The two base classes of Fighter and Mage are implemented for you. If you read the code, you noticed that they are two sub-classes of the class Character.
You will notice there is a function dprint() and every output line is using that instead of print(), in which, it’s controlled by the variable printActionDescription. If it’s True, their actions will be printed or silence otherwise. You should add your classes as an inheritance of the classes Fighter and Mage WITHOUT changing the two base classes. Namely, you should only ADD code to this file instead of changing anything (other than the variable printActionDescription for your own testing.)
battle.py
This is where the “game engine” is. Basically, the whole system is implemented for you and you do not have to do any big changes. The changes you need to do should be:
team.py
You should not change this file. But you should read the implementation because the helper functions will be useful to you.
You should only copy and paste the classes for the three new characters into coursemology from the file characters.py. And there will be no testing feedback for you because the game is random.
I guess the assignment is hard enough but please try the following. (However, it’s only for fun.)
If you are really the designer for a game, you want to know what is the best formation of your team. Is it better to use a team of Fighters or Mage, or some combinations of both? Design some experiment/code/testing to find out the best few teams (e.g. the first 5 best teams) for a certain gold allowance. For example, if you have 600 gold, what is the best team? You should be able to find out the best team for more gold, e.g. 1200 gold
Add two of the following classes:
Or some other classes of your own design! But they must be complicated enough. Requirements are, one class must use multiple inheritance and the other needs some non-trivial modification of a certain base class. Or polymorphism. You can consult me before you do it.
So far, it does not matter for a character in any “position” in the team. The more interesting way to do it is to divide the team into the front row and the back row as a formation (or more rows?!). Impose some rules based on the roll, e.g. a fighter can attack only if he is at the front row and he can attack an enemy on the front row only, unless the whole front roll of his enemy team died, but a Mage type of character can attack any row of his enemy. (Or you can design a class called Archer as a Fighter who can attack from the back roll.)