Beispiel #1
0
 def makeEnt(self, entType, image = None, x = 0, y = 0, frames = 12, direction = 1, cycle = 3, spd = 200, interaction = None, frameSpeed = 100):
     entType = entType.upper()
     if entType == "WALL":
         entity = WALL.Wall(x, y, image)
         self.newLevel.all_sprites.add(entity)
         self.newLevel.WALL_LAYER.add(entity)
     elif entType == "PLAYER":
         entity = PC(x, y, image, spd, direction, frames, cycle, level = self, frameSpeed = frameSpeed)
         self.newLevel.packPC(entity, x, y)
     elif entType == "NPC":
         entity = NPC.Npc(image, x, y, frames, direction, cycle, spd, level = self)
         self.newLevel.all_sprites.add(entity)
         self.newLevel.NPC_LAYER.add(entity)
     elif entType == "TRIGGER":
         entity = TRIGGER.Trigger(x, y, 64,64, interact = interaction, transparent = True, level = self)
         self.newLevel.all_sprites.add(entity)
         self.newLevel.TRIGGER_LAYER.add(entity)
     elif entType == "ANIMATION":
         entity = NPC.Npc(image = image, x = x, y = y, frames = frames, level = self)
         self.newLevel.all_sprites.add(entity)
         self.newLevel.NPC_LAYER.add(entity)
         self.newLevel.animated_sprites.add(entity)
         self.newLevel.solid_sprites.add(entity)
     elif entType == "MELE":
         entity = mele.Mele(image = image, x = x, y = y, frames = frames, frameSpeed = 10)
         self.newLevel.all_sprites.add(entity)
         self.newLevel.NPC_LAYER.add(entity)
Beispiel #2
0
def main():
    print("------Testing Player------")
    Joe = mainPlayer.mainPlayer("Joe")
    Joe.displayStats()
    Joe.levelUp()
    print()
    print("------Testing NPCs------")
    maleficent = NPC.NPC("Zombie")
    maleficent.displayStats()
    print()
    print("------Testing Invalid Input------")
    Anna = mainPlayer.mainPlayer("Max", 0, -1, 0, 0)
    Jacquie = mainPlayer.mainPlayer("Max", 0, 0, -1, 0)
    Isabel = mainPlayer.mainPlayer("Max", 0, 0, 0, -1)
    Max = mainPlayer.mainPlayer("Max", -1, 0, 0, 0)
    Max.displayStats()
    print()
    print("------Testing Attack Win------")
    Joe.attackNPC(maleficent)
    Joe.displayStats()
    print()
    print("------Testing Attack Loss------")
    hades = NPC.NPC("Vampire", 5, 5, 5)
    hades.displayStats()
    Joe.attackNPC(hades)
    Joe.displayStats()
    print()
    print("------Testing Attack Tie------")
    hades = NPC.NPC("Vampire", 2, 2, 2)
    hades.displayStats()
    Joe.displayStats()
    Joe.attackNPC(hades)
    Joe.displayStats()
Beispiel #3
0
def load(gameobj):
    print("LOADING....")
    name = "levels/%s.lvl" % gameobj.loadname
    print(name)

    with open(name, "rb") as file:
        gameobj.blocklist, tempEntList, XMG, YMG, startX, startY, SG = pickle.load(
            file)

    gameobj.blocksetlist.clear()
    gameobj.poslist.clear()
    gameobj.entlist.clear()
    gameobj.entlist = []

    gameobj.player.startPos.x = startX
    gameobj.player.startPos.y = startY
    mapDict["XMAX_GRID"] = XMG
    mapDict["YMAX_GRID"] = YMG
    globDict["scoregoal"] = SG

    mapDict["MAP_WIDTH"] = mapDict["GRID_SIZE"] * mapDict["XMAX_GRID"]
    mapDict["MAP_HEIGHT"] = mapDict["GRID_SIZE"] * mapDict["YMAX_GRID"]

    coordx = 0
    coordy = 0

    gameobj.poslist = [[] for p in range(mapDict["YMAX_GRID"])]

    for i in range(mapDict["XMAX_GRID"] * mapDict["YMAX_GRID"]):
        gameobj.poslist[coordy].append(i)
        if coordx == mapDict["XMAX_GRID"] - 1:
            coordx = 0
            coordy += 1
        else:
            coordx += 1

    for block in gameobj.blocklist:
        if block.blockType == "tower":
            setblock = Tower(block.x, block.y, block.size, block.blockType,
                             gameobj.player, block.range)
            setblock.rofMax = block.rofMax
        elif block.blockType == "respawntower":
            setblock = RespawnTower(block.x, block.y, block.size,
                                    block.blockType, gameobj.player)
        elif block.blockType == "end":
            setblock = EndTower(block.x, block.y, block.size, block.blockType,
                                gameobj.player)
        else:
            setblock = BlockSet(block.x, block.y, block.size, block.blockType)
        gameobj.blocksetlist.append(setblock)
    del gameobj.blocklist

    for ent in tempEntList:
        setent = NPC(ent.x, ent.y, ent.size, ent.blockType, gameobj.player,
                     ent.range)
        setent.rofMax = ent.rofMax
        gameobj.entlist.append(setent)
    del tempEntList
Beispiel #4
0
def main():
    root = Tk()
    root.geometry("600x600")
    canvas = Canvas(root, width=500, height=500)
    canvas.pack()
    app = Map(root)
    # Create grid
    app.draw_grid(canvas=canvas)

    npc1 = NPC(canvas=canvas)
    npc1.draw()

    root.mainloop()
Beispiel #5
0
 def __init__(self, canvasWidth, canvasHeight, player):
     self.pic = Animation("Village Entrance", 2, 15)
     self.canvasWidth = canvasWidth
     self.canvasHeight = canvasHeight
     self.font = createFont("zx_spectrum-7.ttf", 96)
     self.player = player
     self.testBox = Readout(0, canvasHeight*4/5, canvasWidth, canvasHeight/5, "Ayup...It's Harvest Time.")
     self.enterArrows = ArrowChoiceBar(canvasWidth*19/20, canvasHeight*19/20, canvasWidth/5, canvasHeight/5, True, False, False, False)
     self.board = Board(canvasWidth, canvasHeight, "Village", 2, 2, 1)
     self.pharmacist = NPC("cody")
     self.apothePlate = TriggerPlate(canvasWidth*4/5 - canvasWidth/50, canvasHeight*2/5, canvasWidth/20, canvasHeight/20, "apothe", self.player)
     self.leaveApothe = TriggerPlate(self.canvasWidth/2 - self.canvasWidth/40, self.canvasHeight - self.canvasHeight/20, self.canvasWidth/20, self.canvasHeight/20, "village-2", self.player)
     self.talkToApothePlate = TriggerPlate(self.canvasWidth/2 - self.canvasWidth/40, self.canvasHeight/2 + self.canvasHeight/10, self.canvasWidth/20, self.canvasHeight/20, "talkToApothe", self.player)
     self.villagePlates = [self.apothePlate, self.talkToApothePlate, self.leaveApothe] # For checking the plates
     self.apothePopup = Popup("apotheTrade.txt", player, canvasWidth, canvasHeight)
Beispiel #6
0
def receive_connection(Non):
    global receive_socket
    global entity_dict
    global p

    try:
        message = receive_socket.recv(zmq.NOBLOCK).decode()
        m = NetMessage(message)
    except zmq.Again:
        return

    print(Fore.RED + "RECEIVE: " + message)

    # If gets your own ID
    if (m.type == "PLAYER_ID"):
        entity_dict[int(m.data)] = p
        p.id = int(m.data)

    # If gets individual entity information
    elif (m.type == "ENTITY_INFO"):
        id, ent_data = m.data.split("#")
        id = int(id)
        ent_data = ent_data.split(";")
        if (id > 0):
            if (id == p.id):
                return
            entity_dict[id] = Player([int(x) for x in ent_data[0].split(",")],
                                     [int(x) for x in ent_data[1].split(",")],
                                     ent_data[2])
        else:
            entity_dict[id] = NPC([int(x) for x in ent_data[0].split(",")],
                                  [int(x) for x in ent_data[1].split(",")],
                                  ent_data[2])
            entity_dict[id].load()
Beispiel #7
0
 def make_vil(self):
     sx = self.sizex
     sy = self.sizey
     nwpos = (2, 2)
     for i in range(0, 6):
         for j in range(0, 6):
             self.storage[i + nwpos[0]][j + nwpos[1]].set_terrain('1')
             self.vilposes.append((i + nwpos[0], j + nwpos[1]))
     for i in range(3, 5):
         for j in range(0, 2):
             if (i == 3):
                 if (j == 0):
                     self.storage[i +
                                  nwpos[0]][j +
                                            nwpos[1]].set_terrain('3_h_1')
                 elif (j == 1):
                     self.storage[i +
                                  nwpos[0]][j +
                                            nwpos[1]].set_terrain('3_h_4')
             if (i == 4):
                 if (j == 0):
                     self.storage[i +
                                  nwpos[0]][j +
                                            nwpos[1]].set_terrain('3_h_2')
                 elif (j == 1):
                     self.storage[i +
                                  nwpos[0]][j +
                                            nwpos[1]].set_terrain('3_h_3')
     self.storage[6][4].set_terrain('3_h_w')
     self.storage[7][2].set_terrain('3_h_b')
     self.storage[7][3].set_terrain('3_h_b2')
     self.storage[3][6].set_terrain('3_h_t')
     npc = NPC((2, 6), '1')
     self.add_npc(npc)
