Exemple #1
0
    def start(self):
        self.players = []
        self.time_left = 15
        self.time_til_bomb = -1
        self.ct_rounds = 0
        self.t_rounds = 0
        self.bomb_location = None
        if self.player_is_terrorist:
            self.players.append(Player(Terrorist))
            self.players.append(NPC(CounterTerrorist))
        else:
            self.players.append(Player(CounterTerrorist))
            self.players.append(NPC(Terrorist))

        for i in range(1, 5):
            self.players.append(NPC(CounterTerrorist))
            self.players.append(NPC(Terrorist))
        t_with_bomb = randint(1, 5)
        t_index = 0
        for player in self.players:
            if player.side != Terrorist:
                continue
            t_index += 1
            if t_index == t_with_bomb:
                player.give_bomb()
Exemple #2
0
def mouseChunkBuild(gameobj):
    tempx, tempy = pygame.mouse.get_pos()

    mousex = int(((tempx + gameobj.player.pos.x) - mapDict["HALF_WIDTH"]) /
                 mapDict["GRID_SIZE"])  # convert to grid system
    mousey = int(((tempy + gameobj.player.pos.y) - mapDict["HALF_HEIGHT"]) /
                 mapDict["GRID_SIZE"])  # convert to grid system

    try:
        ind = gameobj.poslist[mousey][mousex]
    except:
        return

    chunk = findChunk(gameobj, mousex, mousey)

    if gameobj.blocksetlist[ind].blockType == "empty":
        if globDict["blockbuild"].lower() == "block":
            gameobj.blocksetlist[ind] = BlockSet(mousex * mapDict["GRID_SIZE"],
                                                 mousey * mapDict["GRID_SIZE"],
                                                 globDict["size"], "block")
            gameobj.chunklist[chunk].bl.append(gameobj.blocksetlist[ind])
            gameobj.chunklist[chunk].pl.append(ind)
            gameobj.chunklist[chunk].rl.append(gameobj.blocksetlist[ind].rect)
        elif globDict["blockbuild"].lower() == "npc":
            temp = NPC(mousex * mapDict["GRID_SIZE"],
                       mousey * mapDict["GRID_SIZE"], 1, "npc", gameobj.player,
                       globDict["vrange"])
            gameobj.entlist.append(temp)

            gameobj.mousestate[1] = False
            return
        elif globDict["blockbuild"].lower() == "point":
            gameobj.blocksetlist[ind] = BlockSet(mousex * mapDict["GRID_SIZE"],
                                                 mousey * mapDict["GRID_SIZE"],
                                                 .5, "point")
            gameobj.chunklist[chunk].bl.append(gameobj.blocksetlist[ind])
            gameobj.chunklist[chunk].pl.append(ind)
            gameobj.chunklist[chunk].rl.append(gameobj.blocksetlist[ind].rect)
        elif globDict["blockbuild"].lower() == "tower":
            gameobj.blocksetlist[ind] = Tower(mousex * mapDict["GRID_SIZE"],
                                              mousey * mapDict["GRID_SIZE"], 1,
                                              "tower", gameobj.player,
                                              globDict["vrange"])
            gameobj.chunklist[chunk].bl.append(gameobj.blocksetlist[ind])
            gameobj.chunklist[chunk].pl.append(ind)
            gameobj.chunklist[chunk].rl.append(gameobj.blocksetlist[ind].rect)
        elif globDict["blockbuild"].lower() == "invincible":
            gameobj.blocksetlist[ind] = BlockSet(mousex * mapDict["GRID_SIZE"],
                                                 mousey * mapDict["GRID_SIZE"],
                                                 1, "invincible")
            gameobj.chunklist[chunk].bl.append(gameobj.blocksetlist[ind])
            gameobj.chunklist[chunk].pl.append(ind)
            gameobj.chunklist[chunk].rl.append(gameobj.blocksetlist[ind].rect)
        elif globDict["blockbuild"].lower() == "respawn tower":
            gameobj.blocksetlist[ind] = RespawnTower(
                mousex * mapDict["GRID_SIZE"], mousey * mapDict["GRID_SIZE"],
                1, "respawntower", gameobj.player)
            gameobj.chunklist[chunk].bl.append(gameobj.blocksetlist[ind])
            gameobj.chunklist[chunk].pl.append(ind)
            gameobj.chunklist[chunk].rl.append(gameobj.blocksetlist[ind].rect)
    def inn_decision(self, hero):
        inn_keeper = NPC(weapon_pile().get_random_weapon())
        inn_choices = ["Sleep for the night", "Leave"]
        counter = 1
        for i in inn_choices:
            print(str(counter) + ". " + i)
            counter += 1
        inn_decision = input("Your decision: ")
        if int(inn_decision) is 1:
            print(hero.char.health_display())
            if hero.char.max_health - hero.char.current_health == 0:
                print("It will cost you 5 gold.")
            else:
                print("It will cost you " + str((hero.char.max_health - hero.char.current_health) * 2) + " gold.")
            if hero.char.money >= (hero.char.max_health - hero.char.current_health) * 2 or hero.char.money >= 5:
                sleep_yn = input("Would you like to stay the night: ")
                if sleep_yn.upper() is "Y":
                    if hero.char.max_health - hero.char.current_health == 0:
                        hero.char.decrease_money(5)
                    else:
                        hero.char.decrease_money((hero.char.max_health - hero.char.current_health) * 2)
                        hero.char.current_health = hero.char.max_health
                    print("The " + hero.char.name + " walks upstairs to the rented room, and sleeps for the night.")
            else:
                print("The innkeeper looks at you with a furrowed brow and says \"Sorry, it appears you don't have enough gold.\"")

        print(hero.char.name + " leaves the inn.")
 def case_message_npc_create(self):
     pid = int(self.readdouble())
     name = self.readstring()
     x = self.readdouble()
     y = self.readdouble()
     hpmax = self.readdouble()
     hp = self.readdouble()
     n = NPC(self.world, name, pid, x, y, hpmax)
     n.hp = hp
     self.world.npcs.append(n)
     n.start()
