Ejemplo n.º 1
0
def display_item(item):
    line = "-----------------------------------------------------------------\n"
    line += "{0: <64}".format("| " + item[0]) + "|\n"
    line += "{0: <64}".format("| " + classes.Item_Rarity(item[2]).name + " " + classes.Item(item[1]).name) + "|\n"
    line += "{0: <56}".format("| Attack Power:\t" + str(item[3]) + "\tStamina:\t" + str(item[7]) + "\tArmor:\t" + str(item[8])) + "|\n"
    line += "{0: <53}".format("| Strength:\t\t" + str(item[4]) + "\tAgility:\t" + str(item[5]) + "\tIntel:\t" + str(item[6])) + "|\n"
    line += "-----------------------------------------------------------------"
    return line
Ejemplo n.º 2
0
def display_item(item):
    line = ""
    line += item[0] + "\n"
    line += classes.Item_Rarity(item[2]).name + " " + classes.Item(
        item[1]).name + "\n"
    line += "Attack Power:\t" + str(item[3]) + "\tStamina:\t" + str(
        item[6]) + "\tArmor:\t" + str(item[8]) + "\n"
    line += "Strength:\t" + str(item[4]) + "\tAgility:\t" + str(
        item[5]) + "\tIntel:\t" + str(item[7]) + "\n"
    return line
Ejemplo n.º 3
0
 def loadItems(self):
     # load [item ID, card name] from file into cards list
     with open(self.itemIDFile, 'r') as file:
         lines = file.readlines()
         for line in lines:
             line = line.rstrip('\r\n')
             line = line.split(',')
             line[0] = int(line[0], 16)
             line[0] = line[0].to_bytes(1, byteorder='big')
             item = classes.Item(line[0], line[1])
             self.itemList.append(item)
Ejemplo n.º 4
0
def main():
    """ Fonction principal du programme """

    pygame.init()

    pygame.display.set_caption("Projet 3: Aide Mc Gyver")
    background = pygame.image.load("Pictures/Background.bmp")
    cote = pygame.image.load("Pictures/font_cote.bmp")

    size = (550, 450)
    window = pygame.display.set_mode(size)
    window.blit(background, (0, 0))
    window.blit(cote, (450, 0))

    grille = json.load(open("grille.json"))

    func.draw_grille(window, grille)

    player = classes.Player()
    player.generate_player(window)
    item = classes.Item()
    item.generate_item(window, grille)

    game = True

    while game:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                game = False
            elif event.type == pygame.KEYDOWN:
                window.blit(background, (0, 0))
                func.draw_grille(window, grille)

                if event.key == K_RIGHT:
                    player.move_player(window, 30, 0, grille, item.win)
                elif event.key == K_LEFT:
                    player.move_player(window, -30, 0, grille, item.win)
                elif event.key == K_UP:
                    player.move_player(window, 0, -30, grille, item.win)
                elif event.key == K_DOWN:
                    player.move_player(window, 0, 30, grille, item.win)

                if player.wins is False:
                    item.check_item(
                        (player.coord_player[0], player.coord_player[1]))
                    item.draw_item(window)
                if player.wins is True:
                    game = False

        pygame.display.flip()

    time.sleep(3)
    pygame.quit()
Ejemplo n.º 5
0
def generateItem(enemy, number, name, image):
    while True:
        check = True
        itemList = []
        for i in range(number):
            item = classes.Item(name = name, \
                                image = image, \
                                generatePosition = (enemy.rect.center[0] + random.randint(-enemy.rect.width * 1, enemy.rect.width *1), \
                                                    enemy.rect.center[1] + random.randint(-enemy.rect.height *1, enemy.rect.height *1)))
            itemList.append(item)
        for i in range(len(itemList)):
            for j in range(len(itemList) - i - 1):
                if pygame.sprite.collide_rect(itemList[i],
                                              itemList[i + j + 1]):
                    check = False
        if check:
            break
    for i in range(len(itemList)):
        parameter.getAllSprites().add(itemList[i])
        parameter.getItemSprites().add(itemList[i])
Ejemplo n.º 6
0
item_dict = {}
cursed_item_dict = {}
awful_item_dict = {}
meh_item_dict = {}
good_item_dict = {}
great_item_dict = {}
godly_item_dict = {}
item_dict_list = [
    cursed_item_dict, awful_item_dict, meh_item_dict, good_item_dict,
    great_item_dict, godly_item_dict
]

for item in items.keys():
    item_dict[item] = classes.Item(item, items[item]["description"],
                                   items[item]["teaser"],
                                   items[item]["damage"],
                                   items[item]["quality"], items[item]["type"])
    item_dict_list[item_dict[item].quality][item] = item_dict[item]

# how many items per shop?
NUM_ITEMS = 5


@bot.command(name='randitem')
async def random_item(ctx, modifier=0, number=1, print_items=True):
    # TODO: Implement a global roll function
    return_list = []
    for i in range(0, number):
        modifier += world["modifier"]
        roll = random.randint(1, 20)
        if roll != 1 and roll != 20:
Ejemplo n.º 7
0
cuis = recupDesc("salle-cuisine")
deb = recupDesc("salle-debarras")

#################################################################################################################################
# Génération du labyrinthe
### Étape 1 - Génération d'un labyrinthe vide aux dimensions finales
maze = [[None] * colFin] * ligneFin

### Étape 2 - Génération d'un labyrinthe "surdimensionné"
laby = mazeGen.labyrinthe_aleatoire(ligne, colonne)

### Étape 3 - Convertir le labyrinthe surdimensionné (tableau de booléens) en labyrinthe interprétable (tableau de Salles)
doors = mazeGen.passages(laby[0])

### Étape 4 - On déclare tous les objets à utiliser
seau = classes.Item("Seau d'eau", False, True, 1, True, False)
pelle = classes.Item("Pelle", False, True, -1, False, True,
                     recupDesc("item-pelle"))
bouclier = classes.Item("Bouclier", False, True, 1, False, True,
                        recupDesc("item-bouclier"))
grosseCle = classes.Item("Grosse clé", False, True, 1, False, True,
                         recupDesc("item-grosseCle"))

items = [seau, pelle, bouclier, grosseCle]

### Étape 5 - On déclare tous les mécanismes qui seront ajoutés
feu = classes.Mecanism("Feu", seau, pelle, True, recupDesc("meca-feu"),
                       recupDesc("meca-feu-res"))
sable = classes.Mecanism("Tas de sable", pelle, bouclier, True,
                         recupDesc("meca-sable"), recupDesc("meca-sable-res"))