Beispiel #8
0
 def initNPC(self):
     npc = shopOwner("ImmortalMammal", self.gameTime["Hour"])
     self.npcList = []
     self.npcList.append(npc)
     npc = NPC("Amy", self.gameTime["Hour"])
     self.npcList.append(npc)
     npc = NPC("Katie", self.gameTime["Hour"])
     self.npcList.append(npc)
     npc = NPC("Kim", self.gameTime["Hour"])
     self.npcList.append(npc)
     self.customer = None
     self.npcGroup = pygame.sprite.Group()
     self.objects = self.room.objects
     self.objectGroup = pygame.sprite.Group()
     for objects in self.objects:
         self.objectGroup.add(objects)
Beispiel #9
0
def load_npc(session):
    # load bestiary
    with open(r"NPCS.csv", encoding='utf-8') as csvfile:
        spam_reader = csv.DictReader(csvfile, delimiter=',', quotechar='"')
        creature_list = []
        npc_list = []
        for row in spam_reader:
            # Create new entries
            new_npc = NPC(row)
            session.add(new_npc)
            #creature_list.append(new_npc.creature)
            session.add(new_npc.creature)
            #npc_list.append(new_npc)
        session.commit()
        # max_entries = 5
        # num_creatures = max_entries
        # for creature in creature_list:
        #     num_creatures -= 1
        #     if num_creatures <= 0:
        #         break
        # session.commit()
        #
        # num_npcs = max_entries
        # for npc in npc_list:
        #     session.add(npc)
        #     num_npcs -= 1
        #     if num_npcs <= 0:
        #         break
        # session.commit()

    print("num creatures: " +
          str(session.query(func.count(Creature.Id)).scalar()))
Beispiel #10
0
 def loadNpcs(self, filename):
     data = self.loadData(filename)
     for row, tiles in enumerate(data):
                 for col, tile in enumerate(tiles):
                     if int(tile) > -1:
                         ent = NPC.Npc(x = col * self.tileHeight, y = row * self.tileWidth, image = self.tiles[int(tile)], level = self)
                         self.newLevel.NPC_LAYER.add(ent)
                         self.newLevel.all_sprites.add(ent)
                         self.newLevel.solid_sprites.add(ent)
                         self.newLevel.npc_sprites.add(ent)
Beispiel #11
0
    def on_draw(self):
        """
        Render the screen.
        """

        # This command has to happen before we start drawing
        arcade.start_render()

        # Draw all the sprites.
        hero.player_list.draw()

        countdown(5)

        NPC.interact(
            arcade.get_distance_between_sprites(hero.player_sprite,
                                                boy1.npc_sprite),
            hero.space_key, boy1.text)
        #boy1.npc_sprite.draw()
        # Draw the rooms

        Room.rooms[Room.current_room].wall_list.draw()
Beispiel #12
0
def initMatrix(self, window, map, keyowned, oldcurrentlevel):
    player = None
    self.mapmatrix = []
    for i in range(map.tmxdata.height):
        self.mapmatrix.append([])
        for j in range(map.tmxdata.width):
            self.mapmatrix[i].append(0)
    for object in map.tmxdata.objects:
        if object.name == 'o':
            self.mapmatrix[int(object.y / 16)][int(object.x / 16)] = 1
        if object.name.startswith('player') and int(
                object.name[6:]) == oldcurrentlevel:
            player = Player.Player(object.x, object.y,
                                   int(object.properties['speed']),
                                   "textures/link.png",
                                   [1, 1, 1, 1, 10, 10, 10, 10], 3)
            player.entities.remove(player)
            player.entities.insert(0, player)
            if keyowned:
                player.key = True
                player.keyowned = True
                player.inventory.addItem(window, "key")
        if object.name == 'enemy':
            nbAnimsFrames = []
            for i in object.properties['nbAnimsFrames'].split(','):
                nbAnimsFrames.append(int(i))
            pattern = []
            for i in object.properties['pattern'].split(','):
                pattern.append([])
                for j in i.split(';'):
                    pattern[len(pattern) - 1].append(int(j))
            Enemy.Enemy(object.x, object.y, int(object.properties['speed']),
                        object.properties['texture'], nbAnimsFrames, 2,
                        pattern)
        if object.name == 'npc':
            nbAnimsFrames = []
            for i in object.properties['nbAnimsFrames'].split(','):
                nbAnimsFrames.append(int(i))
            pattern = []
            for i in object.properties['pattern'].split(','):
                pattern.append([])
                for j in i.split(';'):
                    pattern[len(pattern) - 1].append(int(j))
            NPC.NPC(object.x, object.y, int(object.properties['speed']),
                    object.properties['texture'], nbAnimsFrames, 2, pattern,
                    object.properties['dialog'])
        if object.name == "anthony":
            Anthony.Anthony(int(object.properties['minX']),
                            int(object.properties['maxX']),
                            int(object.properties['minY']),
                            int(object.properties['maxY']))
Beispiel #13
0
    def save(self, path, gene=False):
        if str(self.id) + '.pkl' not in os.listdir(path):
            if gene:
                path1 = path + '/objsgene'
                path2 = path + '/npcsgene'
            else:
                path1 = path + '/objs' + str(self.id)
                path2 = path + '/npcs' + str(self.id)
            if not os.path.exists(path1):
                os.makedirs(path1)
            if not os.path.exists(path2):
                os.makedirs(path2)

            path1 += '/'
            for obj in self.objects:
                obj1 = Object.Object(name=obj.name,
                                     info=obj.info,
                                     usages=obj.usages,
                                     image=obj.image_n,
                                     w=obj.w,
                                     h=obj.h)
                obj1.image = None
                self.save_by_name(path1 + obj1.name, obj1)

            path2 += '/'
            for npc in self.npcs:
                npc1 = NPC.NPC(game_display=None,
                               name=npc.name,
                               dialogs=npc.dialogs,
                               acts=npc.acts)
                self.save_by_name(path2 + npc1.name, npc1)
            try:
                if gene:
                    self.save_by_name(path + 'gene', self)
                else:
                    self.save_by_name(path + str(self.id), self)
            except Exception:
                pass

        if self.left is not None:
            if str(self.left.id) + '.pkl' not in os.listdir(path):
                self.left.save(path)
        if self.right is not None:
            if str(self.right.id) + '.pkl' not in os.listdir(path):
                self.right.save(path)
        if self.up is not None:
            if str(self.up.id) + '.pkl' not in os.listdir(path):
                self.up.save(path)
        if self.down is not None:
            if str(self.down.id) + '.pkl' not in os.listdir(path):
                self.down.save(path)
    def __init__(self, dungeonObject, color, numSpawners):
        self.NPCObject = NPC.NPC(356, Display.GAME_SCREEN_START + 56, self,
                                 "Hey! you found me! youre a dick")
        self.winNPC = NPC.NPC(
            356, Display.GAME_SCREEN_START + 56, self,
            "You killed all the spawners. How could you do that? They were endangered. I hope you're happy. Dick"
        )
        self.merchant = Shopkeeper.Shopkeeper(356,
                                              Display.GAME_SCREEN_START + 300,
                                              self,
                                              "Hello friend! Let's trade!")
        self.text = ""
        self.color = color
        self.width = Display.SCREEN_WIDTH
        self.height = Display.SCREEN_HEIGHT
        self.x = 0
        self.y = 0

        #x, y, True if player enters this door, connected room,

        #self.doors =   {'leftDoor': [0, Display.SCREEN_HEIGHT/2, None, 'leftDoor'],
        #                'rightDoor': [Display.SCREEN_WIDTH-DOOR_WIDTH, Display.SCREEN_HEIGHT/2, None, 'rightDoor'],
        #                'upDoor': [Display.SCREEN_WIDTH/2, Display.GAME_SCREEN_START, None, 'upDoor'],
        #                'downDoor': [Display.SCREEN_WIDTH/2, Display.SCREEN_HEIGHT - DOOR_LENGTH, None, 'downDoor']}
        self.doors = [-1, -1, -1, -1]
        Dungeon.listDoors.extend(self.doors)
        self.currentRoom = True
        self.index = dungeonObject.numRooms
        self.playerObj = dungeonObject.playerObj
        self.dungeonObject = dungeonObject
        self.hasSpawners = False
        self.spawnnerlist = []
        self.enemylist = []
        for i in range(0, numSpawners):
            self.hasSpawners = True
            self.spawnnerlist.append(
                Spawnner.Spawnner(self.playerObj, self.enemylist))
        Dungeon.numRooms += 1
Beispiel #15
0
 def make_smallvil(self):
     qpos = random.randint(1, 2)
     if (qpos == 1):
         nwpos = (1, 2)
     elif (qpos == 2):
         nwpos = (7, 2)
     for i in range(0, 2):
         for j in range(0, 2):
             self.storage[i + nwpos[0]][j + nwpos[1]].set_terrain('1')
             self.vilposes.append((i + nwpos[0], j + nwpos[1]))
     self.storage[nwpos[0] + 1][nwpos[1]].set_terrain('3_h_w')
     self.storage[nwpos[0]][nwpos[1]].set_terrain('3_h_s')
     npc = NPC((nwpos[0], nwpos[1] + 1), str(random.randint(2, 3)))
     self.add_npc(npc)
