Пример #1
0
 def draw_maze(self, maze_level):
     # Explores line by line the file containing the maze iot extract the different items (walls, characters, etc)
     file = open(maze_level, "r")
     f = file.readlines()
     for j in range(len(f)):
         for i in range(len(f[j])):
             # Reminder: here are the 2 variables for the x and y of maze items. Value 40 is for the sprite size
             x = i * Config.SPRITE_SIZE
             y = j * Config.SPRITE_SIZE
             # Exploration of the file to get the different items of the maze : wall, hero, warden, corridors
             if f[j][i] == "X":
                 # Draws the walls of the maze and stores the parts of the wall in a maze
                 self.wall = Items.Wall(x, y)
                 self.wall.picture = self.draw_picture(self.wall.pic)
                 self.window.blit(self.wall.picture, (x, y))
                 self.walls[(x, y)] = self.wall
             elif f[j][i] == "W":
                 self.warden = Items.Warden(x, y)
                 self.warden.picture = self.draw_picture(self.warden.pic)
                 self.window.blit(self.warden.picture, (x, y))
             elif f[j][i] == "M":
                 self.macgyver = Items.MacGyver(x, y)
                 self.macgyver.picture = self.draw_picture(
                     self.macgyver.pic)
                 self.window.blit(self.macgyver.picture, (x, y))
             else:
                 if x < MAZE_HEIGHT:
                     # Stores the empty spaces in a list, iot be used for displaying the items
                     self.corridors.append((x, y))
     # Draws the white box where the score will be displayed
     pygame.draw.rect(self.window, Config.SCORE_BACKGROUND,
                      (440, 5, 120, 30))
     self.window.blit(self.text_window, (450, 5))
Пример #2
0
 def __init__(self):
     self.my_coin_pouch = Items.CoinPouch()
     self.my_coin_pouch.add_to_me("Gold", 15)
     self.inventory = [self.my_coin_pouch, Items.Fist()]
     self.hp = 100
     self.location_x, self.location_y = World.starting_position
     self.victory = False
Пример #3
0
def AskForFoodCheck(*variables):
    PlayerList = variables[0]
    TargetList = variables[1]
    DonorsList = [x for x in PlayerList if x not in TargetList]
    if len(DonorsList) < 1 or len(TargetList) < 1:
        return False
    functionList = [
        Items.getItemFunction("edible plant"),
        Items.getItemFunction("processed food")
    ]
    foodExists = False
    foodNeeded = len(TargetList)
    charismaSum = 0
    beggarCharismaSum = 0
    for p in DonorsList:
        charismaSum += p.Charisma
        #result = p.findItemWithOneOfItemFunctions(functionList)
        result = p.findListOfItemsWithOneOfItemFunctions(functionList)
        if len(result) > 0:
            foodNeeded -= len(result)
            if foodNeeded <= 0:
                foodExists = True
    for b in TargetList:
        beggarCharismaSum += b.Charisma
    randomNumber = random.randint(0, 5)
    if foodExists and (beggarCharismaSum / len(TargetList) +
                       randomNumber) > (charismaSum / (len(DonorsList))):
        return True
    return False
Пример #4
0
    def steal(self, pDEX, pClass):
        playerDEX = pDEX
        player = pClass
        stealDC = 20
        stealChance = random.randint(1, 20) + playerDEX
        if stealChance >= stealDC:
            if player == "Child":
                weapon = Items.Weapon("Sword", 2, 6, 0)
            elif player == "Adult":
                weapon = Items.Weapon("Two-Handed Sword", 3, 12, 0)
            elif player == "Anime Fan":
                weapon = Items.Weapon("Gunblade", 4, 8, 0)
            elif player == "LARPer":
                weapon = Items.Weapon("Battle Hammer", 5, 10, 0)
            elif player == "King Arthur":
                weapon = Items.Weapon("Excalibur", 20, 1000000, 0)
            print('''
You have successfully stolen the time, effort, and skill
that was put into this item! I hope it's worth it.
.......you monster.''')
            caught = False
        else:
            print('''
You were caught stealing! They don't take very well to that here.
You have forever lost the love of your family and friends,
and also you get kicked out of the faire.''')
            weapon = None
            caught = True
        return weapon, caught
Пример #5
0
def AskForFoodSuccess(*variables):
    PlayerList = variables[0]
    TargetList = variables[1]
    DonorsList = [x for x in PlayerList if x not in TargetList]
    if len(DonorsList) < 1 or len(TargetList) < 1:
        return False

    listOfPlayersAndCalories = []
    functionList = [
        Items.getItemFunction("edible plant"),
        Items.getItemFunction("processed food")
    ]
    maxCalorie = 0
    maxCaloriePlayer = None
    for b in TargetList:
        for p in DonorsList:
            itemCalories = 0
            listOfFoodItems = p.findListOfItemsWithOneOfItemFunctions(
                functionList)
            for foodItem in listOfFoodItems:
                itemCalories += foodItem.value
            if itemCalories > maxCalorie:
                maxCalorie = itemCalories
                maxCaloriePlayer = p
        itemToGive = maxCaloriePlayer.findItemWithOneOfItemFunctions(
            functionList)
        if maxCalorie == 0 or not itemToGive[0]:
            theLog.writeToLog(
                'Error, m**********r! No food to give, even though check found some!\n'
            )
            raise Exception("Error: food can't be given")
        b.addItem(itemToGive[1])
        maxCaloriePlayer.removeItem(itemToGive[1])
Пример #6
0
 def randomItem(self):
     self.item = Items(BOTTLE)
     #while pygame.sprite.collide_mask(self.item, self.baby):
     while pygame.Rect.colliderect(self.item.rect, self.baby.rect):
         self.item = Items(BOTTLE)
     self.itemSprite = pygame.sprite.GroupSingle(self.item)
     self.itemSprite.draw(self.image)