armure = classes.Mecanism("Armure", bouclier, grosseCle, True,
Ejemplo n.º 8
0
#root.mainline['10'] = c.Armour()
#root.mainline['11'] = c.Weapon()
#root.mainline['12'] = c.Gear()
#root.mainline['13'] = c.Food()
#root.mainline['14'] = c.Magic()
#root.mainline['15'] = c.Spell()
#root.mainline['16'] = c.Skill()
#root.mainline['17'] = c.Quest()
#root.mainline['18'] = c.Encounter()
#root.mainline['19'] = c.Location()
#root.mainline['20'] = c.Building()
#root.mainline['21'] = c.Lodging()

root.structure['1'] = c.Root()  # structural model
root.structure['2'] = c.Actor()
root.structure['3'] = c.Item()
root.structure['4'] = c.Action()
root.structure['5'] = c.Place()
root.structure['6'] = c.Player()
root.structure['7'] = c.NonPlayer()
root.structure['8'] = c.Monster()
root.structure['9'] = c.Animal()
root.structure['10'] = c.Armour()
root.structure['11'] = c.Weapon()
root.structure['12'] = c.Gear()
root.structure['13'] = c.Food()
root.structure['14'] = c.Magic()
root.structure['15'] = c.Spell()
root.structure['16'] = c.Skill()
root.structure['17'] = c.Quest()
root.structure['18'] = c.Encounter()
Ejemplo n.º 9
0
#################################################################################################################################

# Importation des différents modules et programmes complémentaires
import classes as cls
import commande as cmd
import sousFonctions as subFc
import labyrinthe_aleatoire as mazeGen
import genMaze

###---------------------------------------------------------------------------------------------------------------------------###
import tkinter as tk

#################################################################################################################################
# Déclaration des Items
bouclier = cls.Item("Bouclier", False, True, 1, True, True, subFc.recupDesc("item-bouclier"))
grosseCle = cls.Item("Grosse clé", False, True, 1, False, True, subFc.recupDesc("item-grosseCle"))

#################################################################################################################################
# Déclaration des Mecanisms
armure = cls.Mecanism("Armure", bouclier, grosseCle, True, subFc.recupDesc("meca-armure"), subFc.recupDesc("meca-armure-res"))

#################################################################################################################################
# Déclaration des Transports

#################################################################################################################################
# Récupération des fichiers textes
introFichier = open("Backstory.txt",'r', encoding="utf-8")
intro = introFichier.read()
introFichier.close()
Ejemplo n.º 10
0
def interact(action, player_inventory, player_location):
    """Returns the string that tells the player the result of their 
    attempt to interact with the object specified in action.
    Depending on the verb given, the item is moved from location inventory to
    player inventory or vice versa. 
    """
    global CURRENT_CHEESE_ID
    input_list = action.split()
    verb = input_list[0] #the action being done to/with the item
    item_given = ' '.join(input_list[1:]) #item/phrase following the verb
    item = normalize_item(item_given, player_inventory, player_location)
    if verb == 'examine':
        if player_location == CARGO_BAY2:
            if item == 'port':
                message = unlock_engine_room()
            elif item == 'key pad':
                message = key_code_pad.get_description()
                message += unlock_engine_room()
            else:
                message = 'There is nothing to examine in here other than the door and the key pad.'
        elif item == 'door' or item == 'port':
            message = 'The doors on this ship are just plain automatic doors.'
        elif player_location.item_check(item):
            actual_item = player_location.get_item(item)
            message = actual_item.get_description()
        elif inventory_check(item, player_inventory):
            actual_item = get_item_from_inventory(item, player_inventory)
            message = actual_item.get_description()
        else:
            message = 'You do not see that around here.'
    ## taking items: ##
    elif verb == 'take' or verb == 'get':
        if player_location.item_check(item):
            actual_item = player_location.get_item(item)
            if isinstance(actual_item, classes.Item) and actual_item.is_portable:
                if actual_item == rat_food:
                    item_id = CURRENT_CHEESE_ID
                    new_cheese = classes.Item('piece of cheese', item_id)
                    new_cheese.set_consumable_qualities('It was the only food left on board, but the small chunk of cheese is so stinky\nthat only a rat would eat it.',
                                      'sitting on the counter in the kitchenette.')
                    player_inventory[item_id] = classes.Item('piece of cheese', item_id)
                    CURRENT_CHEESE_ID += 1
                else:
                    player_inventory[actual_item.id] = actual_item
                    player_location.remove_item(item)
                message = 'Taken.'
                #TODO increase move counter
            elif isinstance(actual_item, classes.Rat):
                message = 'You reach your hand out to pick up the rat, and it bites you! Better not \ntry that again.'
                if not actual_item.held_item is None:
                    the_old_item = actual_item.held_item.name
                    actual_item.drop_item(player_location)
                    message += ' Thankfully, it dropped the {}.'.format(the_old_item)
            elif isinstance(actual_item, classes.Item):
                message = 'You cannot pick that up.'
            elif isinstance(actual_item, classes.Container):
                message = 'It is bolted to the floor.'
            else:
                message = 'There has been an error in Room.get_item'
        elif inventory_check(item, player_inventory):
            message = 'You already have that.'
        elif (player_location.item_check('rat-like creature') 
                and (player_location.get_item('rat-like creature').held_item.name == item)):
            message = '''You reach to take the {} from the rat and it snaps at you threateningly. 
Looks like you will have to be trickier than that.'''.format(item)
        else:
            message = 'You do not see that in here.'
    ## dropping items: ##
    elif verb == 'drop':
        if inventory_check(item, player_inventory):
            actual_item = get_item_from_inventory(item, player_inventory)
            player_inventory.pop(actual_item.id)
            actual_item.change_loc('on the floor.')
            player_location.put_item(actual_item)
            message = 'Dropped.'
        else:
            message = 'You do not have that!'
    ## putting items: ##
    elif verb == 'put':
        message = attempt_put_in(input_list[1:], player_inventory, player_location)
    elif verb == 'unlock':
        message = attempt_unlock(item, player_location, player_inventory)
    elif verb == 'open' or verb == 'close':
        if item == 'door':
            message = 'All doors on this ship open and close automatically, as long as they are \nunlocked.'
        if player_location.item_check(item):
            actual_container = player_location.get_item(item)
            if isinstance(actual_container, classes.Container):
                message = actual_container.toggle_open()
            else:
                message = 'That cannot be opened or closed.'
        else:
            message = 'You do not see that in this room.'
    elif verb == 'use':
        message = attempt_use(item, player_inventory, player_location)
    else:
        message = 'Sorry, I do not yet know how to {}.'.format(verb) #shouldn't ever happen, but just in case. 
    return message
Ejemplo n.º 11
0
CREW_QUARTERS = classes.Room('Crew Quarters')
CAPT_QUARTERS = classes.Room("Captain's Quarters")
HALLWAY= classes.Room('Hallway')
BRIDGE = classes.Room('Bridge')
CARGO_BAY = classes.Room('Cargo Bay, North End')
CARGO_BAY2 = classes.Room('Cargo Bay, South End')
MESS_REC = classes.Room('Mess Hall and Rec Area')
LAB = classes.Room('Laboratory, South End')
SICK_BAY = classes.Room('Sick Bay')
ENGINE_ROOM = classes.Room('Engine Room')
SHUTTLE_BAY = classes.Room('Shuttle Bay')
SHUTTLE_INTERIOR = classes.Room('Shuttle Interior')
LAB2 = classes.Room('Laboratory, North End')
MAZE = []
##define objects:
key_card = classes.Item('key card', 1)
locker_key = classes.Item('metal key', 2)
capt_log = classes.Item('personal log', 3)
key_code_pad = classes.Item('key pad', 4, False)
machine_part = classes.Item('machine part', 5)
alien_plant = classes.Item('strange plant', 6, False)
sedative = classes.Item('syringe', 7)
ship_log = classes.Item("ship's log", 8)
rat_food = classes.Item('piece of cheese', 9)
CHEESE_ID = 9
CURRENT_CHEESE_ID = 9
#TODO add in a ship's log to add world description
#TODO add in description for the viewport
##Define containers:
CREW_LOCKER = classes.Container('locker')
MED_CABINET = classes.Container('medicine cabinet')