Exemple #5
0
 def __init__(self):
     self.enemies = []
     self.events = [
         Event("Start"),
         Event("Forest"),
         Event("Clean Garden"),
         Event("Get Crown")
     ]
     self.events += [
         Event("Mountain"),
         Event("Ocean"),
         Event("Goblin King")
     ]
     self.locations = ["start", "desert"]
     self.person = []
     self.Done = True
     self.King = King()
     self.Gardener = NPC("Gardener")
     self.Blacksmith = NPC("Blacksmith")
     self.Worker = NPC("Worker")
     self.ChatBot = NPC("ChatBot")
Exemple #6
0
def enter():
    global hero, npc, end, map, cnt, level_of_difficulty, current_time
    current_time = time.time()
    level_of_difficulty = 25

    map = Map()
    cnt = Count()
    hero = Hero()
    npc = [[NPC() for i in range(4)] for i in range(7)]

    start_positon = 2
    end = False
    initialize_NPC(start_positon)  # 빈칸 생성

    game_world.add_object(hero, COLUMN_MAX)
    game_world.add_object(map, 0)
    game_world.add_object(cnt, 0)
    def __init__(self, hero):
        print("\n" + hero.char.name + " currently has " +
              str(hero.char.money) + " gold.")
        print("The shopkeeper greets you")
        input()
        shopkeep = NPC(weapon_pile().get_random_weapon())
        shopper_choice = input("Are you buying or selling?: ")

        if "B" in str(shopper_choice).upper():
            self.buying_menu(hero)
        if "S" in str(shopper_choice).upper():
            self.sellingMenu(hero)
        if "K" in str(shopper_choice).upper() or "A" in str(
                shopper_choice).upper():
            print("\nYou lunge at the " + shopkeep.Name + " with your " +
                  shopkeep.Weapon.name + "!\n")
            Battle(hero, shopkeep)
Exemple #8
0
    def __init__(self, Im_black_piece, Im_black_crown, Im_red_piece,
                 Im_red_crown):
        self.turn = 1
        self.turnNoKill = 0
        self.BLACK_TEAM = "black"
        self.RED_TEAM = "red"
        self.board = []
        self.sequenceKill = False

        #Instancing each piece
        self.blackOnes = []
        self.redOnes = []

        #Making players
        self.npc = NPC(self.board, self.blackOnes)
        self.user = User(self.board, self.redOnes)

        self.images = [
            Im_black_piece, Im_black_crown, Im_red_piece, Im_red_crown
        ]
	def enter_building(self, build_type, player_id, location_id):
		npcInst = NPC()
		print("You enter the {}\n".format(build_type))
		npcInst.create_npc(player_id, build_type, location_id)