Пример #7
0
	def __init__(self):
		self.name = "Character"
		self.player_name = "Zorg"
		self.character_level = 1
		self.hp = 100
		self.location_x, self.location_y = (0,0)

		self.inventory = Inventory()
		self.inventory.add_to_pouch("Gold", 15)
		self.inventory.add_to_inventory(Items.Fist(), 1)
		self.inventory.equip_main_hand("Fist")

		self.inventory.add_to_inventory(Items.ShreddedRags(), 1)
		self.inventory.equip_armor("Shredded Rags")

		
		self.character_class = "No Class"
		self.strength = 10
		self.dexterity = 10
		self.constitution = 10
		self.intellect = 10
		self.attributes = {"Strength: " : self.strength, "Dexterity: " : self.dexterity,
							"Constitution: " : self.constitution, "Intellect: " : self.intellect}


		self.weapon = self.inventory.get_main_hand_equipped()
		self.dmg_mod = 4

		self.armor = self.inventory.get_armor_equipped()
		self.ArmorClass = self.armor.AC
def createCharacter(name):
    global newPlayer
    newPlayer = Player.Player(name)
    newPlayer.equipt("Head", Items.Armour("Nothing", 0, "Head"))
    newPlayer.equipt("Chest", Items.Armour("Nothing", 0, "Chest"))
    newPlayer.equipt("Legs", Items.Armour("Nothing", 0, "Legs"))
    newPlayer.equipt("Left Hand", Items.Weapon(1, 5, "Fist"))
    newPlayer.equipt("Right Hand", Items.Weapon(1, 5, "Fist"))
Пример #9
0
def WriteItemLocations(locations):
	codeLookup = Items.makeItemCodeDict()
	textLookup = Items.makeItemTextDict()
	for i in locations:
		if i.isItem():
			WriteLocationToRom(i,codeLookup,textLookup)
		elif i.isGym():
			WriteBadgeToRom(i)
Пример #10
0
 def __init__(self):
     Ghost.__init__(self)
     self.items = [Items.IronSword(), Items.HpPot(1), Items.ManaPot(1)]
     self.expGained = 108
     self.goldGained = 105
     self.hp = 45
     self.attack = 23
     self.defence = 0
Пример #11
0
 def __init__(self):
     Ghost.__init__(self)
     self.items = [None, Items.HpPot(3),
                   Items.LavaShield()]  # only way to get lava shield
     self.expGained = 2300
     self.goldGained = 1200
     self.hp = 450
     self.attack = 120
     self.defence = 170
Пример #12
0
 def __init__(self):
     Ghost.__init__(self)
     self.items = [None, Items.HpPot(3),
                   Items.GoldShield()]  # shield is rare
     self.expGained = 154
     self.goldGained = 132
     self.hp = 89
     self.attack = 35
     self.defence = 55
Пример #13
0
class Environnement():
    def __init__(self,
                 N_items,
                 N_recommended,
                 behaviour="random",
                 rewardType='Similarity',
                 rewardParameters=[1, 1],
                 proba_p=0.7,
                 specific_items=None,
                 name='envi_01'):  #proba_p for ramdom choice (customer)
        self.items = Items(N_items)
        self.recommendation = Recommendation(self.items, N_recommended)
        self.customer = Customer(self.items, self.recommendation, behaviour,
                                 proba_p, specific_items)
        self.name = name
        self.rewardType = rewardType
        self.rewardParameters = rewardParameters

    def endEpisode(self):
        self.customer.endEpisode()
        self.recommendation.endEpisode()

    #self.step to simulate new step of the environnement
    def step(
        self, agentRecommendation
    ):  #here agentRecommendation is the items recommended by the agent
        self.recommendation.recommend(
            agentRecommendation)  #We have set the new recommendations
        self.customer.choice()
        reward = self.computeReward()
        return reward

    def computeReward(
            self
    ):  #This function will be refined to get more realistic rewards
        if self.rewardType == 'Similarity':
            reward = -self.items.items[
                self.customer.choice_id].cost * self.rewardParameters[0]
            reward += self.items.similarities[
                self.customer.previous_choice_id][
                    self.customer.choice_id] * self.rewardParameters[1]
        elif self.rewardType == 'Trust':
            reward = -(self.items.items[self.customer.choice_id].cost
                       ) * self.rewardParameters[0]
            reward += self.customer.trust_recommendation * self.rewardParameters[
                1]
        else:
            print("Error : wrong reward type")
            return None

        return reward

    def display(self, print_item=False):
        print('---------ENVIRONNEMENT DISPLAY--------')
        self.items.display(print_item)
        self.recommendation.display()
        self.customer.display()
Пример #14
0
    def __init__(self):

        base.disableMouse()
        self.world = World()
        self.items = Items()
        self.energy = self.items.getEnergy()
        self.minicar = self.world.getMinicar()
        self.colisiones = Colisiones(self.energy, self.minicar)
        self.actores = Actors()
Пример #15
0
def Robes(Unit):
    u = Unit
    uHP = WSD[Unit].HP
    uENE = WSD[Unit].ENE
    uSTR = WSD[Unit].STR
    uSPR = WSD[Unit].SPR
    uSKL = WSD[Unit].SKL
    uABL = WSD[Unit].ABL
    uAGI = WSD[Unit].AGI
    uEVA = WSD[Unit].EVA
    uTGH = WSD[Unit].TGH
    uRES = WSD[Unit].RES
    uLCK = WSD[Unit].LCK
    uPAR = WSD[Unit].PAR
    uMAR = WSD[Unit].MAR
    uWT = WSD[Unit].ArmorWT
    choice = input(
        "Select an action type!\n [St]atcheck!\n [B]attlestaff!\n [I]nventory!\n "
    )
    if choice == "ST" or choice == "St" or choice == "st":
        print("-----------------")
        print("HP:", uHP)
        print("ENE:", uENE)
        print("STR:", uSTR)
        print("SPR:", uSPR)
        print("SKL:", uSKL)
        print("ABL:", uABL)
        print("AGI:", uAGI)
        print("EVA:", uEVA)
        print("TGH:", uTGH)
        print("RES:", uRES)
        print("LCK:", uLCK)
        print("PAR:", uPAR)
        print("MAR:", uMAR)
        print("WT:", uWT)
        print("-----------------")
    elif choice == "B" or choice == "b":
        choice = input("Select an action!\n [Q]uick!\n [N]ormal!\n [H]ard!\n ")
        if choice == "Q" or choice == "q":
            AttacksOO.Battlestaff("NormalBronzeBattlestaff2", "Robes", Wind, 1,
                                  0).QATK
        elif choice == "N" or choice == "n":
            AttacksOO.Battlestaff("NormalBronzeBattlestaff2", "Robes", Wind, 1,
                                  0).NATK
        elif choice == "H" or choice == "h":
            AttacksOO.Battlestaff("NormalBronzeBattlestaff2", "Robes", Wind, 1,
                                  0).HATK
    elif choice == "I" or choice == "i":
        choice = input(
            "Select an Item!\n [G]reen Apple!\n [O]range!\n [T]hrowing Stars!\n "
        )
        if choice == "G" or choice == "g":
            Items.GreenApple("Robes")
        elif choice == "O" or choice == "o":
            Items.SweetOrange("Robes")
        elif choice == "T" or choice == "t":
            Items.ThrowingStar("Robes")