def randomNPC():
    if timePeriod == "colonial":
        health = random.randint(25,50)
    elif timePeriod == "1940s":
        health = random.randint(50,100)
    elif timePeriod == "1980s":
        health = random.randint(65,100)
    weapon = random.randint(0,2)
    enemy = random.randint(0,2)
    if enemy == 0:
        isEnemy = True
    else:
        isEnemy = False
    if isEnemy:
        linePossibilities=["You're new around here. Be careful who you bump into.","You never should have come here!","Let's see what you're made of.","You're walking around like you own the place.","If you just turn around, no one will get hurt."]
        repeatLinePossibilities=["I'm itching to fight you.","Back for more?","You know, you should never back down from a fight.","Time to put you in your place!","Someone doesn't know how to listen."]
    else:
        linePossibilities = ["Hello, traveler.","Greetings, stranger.","Who are you?","You're not from around here, are you?","What's with your funny looking clothes?"]
        repeatLinePossibilities = ["Hello again, traveler.","Hello again, stranger.","I still don't entirely trust you.","Now stay on your best behavior.","Now I'm not sure I can believe anything you say."]
    line = random.randint(0,4)
    return NPC.NPC(timePeriod,linePossibilities[line],repeatLinePossibilities[line],health,itemList[weapon],isEnemy,False)
Beispiel #17
0
    def __init__(self, obj):
        attribs = obj.attrib

        # set requried attributes
        self.name = attribs["name"]
        self.shortdesc = attribs["shortdesc"]

        # set unrequired attributes
        self.longdesc = attribs["longdesc"] if "longdesc" in attribs.keys(
        ) else self.shortdesc

        self.visit_count = 0
        self.children = []
        self.children_names = []

        # instantiate children locations, npcs and features
        for element in obj:
            if element.tag == "Location":
                self.children.append(Location(element))
                self.children_names.append(element.attrib["name"])
            elif element.tag == "Feature":
                # features are simply objects that can be interacted with and nothing more
                self.children_names.append(element.attrib["name"])
                self.children.append({
                    "name": element.attrib["name"],
                    "text": element.text,
                    "type": "Feature"
                })
            elif element.tag == "NPC":
                self.children.append(NPC.NPC(element))
                self.children_names.append(element.attrib["name"])

        # add each parent to the child's options so you can go back from a location or NPC
        for child in self.children:
            if type(child) == Location or type(child) == NPC.NPC:
                child.children_names.append(self.name)
                child.children.append(self)
Beispiel #18
0
  def __init__(self):
    super(Game, self).__init__()
    self.map = Map(data)
    self.pathfinding = AStar(self.map)
    pyglet.clock.schedule_interval(self.update, 1/120.0)
    self.pause = False
    self.message = Message(["Well hello there, you sexy beast. This is long text...", "You bastard"]);
    self.player = Player(self, self.map.grid[2,1], 0, 0)
    self.npc = NPC(self, self.map.grid[2,1], self.map.get_tile(7,5))
    self.player.create_animations()
    self.npc.create_animations()
    self.enemy = Enemy(self, self.map.grid[2,1], self.map.get_tile(1,5))
    self.enemy.create_animations()

    #little hack to get the viewport centered and then to follow the player
    temp_size = self.get_size()
    self.viewport_x = temp_size[0]/2
    self.viewport_y = 0

    self.offset_x = 0
    self.offset_y = 0
    
    self.update_viewport(temp_size[0]/2, 0)
    self.viewport_y = temp_size[1]/2
Beispiel #19
0
def spawn_npcs():
    for npc in SETTINGS.levels_list[SETTINGS.current_level].npcs:
        if [x for x in SETTINGS.npc_types
                if x['id'] == npc[2]][0]['name'] == 'random':
            random.seed(SETTINGS.seed)
            stats = copy.deepcopy(
                random.choice(
                    [x for x in SETTINGS.npc_types if x['name'] != 'random']))
        else:
            stats = copy.deepcopy(
                [x for x in SETTINGS.npc_types if x['id'] == npc[2]][0])

        try:
            sounds = ([
                x for x in SETTINGS.npc_soundpacks
                if x['name'] == stats['soundpack']
            ][0])
        except:
            print("Error loading NPC! No soundpack with name ",
                  stats['soundpack'])
        stats['pos'] = npc[0]
        stats['face'] = npc[1]
        SETTINGS.npc_list.append(
            NPC.Npc(stats, sounds, path.join(*stats['filepath'])))
