You are on page 1of 8

ELEMENTAL FORCE XXX

A self-made python game


[CASE STUDY]

CONTENT

1. Introduction

2. Aim

3. Description of the game

4. Classes of the program used

5. Output

Submitted by Solanki Sarkar


Introduction
This case study deals with the development of a game called
Elemental Force XXX. It is a text based 2 player game where
players can choose to input any of the elements given in the
list of elements present to them

Each player will have their own Hp (Health Points) bar and a
set number of turns. This game is supposed to be a fusion of
RPG games (where HP bar is crucial to the player) and turn
based games (where coming up with strategies to get extra
turns ensures victory).

The goal is to deplete the opponent’s Hp bar to 0 or attain a


total of 10 turns.
Whichever player satisfies the goal wins the game

Aim
Similar to the game Tic-Tac-Toe, where putting marks in
certain boxes increases chances of winning, this game is
aimed at building the strategic mindset of players
Planning out whether to inflict damage onto the opponent
a.k.a. the proactive method will ensure a faster yet a reckless
win or else to play the defensive method, increasing the turns
while stacking hp of the player in question.
Description of the game
The game first asks the two players to input their respective
aliases. Then it will generate a list t of elements for each of
the players to use. The list contains a total of 6 elements-
Fire, Water, Wind, Ice, Quantum and Imaginary (each with
their respective function).
Fire- Decreases the hp of the opponent player
Water -Increases the hp of the Player in question
Ice- Decreases the turns of the opponent
Wind- Increases the turns of the player
Quantum- Adds an extra Element in the player’s set
Imaginary- Deletes an element from the opponent’s set
After the game comes to an end, the winner is declared, with
the screen returning to the menu option allowing the players
to exit or start again.

Classes of the program


This program is a simple text-based game where two players
battle using different elements. Let's discuss the classes used
in this program and their functionalities:

1. **Game Runtime Class**:


- This class handles the runtime logic of the game. It
contains methods that handle various aspects of the game
such as damage dealing, turn management, health point (HP)
management, and element manipulation.
- `action phase (self, p_id)`: This method takes the player ID
(`p_id`) as an argument and processes the chosen action
based on the player's input. The actions include elements like
"fire," "water," "wind," etc. Depending on the action and
player ID, different effects are applied such as dealing
damage, increasing HP, or modifying turns.
- `damage_dealer_p1(self)`, `damage_dealer_p2(self)`:
These methods simulate the damage dealing mechanism for
player 1 and player 2, respectively. They deduct a random
amount of damage from the opponent's HP.
- `turns_increase (self, pl_id) `, `turns_decrease (self, pl_id)`:
These methods adjust the number of turns a player has. They
increase or decrease the number of turns based on the
player's ID.
- `hp_increase_p1(self)`, `hp_increase_p2(self)`: These
methods increase the HP of player 1 and player 2,
respectively, based on certain conditions.
- `add_element (self, pl_id)`, `remove_element(self, pl_id)`:
These methods allow players to add or remove elements
from their set of available elements.
2. **MainGameProcess Class**:
- This class is derived from the `Cmd` module, which
provides a framework for building interactive command-line
applications.
- The class is responsible for managing the main game
process, handling commands like starting the game, exiting,
and refreshing the screen.
- `do_welcome_message(self, inp: None)`: This method
displays a welcome message and instructions for starting or
exiting the game.
- `do_exit(self, inp)`: This method exits the game.
- `do_refresh_screen(self, inp: None)`: This method
refreshes the main menu screen with the welcome message.
- `do_start(self, inp: None)`: This method starts the game. It
prompts players for their names, randomly assigns available
elements to each player, and initiates the gameplay loop.
- The gameplay loop alternates between players, allowing
them to choose actions and updating the game status until
one player's HP reaches 0 or one player's turns exceed a limit.
- After the loop ends, the winner is determined based on
the final game conditions.

The program ends by creating an instance of the


`MainGameProcess` class and invoking the `cmdloop()`
method, which starts an interactive command-line interface
for the player to interact with the game.
Overall, the program demonstrates a simple turn-based
battle game where players select actions representing
different elements, manage their HP and turns, and compete
until one player wins.

Code
Output

You might also like