Пример #16
0
	def set_character_class(self, class_name):
		"""
		Changes the player Class instanced attributes (Strength Dexterity Constitution Intellect)
		 Depending on the class_name input.

		Input:
			class_name <str>
		"""
		if (class_name == "Barbarian"):
			self.character_class = class_name
			self.strength = 14
			self.dexterity = 8
			self.constitution = 12
			self.intellect = 6

			self.inventory.add_to_inventory(Items.BattleAxe(), 1)
			self.inventory.equip_main_hand("Battle Axe")

		elif (class_name == "Knight"):
			self.character_class = class_name
			self.strength = 12
			self.dexterity = 8
			self.constitution = 12
			self.intellect = 8

			self.inventory.add_to_inventory(Items.LongSword(), 1)
			self.inventory.equip_main_hand("Long Sword")

		elif (class_name == "Nerd"):
			self.character_class = class_name
			self.strength = 8
			self.dexterity = 8
			self.constitution = 8
			self.intellect = 16

		elif (class_name == "Rogue"):
			self.character_class = class_name
			self.strength = 6
			self.dexterity = 14
			self.constitution = 8
			self.intellect = 12

			self.inventory.add_to_inventory(Items.Dagger(), 1)
			self.inventory.equip_main_hand("Dagger")
	
		else:
			self.character_class = "No Class"
			self.strength = 10
			self.dexterity = 10
			self.constitution = 10
			self.intellect = 10

		self.update_attribute_dictionary("Strength: ", self.strength)
		self.update_attribute_dictionary("Dexterity: ", self.dexterity)
		self.update_attribute_dictionary("Constitution: ", self.constitution)
		self.update_attribute_dictionary("Intellect: ", self.intellect)
Пример #17
0
class Player:
	inventory = [Items.Gold(15), Items.Rock()]
	hp = 100
	location_x, location_y = (2, 2)
	victory = False
	
	def is_alive(self):
		return self.hp > 0
		
	def print_inventory(self):
		for item in self.inventory:
			print(item, '\n')
	
	def do_action(self, action, **kwargs):
		action_method = getattr(self, action.method.__name__)
		if action_method:
			action_method(**kwargs)
			
	def flee(self, tile):
		"""Moves the player randomly to an adjacent tile"""
		available_moves = tile.adjacent_moves()
		r = random.randint(0, len(available_moves) - 1)
		self.do_action(available_moves[r])
	
	def move(self, dx, dy):
		self.location_x += dx
		self.location_y += dy
		print(World.tile_exists(self.location_x, self.location_y).intro_text())

	def move_north(self):
		self.move(dx=0, dy=1)

	def move_south(self):
		self.move(dx=0, dy=-1)
	
	def move_east(self):
		self.move(dx=1, dy=0)
	
	def move_west(self):
		self.move(dx=-1, dy=0)
	
	def attack(self, enemy):
		best_Weapon = None
		max_dmg = 0
		for i in self.inventory:
			if isinstance(i, Items.Weapon):
				if i.damage > max_dmg:
					max_damage = i.damage
					best_Weapon = i
					
		print("You use {} against {}! and deal {}!".format(best_Weapon.name, enemy.name, best_Weapon.damage))
		enemy.hp -= best_Weapon.damage
		if not enemy.is_alive():
			print("You killed {}!".format(enemy.name))
		else:
			print("{} HP is {}.".format(enemy.name, enemy.hp))
Пример #18
0
 def __init__(self):
     Ghost.__init__(self)
     self.items = [Items.LavaSword(),
                   Items.HpPot(3),
                   Items.ManaPot(3)]  #only way to get lava sword
     self.expGained = 2100
     self.goldGained = 1500
     self.hp = 250
     self.attack = 180
     self.defence = 90
Пример #19
0
 def __init__(self):
     self.expGained = 43
     self.goldGained = 54
     self.hp = 43
     self.attack = 32
     self.defence = 3
     self.items = [Items.HpPot(1), Items.ManaPot(1), None]
     self.spirte = None
     self.defenceEquiped = 0
     self.attackEquiped = 0
Пример #20
0
def setMonstersItems(size): # defini aleatoirement la presence de monstres et d'objets dans chaque zone
    Monsters.checkList()
    Items.checkList()
    for i in range (size):
        for j in range (size):
            if (i,j) != (0,0) :
                site = random.randint(0,4)
                if site >= 3:
                    map[i][j]["monster"] = dict(Monsters.addRandom())
                elif site > 0:
                    map[i][j]["items"].append(Items.addRandom())
Пример #21
0
def EatFoodCheck(*variables):
    PlayerList = variables[0]
    if not PlayerList:
        return False
    for p in PlayerList:
        functionList = [
            Items.getItemFunction("edible plant"),
            Items.getItemFunction("processed food")
        ]
        result = p.findItemWithOneOfItemFunctions(functionList)
    return result[0]