Exemple #10
0
    def createRooms(self):

        #Salas

        sala = Room("sala")
        comedor = Room("comedor")
        cocina = Room("cocina")
        lavadero = Room("lavadero")
        jardin = Room("jardin")
        pasillo = Room("pasillo")
        dormitorio = Room("dormitorio")
        baño = Room("baño")
        balcon = Room("balcon")

        #Definimos las salas cerradas
        garaje = lockedRoom("garaje")

        #Definimos salidas

        garaje.setExit('east', sala)
        sala.setExit('north', comedor)
        sala.setExit('east', pasillo)
        sala.setExit('west', garaje)
        comedor.setExit('north', lavadero)
        comedor.setExit('east', cocina)
        comedor.setExit('south', sala)
        cocina.setExit('north', jardin)
        cocina.setExit('west', comedor)
        lavadero.setExit('south', comedor)
        jardin.setExit('south', cocina)
        pasillo.setExit('up', dormitorio)
        pasillo.setExit('west', sala)
        dormitorio.setExit('north', baño)
        dormitorio.setExit('east', balcon)
        dormitorio.setExit('down', pasillo)
        baño.setExit('south', dormitorio)
        balcon.setExit('west', dormitorio)

        #Definimos items

        lampara = Item('lampara', 'Una lámpara rota', 2)
        botella = Item('botella', 'Una botella vacía', 3)
        zapato = Item('zapato', 'Un zapato', 1.5)
        heladera = Item('heladera', 'Una heladera', 8)
        lavarropas = Item('lavarropas', 'Lavarropas', 10)
        tender = Item('tender', 'Un tender con ropa', 6)
        muñeco = Item('muñeco', 'Un muñeco de trapo', 3)
        cuadro = Item('cuadro', 'Un cuadro', 2)
        banco = Item('banco', 'Un banco', 4)
        mesa = Item('mesa', 'Una mesa de madera', 6)
        espejo = Item('espejo', 'Un espejo', 3)
        computadora = Item('computadora', 'Una computadora de escritorio', 6)
        cama = Item('cama', 'Una cama', 7)
        linterna = Item('linterna', 'Una linterna', 1)

        #Definimos items comestibles con sus respectivas propiedades.

        manzana = Comestible('manzana', 'Una manzana ordinaria', 1, 0, None)
        galleta = Comestible('galleta', 'Una galleta mágica', 2, 2, 'weight')

        #Definimos items utilizables, con su respectiva función.
        key = Usable('llave', 'Llave maestra', 1, 'key')
        beamer = Usable('portalgun', 'Arma de portales', 3, 'teleport')

        #Definimos cofres

        magic_box = Chest('Cofre', 'Magico cofre con muchos tesoros dentro',
                          1000, [manzana, galleta, espejo])

        #Añadiendo items a las distintas salas.
        comedor.addItem(zapato)
        sala.addItem(linterna)
        sala.addItem(lampara)
        cocina.addItem(botella)
        cocina.addItem(heladera)
        lavadero.addItem(lavarropas)
        jardin.addItem(tender)
        jardin.addItem(muñeco)
        pasillo.addItem(cuadro)
        balcon.addItem(banco)
        balcon.addItem(mesa)
        baño.addItem(espejo)
        dormitorio.addItem(cama)
        dormitorio.addItem(galleta)
        dormitorio.addItem(computadora)
        sala.addItem(manzana)
        sala.addItem(beamer)
        sala.addItem(key)
        sala.addItem(magic_box)

        #Definimos misiones
        mision1 = Mission('1ra mision',
                          'Llegar al dormitorio en menos de 10 movimientos',
                          10, 'checkpoint', 'dormitorio')

        #Definiendo NPC
        mago = NPC('Mago', sala,
                   'Traeme un arma de portales y te devolveré una galleta',
                   beamer, galleta)
        aprendiz = NPC(
            'Aprendiz', cocina,
            'Bienvenido a Zuul, revisa toda la casa para encontrar objetos importantes'
        )

        #Agregandolo a la sala
        sala.addNPC(mago)
        cocina.addNPC(aprendiz)

        #Definiendo jugador
        self.player = Player('Peter', None, 0)
        self.player.addMission(mision1)

        #Definiendo sala
        self.currentRoom = sala
        self.player.setActualRoom(self.currentRoom)

        return
