0% found this document useful (0 votes)
3 views12 pages

Python 2

The Infinite Castle is a single-player adventure game where the player, as a Hashira, navigates through twelve rooms to find the Nichirin sword, defeat demons, save Nezuko, and destroy the Blue Spider Lily. Players start with a bag containing two poison potions and can collect items while exploring the castle, making strategic decisions about their inventory and movements. The game ends when the player successfully escapes with Nezuko after completing their objectives or is defeated by demons.

Uploaded by

nanikiken
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views12 pages

Python 2

The Infinite Castle is a single-player adventure game where the player, as a Hashira, navigates through twelve rooms to find the Nichirin sword, defeat demons, save Nezuko, and destroy the Blue Spider Lily. Players start with a bag containing two poison potions and can collect items while exploring the castle, making strategic decisions about their inventory and movements. The game ends when the player successfully escapes with Nezuko after completing their objectives or is defeated by demons.

Uploaded by

nanikiken
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

The Infinite Castle

Task 1
Specifications and outcomes
This is a single-player adventure game. At the start, the user is asked to create a
character name. The player plays the role of a Hashira who is mysteriously fallen into Muzan's
Infinite Castle. The game begins with the player having a bag which can stores 4 items and
already contains two poison potions.

Throughout the game, the player can explore twelve different rooms. Each room may
have demons, items, or clues. After each move, the game asks for the next action and shows
where the player is. For example, it might say, "You are in the Hall of Awakening." The player
can move by pressing D to go right, S to go back, A to go left, or W to move forward.

When an item is found, the system asks the player if they want to pick it up. If yes, the
item is placed inside the bag; if no, it remains there. Every item has a specific purpose, such as
a key to open Nezuko's room or the Nichirin sword for battling demons and destroying Blue
Spider Lily.

The goal of the game is to find the Nichirin sword, attack the demons, get the key, save
Nezuko, and finally destroy the Blue Spider Lily, and get out of the castle. The game must
include at least one class, use a list or set to store goods in the bag, and be either text-based or
graphical.

Success Criteria
 The game must have only one player.
 The game must ask for the player’s name at the beginning.
 The player must start with a bag that can store four items.
 At the start, there should be two poison potions in the bag.
 The player should be able to explore at least twelve rooms in the game.
 After every move, the game must show where the player is.
 The player has to choose whether or not to take an item when they find it.
 Each item needs to have its own unique description or purpose.
 Each item in the bag takes up one slot.
 The player can only carry a maximum of four items at the same time.
 The game must include the Nichirin sword, keys, and demons.
 If the player saves Nezuko, destroy the Blue Spider Lily, runs away from the Infinite
Castle and the game ends.

Storyline
This is an interactive adventure game where the player takes the role of a Hashira who
mysteriously falls into the Infinite Castle created by Muzan. Muzan, the lord of demon is seeking
the Blue Spider Lily, a rare flower that can grant him immortality. Nezuko has already found the
flower and hides somewhere deep inside the castle, protecting it from Muzan.

The player has a bag and can store 4 items in it and already store 2 poison potions to kill
the demons when the player goes into the wrong room before its Nichirin sword is found. At the
beginning, the player must find the Nichirin sword which can be used to kill the demons and to
destroy the Blue Spider Lily. By using that Nichirin sword, the player can enter the room and kill
the demons to find a key to open the room where Nezuko is waiting, destroy the Blue Spider Lily
and then find the escape room to complete the game. There are 12 positions in the game:(1)
Hall of awakening, (2) Secret lab, (3) Throne of castle, (4) Final gate, (5) Moon garden, (6)
Mirror maze, (7) Library, (8) Theater, (9), Sitting room, (10) Blood hall, (11) Crimson stage, (12)
Frozen room.

The following table summarizes the positions and their descriptions:

Positions Descriptions
Hall of awakening The spawn point where the player wakes up
inside the castle
Secret Lab The room where Nezuko is waiting the player
with the Blue Spider Lily, the player needs a
key to enter and to destroy the flower.
Throne of castle The room where Muzan exists, if the player
enters this room, Muzan, demon lord will kill
the player and the game is over.
Final gate Final room that the player can esacpe and
win the game.
Moon garden The room where the Nichirin sword is found,
the player needs the sword to kill demons
and to destroy Blue Spider Lily.
Mirror maze The room filled with mirror where the key for
the Secret lab exists.
Library A normal room filled with books.
Theater The player would be safe if it enters a room
like Theater because there are no demons in
it.
Sitting room The room where the map for the Infinite
Castle is found.
Blood hall The room where a demon is found and the
player needs the Nichirin sword or a poison
potion to defeat the demon.
Crimson stage If the player enters the Crimson stage without
Nichirin sword or a poison potion, the demon
from the room will kill the player and lose the
game.
Frozen room The room filled with ice and the player needs
to attack the demon inside with the Nichirin
sword and poison potion.

Data Structure
A list will store items collected in the bag. Details about the player, the character, and the
items will be kept in classes. The map and where things are connected will be shown using a
dictionary. Choices made at each spot will be handled by functions or classes.

Decomposition into subproblems


Subproblems Descriptions
Game start - Display the introduction
Create Player - Set player name and health
Create Inventory - Create a bag with limited space, already
contains two potions
Move Player - Allow movement (forward, backward, left,
right), updates player’s coordinate, show the
current room based on positions
Search Room - Find items, check which room the player is
in, battle with demons and item collection
Game Loop - Repeats player’s actions (move, search,
view, quit), end when player win, die or quit.
Player Class - Holds player’s data: name, health,
inventory, and direction.

Structure Diagram

Main Game