Пример #22
0
def Josephine(Unit):
    u = Unit
    uHP = WSD[Unit].HP
    uENE = WSD[Unit].ENE
    uSTR = WSD[Unit].STR
    uSPR = WSD[Unit].SPR
    uSKL = WSD[Unit].SKL
    uABL = WSD[Unit].ABL
    uAGI = WSD[Unit].AGI
    uEVA = WSD[Unit].EVA
    uTGH = WSD[Unit].TGH
    uRES = WSD[Unit].RES
    uLCK = WSD[Unit].LCK
    uPAR = WSD[Unit].PAR
    uMAR = WSD[Unit].MAR
    uWT = WSD[Unit].ArmorWT
    choice = input(
        "Select something!\n [St]atcheck!\n [K]nife!\n [I]nventory!\n ")
    if choice == "ST" or choice == "St" or choice == "st":
        print("-----------------")
        print("HP:", uHP)
        print("ENE:", uENE)
        print("STR:", uSTR)
        print("SPR:", uSPR)
        print("SKL:", uSKL)
        print("ABL:", uABL)
        print("AGI:", uAGI)
        print("EVA:", uEVA)
        print("TGH:", uTGH)
        print("RES:", uRES)
        print("LCK:", uLCK)
        print("PAR:", uPAR)
        print("MAR:", uMAR)
        print("WT:", uWT)
        print("-----------------")
    elif choice == "K" or choice == "k":
        choice = input("Select an action!\n [Q]uick!\n [N]ormal!\n [H]ard!\n ")
        if choice == "Q" or choice == "q":
            AttacksOO.Knife(WSD["Josephine"].Weapon1, "Josephine", Wind, 1.3,
                            0, 0, 0).QATK
        elif choice == "N" or choice == "n":
            AttacksOO.Knife(WSD["Josephine"].Weapon1, "Josephine", Wind, 1.3,
                            0, 0, 0).NATK
        elif choice == "H" or choice == "h":
            AttacksOO.Knife(WSD["Josephine"].Weapon1, "Josephine", Wind, 1.3,
                            0, 0, 0).HATK
    elif choice == "I" or choice == "i":
        choice = input("Use which Item?\n [P]otion!\n [R]ed Apple!\n ")
        if choice == "P" or choice == "p":
            Items.HealthPotion("Josephine")
        elif choice == "R" or choice == "r":
            Items.RedApple("Josephine")
Пример #23
0
def enemy_death(enemy):
    swan_song()
    print(f"\nThe {enemy.name} has been defeated!")
    if enemy.primary_weapon != None:
        print(f"\t**s {enemy.primary_weapon.quality} {enemy.primary_weapon.name} falls to the ground.")
        print(f"\tThe equipment has been added to your inventory.")
        player.inventory.append(enemy.primary_weapon)
    print(f"\tYou earn {enemy.experience_reward} experience points!")
    print()
    player.experience_points += enemy.experience_reward
    active_enemies.remove(enemy)
    player.level_up(player.level)
    Items.search_for_loot(enemy, player)
    return
Пример #24
0
def Gachum(Gachum):
    u = Gachum
    uMHP = u + "MHP"
    uENE = u + "ENE"
    uSTR = u + "STR"
    uSPR = u + "SPR"
    uSKL = u + "SKL"
    uABL = u + "ABL"
    uAGI = u + "AGI"
    uEVA = u + "EVA"
    uTGH = u + "TGH"
    uRES = u + "RES"
    uLCK = u + "LCK"
    uPAR = u + "PAR"
    uMAR = u + "MAR"
    choice = input(
        "Select an action type!\n [St]atcheck!\n [K]nife!\n [S]licer!\n [I]nventory!\n "
    )
    if choice == "ST" or choice == "St" or choice == "st":
        print("These are the stats for", u, "as they currently stand!")
        print("-----------------")
        print("Health Pool", (WSD[uMHP]))
        print("Energy Pool", (WSD[uENE]))
        print("Strength:", (WSD[uSTR]))
        print("Spirit:", (WSD[uSPR]))
        print("Skill:", (WSD[uSKL]))
        print("Ability:", (WSD[uABL]))
        print("Agility:", (WSD[uAGI]))
        print("Evasion:", (WSD[uEVA]))
        print("Toughness:", (WSD[uTGH]))
        print("Resistance:", (WSD[uRES]))
        print("Luck:", (WSD[uLCK]))
        print("Physical Resist:", (WSD[uPAR]))
        print("Magical Resist:", (WSD[uMAR]))
        print("-----------------")
    elif choice == "K" or choice == "k":
        TLB.Knife("Gachum", "NormalBoneKnife7", "Lightning")
    elif choice == "S" or choice == "s":
        TLB.Slicer("Gachum", "NormalTinSlicer3", "Lightning")
    elif choice == "I" or choice == "i":
        choice = input(
            "Select an Item!\n [G]olden Apple!\n [S]weet Orange!\n [T]hrowing Stars!\n "
        )
        if choice == "G" or choice == "g":
            Items.GoldenApple("Gachum")
        elif choice == "S" or choice == "s":
            Items.SweetOrange("Gachum")
        elif choice == "T" or choice == "t":
            Items.ThrowingStar("Gachum")
Пример #25
0
def extract_info_asignatura(html_text):
    html_soup = BeautifulSoup(html_text, 'html5lib')
    filas_info = html_soup.find("table", {
        "class": "tabla-guias"
    }).find_all("tr")
    nom, cod, curso, tipo, periodo, ects = None, None, None, None, None, None
    for fila_info in filas_info:
        if fila_info.find_all("td") and len(fila_info.find_all("td")) == 2:
            nombre_campo = fila_info.find_all("td")[0].get_text().strip()
            valor_campo = fila_info.find_all("td")[1].get_text().strip()
            # print(nombre_campo, valor_campo)

            if nombre_campo == "NOMBRE DE LA ASIGNATURA":
                nom = valor_campo
                nom = nom.replace("\n", " ")
            elif nombre_campo == "CÓDIGO":
                cod = valor_campo
            elif nombre_campo == "CURSO ACADÉMICO":
                curso = valor_campo
            elif nombre_campo == "TIPO":
                tipo = valor_campo
            elif nombre_campo == "PERIODO":
                periodo = valor_campo
                periodo = periodo.replace(u'\xa0', u' ')
                periodo = periodo.replace(u'  ', u' ')
            elif "ECTS" in nombre_campo:
                ects = valor_campo

    item_asignatura = Items.ItemAsignatura(codigo=cod,
                                           nombre=nom,
                                           curso=curso,
                                           periodo=periodo,
                                           tipo=tipo,
                                           creditos=ects)
    return item_asignatura