Exemple #11
0
# Set player statistcs.
firstPlayer = currentPlayer
if currentPlayer == userColor:
    firstPlayer = userName
    firstColor = userColor
    secondPlayer = "NPC"
    secondColor = npcColor
else:
    firstPlayer = "NPC"
    firstColor = npcColor
    secondPlayer = userName
    secondColor = userColor

# Instantiations
myBoard = Board(currentPlayer)
npc = NPC(npcColor, 3)
prompt = "> "
winner = None
movesMade = []

print myBoard

# Game loop
while (myBoard.blackCount + myBoard.whiteCount) < 36:
    outputFile.write("{}\n{}\n".format(firstPlayer, secondPlayer))
    outputFile.write("{}\n{}\n".format(firstColor.upper(),
                                       secondColor).upper())
    if currentPlayer == firstColor:
        outputFile.write("1\n")
    else:
        outputFile.write("2\n")
    if 'type' in i:
        type = i['type']
    if 'health' in i:
        health = i['health']
    if 'attack' in i:
        attack = i['attack']
    if 'xp' in i:
        xp = i['xp']
    if 'serial' in i:
        serial = i['serial']
    #we'll do text but i got to ask the coop ;)
    #till then we're loading in sample texts
    if 'file_loc' in i:
        file = i['file_loc']

    npc_list.append(NPC(x, y, type, health, attack, xp, a, file, serial))
'''Things that the MAP objects take in and are used for loading in from sprite sheet'''
for i in map_set:
    if 'x' in i:
        x = i['x']
    if 'y' in i:
        y = i['y']
    if 'type' in i:
        type = i['type']
    if 'file_x' in i:
        file_x = i['file_x']
    if 'file_y' in i:
        file_y = i['file_y']
    if 'width' in i:
        width = i['width']
    if 'height' in i:
Exemple #13
0
    def play_game(self):
        """ Does the work of putting rooms in the game, laying out the map and progression """
        # def __init__(self, name, desc, n_exit, e_exit, s_exit, w_exit, special_command) for a Room
        # def __init__(self, name, desc, n_exit, e_exit, s_exit, w_exit, special_command, puzzle_number) for a puzzle Room
        # def __init__(self, name, desc, n_exit, e_exit, s_exit, w_exit, special_command, npc_character) for a room with a NPC
        start_room = Room("Forest Clearing",
                          "You're in a warmly lit area surrounded by trees. ",
                          None, None, None, None, False)
        tree_with_branch = RoomWithPuzzle(
            "Bushy Tree",
            "A well grown tree inhabits this part of the woods. One of its branches seems to have fallen to the ground.",
            None, None, None, None, True, 1)
        hiker_area = RoomWithNPC(
            "Someone's Campsite",
            "A well cleaned tent area occupies the south part of the area.\nA lone, burly man is sitting on a chair, reading a book called \'Bear Survival\'.",
            None, None, None, None, True, None)
        hiker_tent = RoomWithPuzzle(
            "Hiker's Tent",
            "You immediatly regret your decision on coming here. Filtering out the weird stuff, you notice a flashlight in the corner of the room",
            None, None, None, None, True, 9)
        crash_site = RoomWithPuzzle(
            "Car Crash Site",
            "A used to be fancy car sits dejectely, smoke and oil leaking out of it. You recalled that this was your sweet ride! To your dismay, the car seems to be sealed shut...maybe if you had some sort of leverage to pull it open?",
            None, None, None, None, True, 2)
        thick_brush = RoomWithPuzzle(
            "Thorny Path",
            "A thick, spiky overgrowth blocks the east path. There's no other way around it.",
            None, None, None, None, True, 3)
        open_field = Room("Forest Entrance",
                          "A vast field of grass occupies this space.", None,
                          None, None, None, False)
        bear_den = RoomWithPuzzle(
            "Grizzly Bear's Den",
            "A wretched stench greets you as you see a huge grizzly bear sleeping on a leafy patch. There seems to be something gleaming past it though...",
            None, None, None, None, True, 4)
        hill_shack = RoomWithPuzzle(
            "Hill's Foot",
            "The old shack looms at the top of the hill. It might be a good idea to investigate it...to the south you see a shriveld old man sitting on a stump.",
            None, None, None, None, True, 5)
        shack_patio = RoomWithNPC(
            "Sunny Stump",
            "Upon coming here, the old man seems to be looking at his oddly out of place smartphone.",
            None, None, None, None, True, None)
        river_area = RoomWithPuzzle(
            "Raging River",
            "A river stands between you and a dark cave. To the east is a lone, young man sitting on a towel. The river is extrememy fast...",
            None, None, None, None, True, 6)
        picnic_area = RoomWithNPC(
            "Sunny Spot",
            "The man appears to be in some sort of weird trance. He looks friendly though. Too friendly maybe.",
            None, None, None, None, True, None)
        dark_cave = RoomWithPuzzle(
            "Dark Cave Entrance",
            "There's little light in here to see anything. It might be wise to not go in blindly...",
            None, None, None, None, True, 7)
        golden_door = RoomWithPuzzle(
            "Gold Door",
            "After traveling a while, a huge golden door sits in front of you. It reads: \'ENTER PASSWORD\'",
            None, None, None, None, True, 8)

        # def __init__(self, name, talk_d, attack_d, fatal) for a NPC
        npc_1 = NPC(
            "Hiker Joe",
            "Ahoy, mate! You're looking pretty beaten up! I would help you, but I'm in the middle of bear watching! These woods are filled with them!\nIf you ever see one, sleeping or not, the best thing to do is to SNEAK by them! Trust me.\nHey, if you want some grub, I have some stuff in my tent! Just don't make a bear mess in there! Haha!",
            "WOAH! What you think you're doing?! You're lucky you're not a bear, since I would immediatly beat your ass up!",
            False)
        npc_2 = NPC(
            "Hermit Bill",
            "Hm? What brings you here, sonny? I rarely get visitors around here ever since the bear incident. You look like you want to access the Internet don't you?\nI know you young ones...always wanting to get the Internet without anyone's permission! Well, since you look desperate, I'll let you use mine.\nThe password is 1234567890...oh you're phone's dead? Sucker!",
            "SON. I'll have you know that I am a secret agent working here to kill anyone that tries to attack me in hopes to get my wifi.\nAnd you done f****d up.",
            True)
        npc_3 = NPC(
            "High Hugo",
            "Sup dude? You look like you've been to some shit rave...man...times like this is when you just need to relax and drink some good 231.\nWhat's 231? Dude, that's the bro code for having a good time and when you need a easy solution to something. Remember it well. You'll thank me later.",
            "ASDFGHJJ TIME TO ACTIVATE BRO TIME! GET REKED!", True)

        # def __init__(self, path_destination, is_locked) for a Path
        path1_n = Path(thick_brush, False)
        path1_s = Path(tree_with_branch, False)
        path1_e = Path(hiker_area, False)
        path1_w = Path(crash_site, False)
        path2_n = Path(start_room, False)
        path3_w = Path(start_room, False)
        path3_s = Path(hiker_tent, False)
        path4_n = Path(hiker_area, False)
        path5_e = Path(start_room, False)
        path6_s = Path(start_room, False)
        path6_e = Path(open_field, True)
        path7_n = Path(bear_den, False)
        path7_e = Path(hill_shack, False)
        path7_s = Path(river_area, False)
        path7_w = Path(thick_brush, False)
        path8_w = Path(open_field, False)
        path9_w = Path(open_field, False)
        path9_s = Path(shack_patio, False)
        path10_w = Path(hill_shack, False)
        path11_e = Path(picnic_area, False)
        path11_s = Path(dark_cave, True)
        path11_n = Path(open_field, False)
        path12_n = Path(river_area, False)
        path12_s = Path(golden_door, True)
        path13_n = Path(dark_cave, False)

        start_room.set_exits(path1_n, path1_s, path1_e, path1_w)
        tree_with_branch.set_exits(path2_n, None, None, None)
        hiker_area.set_exits(None, path3_s, None, path3_w)
        hiker_tent.set_exits(path4_n, None, None, None)
        crash_site.set_exits(None, None, path5_e, None)
        thick_brush.set_exits(None, path6_s, path6_e, None)
        open_field.set_exits(path7_n, path7_s, path7_e, path7_w)
        bear_den.set_exits(None, None, None, path8_w)
        hill_shack.set_exits(None, path9_s, None, path9_w)
        shack_patio.set_exits(None, None, None, path10_w)
        river_area.set_exits(path11_n, path11_s, path11_e, None)
        dark_cave.set_exits(path12_n, path12_s, None, None)
        golden_door.set_exits(path13_n, None, None, None)

        hiker_area.npc_character = npc_1
        shack_patio.npc_character = npc_2
        picnic_area.npc_character = npc_3

        print "You were enjoying a lovely evening on your hot date when suddenly, you forgot to use yout turn signal and ran into another car that was passing by!"
        print "You would have been fine if you weren't on a mountain, but you were and now your car was in a wreck and your date missing!"
        print "It's your goal now to salvage what you can find and get out of here!"

        self.set_room(start_room)
        while self.player.clear_game == False:
            print "\n"
            self.current_room.examine_room()
            self.command_parser()