Beispiel #20
0
def main():
    print('Program is Running')
    current_PC_pool = []
    current_NPC_pool = []
    selected_PCs = []
    selected_NPCs = []
    check_parameters = []

    # TODO: Remove these 8 lines when working
    test_PC = PC.PC('Malcolm', 5, 5, 5, 5, 20)
    test_PC2 = PC.PC('Amy', 5, 5, 5, 5, 20)
    test_NPC = NPC.NPC('Guard1', 2, 2)
    test_NPC2 = NPC.NPC('Guard2', 2, 2)
    selected_PCs.append(test_PC)
    selected_PCs.append(test_PC2)
    selected_NPCs.append(test_NPC)
    selected_NPCs.append(test_NPC2)

    outermost_loop_variable = True

    # Follows are the various menus that the user will be navigating
    def display_main_menu():
        print('Welcome to the stealth simplifier app.'
              '\nMore options to come in future editions.'
              '\n----------'
              '\n1)Setup and run stealth checks.'
              '\n2)Exit program.')

    # One menu deep, this is where PCs and NPCs will be chosen and

    def display_setup_menu():
        print('----------'
              '\nSetup Menu'
              '\n----------'
              '\n1)Create PC\'s to add to the Current PC\'s Pool'
              '\n2)Create NPC\'s to add to the Current NPC\'s Pool')

        if current_PC_pool:
            print('3)Select PC from Current PC\'s Pool')

        if current_NPC_pool:
            print('4)Select NPC from Current NPC\'s Pool')

        if len(selected_NPCs) >= 1 and len(selected_PCs) >= 1:
            print(
                '5)Run Stealth Checks with currently selected NPC\'s and PC\'s.'
            )
            selections_display()
        print('X) Exit this menu to main menu.\n')

    def selections_display():
        print('---Selected PC\'s---')
        for pc in selected_PCs:
            print(pc.name)
        print('---Selected NPC\'s---')
        for npc in selected_NPCs:
            print(npc.name)

        # print(tabulate(selected_PCs, headers=["Selected PC's"], tablefmt="pipe"))
        # print(tabulate(selected_NPCs, headers=["Selected NPC's"], tablefmt="pipe"))

    def display_pc_pool():
        menu_counter = 0
        print('Currently created PC\'s\n--------------------------')
        for pc in current_PC_pool:
            menu_counter = menu_counter + 1
            print('{}) {}'.format(menu_counter, pc.name))

    def display_npc_pool():
        menu_counter = 0
        print('Currently created NPC\'s\n--------------------------')
        for npc in current_NPC_pool:
            menu_counter = menu_counter + 1
            print('{}) {}'.format(menu_counter, npc.name))

    def display_terrain_mods():
        print('---Terrain Modifiers---')
        print(
            '1) No terrain modifier\n'
            '2) Noisy (scree, shallow or deep bog, undergrowth, dense rubble)\n'
            '3) Very noisy (dense undergrowth, deep snow)')

    def display_speed_mod_options():
        print('---Speed Modifiers---')
        print('1) Moving Up To Half Speed (No Modifier)\n'
              '2) Moving Up To Full Speed (-5)\n'
              '3) Moving Full Speed or Faster (-20)\n')

    # add pcs to pool

    def add_NPC_to_pool():
        stats_list = []
        name = input('What is the Character\'s name?')
        stats_list.append(name)
        # TODO: Switch it so instead of "Character's" it actually says the name.
        # I had to use seperate and repeating try/except/while loops to achieve the results I wanted.
        # I wanted the user to only have to input a single piece of information again should something be entered wrong.
        while True:
            try:
                spot_mod = int(
                    input('What is the Character\'s Spot Modifier?'))
                stats_list.append(spot_mod)
                break
            except ValueError:
                print('That was not a valid number please enter an integer.')
        while True:
            try:
                listen_mod = int(
                    input('What is the Character\'s Listen Modifier?'))
                stats_list.append(listen_mod)
                break
            except ValueError:
                print('That was not a valid number please enter an integer.')
        #         Pass these stats back out.  This is so that I could reuse this code for the PC createion as well.
        return stats_list

    def add_PC_to_pool():
        # TODO: Add a detector for whatever symbol you keep the items in the file seperated by once File Support is inlcuded

        # run the NPC creator, take the elements that it provides and then filll in the others.
        pc_data_set = add_NPC_to_pool()
        # while there is a ValueError exception, keep asking for data until they finally give you something correct.
        while True:
            # try:
            #     spot_mod = int(input('What is the PC\'s Spot Modifier?'))
            # except ValueError:
            #     print('That was not a valid number please enter an integer.')
            #
            # try:
            #     listen_mod = int(input('What is the PC\'s Listen Modifier?'))
            # except ValueError:
            #     print('That was not a valid number please enter an integer.')
            #
            try:
                sneak_mod = int(
                    input('What is the PC\'s Move Silently Modifier?'))
                pc_data_set.append(sneak_mod)
                break
            except ValueError:
                print('That was not a valid number please enter an integer.')
        while True:
            try:
                hide_mod = int(input('What is the PC\'s Hide Modifier?'))
                pc_data_set.append(hide_mod)
                break
            except ValueError:
                print('That was not a valid number please enter an integer.')
        try:
            # Check for a value error, but more importantly...
            while True:
                speed = int(
                    input(
                        'What is the PC\'s speed in 5 foot intervals(5 or 10 or 15, etc...)?'
                    ))
                # Check that the number they gave yyou is divisible by 5.  This is D&D Dammit not the real world.
                if (speed % 5) != 0:

                    print('That was not a valid speed, try again.)')
                elif (speed % 5) == 0:
                    pc_data_set.append(speed)
                    break
        except ValueError:
            print('That was not a valid number please enter an integer.')

        #         MAKE THE PC If EVERYTHING WENT FINE
        new_pc = PC.PC(pc_data_set[0], pc_data_set[1], pc_data_set[2],
                       pc_data_set[3], pc_data_set[4], pc_data_set[5])
        # Add them to the pool of PCS
        current_PC_pool.append(new_pc)

    def create_check_parameters():
        # Empty the list of parameters so it is fresh.
        del check_parameters[:]
        while True:
            try:
                # Didtance?
                distance = int(
                    input(
                        'How far are the PC\'s attempting to stealth, in feet?'
                    ))
                check_parameters.append(distance)
                break

            except ValueError:
                'That was not a Integer, please try again.'

        while True:
            # display options
            display_speed_mod_options()
            # speed modifiers for the roll
            speed_mod_choice = input('What is the Speed Modifier Option?')

            if speed_mod_choice in '123':
                check_parameters.append(speed_mod_choice)
                break

            else:
                print('Please Choose An Option From the Menu')

        while True:
            # Display Options
            display_terrain_mods()
            # terrain modifiers for the rolls?
            terrain_mod_choice = input('What type of terrain?')
            if terrain_mod_choice in '123':
                check_parameters.append(terrain_mod_choice)
                break
            else:
                print('Please select an option from above.')
        # return the parameters so that the next function can use them
        return check_parameters

    def run_checks():
        # Make the parameters
        check_params = create_check_parameters()
        # Pass them to the checks function (Which needs to be broken down further into even MORE discrete bits.)
        final_list = pcs_vs_npcs_checks(check_params)
        # Display the list or results using this nice and fancy tabulate module
        print(
            tabulate(final_list,
                     headers=[
                         'PC', selected_NPCs[0].name, selected_NPCs[0].name,
                         selected_NPCs[1].name, selected_NPCs[1].name
                     ],
                     tablefmt="pipe",
                     missingval='Null'))

    def pcs_vs_npcs_checks(check_parameters):
        # TODO: Make this smoother code in the future.
        terrain_modifier = 0
        speed_modifier = 0
        total_env_mods = 0
        row_result = []
        final_results = []
        distance = int(check_parameters[0])
        fastest_pc_speed = 0
        # For each character find out which is fastest, and use their speed for the checks since they will reach the destination first.
        # TODO: Put this in its own function (EASY)
        for pc in selected_PCs:
            if pc.speed > 0:
                fastest_pc_speed = pc.speed
                if check_parameters[1] == '1':
                    fastest_pc_speed = fastest_pc_speed / 2
                elif check_parameters[1] == '3':
                    fastest_pc_speed = fastest_pc_speed * 2
        # Figure out what those parameters that were passed to you even mean! These are for how fast they're moving
        if check_parameters[1] == '2':
            # Ah! theyre moving quickly, hard to be stealthy when quick! MINUS 5
            speed_modifier = speed_modifier - 5
        elif check_parameters[1] == '3':
            # Theyre literally running while trying to be stealthy.  nearly impossible. MINUS 20
            speed_modifier = speed_modifier - 20
        # These params are for the type of terrain theyre going over
        if check_parameters[2] == '2':
            # Sort of noisy terrain, MINUS 2
            terrain_modifier = terrain_modifier - 2
        elif check_parameters[2] == '3':
            # Fairly loud terrain, MINUS 5
            terrain_modifier = terrain_modifier - 5

        #     Add the modifiers together into a lump mod to be subtracted from the roll
        total_env_mods = total_env_mods - speed_modifier - terrain_modifier

        # This variable is improperly named, but wont be changed until v1.2
        # It was originally a checker for just 2 players stealthing, to see that the distance(or number of checks really)
        # Isnt changed until all the PC's have taken a check.  I realized later on that I could use the modulus of the length of the
        # selected_PCs list to more accurately track that, since I could have 5 players doing it, or just 1 even
        even_or_odd = 0
        # While the PCs are not at their end point
        while distance >= 0:
            # for each PC check their stealth and hides against
            for pc in selected_PCs:
                # This bit here is causing trouble, and I am getting repeat rows... not sure whats wrong with it...
                row_result = []
                # keep the tracker counting
                even_or_odd = even_or_odd + 1
                # Add the name to the results row
                row_result.append(pc.name)
                # Each of the NPC's looking and listening
                for npc in selected_NPCs:
                    # Make the PC's Checks
                    sneak_result = d20.d20.roll(d20,
                                                pc.sneak_mod - total_env_mods)
                    # and the NPCs checks
                    listen_result = d20.d20.roll(d20, npc.listen_mod)
                    # PC
                    hide_result = d20.d20.roll(d20, pc.hide_mod)
                    # NPC
                    spot_result = d20.d20.roll(d20, npc.spot_mod)
                    # COMPARE RESULTS TO SEE IF SPOTTED OR HEARD
                    if sneak_result > listen_result:
                        row_result.append('Sneak: Success')
                    else:
                        row_result.append('-----FAIL-----')

                    if hide_result > spot_result:
                        row_result.append('Hide:  Success')
                    else:
                        row_result.append('-----FAIL-----')
                #         Push the results out onto the display board
                final_results.append(row_result)
                # If each PC has gone, then subtract the speed they are going from distance remaining
                if even_or_odd % len(selected_PCs) == 0:
                    distance = distance - fastest_pc_speed
        #             return the final list to be tabulated
        return final_results

    #  This function allows a character to be selected, it has been generified to work on either the NPC list or the PC list
    def select_the_char(which_list):
        if which_list == 0:
            # This is going to take a NPC
            choice = int(input('Which Character to add to the selected list?'))
            npc = current_NPC_pool[choice - 1]
            selected_NPCs.append(npc)
            del current_NPC_pool[choice - 1]

        elif which_list == 1:
            # This will take a PC
            choice = int(input('Which PC to add to the selected list?'))
            pc = current_PC_pool[choice - 1]
            selected_PCs.append(pc)
            del current_PC_pool[choice - 1]

    #         removes all characters from the selected pool automatically

    def remove_all_chars_from_selected():
        counter = 0
        for pc in selected_PCs:
            current_PC_pool.append(pc)
            counter = counter + 1
        del selected_PCs[:]
        counter2 = 0
        for npc in selected_NPCs:
            current_NPC_pool.append(npc)
            counter2 = counter2 + 1
        del selected_NPCs[:]

    # TODO: Put all of this below into a method as well. Maybe
    # Here begins the guts of the runtime components
    while outermost_loop_variable:
        display_main_menu()
        main_menu_choice = input('Please Choose An Option From Above.\n')

        if main_menu_choice == '1':
            setup_menu_loop = True
            print('ENTERING SETUP AND RUN')
            while setup_menu_loop:
                # Show the Setup Menu
                display_setup_menu()
                # User Selects and Option
                # TODO: Surely there is a better way to do menus.
                setup_menu_choice = input(
                    'Please Choose And Option From Above.\n')
                if setup_menu_choice == '1':
                    print('Running Add PC to Pool Method')
                    # Add a PC
                    add_PC_to_pool()
                elif setup_menu_choice == '2':
                    print('Running Add NPC to Pool Method')
                    # add an NPC
                    char_data_set = add_NPC_to_pool()
                    new_npc = NPC.NPC(char_data_set[0], char_data_set[1],
                                      char_data_set[2])
                    current_NPC_pool.append(new_npc)

                elif setup_menu_choice == '3' and len(current_PC_pool) >= 1:
                    print('Running Select a PC Method')
                    display_pc_pool()
                    select_the_char(1)

                elif setup_menu_choice == '4' and len(current_NPC_pool) >= 1:
                    print('Running Select a NPC Method')
                    display_npc_pool()
                    select_the_char(0)

                elif setup_menu_choice == '5' and len(
                        selected_PCs) >= 1 and len(selected_NPCs) >= 1:
                    print('Running Checks with Tabulate OutPut')
                    run_checks()
                    remove_all_chars_from_selected()

                elif setup_menu_choice.lower() == 'x':
                    print('Exiting Setup Menu')
                    setup_menu_loop = False

        elif main_menu_choice == '2':
            # Version 2.0 will save some of these and allow editing of saved ones.
            print('EXITING PROGRAM\nFLUSHING ALL CURRENT PCS AND NPCS')
            sys.exit()
        else:
            print(
                'Sorry, the option you selected either is not yet available or never will be.'
                '\nPlease select a different option'
                '\n')