Пример #26
0
 def display_objects(self):
     # Randomly displays the objects in the maze corridors
     # Chosen variables intend to lay objects far enough from warden
     number_items = len(Config.objects_to_be_collected_pictures)
     low = 1
     high = len(self.corridors) // (number_items + 2)
     # Scatters the objects on the corridors of the maze by slicing the list of corridor coordinates \
     # and randomly laying an object in this very slice
     for i in range(number_items):
         # Displays the objects in the maze and stores them in a class list
         location = randrange(low, high)
         # The coordinates of the corridors have been saved as tuples as (x,y)
         self.object_to_collect = Items.ToCollect(
             self.corridors[location][0], self.corridors[location][1])
         self.object_to_collect.picture = self.draw_picture(
             self.object_to_collect.pic)
         # Steps up to another slice of the list
         low += high
         high += high
         # Objects to collect are store in this list, iot be retrieved afterwards
         self.objects_to_collect.append(self.object_to_collect)
         self.window.blit(
             self.object_to_collect.picture,
             (self.corridors[location][0], self.corridors[location][1]))
     return self.window
Пример #27
0
 def __init__(self,
              N_items,
              N_recommended,
              behaviour="random",
              rewardType='Similarity',
              rewardParameters=[1, 1],
              proba_p=0.7,
              specific_items=None,
              name='envi_01'):  #proba_p for ramdom choice (customer)
     self.items = Items(N_items)
     self.recommendation = Recommendation(self.items, N_recommended)
     self.customer = Customer(self.items, self.recommendation, behaviour,
                              proba_p, specific_items)
     self.name = name
     self.rewardType = rewardType
     self.rewardParameters = rewardParameters
Пример #28
0
def random_event():
    x = random.randint(0, 50)
    if x in [0, 1]:
        print("\nThe grinding sound of metal gears unexpectedly catches your attention...")
        enemy = Entities.BasicEnemy(name='Drone', target=player)
        if random.randint(0, 1) < 1 == True:
            weapon = Items.Weapon(*Items.basic_primary_weapons[random.randint(0, len(Items.basic_primary_weapons) - 1)])
            enemy.equip_primary_weapon(weapon)
        active_enemies.append(enemy)
        time.sleep(2)
        print(f"You've wandered into a hidden {enemy.name}!")
        time.sleep(1)
        enemy.combat_turn()
        enemy_encounter(player, enemy)
    # elif x == 3:
    #     print()
    #     print("You happen upon some edible berries on the side of the road!")
    #     print("\tYour health is increased by 1!")
    #     time.sleep(2)
    #     player_health += 1
    # elif x == 4:
    #     print()
    #     print("An angry squirrel bites you on the ankle!")
    #     print("\tYour health is decreased by 1!")
    #     player_health -= 1
    #     time.sleep(2)
    else:
        return
Пример #29
0
 def startGame(self):
     #score
     self.numDP = 0
     self.numDH = 3
     self.heartString = '♥♥♥'
     self.numBH = 5
     self.babyHealthString = '▓▓▓▓▓▓'
     self.numProj = 10
     self.textBH = self.font.render(
         BABY_HEALTH_LABEL + self.babyHealthString, True, PINK, WHITE)
     #daddy
     self.daddy = Daddy()
     self.daddy.rect.center = self.rect.center
     self.daddySprite = pygame.sprite.GroupSingle(self.daddy)
     self.daddySprite.draw(self.image)
     #baby
     self.baby = Baby()
     self.babySprite = pygame.sprite.GroupSingle(self.baby)
     self.babySprite.draw(self.image)
     while self.baby.rect.colliderect(self.daddy.rect):
         self.baby = Baby()
         self.babySprite.add(self.baby)
         self.babySprite.draw(self.image)
     #items
     self.item = Items(EMPTY)
     self.itemSprite = pygame.sprite.GroupSingle(self.item)
     #enemies!
     self.enemyGroup = pygame.sprite.Group()
     #projectiles!
     self.projectileGroup = pygame.sprite.Group()
     #sound volumes
     self.zombieEats.set_volume(.1)
Пример #30
0
def loadInventory(player):
    inventoryInfile = open(inventoryData, 'rb')
    inventorySave = pickle.load(inventoryInfile)
    items = []
    for item in inventorySave[2]:
        items.append(Items.Item(item[0], item[1], item[2], item[3], item[4], item[5]))
    return Inventory.Inventory(inventorySave[0], inventorySave[1], items, player)
