def read_items(self): tree = ET.parse(r".\res\adventure_data.xml") root = tree.getroot() # def __init__(self, id=0, desc="", take=True, name="", desc_room=""): for child in root.iter("item"): ch_id = int(child.find("id").text) ch_look = child.find("look_text").text ch_word = child.find("word").text ch_take = child.find("takeable").text ch_name = child.find("word_use").text ch_room = child.find("room_text").text ch_in_room = int(child.find("in_room").text) w = Word(ch_word, 3, int(ch_id)) # Add to Wordlist self.pars.wordlist.append(w) item_to_add = Item(ch_id, ch_look, ch_take == "True", ch_name, ch_room) if ch_in_room > 0: self.my_world.find_room_by_id(ch_in_room).add_item(item_to_add) else: self.my_world.find_room_by_id(world.SECRET_STORAGE).add_item( item_to_add) #create items not in room yet
print("\n\n") # Create Black Magic fire = Spell("Fire", 25, 600, "black") thunder = Spell("Thunder", 25, 600, "black") blizzard = Spell("Blizzard", 25, 600, "black") meteor = Spell("Meteor", 40, 1200, "black") quake = Spell("Quake", 14, 140, "black") # Create White Magic cure = Spell("Cure", 25, 620, "white") cura = Spell("Cura", 32, 1500, "white") curaga = Spell("Curaga", 50, 6000, "white") # Create some Items potion = Item("Potion", "potion", "Heals 50 HP", 50) hipotion = Item("Hi-Potion", "potion", "Heals 100 HP", 100) superpotion = Item("Super Potion", "potion", "Heals 1000 HP", 1000) elixer = Item("Elixer", "elixer", "Fully restores HP/MP of one party membrer", 9999) hielixer = Item("MegaElixer", "elixer", "Fully restores party's HP/MP", 9999) grenade = Item("Grenade", "attack", "Deals 500 damage", 500) player_spells = [fire, thunder, blizzard, meteor, cure, cura] enemy_spells = [fire, meteor, curaga] player_items = [{"item": potion, "quantity": 15}, {"item": hipotion, "quantity": 5}, {"item": superpotion, "quantity": 5}, {"item": elixer, "quantity": 5}, {"item": hielixer, "quantity": 2}, {"item": grenade, "quantity": 5}] #Instantiate People player1 = Person( "Pramod:", 3260, 132, 300, 34, player_spells, player_items)
from inventory import Item newfile = open("stats.txt", "w+") # Offensive spells Fire = Spell("Fire", 30, 30, "Offensive") Thunder = Spell("Thunder", 150, 120, "Offensive") Blizzard = Spell("Blizzard", 50, 70, "Offensive") Meteor = Spell("Meteor", 200, 300, "Offensive") Quake = Spell("Quake", 100, 100, "Offensive") # Defensive spells Heal = Spell("Heal", 12, 100, "Defensive") Super_Heal = Spell("Super_Heal", 20, 200, "Defensive") # Create items Potion = Item("Potion", "HP_potion", "Heals 50 HP", 50) SuperPotion = Item("SuperPotion", "HP_potion", "Heals 150 HP", 150) Elixer = Item("Elixer", "elixer", "Fully restores HP/MP", 9999) ManaPotion = Item("ManaPotion", "MP_potion", "Restore 50 MP", 50) Sword = Item("Sword", "Weapon", "Deals bonus 50 dmg", 50) Axe = Item("Axe", "Weapon", "Deals bonus 75 HP", 75) Bow = Item("Bow", "Weapon", "Deals bonus 50 dmg", 50) Hammer = Item("Hammer", "Weapon", "Deals bonus 100 dmg", 100) Dagger = Item("Dagger", "Weapon", "Deals bonus 25 dmg", 20) # Spells mage_spells = [Fire, Quake, Blizzard, Meteor, Heal, Super_Heal] warrior_spells = [Fire, Heal] assassin_spells = [Fire, Blizzard, Heal] enemy_spells = [Thunder, Super_Heal, Blizzard]
from magic import Spell from RPG_Battle import Person, bcolors from inventory import Item # Create black Magic fire = Spell("Fire", 10, 100, "black") thunder = Spell("Thunder", 10, 100, "black") meteor = Spell("Metor", 20, 200, "black") blazzerd = Spell("Blazzerd", 10, 100, "black") quake = Spell("Quake", 14, 140, "black") #some White Magic cure = Spell("Cure", 12, 120, "White") cura = Spell("Cura", 18, 200, 'White') #creating Inventory potion = Item("Potion", 'potion', 'heals 50 HP', 50) hipotion = Item("Hi Potion", 'potion', 'heals 100 HP', 100) superpotion = Item("Mega Potion", 'potion', 'heals 500 HP', 500) elixer = Item("Elixer", 'elixer', 'Fully restore one person HP', 99999) HiElixer = Item("Mega elixer", 'elixer', 'Fully restore all charactors Hp/Mp', 99999) granade = Item("Grenade", 'attack', 'deals 500 damage point', 500) player_magic = [fire, thunder, blazzerd, meteor, cure, cura] player_item = [{ 'item': potion, 'quantity': 15 }, { 'item': hipotion, 'quantity': 5 }, {
def test_init_item(self): potion = Item("Potion", "potion", "Heals 50 HP", 50) self.assertEqual("Potion", potion.name) self.assertEqual("potion", potion.type) self.assertEqual("Heals 50 HP", potion.description) self.assertEqual(50, potion.prop)
# Instantiate Black magic # (self, name, cost, dmg, type_spell): fire = Spell("Fire", 30, 332, "black") thunder = Spell("Thunder", 40, 488, "black") blizzard = Spell("Blizzard", 10, 145, "black") meteor = Spell("Meteor", 50, 650, "black") quake = Spell("Quake", 20, 256, "black") # Instantiate White Magic cure = Spell("Cure", 80, 1000, "white") cura = Spell("Cura", 100, 1500, "white") # Instantiate Inventory # (self, name, types, description, prop) potion = Item("Potion", "potion", "Heals 50 HP", 50) hipotion = Item("Hi-Potion", "potion", "Heals 100 HP", 100) superpotion = Item("Super-Potion", "potion", "Heals 150 HP", 150) elixer = Item("Elixer", "elixer", "Fully restores HP/MP", 99999) hielixer = Item("MegaElixer", "elixer", "Fully restores HP/MP of every player", 99999) grenade = Item("Grenade", "attack", "Deals 500 damage", 500) player_spells = [fire, thunder, blizzard, meteor, quake, cure, cura] # player_items = [potion, hipotion, superpotion, elixer, hielixer, grenade]) player_items = [{ "name": potion, "quantity": 15 }, { "name": hipotion,
def getItem(name): for i in items: if i["name"].lower() == name: return Item(**i) print("Nonexistent item '" + name + "'")
import json from customer import Customer from inventory import Inventory, Item from payment_processor import PaymentProcessor inventory = Inventory() customers = [] shopping_list = [] with open("example_data.json", "r") as f: items = json.load(f) for k, v in items['inventory'].items(): inventory.add(Item(k), v) for k, v in items['customers'].items(): customers.append(Customer(k, v)) for k, v in enumerate(items['shopping_list']): amounts = items['shopping_list'][v] for amount in amounts: shopping_list.append((Item(v), amount)) payment_processor = PaymentProcessor(inventory) for k, v in enumerate(customers): payment_processor.start_transaction(v, shopping_list[k][0], shopping_list[k][1])
import random ##Black Magic fire = Spell("Fire", 25, 600, "black") thunder = Spell("Thunder", 25, 600, "black") ice = Spell("Ice", 25, 600, "black") meteor = Spell("Fire", 40, 1200, "black") quake = Spell("Quake", 14, 140, "black") ##White Magic1 cure = Spell("Cure", 25, 620, "white") cura = Spell("Cura", 32, 1500, "white") curaga = Spell("Curaga", 50, 6000, "white") ##Create some items potion = Item("Potion", "potion", "Heals 50 HP", 50) hipotion = Item("Hi-Potion", "potion", "Heals for 100 HP", 100) superpotion = Item("Super Potion", "potion", "Heals for 1000 HP", 1000) elixer = Item("Elixer", "elixer", "Fully restores HP/MP of one member", 9999) hielixer = Item("Mega Elixer", "elixer", "Fully restores HP/MP of both of them", 9999) grenade = Item("Grenade", "attack", "Deals 100 Damage", 100) bomb = Item("Bomb", "attack", "Deals with 500 Damage", 500) player_spells = [fire, thunder, ice, meteor, quake, cure, cura] enemy_spells = [fire, meteor, curaga] player_items = [{ "item": potion, "quantity": 15 }, {
import random # create Black Magic: fire = Spell("Fire", 30, 150, "Black") thunder = Spell("Thunder", 40, 200, "Black") blizzard = Spell("Blizzard", 35, 170, "Black") meteor = Spell("Meteor", 20, 110, "Black") quake = Spell("Quake", 25, 130, "Black") # create White Magic: cure = Spell("Cure", 40, 1000, "White") cura = Spell("Cura", 60, 1500, "White") # Create some Items to be used potion = Item("Potion", "Potion", "Heals 50 Hp", 50, 10) hipotion = Item("Hipotion", "Potion", "Heals 100 Hp", 100, 5) superpotion = Item("Superpotion", "Potion", "Heals 500 Hp", 500, 5) elixir = Item("Elixir", "Elixir", "Fully restores HP/MP of one party member", 9999, 5) superelixir = Item("Superelixir", "Elixir", "Fully restores Party's HP/MP", 9999, 2) grenade = Item("Grenade", "Attack", "Deals 500 damage", 500, 3) # Adding magic spells for the player player_magic = [fire, thunder, blizzard, meteor, quake, cure, cura] # Adding magic spells for the enemy enemy_magic = [fire, thunder, blizzard, cure] # Instantiating the items and their quantity player_items = [{"item": potion, "quantity": 10}, {"item": hipotion, "quantity": 5},
penetration = Spell("Penetracja", 85, 650, "black") assassination = Spell("Natychmiastowe zabójstwo", 250, 9999999999999999999999999999, "black") shout = Spell("'Tanio skóry nie sprzedam'", 220, 0, "black") carnage = Spell("Rzeź", 50, 250, "black") stone_fists = Spell("Kamienne Pięści", 40, 200, "black") cure = Spell("Uleczenie", 55, 300, "white") heal = Spell("Uzdrowienie", 200, 9999999999999999999999999999999, "white") block = Spell("Garda", 20, 0, "block") HP_steal = Spell("Kradzież życia", 50, 250, "HP steal") MP_steal = Spell("Kradzież many", 25, 50, "MP steal") stun = Spell("Ogłuszenie", 120, 0, "stun") snap = Spell("Snap", 175, 420, "snap") # Przedmioty health_potion = Item("Mikstura zdrowia", "potion", "Przywraca 150 HP", 150) mana_potion = Item("Mikstura many", "potion", "Przywraca 50 MP", 50) grenade = Item("Granat", "attack", "Zadaje 300 DMG", 300) # Klasy postaci warrior_soil = Person("Wojownik", "Ziemia", 4250, 250, 45, 45, 0, [], [power_hit, smash, block], [{ "item": health_potion, "quantity": 2 }, { "item": mana_potion, "quantity": 2 }, { "item": grenade, "quantity": 1 }])
###Spells### #Dark Spells meteor = Spell("Meteor Strike", 20, 50, "Dark") typhoon = Spell("Typhoon Strike", 25, 55, "Dark") lighting = Spell("Lightning Strike", 50, 70, "Dark") ultra = Spell("PLUS ULTRA", 100, 100, "Dark") #Light Spells cure = Spell("Cure", 10, 15, "Light") cure_p = Spell("Cure +", 15, 20, "Light") player1_spells = [meteor, typhoon, lighting, ultra, cure, cure_p] enemy_spells = [meteor, lighting, cure] ###Items### #Health Potions red_potion = Item("Red Potion", "Potion", "Heals 10 HP", 10) orange_potion = Item("Orange Potion", "Potion", "Heals 25 HP", 25) white_potion = Item("White Potion", "Potion", "Heals 50 HP", 50) #Mana Potions blue_potion = Item("Blue Potion", "Potion", "Heals 10 MP", 10) big_blue_potion = Item("Big Blue Potion", "Potion", "Heals 50 MP", 50) #Elixirs purple_elixir = Item("Purple Elixir", "Elixir", "Fully restores HP/MP of one party member", 999) big_purple_elixir = Item("Big Purple Elixir", "Elixir", "Fully restores parties HP/MP", 999) #Throwing Stars shuriken = Item("Shuriken", "Throwing Star", "Throw a shuriken dealing 80 damage", 80) player1_items = [{
#black magic fire = spell("Fire", 5, 100, "Black") thunder = spell("Thunder", 10, 130, "Black") bizzard = spell("Bizzard", 15, 150, "Black") meteor = spell("Meteor", 20, 200, "Black") quake = spell("Quake", 30, 300, "Black") #white magic cure = spell("Cure", 16, 120, "White") cura = spell("Cura", 18, 178, "White") #create some item potion = Item("Potion", "potion", "Heals 100 HP", 100) hipotion = Item("Hipotion", "hipotion", "Heals 300 HP", 300) superpotion = Item("Superpotion", "superpotion", "Heals 500 HP", 500) elixer = Item("Elixer", "elixer", "fully restores HP/MP of one party memeber", 9999) hielixer = Item("MegaElixer", "elixer", "Fully restore party's HP/MP", 9999) grenade = Item("Grenade", "Attack", "Deals 500 damage", 500) player_spells = [fire, thunder, bizzard, meteor, quake, cure, cura] enemy_spells = [thunder, quake, cura] player_items = [{ "item": potion, "Quantity": 10 }, {