Game Set up[ Player Actions

Create Player Create Inventory Move Player Search

Room Coordinate Directions Find items Defeat demons

View Inventory Quit

Game Conditions

Health<=0 -> Game Enter wrong room->


over Game over

Save Nezuko+Destroy
Lily+Reach Final Gate-
> Win
Hall of Awakening

Blood Hall Library

Sitting Room Moon Garden Theater

Pseudocode

Frozen Room
Declarations

Name as string
Throne of Castle Crimson Stage Mirror Maze
Direction as string

Inventory as list
Secret Lab Final Gate
Inventory space as whole number

Current room as string

Health as whole number

Has sword as boolean

Has key as boolean

Saved Nezuko as boolean

Destroyed Lily as boolean

Rooms as list

Function game start

OUTPUT “Welcome Hashira”, Name,”!”

OUTPUT “You have fallen into Muzan’s Infinite Castle...”


OUTPUT “Muzan, the lord of demon is looking for Blue Spider Lily which can grant him
immortality”

OUTPUT “Find the Nichirin sword to defeat the demons, save Nezuko and destroy the
Blue Spider Lily!”

CREATE Rooms LIST: [ “Hall of Awakening”, “Secret Lab”, “Throne of Castle”, “Final
Gate”, “Moon Garden”, “Mirror Maze”, “Library”, “Theater”, “Sitting Room”, “Blood Hall”,
“Crimson Stage”, “Frozen Room”]

END FUNCTION

Function create player (Name)

OUTPUT “Enter your Hashira’s name:”

INPUT Name

OUTPUT “You are Hashira”,Name,”.”

SET Health = 100

SET Has sword = FALSE

SET Has key = FALSE

SET Saved Nezuko = FALSE

SET Destroyed Lily = FALSE

END FUNCTION

Function create inventory

SET Inventory space = 4

SET Inventory = [“Poison Potion”, “Poison Potion”]

OUTPUT “Your bag already contains two poison potions to defeat the demons before
you get the Nichirin sword”

END FUNCTION

Function move player

SET x = 0
SET y = 0

Rooms = [(0,0):”Hall of Awakening”, (10,0):”Blood Hall”, (-10,0):”Library”, (10,10):”Sitting


Room”, (0,10):”Moon Garden”, (-10,10):”Theater”, (-10,20):”Frozen Room”,
(10,30):”Throne of Castle”, (0,30):”Crimson Stage”, (-10,30):”Mirror Maze”, (0,40):”Secret
Lab”, (-10,40):”Final Gate”]

OUTPUT “Enter (forward, backward, left, right) to move:”

INPUT move

IF move = “forward” THEN

y=y+10

ELSE IF move = “backward” THEN

y=y-10

ELSE IF move = “left” THEN

x=x-10

ELSE IF move = “right” THEN

x=x+10

ELSE

OUTPUT “You can’t move!”

END IF

IF (x,y) exists in rooms THEN

OUTPUT “You are in”,rooms[(x,y)]

ELSE

OUTPUT “You are in an unknown hallway.”

END IF

END FUNCTION

Function Search room (Current room)


IF Current room = "Moon Garden" THEN

OUTPUT "You found the Nichirin Sword! Do you want to pick up (yes or no)"

INPUT pick

IF pick = “yes”

SET Has sword = TRUE

ADD "Nichirin Sword" to Inventory

ELSE

SET Has sword = FALSE

ELSE IF Current room = "Blood Hall" OR Current room = "Crimson Stage" OR Current
room = ”Frozen room” THEN

OUTPUT “A demon just appears!”

IF Has sword = TRUE THEN

OUTPUT “Use the Nichirin Sword to defeat the demon.”

ELSE

OUTPUT “You have to use one Poison Potion.”

REMOVE one “Poison Potion” from Inventory

DECREASE Health by 50

IF Health <= 0 THEN

OUTPUT “You are defeated by the demon.”

OUTPUT “GAME OVER”

END IF

ELSE IF Current room = “Mirror Maze” THEN

OUTPUT “A Key for the Secret Lab is found! Do you want to pick?(yes or no)”

INPUT pickkey
IF pickkey = “yes”

SET Has key = TRUE

ADD "Key" to Inventory

ELSE

SET Has key = FALSE

ELSE IF Current room = “Secret Lab” THEN

IF Has key = TRUE THEN

OUTPUT “Secret Lab is unlocked, save Nezuko!”

SET Saved Nezuko = TRUE

ELSE

OUTPUT “The door is locked. A key is required!”

IF Has sword = TRUE THEN

OUTPUT “Destroy the Blue Spider Lily! (Enter destroy) ”

INPUT sworduse

IF sworduse = “destroy”

SET Destroyed Lily = TRUE

OUTPUT “Blue Spider Lily is destroyed. Find the Final Gate and escape with
Nezuko”

ELSE

OUTPUT “You need the Nichirin sword to destroy Blue Spider Lily.”

END IF

ELSE IF Current room = “Throne of Castle” THEN

OUTPUT “Muzan, Lord of demons appears! You enter the wrong room.”

OUTPUT “GAME OVER”


ELSE IF Current room = “Final Gate” AND Saved Nezuko = TRUE AND Destroyed Lily =
TRUE THEN

OUTPUT “You escaped the Infinite Castle with Nezuko!”

OUTPUT “Congratulations, You Win the Game!”

ELSE

OUTPUT “You search the room but find nothing special.”

END IF

END FUNCTION

Function loop

WHILE Saved Nezuko = FALSE AND Destroyed Lily = FALSE DO

OUTPUT “What do you want to do? (move/search/view/quit)”

INPUT plyer choice

IF plyer choice = “move” THEN

Call Move player

ELSE IF player choice = “search” THEN

Call Search room(Current room)

ELSE IF player choice = “view” THEN

OUTPUT “Your bag contains:”, Inventory

ELSE IF player choice = “quit” THEN

OUTPUT “You are trapped in the Infinite Castle...”

BREAK LOOP

ELSE

OUTPUT “Invalid option, Try again”

END IF
END WHILE

END FUNCTION

Class Player

PRIVATE Name

PRIVATE Health

PRIVATE Inventory

PRIVATE Direction

PUBLIC CONSTRUCTOR (PlayerName, PlayerHealth, PlayerInventory, PlayerDirection)

SET Name = PlayerName

SET Health = PlayerHealth

SET Inventory = PlayerInventory

SET Direction = PlayerDirection

END CONSTRUCTOR

You might also like