Пример #31
0
def Robes(Robes):
    u = Robes
    uMHP = u + "MHP"
    uENE = u + "ENE"
    uSTR = u + "STR"
    uSPR = u + "SPR"
    uSKL = u + "SKL"
    uABL = u + "ABL"
    uAGI = u + "AGI"
    uEVA = u + "EVA"
    uTGH = u + "TGH"
    uRES = u + "RES"
    uLCK = u + "LCK"
    uPAR = u + "PAR"
    uMAR = u + "MAR"
    choice = input(
        "Select an action type!\n [St]atcheck!\n [B]attlestaff!\n [I]nventory!\n "
    )
    if choice == "ST" or choice == "St" or choice == "st":
        print("These are the stats for", u, "as they currently stand!")
        print("-----------------")
        print("Health Pool", (WSD[uMHP]))
        print("Energy Pool", (WSD[uENE]))
        print("Strength:", (WSD[uSTR]))
        print("Spirit:", (WSD[uSPR]))
        print("Skill:", (WSD[uSKL]))
        print("Ability:", (WSD[uABL]))
        print("Agility:", (WSD[uAGI]))
        print("Evasion:", (WSD[uEVA]))
        print("Toughness:", (WSD[uTGH]))
        print("Resistance:", (WSD[uRES]))
        print("Luck:", (WSD[uLCK]))
        print("Physical Resist:", (WSD[uPAR]))
        print("Magical Resist:", (WSD[uMAR]))
        print("-----------------")
    elif choice == "B" or choice == "b":
        TLB.Staff("Robes", "NormalBronzeBattlestaff2", "Wind")
    elif choice == "I" or choice == "i":
        choice = input(
            "Select an Item!\n [G]reen Apple!\n [O]range!\n [T]hrowing Stars!\n "
        )
        if choice == "G" or choice == "g":
            Items.GreenApple("Robes")
        elif choice == "O" or choice == "o":
            Items.SweetOrange("Robes")
        elif choice == "T" or choice == "t":
            Items.ThrowingStar("Robes")
Пример #32
0
 def h_type_all_categories(self, m):
     return (
         "<ul>"
         + "\n".join(
             '<li><a href="' + getname(i["category"], self.params["ext"]) + '">' + i["category"] + "</a></li>"
             for i in Items.getCategoriesForType(self.params["type"])
         )
         + "</ul>"
     )
Пример #33
0
 def h_type_all_link(self, m):
     return (
         "<ul>"
         + "\n".join(
             '<li><a href="' + getname(i["type"], self.params["ext"]) + '">' + i["type"] + "</a></li>"
             for i in Items.getTypes()
         )
         + "</ul>"
     )
Пример #34
0
def setMonstersItems(size):
    for i in range (size):
        for j in range (size):
            if (i,j) != (0,0) :
                site = random.randint(0,4)
                if site >= 3:
                    map[i][j]["monster"] = dict(Monsters.addRandom())
                elif site > 0:
                    map[i][j]["items"].append(Items.addRandom())
Пример #35
0
    def __init__(self):

        base.disableMouse()
        self.world      = World()
        self.items      = Items()
        self.energy     = self.items.getEnergy()
        self.minicar    = self.world.getMinicar()
        self.colisiones = Colisiones( self.energy, self.minicar )
        self.actores    = Actors()
Пример #36
0
def generate_tree():
    print "Generating tree..."
    os.system("rm -f -r tmp/*")
    for row in Items.getdata():
        path = strtopath(row[11], row[1])
        path1 = "tmp/" + path
        print "Store data to " + path1
        try:
            os.makedirs(path1)
        except:
            pass
        tmprow = []
        for i in row:
            tmprow.append(re.sub("\s+", " ", str(i)).strip())
        X.File.save(path1 + "/data.txt", "\t".join(tmprow) + "\n", True)
        X.File.save("tmp/categories_list.txt", path + "\n", True)
        # Generate other static data
    os.system("sort -u -otmp/categories.txt tmp/categories_list.txt")
    X.File.save("tmp/letters.txt", "\n".join(Items.getletters()))
Пример #37
0
 def h_category_all_link(self, m):
     res = ["<ul>"]
     for i in Items.getcategories("tmp/" + self.params["category"]):
         res.append(
             '<li><a href="http://'
             + self.params["name"]
             + "/"
             + self.params["category"]
             + "/"
             + i
             + '">'
             + pathtostr(self.params["category"] + "/" + i)
             + "</a></li>"
         )
     res.append("</ul>")
     return "\n".join(res)
Пример #38
0
 def h_topdownloads_all_link(self, m):
     res = ["<ul>"]
     for i in Items.gettopitems(self.params["topitems"]):
         res.append(
             '<li><a href="http://'
             + self.params["name"]
             + "/"
             + strtopath(i["manufacturer"], i["category"])
             + "/"
             + getname(i["name"], self.params["ext"])
             + '">'
             + i["name"]
             + "</a></li>"
         )
     res.append("</ul>")
     return "\n".join(res)
Пример #39
0
 def h_letter_all_items(self, m):
     return (
         "<ul>"
         + "\n".join(
             '<li><a href="http://'
             + self.params["name"]
             + "/"
             + strtopath(i["manufacturer"], i["category"])
             + "/"
             + getname(i["name"], self.params["ext"])
             + '">'
             + i["name"]
             + "</a> </li>"
             for i in Items.getletteritems(self.params["letter"], int(self.params["page"]), self.params["num"])
         )
         + "</ul>"
     )
Пример #40
0
 def h_recent_downloads(self, m):
     res = ["<ul>"]
     for i in Items.gettopitems(int(m[1])):
         res.append(
             '<li><a href="http://'
             + self.params["name"]
             + "/"
             + strtopath(i["manufacturer"], i["category"])
             + "/"
             + getname(i["name"], self.params["ext"])
             + '">'
             + i["name"]
             + "</a><br><span>"
             + str(i["uploader_notes"])
             + "</span></li>"
         )
     res.append("</ul>")
     return "\n".join(res)
Пример #41
0
 def h_category_items_link(self, m):
     res = ["<ul>"]
     for i in Items.getitems("tmp/" + self.params["category"]):
         item = dict(map(None, Items.fields, i))
         res.append(
             '<li><a href="http://'
             + self.params["name"]
             + "/"
             + self.params["category"]
             + "/"
             + getname(item["name"], self.params["ext"])
             + '">'
             + item["name"]
             + "</a><br><span>"
             + item["uploader_notes"]
             + "</span></li>"
         )
     res.append("</ul>")
     return "\n".join(res)