Beispiel #21
0
import pygame, time

pygame.init()

import Room, ChatBox, NPC, Player, Object
from globals import *
import globals_vars

import ui_util


game_display = pygame.display.set_mode((DISPLAY_WIDTH, DISPLAY_HEIGHT))
def c_h():
    cb.string = 'Hell Yeah'

joe = NPC.NPC(game_display, 'Joe', {'F**K YOU': 'Nah f**k you!'}, {"TEST":c_h})
dale = NPC.NPC(game_display, 'Dale', {'F**K YOU': 'Nah f**k you!'}, {"TEST":c_h})
chicken_leg = Object.Object('Chicken Leg',
                            info = 'Its a f*****g chicken leg.',
                            image = 'imgs/pulke.png',
                            w = 780, h = 370)

genesis = Room.Room(npcs=[joe], objects=[chicken_leg], id_n=1)
r1 = Room.Room(npcs=[dale], right=genesis, objects=[chicken_leg], id_n=2)
r2 = Room.Room(left=genesis, objects=[chicken_leg], id_n=3)
r3 = Room.Room(up=r2, objects=[chicken_leg], id_n=4)
r4 = Room.Room(right=r3, up=genesis, objects=[chicken_leg], id_n=5)
r2.down = r3
r3.left = r4

player = Player.Player(game_display, genesis)
Beispiel #22
0
import NPC
import HelperFunctions as HF

spider = NPC.Enemy("sprites/spider", 5, 20)
spider.rect.centerx = HF.WINDOWWIDTH / 3
spider.rect.centery = HF.WINDOWHEIGHT / 1.33

spider2 = NPC.Enemy("sprites/spider", 5, 20)
spider2.rect.centerx = HF.WINDOWWIDTH / 2.5
spider2.rect.centery = HF.WINDOWHEIGHT / 1.67
Beispiel #23
0
from globals import *
from consumables import *
from NPC import *
from player import *
from map_engine import *
from textures import *
from UltraColor import *

pygame.init()

#Declaring NPC's, player, world and ither variables / functions needed in the main gameloop---------------------------------------

player1 = player("Alex", 9)
player.pos_calc(player1, [Globals.camera_x, Globals.camera_y])

steffan = NPC("stwffin", [0, 0],["Have you seen link?", "We still haven't finished..."], [0, 128])
Skinner = NPC("Skinner", [256, 128], ["Do you know what I did in Nam?", "It wasn't pretty..."], [256, 512])

npc_list = [steffan, Skinner]

for npc in npc_list:
    NPC.npc_pos(npc)

size = [800, 600]
window = pygame.display.set_mode(size, pygame.HWSURFACE|pygame.RESIZABLE|pygame.DOUBLEBUF)
pygame.display.set_caption("The Dungeons of Plasmawr")

tile_data = map_engine.load_map("/home/euler/Desktop/plasmawr_game/maps/blank.txt")
Tiles.blocked = map_engine.blocked(tile_data, Tiles.blocked_types, Tiles.blocked)
render_chunk = pygame.Rect(-64, -64, (size[0] + 128), (size[1] + 128))
Beispiel #24
0
class World:  # I choose to define the world as a class. This makes it more straightforward to import into the game.
    map = [[
        TopLeft(barriers=[barriers.Wall('n')]),
        TopMiddle(barriers=[barriers.Wall('n')]),
        DoorEntrance(barriers=[barriers.Wall('n'),
                               barriers.Door('e')]),
        DoorExit(barriers=[barriers.Wall('n')]),
        FusionCannon(barriers=[barriers.Wall('n'),
                               barriers.Wall('e')],
                     items=[items.FusionCannon()]),
        SpaceTile(),
        SpaceTile(),
        SpaceTile(),
        SpaceTile(),
        SpaceTile()
    ],
           [
               Nail(items=[items.Nail()]),
               ShipTile(),
               Hammer(barriers=[barriers.Wall('e')], items=[items.Hammer()]),
               Cortex(barriers=[barriers.Wall('w')], items=[items.Cortex()]),
               R2Blank(barriers=[barriers.Wall('e')]),
               SpaceTile(),
               SpaceTile(),
               SpaceTile(),
               SpaceTile(),
               SpaceTile()
           ],
           [
               BottomLeft(barriers=[barriers.Wall('w'),
                                    barriers.Wall('s')]),
               MiddleLeft(barriers=[barriers.Wall('s')]),
               HatchEntrance(barriers=[
                   barriers.Wall('e'),
                   barriers.Wall('s'),
                   barriers.HatchDoor('e')
               ]),
               HatchExit(barriers=[barriers.Wall('w'),
                                   barriers.Wall('s')]),
               R2Blank(barriers=[barriers.Wall('e'),
                                 barriers.Wall('s')]),
               SpaceTile(),
               SpaceTile(),
               wormHole(),
               SpaceTile(),
               SpaceTile()
           ],
           [
               SpaceTile(),
               SpaceTile(),
               SpaceTile(),
               SpaceTile(),
               SpaceTile(),
               SpaceTile(),
               SpaceTile(),
               wormHole(),
               SpaceTile(),
               SpaceTile()
           ],
           [
               SpaceTile(),
               SpaceTile(),
               SpaceTile(),
               SpaceTile(),
               SpaceTile(),
               SpaceTile(),
               SpaceTile(),
               wormHole(),
               SpaceTile(),
               SpaceTile()
           ],
           [
               wilkinsTile(barriers=[barriers.Wall('w'),
                                     barriers.Wall('n')],
                           npcs=[NPC.Wilkins()]),
               EmptySpace(barriers=[barriers.Wall('n')]),
               EmptySpace(barriers=[barriers.Wall('e'),
                                    barriers.Wall('n')]),
               SpaceTile(),
               SpaceTile(),
               SpaceTile(),
               SpaceTile(),
               SpaceTile(),
               SpaceTile(),
               SpaceTile()
           ],
           [
               EmptySpace(barriers=[barriers.Wall('w')]),
               EmptySpace(),
               groundNPC(
                   barriers=[barriers.Wall('e')],
                   enemies=[enemies.Invader(loot=[items.Sparkling_Gem()])]),
               SpaceTile(barriers=[
                   barriers.Asteroid('w'),
                   barriers.Asteroid('n'),
                   barriers.Asteroid('s')
               ]),
               SpaceTile(
                   barriers=[barriers.Asteroid('n'),
                             barriers.Asteroid('s')]),
               SpaceTile(),
               SpaceTile(barriers=[barriers.Asteroid('e')]),
               SpaceTile(),
               SpaceTile(),
               SpaceTile()
           ],
           [
               EmptySpace(barriers=[barriers.Wall('w')], npcs=[NPC.Riddler()]),
               EmptySpace(),
               EmptySpace(barriers=[barriers.Wall('e')]),
               SpaceTile(barriers=[barriers.pWall('w')]),
               SpaceTile(),
               SpaceTile(),
               SpaceTile(),
               SpaceTile(),
               SpaceTile(),
               SpaceTile()
           ],
           [
               groundNPC(barriers=[barriers.Wall('e'),
                                   barriers.Wall('s')],
                         enemies=[enemies.Invader()]),
               planetEntrance(),
               merchantTile(barriers=[barriers.Wall('e'),
                                      barriers.Wall('s')],
                            npcs=[NPC.Merchant()]),
               SpaceTile(barriers=[barriers.pWall('w')]),
               SpaceTile(),
               SpaceTile(),
               SpaceTile(),
               SpaceTile(),
               SpaceTile(),
               SpaceTile()
           ],
           [
               SpaceTile(),
               SpaceTile(barriers=[barriers.pWall('go')]),
               SpaceTile(barriers=[barriers.pWall('a'),
                                   barriers.pWall('n')]),
               SpaceTile(barriers=[barriers.pWall('a')]),
               SpaceTile(),
               SpaceTile(),
               SpaceTile(),
               SpaceTile(),
               SpaceTile(),
               SpaceTile()
           ]]

    def __init__(self):
        for i in range(
                len(self.map)
        ):  # We want to set the x, y coordinates for each tile so that it "knows" where it is in the map.
            for j in range(
                    len(self.map[i])
            ):  # I prefer to handle this automatically so there is no chance that the map index does not match
                if (self.map[i][j]):  # the tile's internal coordinates.
                    self.map[i][j].x = j
                    self.map[i][j].y = i

                    self.add_implied_barriers(
                        j, i
                    )  # If there are implied barriers (e.g. edge of map, adjacent None room, etc.) add a Wall.

    def tile_at(self, x, y):
        if x < 0 or y < 0:
            return None
        try:
            return self.map[y][x]
        except IndexError:
            return None

    def check_north(self, x, y):
        for enemy in self.map[y][x].enemies:
            if (enemy.direction == 'north'):
                return [False, enemy.check_text()]
        for barrier in self.map[y][x].barriers:
            if (barrier.direction == 'north' and not barrier.passable):
                return [False, barrier.description()]

        if y - 1 < 0:
            room = None
        else:
            try:
                room = self.map[y - 1][x]
            except IndexError:
                room = None

        if (room):
            return [True, "You head to the north."]
        else:
            return [False, "There doesn't seem to be a path to the north."]

    def check_south(self, x, y):
        for enemy in self.map[y][x].enemies:
            if (enemy.direction == 'south'):
                return [False, enemy.check_text()]
        for barrier in self.map[y][x].barriers:
            if (barrier.direction == 'south' and not barrier.passable):
                return [False, barrier.description()]

        if y + 1 < 0:
            room = None
        else:
            try:
                room = self.map[y + 1][x]
            except IndexError:
                room = None

        if (room):
            return [True, "You head to the south."]
        else:
            return [False, "There doesn't seem to be a path to the south."]

    def check_west(self, x, y):
        for enemy in self.map[y][x].enemies:
            if (enemy.direction == 'west'):
                return [False, enemy.check_text()]
        for barrier in self.map[y][x].barriers:
            if (barrier.direction == 'west' and not barrier.passable):
                return [False, barrier.description()]

        if x - 1 < 0:
            room = None
        else:
            try:
                room = self.map[y][x - 1]
            except IndexError:
                room = None

        if (room):
            return [True, "You head to the west."]
        else:
            return [False, "There doesn't seem to be a path to the west."]

    def check_east(self, x, y):
        for enemy in self.map[y][x].enemies:
            if (enemy.direction == 'east'):
                return [False, enemy.check_text()]
        for barrier in self.map[y][x].barriers:
            if (barrier.direction == 'east' and not barrier.passable):
                return [False, barrier.description()]

        if x + 1 < 0:
            room = None
        else:
            try:
                room = self.map[y][x + 1]
            except IndexError:
                room = None

        if (room):
            return [True, "You head to the east."]
        else:
            return [False, "There doesn't seem to be a path to the east."]

    def add_implied_barriers(self, x, y):

        [status, text] = self.check_north(x, y)
        barrier_present = False
        if (not status):
            for enemy in self.map[y][x].enemies:
                if enemy.direction == 'north':
                    barrier_present = True
            for barrier in self.map[y][x].barriers:
                if barrier.direction == 'north':
                    barrier_present = True
            if (not barrier_present):
                self.map[y][x].add_barrier(barriers.Wall('n'))

        [status, text] = self.check_south(x, y)
        barrier_present = False
        if (not status):
            for enemy in self.map[y][x].enemies:
                if enemy.direction == 'south':
                    barrier_present = True
            for barrier in self.map[y][x].barriers:
                if barrier.direction == 'south':
                    barrier_present = True
            if (not barrier_present):
                self.map[y][x].add_barrier(barriers.Wall('s'))

        [status, text] = self.check_east(x, y)
        barrier_present = False
        if (not status):
            for enemy in self.map[y][x].enemies:
                if enemy.direction == 'east':
                    barrier_present = True
            for barrier in self.map[y][x].barriers:
                if barrier.direction == 'east':
                    barrier_present = True
            if (not barrier_present):
                self.map[y][x].add_barrier(barriers.Wall('e'))

        [status, text] = self.check_west(x, y)
        barrier_present = False
        if (not status):
            for enemy in self.map[y][x].enemies:
                if enemy.direction == 'west':
                    barrier_present = True
            for barrier in self.map[y][x].barriers:
                if barrier.direction == 'west':
                    barrier_present = True
            if (not barrier_present):
                self.map[y][x].add_barrier(barriers.Wall('w'))

    def update_rooms(self, player):
        for row in self.map:
            for room in row:
                if (room):
                    room.update(player)
