python代写 python作业代写 python程序代写 代写python程序

python作业代写,python程序代写

You will write a text adventure game. The idea of a text adventure game is that the player is in a virtual room in a “dungeon”, and each room has a text description associated with it, such as, “This room in big and brightly lit. It has doors on the north and west walls”. The player can move from room to room using compass directional commands. Each room can contain items inside it. The player can pick up items in a room and drop items in a room.


Your program will be a function called adventure which takes no arguments and returns no values. Your function adventure will allow the user to enter commands related to moving through the dungeon and interacting with objects. Your function should print out a prompt to indicate that the user can enter a command. Your prompt should be a ‘$’ character. At the prompt the user will type a command followed by a set of arguments for the command. Your function will perform whatever action is indicated by the command, and then your program will print a ‘$’ character on a new line in order to let the user know that he/she can type a new command. If the command is a compass command which moves the player into a new room, your program will print the description of the room and a list of items in the room, before printing the ’$’ character on the next line.


Dungeon File

The rooms in the dungeon, and their arrangement, is stored in a dungeon file. When the game starts, the player will have to issue a command to load a dungeon file describing the dungeon. The dungeon file will be a text file containing information about each room in a specific format. Each line of the file will contain information about a single room in the dungeon. Each room is associated with the following 6 fields of information.

1. Room number: This is a positive integer which uniquely identifies the room.

2. Description: This is a string which is printed when the player enters the room.

3. North room: This is the room number of the room immediately to the north of this room. If there is no room to the north of this room then this value is -1.

4. South room: This is the room number of the room immediately to the south of this room. If there is no room to the south of this room then this value is -1.

5. East room: This is the room number of the room immediately to the east of this room. If there is no room to the east of this room then this value is -1.

6. West room: This is the room number of the room immediately to the west of this room. If there is no room to the west of this room then this value is -1.


All 6 fields of information about each room are contained in order on a single line in the dungeon file. Each field of information is separated by one or more spaces. The room described on the first line of the file is the initial room where the player will start after the dungeon file is loaded.


dungeon. The function takes one argument, the name of the dungeon file. The function returns no values. After executing this command, the rooms of the dungeon should contain no items. The loaddungeon command can only be issued once. If the player tries to issue the command a second time, the error “Dungeon already loaded” should be printed.

Moving Through the Dungeon

The program must keep track of the current room which is the room which the player is currently in. The player will enter compass direction commands to move from one room to another. Your program should accept the following commands related to movement:

1. north: This command moves the player into the room to the north of the current room. If there is a room to the north then the description of the new room is printed. If there is no room to the north then the message, “You can’t go there.” is printed to the screen.

2. south: This command moves the player into the room to the south of the current room. If there is a room to the south then the description of the new room is printed. If there is no room to the south then the message, “You can’t go there.” is printed to the screen.

3. east: This command moves the player into the room to the east of the current room. If there is a room to the east then the description of the new room is printed. If there is no room to the east then the message, “You can’t go there.” is printed to the screen.

4. west: This command moves the player into the room to the west of the current room. If there is a room to the west then the description of the new room is printed. If there is no room to the west then the message, “You can’t go there.” is printed to the screen.

Items and Inventories

The adventure game can have several items which can be picked up and dropped by the player. Each item has a unique name. The player has a player inventory which contains every item in the possession of the player. Each room has a room inventory which contains every item in the room. When a player picks up an item, the item is deleted from the inventory of the room which the player is in, and is added to the inventory of the player. A player cannot pick up an item if the item is not contained in the current room. When a player drops an item, the item is deleted from the player’s inventory and added to the inventory of the current room. A player cannot drop an item if that item is not contained in the player’s inventory.

Your program should accept the following command related to items and inventories:

1. rinventory: This command takes no arguments and prints out the inventory of the current room. For example, if the current room contains apple and orange, the rinventory command would print the following:

This room contains: apple, orange

If the room is empty, the command would print:

This room contains: nothing

2. take: This command removes an item from the inventory of the current room and adds that item to the inventory of the player. The command takes one argument, the name of the item to be taken. If the item is not contained in the room’s inventory the following message should be printed, “That item is not in this room”.

3. drop: This command removes an item from the inventory of the player and adds that item to the inventory of the current room. The command takes one argument, the name of the item to be dropped. If the item is not contained in the player’s inventory the following message should be printed, “You don’t have that item”.

4. pinventory: This command prints out the contents of the player’s inventory. For example, if the player has sword and box, the following would be printed:

You have: sword, box.

If the player has nothing, the command would print:

You have: nothing


京ICP备2025144562号-1
微信
程序代写,编程代写
使用微信扫一扫关注
在线客服
欢迎在线资讯
联系时间: 全天