Пример #42
0
 def h_best_downloads(self, m):
     return (
         "<ul>"
         + "\n".join(
             '<li><a href="http://'
             + self.params["name"]
             + "/"
             + self.params["category"]
             + "/"
             + getname(i["name"], self.params["ext"])
             + '">'
             + i["name"]
             + "</a><br><span>"
             + i["uploader_notes"]
             + "</span></li>"
             for i in Items.gettopitems(int(m[1]), "tmp/" + self.params["category"])
         )
         + "</ul>"
     )
 def on_init(self):
     pygame.init()
     self._display_surf = pygame.display.set_mode(self.size, pygame.HWSURFACE | pygame.DOUBLEBUF)
     self._display_surf.fill(self._background)
     self._running = True
     self._screen = "Main" #Main - original screen. itemCat - screen showing items. checkOut - checkout screen.
     self.buttons = []
     self._itemCategories = []
     def itemCategory0Command(self):
         print "itemCat0Command"
         self._screen = "itemCatScreen:00"
     def itemCategory1Command(self):
         print "itemCat0Command"
         self._screen = "itemCatScreen:01"
     def itemCategory2Command(self):
         print "itemCat0Command"
         self._screen = "itemCatScreen:02"
     def itemCategory3Command(self):
         print "itemCat0Command"
         self._screen = "itemCatScreen:03"
         
     def itemIncrementCommand(self):
         print "itemIncerementCommand"
         self.incriment()
     
     def itemDecrementCommand(self):
         print "itemDecrementCommand"
         self.decrement()
     
     itemsToAdd = []    
     itemCat0ItemNumber0 = Items.item("Apollo", 0000, 40000, 0, (100,100), 144, 144, "Images/APOLLO.jpg", itemIncrementCommand, itemDecrementCommand)
     itemCat0ItemNumber1 = Items.item("Mercury", 0001, 40000, 0, (100,300), 144, 144, "Images/Mercury.jpg", itemIncrementCommand, itemDecrementCommand)
     itemCat0ItemNumber2 = Items.item("x38", 0002, 40000, 0, (300,100), 144, 144, "Images/x38c.jpg", itemIncrementCommand, itemDecrementCommand)
     itemCat0ItemNumber3 = Items.item("GEMINI", 0003, 40000, 0, (300,300), 144, 144, "Images/GEMINI.jpg", itemIncrementCommand, itemDecrementCommand)
    
     itemsToAdd.append(itemCat0ItemNumber0)
     itemsToAdd.append(itemCat0ItemNumber1)
     itemsToAdd.append(itemCat0ItemNumber2)
     itemsToAdd.append(itemCat0ItemNumber3)
     self._itemCategories.append(iC.itemCatergory("NASA", 00, itemsToAdd, (100,100), 144, 144, "Images/NASA.jpg", itemCategory0Command, self))
     
     itemsToAdd = []
     itemCat1ItemNumber0 = Items.item("Sputnik", 0100, 40000, 0, (100,100), 144, 144, "Images/Sputnik.jpg", itemIncrementCommand, itemDecrementCommand)
     itemCat1ItemNumber1 = Items.item("Vostok", 0101, 40000, 0, (100,300), 144, 144, "Images/Vostok.jpg", itemIncrementCommand, itemDecrementCommand)
     itemCat1ItemNumber2 = Items.item("Voskhod", 0102, 40000, 0, (300,100), 144, 144, "Images/voskhod-1__1.jpg", itemIncrementCommand, itemDecrementCommand)
    
     itemsToAdd.append(itemCat1ItemNumber0)
     itemsToAdd.append(itemCat1ItemNumber1)
     itemsToAdd.append(itemCat1ItemNumber2)
     self._itemCategories.append(iC.itemCatergory("Russian Spaceships", 01, itemsToAdd, (300,100), 144, 144, "Images/Sputnik.jpg", itemCategory1Command, self))
     
     itemsToAdd = []
     itemCat2ItemNumber0 = Items.item("SPACEX - DRAGON 7", 0200, 40000, 0, (100,100), 144, 144, "Images/SPACEX - DRAGON 7.jpg", itemIncrementCommand, itemDecrementCommand)        
     itemCat2ItemNumber1 = Items.item("DREAMCHASER 7", 0201, 40000, 0, (100,300), 144, 144, "Images/DREAMCHASER 7.jpg", itemIncrementCommand, itemDecrementCommand)       
     itemCat2ItemNumber2 = Items.item("CST-100", 0202, 40000, 0, (300,100), 144, 144, "Images/CST-100.jpg", itemIncrementCommand, itemDecrementCommand)       
    
     itemsToAdd.append(itemCat2ItemNumber0)
     itemsToAdd.append(itemCat2ItemNumber1)
     itemsToAdd.append(itemCat2ItemNumber2)
     self._itemCategories.append(iC.itemCatergory("Other Spaceships", 02, itemsToAdd,(100,300) , 144, 144, "Images/CST-100.jpg", itemCategory2Command, self))        
     
     itemsToAdd = []
     itemCat3ItemNumber0 = Items.item("Lemonade", 0300, 40000, 0, (100,100), 144, 144, "Images/Lemonade.jpg", itemIncrementCommand, itemDecrementCommand)       
     itemCat3ItemNumber1 = Items.item("Orange", 0301, 40000, 0, (100,300), 144, 144, "Images/Orange.jpeg", itemIncrementCommand, itemDecrementCommand)       
     itemCat3ItemNumber2 = Items.item("Grapefruit", 0302, 40000, 0, (300,100), 144, 144, "Images/Grapefruit.jpg", itemIncrementCommand, itemDecrementCommand)       
     itemCat3ItemNumber3 = Items.item("Peach Mango", 0303, 40000, 0, (300,300), 144, 144, "Images/Peach Mango.jpg", itemIncrementCommand, itemDecrementCommand)       
    
     itemsToAdd.append(itemCat3ItemNumber0)
     itemsToAdd.append(itemCat3ItemNumber1)
     itemsToAdd.append(itemCat3ItemNumber2)
     itemsToAdd.append(itemCat3ItemNumber3)
     self._itemCategories.append(iC.itemCatergory("TROPICANA FLORIDA SUNSHINE", 03, itemsToAdd, (300,300), 144, 144, "Images/Orange.jpeg", itemCategory3Command, self))
   
   
     
     def goBackCommand(self):
         self._screen = "Main"
     self.backButton = Button.Button(144, 50, (50,50), goBackCommand, None, self)
     self.backButton.currentColor = self.backButton.default_color = self.backButton.hover_color = None #Make sure that the surface is not overwritten
     self.backButton.surface = Label.Label("BACK").getSurface()
   
   
     def goToCheckout(self):
         self._screen = "checkOut"
     self.checkoutButton = Button.Button(144, 50, (500,275), goToCheckout, None, self)
     self.checkoutButton.currentColor = self.checkoutButton.default_color = self.checkoutButton.hover_color = None #Make sure that the surface is not overwritten
     self.checkoutButton.surface = Label.Label("CHECK OUT").getSurface()
     self.surfacesOfItemsShopped = [] #Used for listing items in checkout screen
     self.title = Label.Label("Main Screen").getSurface()
     self.titleLocation = (200, 50)
     #self._image_surf = pygame.image.load("Images/myimage.jpg").convert()
     #self._image_loc = pygame.Rect(70, 70, 50, 20)
     #self._testText = Label.Label("Heyyy")
     
     self.moneyPutInside = 0
     
     def finishButtonClicked(self):
         totalMoneyNeeded = 0
         for itemCat in self._itemCategories:
             for item in itemCat.items:
                 totalMoneyNeeded+=item.amount*item.price
         
         if self.moneyPutInside >= totalMoneyNeeded:
             self._screen= "Main"
             for itemCat in self._itemCategories:
                 for item in itemCat.items:
                     item.amount = 0
             self.moneyPutInside = self.moneyPutInside - totalMoneyNeeded
     self.finishButton = Button.Button(100,50, (600, 250), finishButtonClicked, None, self)
     self.finishButton.currentColor = self.finishButton.default_color = self.finishButton.hover_color = None
     self.finishButton.surface = Label.Label("FINISH").getSurface()
     
     def addMoney10(self):
         self.moneyPutInside+=10
     self.addMoney10Button = Button.Button(60,50, (575, 200), addMoney10, None, self)
     self.addMoney10Button.currentColor = self.addMoney10Button.default_color = self.addMoney10Button.hover_color = None
     self.addMoney10Button.surface = Label.Label("+$10").getSurface()
     
     def addMoney10M(self):
         self.moneyPutInside+=10000000
     self.addMoney10MButton = Button.Button(100,50, (650, 200), addMoney10M, None, self)
     self.addMoney10MButton.currentColor = self.addMoney10MButton.default_color = self.addMoney10MButton.hover_color = None
     self.addMoney10MButton.surface = Label.Label("+$10M").getSurface()