Beispiel #25
0
    def __init__(self):
        self.objects = [
            [
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
            ],
            [
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
            ],
            [
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
            ],
            [
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
            ],
            [
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
            ],
            [
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
            ],
            [
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
            ],
            [
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
            ],
            [
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                1, 1, 1, 1, 1, 1, 1, 1, 30, 1, 1, 1, 1, 1, 1, 40, 1, 1, 1, 1,
                1, 1, 1, 1, 1, 1, 1, 40, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
            ],
            [
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 10, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 2, 0, 0, 0, 0, 14, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
            ],
            [
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
            ],
            [
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
            ],
            [
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
            ],
            [
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 1, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
            ],
            [
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
            ],
            [
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                1, 1, 1, 1, 1, 1, 1, 1, 50, 1, 1, 1, 1, 1, 1, 61, 1, 1, 1, 1,
                1, 1, 1, 1, 1, 1, 1, 30, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
            ],
            [
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 16, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 2, 0, 0, 0, 0, 15, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
            ],
            [
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
            ],
            [
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
            ],
            [
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
            ],
            [
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
            ],
            [
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
            ],
            [
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 1, 1, 1, 1, 1, 1, 1, 1,
                1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 71, 1, 1, 1, 1, 1,
                1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 91, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
            ],
            [
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 13, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
            ],
            [
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
            ],
            [
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
            ],
            [
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
            ],
            [
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0,
                7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
            ],
            [
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
            ],
            [
                1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
            ],
        ]
        self.npc = [
            NPC(232, 288 + DELTA, "john", player_steps1, [
                ("Привет, проходи. У меня есть для тебя задание", "", "",
                 None),
                ("Ты же знаешь, что 3 квартира давно заброшена? Недавно я нашел ключи от нее. Но я боюсь туда зайти. Я до ужаса боюсь крыс. Я слышу по ночам там шуршание.",
                 '', "", None),
                ("Ты не мог бы осмотреть комнату за меня? можешь забрать что-нибудь оттуда. Я дам тебе ключи, но перед этим, ты можешь принести свечу, уж больно темновато тут.",
                 "", "Да, конечно", None),
                ("Спасибо, Но не мог бы ты найти свечу, без нее мне не найти ключа",
                 "", "", None),
                (
                    "Отлично, где же этот ключ...",
                    "Без свечки я не найду ключа. Поищи у себя",
                    "",
                    "x",
                ), ("А, вот, держи", "", "", None, "c"),
                ("Вот это да!", "Я не вижу у тебя за спиной мешок!", "", "p"),
                ("Слушай, я знаю, что ты хочешь сбежать.", "", "", None),
                ("Джейн из 2 квартиры живет тут больше всех. Я думаю если ты подаришь ей что нибудь, то она может тебе помочь.",
                 "",
                 "А что она любит? Может в этом барахле найдется что-нибудь",
                 None),
                ("Я знаю, она любит музыку.Ты можешь дать ей что-нибудь и разговорить ее.",
                 "", "Хорошо, я подумаю", None), ("Удачи", "", "", None)
            ]),
            NPC(640, 288 + DELTA, "jane", player_steps2, [
                ("А что это у тебя в руках?",
                 "Можно потише, у еня ребенок спит", "", "g"),
                ("Если ты думаешь, что если я одинокая женщина с ребенком, то ты можешь взять меня простым подарком? Даже не думай",
                 "", "Нет, подожди, ты должна мне помочь", None),
                ("Ну что еще?", "",
                 "Я хочу сбежать оттуда, а единственный выход-через вахтера. Джон сказал мне, что ты знаешь как выйти отсюда",
                 None),
                ("Ладно. Я знаю, что он в свое время занимал всокую должность при Большом Брате...",
                 "", "И как он оказался здесь?", None),
                ("Он стал просто не нужен. И все. Самое интересное, что он не оставил своей любви к партии.",
                 "",
                 "Стой, ведь город захватили повстанцы? Как он остался жив?",
                 None),
                ("Он не выходит из своей дыры уже месяц, даже представить не могу что он там делает.",
                 "",
                 "А если шантажировать его? Сказать, что если он не откроет дверь, то мы сдадим его?",
                 None),
                ("Хорошая идея. Если честно, меня от него тошнит. И вот, покажи ему это. это досье на него.",
                 "", "Хорошо. Тогда я пошел", None, "v"),
                ("Я верю в тебя", "", "", None)
            ]),
            EnemyNPC(700, 400 + DELTA, "tom", player_steps3, [
                ("Что это у тебя? Урод, а ну дай сюда",
                 "А ну пошел вон отсюда!", "", "v"),
                ("Что тебе надо?", "",
                 "Если ты сейчас же не откроешь мне дверь-этот листок увидят все. Что тут у нас: Политиче..",
                 None),
                ("Нет! Стой! Я сам не знаю где ключ!", "",
                 "Врешь! Я сейчас пройдусь ломом по твоей пустой башке, если ты не скажешь где ключ!",
                 None), ("Аггггхххх", "Ну давай, попробуй", "", "r")
            ])
        ]

        self.obj = []
        self.obj1 = []
        self.dict = {
            10: wall2,
            11: wall1,
            12: wall3,
            13: wall4,
            14: wall6,
            15: wall7,
            16: wall8,
            20: roof
        }
        x = 0
        y = 0
        for i in range(len(self.objects)):
            self.obj.append([
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
            ], )
            for j in range(len(self.objects[i])):
                if self.objects[i][j] == 3:
                    obj = Entity(x, y + DELTA, "shelf", ["g", "p"])
                    self.obj[i][j] = obj
                elif self.objects[i][j] == 4:
                    obj = Entity(x, y + DELTA, "bed1", [])
                    self.obj[i][j] = obj
                elif self.objects[i][j] == 5:
                    obj = Entity(x, y + DELTA, "bed", [])
                    self.obj[i][j] = obj
                elif self.objects[i][j] == 6:
                    obj = Entity(x, y + DELTA, "table1", ["r"])
                    self.obj[i][j] = obj
                elif self.objects[i][j] == 7:
                    obj = Entity(x, y + DELTA, "bed2", [])
                    self.obj[i][j] = obj
                elif self.objects[i][j] == 8:
                    obj = Entity(x, y + DELTA, "shelf1", ["d"])
                    self.obj[i][j] = obj
                elif self.objects[i][j] == 9:
                    obj = Entity(x, y + DELTA, "comp", ["x"])
                    self.obj[i][j] = obj
                elif self.objects[i][j] == 2:
                    obj = Ladder(x, y + DELTA)
                    self.obj[i][j] = obj
                elif self.objects[i][j] == 40:
                    obj = Door(x, y + DELTA, "Door1")
                    self.obj[i][j] = obj
                elif self.objects[i][j] == 30:
                    obj = Door(x, y + DELTA, "Door1", "c")
                    self.obj[i][j] = obj
                elif self.objects[i][j] == 31:
                    obj = Door(x, y + DELTA, "Door1", "c")
                    self.obj[i][j] = obj
                elif self.objects[i][j] == 50:
                    obj = Door(x, y + DELTA, "Door1", "u", self.npc[0])
                    self.obj1.append(obj)
                    self.obj[i][j] = obj
                elif self.objects[i][j] == 61:
                    obj = Door(x, y + DELTA, "Door1", "u", self.npc[1])
                    self.obj1.append(obj)
                    self.obj[i][j] = obj
                elif self.objects[i][j] == 71:
                    obj = Door(x, y + DELTA, "Door1", "u", self.npc[2])
                    self.obj1.append(obj)
                    self.obj[i][j] = obj
                elif self.objects[i][j] == 91:
                    obj = Door(x, y + DELTA, "Door2", "d")
                    self.obj[i][j] = obj
                x += SCALE
            y += SCALE
            x = 0
