*IN PYTHON*
A role-playing game or RPG is a game in which players assume the roles of characters in a fictional setting. The popularity of the epic saga told in J.R.R. Tolkien's The Hobbit and The Lord of The Rings greatly influenced the genre, as seen in the game Dungeons & Dragons and all of its subsequent variants.
In most RPGs, a player creates a character of a specific archetype or class, such as "Fighter", "Wizard", or "Thief". (Note: do not confuse a "character class" with a Python class; although we will define character classes using Python classes, they do not mean the same thing, so it might be a little confusing.) The class defines a set of characteristics, constraints, and behavior that apply to all characters of that class. For example, a Thief has the ability to move with great stealth; however, in order to do that effectively, the Thief cannot wear bulky, noisy armor or carry large weapons.
In this assignment, you will create a very simple RPG. You will define two character classes, define characteristics and actions associated with those classes, and create one character of each class. You will define types of weapons and armor suitable for your characters to use. Finally, you will have your two characters battle each other!
Weapons:
Define a Python class called Weapon. When a Weapon object is created, it should include as a parameter a String that identifies the weapon type. Each weapon type will do a specific amount of damage when it strikes an opponent.
Valid weapon types and the damage done by each are:
Armor:
Define a Python class called Armor. When an Armor object is created, it should include as a parameter a String that identifies the armor type. Each armor type offers a specific amount of protection (the "Armor Class" or AC) when an opponent attacks the character wearing the armor.
Valid armor types and the AC associated with each are:
Characters:
Define a Python class called RPGCharacter.
Define a subclass of RPGCharacter called Fighter. Fighters possess the following characteristics:
Define a subclass of RPGCharacter called Wizard. Wizards possess the following characteristics:
When a character is created, it should include as a parameter a String that identifies the character's name. Creation of a character should also initialize the following characteristics:
Actions:
A character of any class can perform the following actions:
A wizard (and only a wizard) can also perform the following action:
Two other methods you must define are:
Name of character Current Health: ## Current Spell Points: ## Wielding: "xxxxx" Wearing: "xxxxx" Armor Class: ##
main program was given
def main(): plateMail = Armor("plate") chainMail = Armor("chain") sword = Weapon("sword") staff = Weapon("staff") axe = Weapon("axe") gandalf = Wizard("Gandalf the Grey") gandalf.wield(staff) aragorn = Fighter("Aragorn") aragorn.putOnArmor(plateMail) aragorn.wield(axe) print(gandalf) print(aragorn) gandalf.castSpell("Fireball",aragorn) aragorn.fight(gandalf) print(gandalf) print(aragorn) gandalf.castSpell("Lightning Bolt",aragorn) aragorn.wield(sword) print(gandalf) print(aragorn) gandalf.castSpell("Heal",gandalf) aragorn.fight(gandalf) gandalf.fight(aragorn) aragorn.fight(gandalf) print(gandalf) print(aragorn) main()
#!/bin/python3
def showInstructions():
#print a main menu and the commands
print('''
RPG Game
========
Get to the Garden with a key and a potion
Avoid the monsters!
Commands:
go [direction]
get [item]
''')
def showStatus():
#print the player's current status
print('---------------------------')
print('You are in the ' + currentRoom)
#print the current inventory
print("Inventory : " + str(inventory))
#print an item if there is one
if "item" in rooms[currentRoom]:
print('You see a ' +
rooms[currentRoom]['item'])
print("---------------------------")
#an inventory, which is initially empty
inventory = []
#a dictionary linking a room to other room positions
rooms = {
'Hall' : { 'south' : 'Kitchen',
'east' : 'Dining Room',
'item' : 'key'
},
'Kitchen' : { 'north' : 'Hall',
'item' : 'monster'
},
'Dining Room' : { 'west' : 'Hall',
'south' : 'Garden',
'item' : 'potion'
},
'Garden' : { 'north' : 'Dining Room' }
}
#start the player in the Hall
currentRoom = 'Hall'
showInstructions()
#loop forever
while True:
showStatus()
#get the player's next 'move'
#.split() breaks it up into an list array
#eg typing 'go east' would give the list:
#['go','east']
move = ''
while move == '':
move = input('>')
move = move.lower().split()
#if they type 'go' first
if move[0] == 'go':
#check that they are allowed wherever they want
to go
if move[1] in rooms[currentRoom]:
#set the current room to the new
room
currentRoom =
rooms[currentRoom][move[1]]
#there is no door (link) to the new room
else:
print('You can\'t go that way!')
#if they type 'get' first
if move[0] == 'get' :
#if the room contains an item, and the item is
the one they want to get
if 'item' in rooms[currentRoom] and move[1] in
rooms[currentRoom]['item']:
#add the item to their
inventory
inventory += [move[1]]
#display a helpful message
print(move[1] + ' got!')
#delete the item from the room
del rooms[currentRoom]['item']
#otherwise, if the item isn't there to get
else:
#tell them they can't get it
print('Can\'t get ' + move[1] +
'!')
# player loses if they enter a room with a monster
if 'item' in rooms[currentRoom] and 'monster' in
rooms[currentRoom]['item']:
print('A monster has got you... GAME
OVER!')
break
# player wins if they get to the garden with a key and a
shield
if currentRoom == 'Garden' and 'key' in inventory and 'potion' in
inventory:
print('You escaped the house... YOU WIN!')
break
*IN PYTHON* A role-playing game or RPG is a game in which players assume the roles...
C++ programming question, please help! Thank you so much in advance!!! In this exercise, you will work with 2 classes to be used in a RPG videogame. The first class is the class Character. The Character class has two string type properties: name and race. The Character class also has the following methods: a constructor Character(string Name, string Race), that will set the values for the name and the race variables set/get functions for the two attributes a function print(),...
UML CLASS DIAGRAM This is a Design Exercise. You will need to make classes that could be used to stage a battle as described below. You have been tasked to create a number of items that can be used in an online game. All items can be used on a game character who will have a name, a number of health-points and a bag to hold the items. Here are examples of items that can be made: Item type of...
IS 331 NJIT Assignment 5 Steps to complete in Microsoft Access Use the sample solution to assignment 4 (below) as the conceptual model, develop a logical model (relational model) based on it. Specify all the integrity constraints in English. For each table in the Assignment 4 solution, write a relation in the form TableName(PK attribute, attribute 1, attribute 2, etc) For each relationship connection between the tables, write a constraint in the form CONSTRAINT foreign_key REFERENCES reference_table_name For any N:M...
C++ Inheritance Problem Step a: Suppose you are creating a fantasy role-playing game. In this game we have four different types of Creatures: Humans, Cyberdemons, Balrogs, and elves. To represent one of these Creatures we might define a Creature class as follows: class Creature { private: int type; // 0 Human, 1 Cyberdemon, 2 Balrog, 3 elf int strength; // how much damage this Creature inflicts int hitpoints; // how much damage this Creature can sustain string getSpecies() const; //...
(a) FileIO In the FileIO class add a public static method named writeCharacter. This method takes as input a Character to write, and a String which is the filename to write to. Within this writeCharacter method, use the FileWriter and BufferedWriter objects to write the character’s information back to a file. Make sure to catch the IOException when writing a file, and throw an IllegalArgumentException with an appropriate error message. If you prefer, you can also use the throws statement...
Write three object-oriented classes to simulate your own kind of team in which a senior member type can give orders to a junior member type object, but both senior and junior members are team members. So, there is a general team member type, but also two specific types that inherit from that general type: one senior and one junior. Write a Python object-oriented class definition that is a generic member of your team. For this writeup we call it X....
Zybooks 11.12 LAB*: Program: Online shopping cart (continued) Python 3 is the code needed and this is in Zybooks Existing Code # Type code for classes here class ItemToPurchase: def __init__(self, item_name="none", item_price=0, item_quantity=0): self.item_name = item_name self.item_price = item_price self.item_quantity = item_quantity # def __mul__(self): # print_item_cost = (self.item_quantity * self.item_price) # return '{} {} @ ${} = ${}' .format(self_item_name, self.item_quantity, self.item_price, print_item_cost) def print_item_cost(self): self.print_cost = (self.item_quantity * self.item_price) print(('{} {} @ ${} = ${}') .format(self.item_name, self.item_quantity, self.item_price,...
CIS4100 Final Project Description The Objective of this Final Project is to implement the theoretical concepts covered in the course. You are required to build the classes and test all the functions as described. Each class should have its own .h (specification) and .cpp (implementation) files, then test all the classes in the main.cpp The Diagram below shows the classes inheritance relationships: The assigned Types are as follow: Type 1 Type 2 Type 3 PitBull Lion Tiger The class...
In Java plz due today Assignment 4 - Email, Shwitter and Inheritance Select one option from below. All (both) options are worth the same number of points. The more advanced option(s) are provided for students who find the basic one too easy and want more of a challenge. OPTION A (Basic): Message, EMail and Tweet Understand the Classes and Problem Every message contains some content ("The British are coming! The British are coming!"). We could enhance this by adding other...
Please use Java only. Write the class TopResult, which keeps track of the best (highest numbered or highest ordered) result it has seen so far. The class will be a generic type, so the type of results it sees depends on how it is declared. TopResult Task: There are a number of situations in which we want to keep track of the highest value we've seen so far - a highest score, a most recent entry, a name which is...