def __init__(self, name,): self.name = name self.power_level = 700000 self.health = 750 self.weapon_options = [Weapons('Longsword', 60), Weapons('Laser Beam', 35), Weapons('105mm Howitzer', 85)] self.chosen_weapon = None self.is_breaking_down = False self.is_destroyed = False
def load(self, root_dir, fail_fast=True): # load the version version_dir = join(root_dir, "docs") version_fname = join(version_dir, "version.xml") self.version = Version.load(version_fname) # load the abilities abilities_dir = join(root_dir, "abilities") self.ability_groups = AbilityGroups() self.ability_groups.load(abilities_dir, fail_fast=fail_fast) # load the archetypes archetype_dir = join(root_dir, "archetypes") self.archetypes = Archetypes() self.archetypes.load(ability_groups=self.ability_groups, archetypes_dir=archetype_dir, fail_fast=fail_fast) # load the monsters monsters_dir = join(root_dir, "monsters") self.monster_groups = MonsterGroups() self.monster_groups.load(monsters_dir, fail_fast=fail_fast) # load the patrons patrons_dir = join(root_dir, "patrons") self.patrons = Patrons() self.patrons.load(patrons_dir=patrons_dir, ability_groups=self.ability_groups, fail_fast=fail_fast) # load the npcs npcs_dir = join(root_dir, "encounters") # FIXME self.npc_gangs = NPCGangs() self.npc_gangs.load(npcs_dir=npcs_dir, monster_groups=self.monster_groups, fail_fast=fail_fast) # licenses resource_dir = join(root_dir, "resources") unused_resource_dir = join(root_dir, "unused_resources") self.licenses = Licenses() self.licenses.load((resource_dir, unused_resource_dir)) # melee weapons melee_weapons_xml = join(root_dir, "items", "melee_weapons.xml") self.melee_weapons = Weapons(fname=melee_weapons_xml) self.melee_weapons.load() # missile weapons missile_weapons_xml = join(root_dir, "items", "missile_weapons.xml") self.missile_weapons = Weapons(fname=missile_weapons_xml) self.missile_weapons.load() assert self.missile_weapons is not None return
def __init__(self, texture_enemies): self.doors = [] self.current_level = None self.rifle = Weapons(ident='rifle', ammo=50, enabled=1) self.pistol = Weapons(ident='pistol', ammo=10, enabled=1) self.knife = Weapons(ident='knife', ammo=0, enabled=1) self.player = Player(gamemap=self.current_level, weapon=self.knife) if HEAD_BOB == True: self.bob_top = True else: self.bob_top = 'no bobbing' self.entities = [] #8-14 x, 6-9 y for x in range(10, 11): for y in range(7, 8): test = Entity(x, y, texture_enemies, 0, 0) self.entities.append(test)
def __init__(self, gs, ship_type, player): img = ship_type + "/ship" + player + ".png" settings = ship_type + "/settings" + player + ".csv" gridfile = ship_type + "/grid" + player + ".dat" self.player = player pygame.sprite.Sprite.__init__(self) with open(settings) as f: data = csv.DictReader(f) for s in data: self.settings = s self.gs = gs self.image = pygame.image.load(img) self.rect = self.image.get_rect() # position self.rect.x = int(self.settings['x']) self.rect.y = int(self.settings['y']) grid_pos = (0,0) if ship_type == "cruiser": grid_pos = (self.rect.x+70, self.rect.y+50) else: grid_pos = (self.rect.x+100, self.rect.y+50) self.grid = Maps(self, grid_pos, gridfile) # resize scale_fac = float(self.settings['scale_fac']) self.size = self.image.get_size() self.image = pygame.transform.scale(self.image, (int(self.size[0]*scale_fac), int(self.size[1]*scale_fac))) ship_rect = self.image.get_rect() self.shield_rect = None if int(self.player) == 1: self.shield_rect = ship_rect.move(self.rect.x+30, self.rect.y) else: self.shield_rect = ship_rect.move(self.rect.x-30, self.rect.y) # shields self.shields = 3 self.currentShield = 3 # health self.health = 20 # weapons weapon_name = "ion2.png" weapon_dir = "weapons/"+weapon_name self.weapon = Weapons(self, weapon_dir)
def __init__( self, name="", des="", lvl=1, mhp=0, mmp=0, atk=0, pdef=0, spd=0, crit=0, equipped={ "weapon": Weapons(), "talisman": Item(), "bracelet": Item(), "ring": Item() }, eqarmors={ "left": Armor(), "right": Armor(), "head": Armor(), "body": Armor() }, drop={ "items": [], "xp": 0 }): self.info = { "name": name, "description": des, "level": lvl, "mhp": mhp, "mmp": mmp, "hp": mhp, "mp": mmp, "atk": atk, "def": pdef, "spd": spd, "crit": crit, "equipped": equipped, "equipped armors": eqarmors, "drop": drop }
def __init__( self, name="", race="", gender="", pclass="", personality={ "strength": 5, "dexterity": 5, "constitution": 5, "intelligence": 5, "wisdom": 5, "charisma": 5 }): self.info = { "name": name, "race": race, "gender": gender, "class": pclass, "personality": personality, "level": 1, "mhp": 100, "mmp": 100, "hp": 100, "mp": 100, "xp": 0, "def": 3 * int(personality["strength"]), "atk": 5 * int(personality["strength"]), "spd": 5 * int(personality["dexterity"]), "crit": 2 * int(personality["dexterity"]), "money": 0, "invlimit": 3 * int((personality["strength"] + personality["dexterity"]) / 2), "wplimit": 2 * int((personality["strength"] + personality["dexterity"]) / 2), "arlimit": int((personality["strength"] + personality["dexterity"]) / 2), "inventory": { "weapons": [], "armors": [], "items": [], "potions": [] }, "equipped armors": { "left": Armor(), "right": Armor(), "head": Armor(), "body": Armor() }, "equipped": { "weapon": Weapons(), "talisman": Item(), "bracelet": Item(), "ring": Item() } }
class Ship(pygame.sprite.Sprite): def __init__(self, gs, ship_type, player): img = ship_type + "/ship" + player + ".png" settings = ship_type + "/settings" + player + ".csv" gridfile = ship_type + "/grid" + player + ".dat" self.player = player pygame.sprite.Sprite.__init__(self) with open(settings) as f: data = csv.DictReader(f) for s in data: self.settings = s self.gs = gs self.image = pygame.image.load(img) self.rect = self.image.get_rect() # position self.rect.x = int(self.settings['x']) self.rect.y = int(self.settings['y']) grid_pos = (0,0) if ship_type == "cruiser": grid_pos = (self.rect.x+70, self.rect.y+50) else: grid_pos = (self.rect.x+100, self.rect.y+50) self.grid = Maps(self, grid_pos, gridfile) # resize scale_fac = float(self.settings['scale_fac']) self.size = self.image.get_size() self.image = pygame.transform.scale(self.image, (int(self.size[0]*scale_fac), int(self.size[1]*scale_fac))) ship_rect = self.image.get_rect() self.shield_rect = None if int(self.player) == 1: self.shield_rect = ship_rect.move(self.rect.x+30, self.rect.y) else: self.shield_rect = ship_rect.move(self.rect.x-30, self.rect.y) # shields self.shields = 3 self.currentShield = 3 # health self.health = 20 # weapons weapon_name = "ion2.png" weapon_dir = "weapons/"+weapon_name self.weapon = Weapons(self, weapon_dir) # crew? def tick(self): self.gs.screen.blit(self.image, self.rect) # Health Icons for i in range(0, self.health): healthRect = pygame.Rect(self.rect.x + i*20, self.rect.y - 40, 15, 15) pygame.draw.rect(self.gs.screen, (0, 255, 0), healthRect, 0) # Shield Icons for i in range(0, self.shields): width = 0 if i >= self.currentShield: width = 2 shieldCircle = pygame.draw.circle(self.gs.screen, (0, 0, 255), (self.rect.x + i*30 + 10, self.rect.y - 10), 10, width) # Shield if self.currentShield != 0: angle1 = angle2 = 0 if int(self.player) == 1: angle1 = math.pi*1.5 angle2 = math.pi*2.5 else: angle1 = math.pi*0.5 angle2 = math.pi*1.5 pygame.draw.arc(self.gs.screen, (0,0,255), self.shield_rect, angle1, angle2, self.currentShield) self.grid.tick() self.weapon.tick()
def loadConfig(self): config = ConfigParser.SafeConfigParser(allow_no_value=True) config.read('main.ini') self.mods["base"] = self.loadMod("base") self.Weapons = Weapons() self.announcer = announcer.Announcer(self.actionHandler) self.announcer.start() requiredImports = [] moduleImports = {} for mod in config.options("mods"): mod = str(mod).strip() if not mod in self.mods and mod != "base" and mod[0] != "#": logging.debug("Attempting to load module %s" % mod) curmod = self.loadMod(mod) if curmod: self.mods[mod] = curmod if hasattr(curmod, "requiredImports"): requiredImports.extend(curmod.requiredImports) moduleImports[ mod] = curmod.requiredImports #this is used to check whether all dependencies are met before initializing the module else: moduleImports[mod] = [] failedImports = [] while len(requiredImports) > 0: impModule = requiredImports.pop() if not impModule in dir() or not impModule in self.mods: logging.info( "Trying to import additional required module %s :" % impModule) try: file, pathname, descr = imp.find_module(impModule) except ImportError: iM = self.loadMod(impModule) if iM: if hasattr(iM, "requiredImports"): requiredImports.extend(iM.requiredImports) self.mods[impModule] = iM logging.info("Successfully imported module %s!" % impModule) else: logging.info( "Could not import %s! (does the module exist?)" % impModule) failedImports.append(str(os.path.basename(impModule))) else: imp.load_module(impModule, file, pathname, descr) logging.info("Successfully imported module %s !" % impModule) for n, m in self.mods.items(): #name, module instance logging.info("Trying to initalize mod %s" % n) unmet = set(moduleImports.setdefault(n, [])) & set(failedImports) if len(unmet) > 0: logging.info("Unmet dependencies for module %s :" % n) logging.info(unmet) logging.info("Unloading module!") del (self.mods[n]) else: logging.info("Loaded %s ( %s ) by %s" % (m.name, n, m.author)) modConfig = ConfigParser.SafeConfigParser(allow_no_value=True) modConfig.read('configs/%s.cfg' % os.path.basename(n)) self.mods[n] = m.Bf3Mod(self, self.actionHandler, modConfig) for n, m in self.mods.items(): self.mods[n].modInit()
from robots import Robot from dinosaurs import Dinosaur from fleet import Fleet from herd import Herd from battlefield import Battlefield from weapons import Weapons import ctypes import random if __name__ == '__main__': #Battlefield battlefield = Battlefield() #Weapons weapons = Weapons() # Robots robot_wally = Robot("Wall-E") robot_wally.power_level = 100 robot_wally.attack_power = 60 # weapons.choose_weapon(robot_wally) robot_megaman = Robot("Megaman") robot_megaman.power_level = 110 robot_megaman.attack_power = 100 # weapons.choose_weapon(robot_megaman) robot_marvin = Robot("Marvin") robot_marvin.power_level = 120 robot_marvin.attack_power = 70
def newWeapons(self): weapons = Weapons() weapons.newMissile.connect(self.newMissile) weapons.newSprite.connect(self.newSprite) weapons.init() return weapons
from typing import List import discord from discord.ext import commands from discord.ext.commands import Context from pubg_python import PUBG, Shard from config import Config from stat_options import StatOptions from weapons import Weapons conf = Config() pubg_api = PUBG(conf.pubg_api, Shard.PC_NA) # client = discord.Client() bot = commands.Bot(command_prefix='$') _weapons = Weapons() stat_options = StatOptions() @bot.command() async def weapon(ctx: Context, weapon_name: str = '', player_name: str = ''): """Look up a specific weapon and print its stats to Discord.""" print('You are in the weapon function') p_name = _player_name(ctx.author, player_name) author = ctx.author.name pubg_player_id = player_id(p_name) if pubg_player_id == -1: await ctx.send('Player Unknown') if weapon_name != '':
class Shop(): def __init__(self): global all_weapons self.all_weapons = all_weapons bronze_shortsword = Weapons("shortsword", "bronze") iron_shortsword = Weapons("shortsword", "bron") silver_shortsword = Weapons("shortsword", "silver") gold_shortsword = Weapons("shortsword", "gold") bronze_axe = Weapons("axe", "bronze") iron_axe = Weapons("axe", "iron") silver_axe = Weapons("axe", "silver") gold_axe = Weapons("axe", "gold") bronze_lance = Weapons("lance", "bronze") iron_lance = Weapons("lance", "iron") silver_lance = Weapons("lance", "silver") gold_lance = Weapons("lance", "gold") bronze_bow = Weapons("bow", "bronze") iron_bow = Weapons("bow", "iron") silver_bow = Weapons("bow", "silver") gold_bow = Weapons("bow", "gold") all_weapons = [ bronze_shortsword, iron_shortsword, silver_shortsword, gold_shortsword, bronze_axe, iron_axe, silver_axe, gold_axe, bronze_lance, iron_lance, silver_lance, gold_lance, bronze_bow, iron_bow, silver_bow, gold_bow ] def weapons_shop(character, currency): global all_weapons global unlocked_weapons unlocked_weapons = [] counter = 1 ui.restartPage() print(Style.RESET_ALL + "Welcome to the shop, {}\n".format(character.name) + "|" + "─" * 50) print(" _͟ _") print("╱___╲") print("│=|=│\n" + "-" * 50) time.sleep(2) for i in all_weapons: if character.level >= i.required_level: print("|({1}) {0.material} {0.category} ".format(i, counter) + Fore.YELLOW + "({0.price} coins)".format(i) + Style.RESET_ALL + "\n" + "|" + "─" * 50) counter += 1 unlocked_weapons.append(i) elif character.level < i.required_level: print("|" + Fore.RED + "You have not unlocked this yet!\n" + Style.RESET_ALL + "|" + "─" * 50) select = input( "Select the number of the weapon you would like to purchase: ") while select.isdigit() == False: print("\nINVALID INPUT\n") select = input( "Select the number of the weapon you would like to purchase: ") select = int(select) - 1 while select < 0 or select > len(unlocked_weapons): print("\nINVALID INPUT") select = input( "Select the number of the weapon you would like to purchase: ") while select.isdigit() == False: print("\nINVALID INPUT\n") select = input( "Select the number of the weapon you would like to purchase: " ) select = int(select) - 1 selected_weapon = unlocked_weapons[select] cont = input( "So would you like to purchase the {0.material} {0.category}? It costs " .format(selected_weapon) + Fore.YELLOW + "{0.price} coins.".format(selected_weapon) + Style.RESET_ALL + " Y/N: ") cont = cont.lower() while cont not in ["y", "n"]: print("\nINVALID INPUT") cont = input( "So would you like to purchase the {0.material} {0.category}? It costs " .format(selected_weapon) + Fore.YELLOW + "{0.price} coins.".format(selected_weapon) + Style.RESET_ALL + " Y/N: ") cont = cont.lower() if cont == "n": # ui.restartPage() # Shop.shop(character, currency) pass else: return selected_weapon pillow = Items( 40, 'none', 'none', 5, "Pillow", "The pillow restores your energy so you can take on the enemies...\n and it's also very soft.", "You had a relaxing nap") Items = [pillow]
print('---------------') def drop_item(dropped): if dropped in inventory: print({dropped}, 'dropped!') roomItems.append(dropped) rooms[currentRoom]['items'] = roomItems print(roomItems) inventory.remove(dropped) # # weapons should do different damage to different enemy types weapons = [ Weapons('sword', 0, 5, 50, 100, 1), Weapons('mace', 'n', 6, 60, 100, 2), Weapons('axe', 'n', 7, 70, 100, 3) ] allItems = { #0 = weapons, 1 = helms, 2 = armor, 3 = items 0: { 0: { 'name': 'noweap', 'defense': 0, 'attack': 0 }, 1: { 'name': 'sword',
def intro(character, melee_weapon, items, currency): print("PROLOGUE: THE FIRST FIGHT") wait(3) cont = input("Press enter to continue: ") ui.restartPage() print_text_file('StoryTexts/IntroTexts/intro1.txt') wait(10) option = input( Style.RESET_ALL + "\nWhat do you do?\n[A]pproach the lights, [R]un the other way, [W]ait for the lights to come to you: " ) option = option.lower() while option not in ["a", "r", "w"]: print("\nINVALID INPUT") option = input( "What do you do?\n[A]pproach the lights, [R]un the other way, [W]ait for the lights to come to you: " ) option = option.lower() if option == "w": print(Style.RESET_ALL + Fore.LIGHTBLACK_EX + "\nYou see a faint glimpse of something coming closer") wait(3) print( Style.BRIGHT + Fore.RED + "Then it hits you with surprising power!", Style.RESET_ALL) elif option == "a": print(Style.RESET_ALL + Fore.LIGHTBLACK_EX + "\nAs you approach the lights you get blinded and faint") wait(3) print( Style.BRIGHT + Fore.RED + "Then you suddenly stir and realize that you're in another room.", Style.RESET_ALL) elif option == "r": print( Style.RESET_ALL + Fore.LIGHTBLACK_EX + "\nYou run around a corner where you can no longer see the light") wait(3) print( Style.BRIGHT + Fore.RED + "You turn to look if there is anywhere else to go, but as you do you get ambushed!", Style.RESET_ALL) wait(3) ui.restartPage() print_text_file('StoryTexts/IntroTexts/intro2.txt') wait(20) cont = input("Press enter to continue: ") del cont goblin1 = Enemies("goblin", "Dark", Weapons("shortsword", "bronze"), 20, 15, 11, 9, 1) goblin2 = Enemies("goblin", "Dark", Weapons("shortsword", "bronze"), 18, 16, 13, 9, 1) ui.restartPage() print("Let's set up your spells!\n") my_spells = character.spell_by_level() Combat.main_fight(character, melee_weapon, my_spells, (goblin1, goblin2), items) wait(5) ui.restartPage() goblin1 = Enemies("goblin", "Dark", Weapons("shortsword", "bronze"), 20, 15, 11, 9, 1) goblin2 = Enemies("goblin", "Dark", Weapons("shortsword", "bronze"), 18, 16, 13, 9, 1) character.level_up((goblin1, goblin2), money) del (goblin1, goblin2) wait(3) cont = input("Press enter to continue: ") del cont ui.restartPage() print_text_file('StoryTexts/IntroTexts/intro3.txt') wait(15) cont = input("Press enter to continue: ") del cont return
def __init__(self, user=None): self.setup(user) self.weapons = Weapons().get_weapons()
def initialize_battle(): #Weapons List weapons = Weapons() #Fighters marvin = Robot('Marvin') megaman = Robot('Megaman') wall_E = Robot('Wall-e') stegosaurus = Dinosaur('Stegosaurus') velociraptor = Dinosaur('Velociraptor') tyrannosaurus = Dinosaur('Tyrannosaurus') #Select Weapon/Attack weapons.choose_weapon(marvin) weapons.choose_weapon(megaman) weapons.choose_weapon(wall_E) weapons.choose_attack(stegosaurus) weapons.choose_attack(velociraptor) weapons.choose_attack(tyrannosaurus) #Robots marvin.power_level = 120 marvin.attack_power = 70 megaman.power_level = 110 megaman.attack_power = 100 wall_E.power_level = 100 wall_E.attack_power = 60 #Dinos stegosaurus.attack_power = 60 velociraptor.attack_power = 80 tyrannosaurus.attack_power = 100 #Fleet robot_fleet = Fleet() robot_fleet.add_to_fleet([marvin, megaman, wall_E]) # print(robot_fleet.fleet) #Herd dino_herd = Herd() dino_herd.add_to_herd([stegosaurus, velociraptor, tyrannosaurus]) # print(dino_herd.herd) #Display fighters and battlefield display(battlefield) # --- Fighters will attack each other randomly, last fighter standing wins!--- def battle(fleet, herd): counter = 0 for element in fleet: fleet_health = 0 for i in range(0, len(element)): fleet_health += element[i].health for obj in herd: herd_health = 0 for a in range(0, len(obj)): herd_health += obj[a].health while counter <= 100 or fleet_health <= 0 or herd_health <= 0: n = random.randint(0, 2) i = random.randint(0, 2) obj[n].attack_robo(element[n]) element[n].attack_dino(obj[i]) counter += 1 battle(robot_fleet.fleet, dino_herd.herd) #Stats print(wall_E) print(megaman) print(marvin) print(stegosaurus) print(velociraptor) print(tyrannosaurus) def conclude_battle(robot_fleet, dino_herd): for element in robot_fleet.fleet: count = 0 while count <= len(element): for robot in element: if robot.status == 'Defeated' or robot.status == 'Resting': element.remove(robot) count += 1 if len(element) == 0: return ctypes.windll.user32.MessageBoxW( 0, 'Battle concluded: Dinos have won!', 'Robots vs Dinosaurs', 64) for element in dino_herd.herd: count = 0 while count <= len(element): for dino in element: if dino.health <= 0 or dino.status == 'Resting': element.remove(dino) count += 1 if len(element) == 0: return ctypes.windll.user32.MessageBoxW( 0, 'Battle concluded: Robos have won!', 'Robots vs Dinosaurs', 64) return ctypes.windll.user32.MessageBoxW(0, 'Battle is Ongoing!', 'Robots vs Dinosaurs', 64) conclude_battle(robot_fleet, dino_herd)