Beispiel #26
0
class Village: # Level 0 and 1
    def __init__(self, canvasWidth, canvasHeight, player):
        self.pic = Animation("Village Entrance", 2, 15)
        self.canvasWidth = canvasWidth
        self.canvasHeight = canvasHeight
        self.font = createFont("zx_spectrum-7.ttf", 96)
        self.player = player
        self.testBox = Readout(0, canvasHeight*4/5, canvasWidth, canvasHeight/5, "Ayup...It's Harvest Time.")
        self.enterArrows = ArrowChoiceBar(canvasWidth*19/20, canvasHeight*19/20, canvasWidth/5, canvasHeight/5, True, False, False, False)
        self.board = Board(canvasWidth, canvasHeight, "Village", 2, 2, 1)
        self.pharmacist = NPC("cody")
        self.apothePlate = TriggerPlate(canvasWidth*4/5 - canvasWidth/50, canvasHeight*2/5, canvasWidth/20, canvasHeight/20, "apothe", self.player)
        self.leaveApothe = TriggerPlate(self.canvasWidth/2 - self.canvasWidth/40, self.canvasHeight - self.canvasHeight/20, self.canvasWidth/20, self.canvasHeight/20, "village-2", self.player)
        self.talkToApothePlate = TriggerPlate(self.canvasWidth/2 - self.canvasWidth/40, self.canvasHeight/2 + self.canvasHeight/10, self.canvasWidth/20, self.canvasHeight/20, "talkToApothe", self.player)
        self.villagePlates = [self.apothePlate, self.talkToApothePlate, self.leaveApothe] # For checking the plates
        self.apothePopup = Popup("apotheTrade.txt", player, canvasWidth, canvasHeight)
        
    def leadUp(self, modeTime): # For level 0
        self.pic.display(self.canvasWidth/2, self.canvasHeight/2, self.canvasWidth, self.canvasHeight)
        if modeTime < 256:
            fill(0, 355 - 2*modeTime)
            rect(0, 0, self.canvasWidth, self.canvasHeight)
            fill(255, 255 - 2*modeTime)
            stroke(0, 255 - 2*modeTime)
            textFont(self.font)
            textAlign(CENTER)
            text("The Village", self.canvasWidth/2, self.canvasHeight/2)
            fill(0, 255 - 2*modeTime)
            self.player.attributes["view"] = "o"
            self.player.attributes["facing"] = "n"
            self.player.attributes["x"] = self.canvasWidth/2
            self.player.attributes["y"] = self.canvasHeight*7/8
            self.player.attributes["w"] = self.canvasWidth/10
            self.player.attributes["h"] = self.canvasHeight/10
            self.player.attributes["state"] = "still"
        self.enterArrows.display()
        
    def run(self, modeTime, screen, popup): # For level 1
        self.board.run()
        if screen == "village":
            if modeTime < 3:
                self.board = Board(self.canvasWidth, self.canvasHeight, "Village", 2, 2, 1)
        if screen == "apothecary": # It would have been too much of a pain to do fractional levels, so I'll keep those reserved for other lead-ups
            if modeTime < 3:
                self.player.attributes["x"] = self.canvasWidth/2
                self.player.attributes["y"] = self.canvasHeight*4/5
                self.player.attributes["w"] = self.canvasWidth/5
                self.player.attributes["h"] = self.canvasHeight/5
                self.player.attributes["speed"] = 10
                self.pharmacist.attributes["x"] = self.canvasWidth/2
                self.pharmacist.attributes["y"] = self.canvasHeight*3/8
                self.pharmacist.attributes["w"] = self.canvasWidth/5
                self.pharmacist.attributes["h"] = self.canvasHeight/5
                self.pharmacist.attributes["speed"] = 10
                self.pharmacist.attributes["facing"] = "s"
                self.pharmacist.updateImage()
                self.board = Board(self.canvasWidth, self.canvasHeight, "Apothecary", 1, 1, 0)
            fill(255)
            noStroke()
            rect(self.canvasWidth/2 - self.canvasWidth/40, self.canvasHeight/2 + self.canvasHeight/10, self.canvasWidth/20, self.canvasHeight/20, 5)
            fill(150, 150, 0)
            rect(self.leaveApothe.x, self.leaveApothe.y, self.leaveApothe.w, self.leaveApothe.h, 5)
            self.pharmacist.run()
        self.player.run()
        if popup == "talkToApothe":
                self.apothePopup.run()
Beispiel #27
0
class Game(pyglet.window.Window):
  def __init__(self):
    super(Game, self).__init__()
    self.map = Map(data)
    self.pathfinding = AStar(self.map)
    pyglet.clock.schedule_interval(self.update, 1/120.0)
    self.pause = False
    self.message = Message(["Well hello there, you sexy beast. This is long text...", "You bastard"]);
    self.player = Player(self, self.map.grid[2,1], 0, 0)
    self.npc = NPC(self, self.map.grid[2,1], self.map.get_tile(7,5))
    self.player.create_animations()
    self.npc.create_animations()
    self.enemy = Enemy(self, self.map.grid[2,1], self.map.get_tile(1,5))
    self.enemy.create_animations()

    #little hack to get the viewport centered and then to follow the player
    temp_size = self.get_size()
    self.viewport_x = temp_size[0]/2
    self.viewport_y = 0

    self.offset_x = 0
    self.offset_y = 0
    
    self.update_viewport(temp_size[0]/2, 0)
    self.viewport_y = temp_size[1]/2
 
  def update(self, dt):
    self.clear()
    self.map.draw()
    self.player.draw()
    self.enemy.draw()
    self.npc.draw()
    self.player.inventory.update(self.offset_x, self.offset_y)

    if not self.message.finished:
      self.pause = True
      self.message.show()
    else:
      self.pause = False
    if self.pause:
      return  
    self.player.update(dt)
    if self.enemy.is_alive():
      if not self.enemy.tasks.has_tasks(): 
        self.enemy.calculate_next_move()
        if self.enemy.next_move != self.enemy.tile:
          self.enemy.tasks.add_task(self.enemy.next_move, TASK_WALK)
    self.enemy.update(dt)

  def update_viewport(self, x = -1, y = -1):
    x_pos, y_pos = x, y
    if x == -1:
      x_pos = -self.player.x + self.viewport_x
    if y == -1:
      y_pos = -self.player.y + self.viewport_y

    self.offset_x = x_pos
    self.offset_y = y_pos
    
    glMatrixMode(GL_MODELVIEW)
    glLoadIdentity()
    glTranslatef(x_pos, y_pos, 1.0)
    glPushMatrix()
    glPopMatrix()
    

  def on_mouse_press(self, x, y, button, modifiers):
    x_pos = x - self.offset_x
    y_pos = y - self.offset_y

    
    if button == LEFT_CLICK:
      if self.message:
        self.message.next()
    if self.pause:
      return
    if button == RIGHT_CLICK:
      for tile in self.map.tiles:
        if(tile.contains(tile.image, x_pos, y_pos) == True):
          if tile.is_passable():
            move_loc = tile.get_move_loc()
            tasks = self.pathfinding.calcShortest(self.map.get_tile(self.player.grid_x, self.player.grid_y), self.map.get_tile(move_loc[0], move_loc[1]))
            if tasks:
              if len(tasks) > 1:
                self.player.tasks.clear_tasks()
                tasks.reverse()
                tasks.pop(0)
                index = len(tasks) - 1
                for task in tasks:
                  self.player.tasks.add_task(task, TASK_WALK)

                if type(tasks[index].person) == NPC:
                  action = self.player.tasks.add_task(tasks[index].person, TASK_SPEAK)
                if type(tasks[index].person) == Enemy:
                  tasks[index].person.under_attack = True
                  self.player.tasks = TaskQueue()
                  self.player.tasks.add_task(tasks[index].person, TASK_GOTO)
                  print "Task Attack"
                  self.player.tasks.add_task(tasks[index].person, TASK_ATTACK)
                  
            else:
              print "No path!"
            break;

      for item in self.map.items:
        if item.is_chest_item():
          if item.image.frames:
            if item.contains(item.image.frames[0].image, x_pos, y_pos):
              self.player.tasks.add_task(item, TASK_ACTION)
          else:
            if item.contains(item.image, x_pos, y_pos):
              self.player.tasks.add_task(item, TASK_ACTION)

      for item in  self.player.inventory.items:
        if item.contains(item.image, x_pos, y_pos):
          item.action(self.player)
          self.player.inventory.items.remove(item)

      if self.enemy.contains(self.enemy.image.frames[0].image, x_pos, y_pos):
        self.enemy.under_attack = True
        self.player.tasks = TaskQueue()
        self.player.tasks.add_task(self.enemy, TASK_GOTO)
        print "Enemy click Task Attack"
        self.player.tasks.add_task(self.enemy, TASK_ATTACK)