Exemple #14
0
from NPC import NPC
from player import player

player1 = player({})
NPC1 = NPC('阿尔萨斯', '   使用霜之哀伤的怒火攻击敌人', '1')
NPC2 = NPC('吉安娜', '   使用奥数法术攻击敌人', '2')
NPC3 = NPC('乌塞尔', '   使用圣光的力量治愈盟友', '3')
while True:
    NPC.show()
    player1.showdangqian()
    c = input('请选择你要继续的操作:' '1. 邀请组队 ' '2. 踢出队伍 ' '0. 完成 \n' '')
    if c == '1':
        b = input('请选择可选NPC中要组队的NPC的ID\n')
        if b == '1':
            player1.addNPC(b)
        if b == '2':
            player1.addNPC(b)
        if b == '3':
            player1.addNPC(b)
    if c == '2':
        b = input('请选择可选NPC中要踢出的NPC的ID\n')
        if b == '1':
            player1.removeNPC(b)
        if b == '2':
            player1.removeNPC(b)
        if b == '3':
            player1.removeNPC(b)
    if c == '0':
        break
Exemple #15
0
 def createHouse(self):
     arrNPCs = [NPC() for i in range(self.population)]
     print("Creating a house with", len(arrNPCs), "monsters.")
 def get_location(id):
     # TODO AAA
     start = [NPC('start', '1')]
     return Location(start,
                     'История первая: "Прототип движения по диалогам"')
Exemple #17
0
from NPC import NPC, DialogNode

arry_npc = NPC("'Arry")

arry_dialog_0 = DialogNode("Anything else?")

arry_dialog_1 = DialogNode("Hey there mate, how can I help?", arry_dialog_0)
arry_dialog_2 = DialogNode(
    "Well, I moved here when my ol Dorris passed, oh that must of been 7 years back? I couldn't stay in Noamsted, too many memories."
)
arry_dialog_3 = DialogNode("Used to be quite nice... used to be",
                           arry_dialog_0)
arry_dialog_4 = DialogNode(
    "Well, I myself like to fish, not very good at it but helps pass the time."
)
arry_dialog_5 = DialogNode(
    "Ha Ha Ha Ha, well I definitely wouldn't know anything about that. Im all legit, 100% all import export... uh fish that is."
)
arry_dialog_6 = DialogNode(
    "Despite my appearance, I used to live a very different life. If I had realised Dorris would be caught up in it, I would have moved a long time ago.",
    arry_dialog_0)

arry_dialog_0.responses = [[
    "How long have you lived here for?", arry_dialog_2
], ["What do you do around here?", arry_dialog_4]]
arry_dialog_2.responses = [["How did you like Noamsted?", arry_dialog_3],
                           [
                               "Im sorry to hear that, how did she pass?",
                               arry_dialog_6
                           ]]
arry_dialog_4.responses = [[