Пример #44
0
def process_site(rec):
    params = dict(map(None, ["name", "num", "output", "map", "ext"], rec.split("|")))
    params["num"] = int(params["num"])
    params["topitems"] = 250

    os.system("rm -f -r " + params["output"] + "/*")
    try:
        os.makedirs(params["output"])
    except:
        pass
    os.system("cp -r tmp/* " + params["output"])

    templater = PageTemplater()
    tparams = copy.copy(params)

    print "Generate index"
    fname = TEMPLATES_DIR + params["name"] + "/index.tpl"
    X.File.save(
        params["output"] + "/" + os.path.splitext(os.path.basename(fname))[0] + "." + params["ext"],
        templater.process(X.File.load(fname), params),
    )

    print "Generate top downloads"
    fname = TEMPLATES_DIR + params["name"] + "/top-downloads.tpl"
    X.File.save(
        params["output"] + "/" + os.path.splitext(os.path.basename(fname))[0] + "." + params["ext"],
        templater.process(X.File.load(fname), params),
    )
    print "Generate partners"
    fname = TEMPLATES_DIR + params["name"] + "/partners.tpl"
    X.File.save(
        params["output"] + "/" + os.path.splitext(os.path.basename(fname))[0] + "." + params["ext"],
        templater.process(X.File.load(fname), params),
    )

    print "Generate letters"
    fname = TEMPLATES_DIR + params["name"] + "/letter.tpl"
    templateCode = X.File.load(fname)
    for letter in CurrentLetters:
        print "Generate for '" + letter + "'"
        itemsNum = Items.getnumletteritems(letter)
        pagesNum = int(math.ceil(float(itemsNum) / tparams["num"]))
        print "Pages count: " + str(pagesNum) + "\tItems count: " + str(itemsNum)
        tparams["letter"] = letter
        tparams["pages"] = pagesNum
        for i in xrange(pagesNum):
            tparams["page"] = i
            if i == 0:
                s = ""
            else:
                s = str(i)
            X.File.save(
                params["output"] + "/" + letter + s + "." + params["ext"], templater.process(templateCode, tparams)
            )

    f = open("tmp/categories.txt", "r")
    for category in f:
        try:
            print "Subcategory: " + params["output"] + "/" + category.strip()
            fname = TEMPLATES_DIR + params["name"] + "/item.tpl"
            tparams["category"] = category.strip()
            for i in Items.getitems("tmp/" + category.strip()):
                tparams["item"] = dict(map(None, Items.fields, i))
                X.File.save(
                    params["output"] + "/" + category.strip() + "/" + getname(tparams["item"]["name"], params["ext"]),
                    templater.process(X.File.load(fname), tparams),
                )
            fname = TEMPLATES_DIR + params["name"] + "/category.tpl"
            X.File.save(
                params["output"] + "/" + category.strip() + "/index." + params["ext"],
                templater.process(X.File.load(fname), tparams),
            )
        except:
            print sys.exc_info()[0]
            print sys.exc_info()[1]

    print "Generate categories"
    fname = TEMPLATES_DIR + params["name"] + "/categories.tpl"
    for root, dirs, files in os.walk("tmp"):
        if not os.path.isfile(root + "/data.txt") and root != "tmp":
            tparams["category"] = root[4:]
            X.File.save(
                params["output"] + "/" + tparams["category"] + "/index." + params["ext"],
                templater.process(X.File.load(fname), tparams),
            )