Beispiel #28
0
 def talk_to_bartender(self):
     bartender = NPC.basic_bartender(self.player)
     bartender.perform()
 def MakeNPCs(self, file_path):
     with open(file_path) as data_file:
         data = json.load(data_file)
         for npc in data:
             a_npc = NPC.NPC(data, npc)
             self.NPCs.append(a_npc)
Beispiel #30
0
import Room
import NPC
import story
import time

SCREEN_WIDTH = 1100
SCREEN_HEIGHT = 700

text1 = displayText.displayText("aaron is aaron")
text2 = displayText.displayText("")

port = Portal.Portal(SCREEN_WIDTH, SCREEN_HEIGHT)

hero = Character.setup_player()

boy1 = NPC.setup_npc0()

room0 = Room.setup_room_0()
Room.rooms.append(room0)
room1 = Room.setup_room_1()
Room.rooms.append(room1)
room2 = Room.setup_room_2()
Room.rooms.append(room2)


def countdown(n):
    while n > 0:
        n = n - 1
    if n <= 0:
        text1.showDisplay(True)
def createRooms():
    centerRoom=Room()
    southRoom=Room()
    northRoom=Room()
    lessNorthRoom=Room()
    eastRoom=Room()
    northEastRoom=Room()
    southEastRoom=Room()
    southWestRoom=Room()
    centerRoom.addExit(lessNorthRoom,False,"north")
    centerRoom.addExit(southRoom,False,"south")
    centerRoom.addExit(eastRoom,False,"east")
    eastRoom.addExit(centerRoom,False,"west")
    southRoom.addExit(centerRoom,False,"north")
    southRoom.addExit(southEastRoom,False,"east")
    southRoom.addExit(southWestRoom,True,"west")
    southEastRoom.addExit(southRoom,False,"west")
    southWestRoom.addExit(southRoom,True,"east")
    eastRoom.addExit(northEastRoom,False,"north")
    northEastRoom.addExit(eastRoom,False,"south")
    northRoom.addExit(lessNorthRoom,False,"south")
    lessNorthRoom.addExit(northRoom,False,"north")
    lessNorthRoom.addExit(centerRoom,False,"south")
    rooms=[southRoom,northRoom,lessNorthRoom,eastRoom,northEastRoom,southEastRoom]
    player.setCurrentRoom(centerRoom)
    if timePeriod=="1980s":
        centerRoom.setDescription("in the middle of the road, where you should try not to get hit by a car.")
        southRoom.setDescription("in the Watergate Hotel which is lavish and fancy with many fancy amenities.")
        northRoom.setDescription("in the police station accross from the Watergate hotel monitoring for suspicious activity.")
        lessNorthRoom.setDescription("in the parking lot in front of the police station where numerous Ford Mustangs are parked. There is a Hot Rod parked in the lot.")
        eastRoom.setDescription("in the Watergate office building, where numerous offices such as the Democratic Party's office is located.")
        northEastRoom.setDescription("in a gas station, in which you can fill up your car. You are next to the police station and Watergate office bulding.")
        southEastRoom.setDescription("in the building east of the Watergate hotel.")
        southWestRoom.setDescription("in the building west of the Watergate hotel.")
    elif timePeriod=="1940s":
        centerRoom.setDescription("in the middle square of the hollywood studio where everyone gathers and is the central hub of the studio.")
        southRoom.setDescription("in the main entrance of the studio, this has heavy studio to protect our actors, if you get here at a good time you might even catch a peek at an actor.")
        northRoom.setDescription("in the main studio where all the movies are filmed and the biggest space in the hollywood studio.")
        lessNorthRoom.setDescription("in the room where all the cameras and equipment are housed. Be carefull, this stuff ain't cheep.")
        eastRoom.setDescription("in the room where all the actors get ready for shooting their scenes.")
        northEastRoom.setDescription("in the closet where all the makeup and equipment is stored to get the actors ready.")
        southEastRoom.setDescription("in the place where all the cars are parked for the day. Contains lots of fancy cars from all the rich producers and actors.")
        southWestRoom.setDescription("in the shed where all the props are stored.")
    elif timePeriod=="colonial":
        centerRoom.setDescription("in a small clearing in a forest, where a road travels north to a small Native American village and south to a small town of colonists.")
        southRoom.setDescription("in a town filled with primarily sick and tired residents. You see most out tending to farms and working other jobs.")
        northRoom.setDescription("in a small Native American village that has the air of impending doom covering it like a blanket. You can feel the tensions between the two factions rising.")
        lessNorthRoom.setDescription("in an outside wall going into the Native American tribe. You can see some weapons with blood splattering every inch, and others collecting dust.")
        eastRoom.setDescription("in a dark and gloomy forest, with the sun's warm rays being blocked by the dense leaves of the treese above. Birds sing their songs and wildlife scurries at your feet.")
        northEastRoom.setDescription("in a clearing. It looks as if a massacre has taken place as the body of a deer is being held up by a bloodied colonial soldier.")
        southEastRoom.setDescription("in the eastmost part of the town, where the butcher's shop resides. The area smells of death and you can see the butcher standing outside.")
        southWestRoom.setDescription("in an area near a small building. People are gathering near the town hall as tensions rise concerning the Native American threat that looms on the other side of the forest. Inside, the mayor sits at his table with his head in his hands.")
    for room in rooms:
        num = random.randint(0, 3)
        for times in range(num):
            room.addNPC(randomNPC())
    randRoom=random.randint(0,len(rooms)-1)
    rooms[randRoom].addNPC(NPC.NPC(timePeriod,"Greetings, time traveler. I have been looking for you. Are you ready to die?","You come again time traveler. Face me.",90,Item(itemList[2].name,itemList[2].description,itemList[2].type,itemList[2].value),True,True))
    for room in rooms:
        for n in range(3):
            r=random.randint(0,len(itemList)-2)
            room.addItem(itemList[r])
Beispiel #32
0
tDirections = {0: "North", 1: "South", 2: "East", 3: "West"}

#Define NPCs
pFamily = NPC(
    0,
    "Cranky Family",
    "You notice what appears to be a family of 4. Looks like they're arguing.",
    "You see the cranky family.",
    1,
    [
        [
            "Cranky Family: Honey, where's Jack's binky?",
            "Cranky Family: It's in his diaper bag.",
            "Cranky Family: And where's his diaper bag?",
            "Cranky Family: I'm hungry!",
            "Cranky Family: Hold on, sweety! I don't know, check the trunk!",
            "Cranky Family: Don't tell me you left it at the rest stop...",
            "Cranky Family: Is it not there? How is that my problem? You're the one that changed him!",
            "Cranky Family: Waaaaaaah!!!",
            "Cranky Family: Oh, so it's my fault now? Maybe if you helped out for once we're being having this discussion!",
            "Cranky Family: I gotta go potty!",
            "Cranky Family: Why does everything have to be an argument with you? Look, you take Anna to the bathroom and check in, I'll get the diaper bag.",
            "Cranky Family: Yeah, sure, how about YOU take Anna to the bathroom and I'll get the diaper bag? As if I trust you!",
            "Cranky Family: Here we go again with this! Whyyyy does it matter who does what?!",
            "It's doesn't seem like they're going to stop anytime soon..."
        ],  #0
        ["They're still going at it. Perhaps you should stay out of this."]  #1
    ])
pAngryWoman = NPC(
    1,
    "Irritated Lady",