コード例 #1
0
ファイル: world.py プロジェクト: Nitin71/Hive-Ambush
class StoreRoom(MapTile):
    items = [items.RPG("There is a rocket launcher lying on the ground."), \
      items.Red_Potion("A glowing bottle of mysterious red potion sits on one of the shelves."), \
      items.Old_Chest([items.Mountain_of_Gold()]), \
      items.Gold_Coins("A shiny handful of gold coins is on the ground near the chest.")]

    description = """You seem to have entered an underground storeroom!"""
コード例 #2
0
ファイル: world.py プロジェクト: lenchatterjee/lenception
class StoreRoom(MapTile):
	items = [items.Rusty_Scalpel("A rusty scalpel is propped against a shelf in the corner of the room."), \
			items.PurdueScholarship_Potion("A glowing bottle of mysterious red potion sits on one of the shelves."), \
			items.Old_Chest([items.Mountain_of_Gold()]), \
			items.Gold_Coins("A shiny handful of gold coins is on the ground near the chest.")]

	description = """You seem to have entered an underground storeroom!"""
コード例 #3
0
ファイル: enemies.py プロジェクト: saisarnala/TSOGame
class FallenSoldier(Enemy):
    name = "Fallen Soldier"
    description = "The fallen soldier draws its sword and silently screams, its ghost-like body transparent by torch light."
    hp = 10
    damage = 2
    goldCoins = items.Gold_Coins("Gold Coins glisten on the ground")
    goldCoins.Gold_Amount(random.randint(3, 5))
    loot = [goldCoins]
    exp = 5
コード例 #4
0
ファイル: enemies.py プロジェクト: saisarnala/TSOGame
class FallenBarbarian(Enemy):
    name = "Fallen Barbarian"
    description = "The fallen barbarain hefts its axe and charges."
    hp = 15
    exp = 15
    damage = 15
    goldCoins = items.Gold_Coins("Gold Coins glisten on the ground")
    goldCoins.Gold_Amount(random.randint(5, 10))
    loot = [goldCoins, items.Red_Potion()]
    agro = True
コード例 #5
0
ファイル: enemies.py プロジェクト: saisarnala/TSOGame
class DarkKnight(Enemy):
    name = "Dark Knight"
    description = "The dark knight's body is wrapped in darkness, absorbing all light."
    hp = 100
    damage = 4
    exp = 40
    goldCoins = items.Gold_Coins("Gold Coins glisten on the ground")
    goldCoins.Gold_Amount(random.randint(10, 20))
    loot = [
        goldCoins,
        items.Red_Potion("You see a red potion rolling on the ground")
    ]
    agro = True
コード例 #6
0
ファイル: enemies.py プロジェクト: saisarnala/TSOGame
class DarkWizard(Enemy):
    name = "Dark Wizard"
    description = "A dark wizard suddenly appears from the shadows, a shiny special key glistening on his belt."
    hp = 50
    damage = 15
    exp = 50
    goldCoins = items.Gold_Coins("Gold Coins glisten on the ground")
    goldCoins.Gold_Amount(random.randint(20, 30))
    loot = [
        goldCoins,
        items.Special_Key(
            "A special key sits on the ground, perfect for opening locked chests."
        )
    ]
コード例 #7
0
ファイル: NPC.py プロジェクト: ExistNot/GalacticCombat
class Riddler(NPC):
	name = "Riddler"
	goods = [items.Gold_Coins()]
	quantities = [1, -1, 2]		# Set quantity to -1 if you want it to be infinite.
	description = "A Riddler that gives riddles for Gold."
	def talk(self):		# Add to this method if you want to be able to talk to your NPC. ###CHANGE LATER
		print("Want some Gold? Ask for a riddle and I shall fiddle your mind down the to middle!")
		print("the riddle")
		ranswer = "the answer"
		pans = input("What is your response?")
		return""
		
	def riddle(self):
		print("Want some Gold? Ask for a riddle and I shall fiddle your mind down the to middle!")
		print("the riddle")
		ranswer = "the answer"
		pans = input("What is your response?")
		return pans==ranswer 

	def give(self, item, inventory):
		for good in self.goods:
			if(good == item):
				inventory.append(good)
				if(self.quantities[self.goods.index(good)] > 0):
					self.quantities[self.goods.index(good)] -= 1
		return inventory

	def first_time(self):		# Used to have your NPC do something different the first time you see them.
		self.first_encounter = False
		text = self.description
		text += " Hello! A Riddler is my name, riddles are my game! Ask for one and receive the pain. Get it, because they are hard?? Oh? You want a Riddle? Hehehe, Here it is:"
		return text
	def handle_input(self, verb, noun1, noun2, inventory):
		if(noun1 == 'riddler' or noun1 == 'a riddler'):
			if(verb == 'check'):
				return [True, self.check_text(), inventory]
			elif(verb == 'talk'):
				text = self.talk()
				return [True, text, inventory]
コード例 #8
0
ファイル: world.py プロジェクト: 175552/TSOGame
class FalseVictory(MapTile):
    description = "The light you saw turned out to be a fire..."


class SlimeTile(MapTile):
    description = "You enter a dimly lit room with a goo that looks like...slime?"
    enemies = [enemies.BossSlime('e')]


class FinalBattle(MapTile):
    description = "You enter a room that looks to be an arena."
    enemies = [enemies.BossElf('w', 'e')]


normalChest = items.Old_Chest()
goldCoins = items.Gold_Coins()
goldCoins.Gold_Amount(5)
normalChest.contents = [items.Dagger(), goldCoins]
bossChest1 = items.Locked_Chest()
bossChest1.contents = [items.Flame_Sword(), items.Red_Potion()]


class World:  # I choose to define the world as a class. This makes it more straightforward to import into the game.
    map = [
        [
            SlimeTile(),
            FinalBattle(),
            NearVictory(), None, None,
            FalseVictory(enemies=[enemies.BossOgre('e')], items=[bossChest1]),
            NearFalseVictory(), None
        ],
コード例 #9
0
ファイル: game.py プロジェクト: ExistNot/GalacticCombat
def handle_input(verb, noun1, noun2):
    global debug_mode
    if (verb == 'help'):
        if (not noun1):
            return help_text
        else:
            return "I'm not sure what you need help with. Try using 'help' on its own."

    elif (verb == 'exit'):
        if (not noun1):
            exit()
        else:
            return "Are you trying to quit the game? If so, just type 'exit' on its own."

    elif (verb == 'debug'):
        if (not noun1):
            if (debug_mode):
                debug_mode = False
                return "Debug mode turned off."
            else:
                debug_mode = True
                return "Debug mode turned on."
        else:
            return "I don't know what you are trying to debug. If you want to toggle the parser's output text, just type 'debug' on its own."

    elif (verb == 'go'):
        if (not noun2):
            if (noun1 == 'north'):
                [move_status,
                 move_description] = world.check_north(player.x, player.y)
                if (move_status):
                    player.move_north()
                    world.tile_at(player.x, player.y).random_spawn(
                    )  # Randomly spawn enemies if possible.
                    return [
                        move_description,
                        world.tile_at(player.x, player.y).intro_text()
                    ]
                else:
                    return move_description

            elif (noun1 == 'south'):
                [move_status,
                 move_description] = world.check_south(player.x, player.y)
                if (move_status):
                    player.move_south()
                    world.tile_at(player.x, player.y).random_spawn(
                    )  # Randomly spawn enemies if possible.
                    return [
                        move_description,
                        world.tile_at(player.x, player.y).intro_text()
                    ]
                else:
                    return move_description

            elif (noun1 == 'east'):
                [move_status,
                 move_description] = world.check_east(player.x, player.y)
                if (move_status):
                    player.move_east()
                    world.tile_at(player.x, player.y).random_spawn(
                    )  # Randomly spawn enemies if possible.
                    return [
                        move_description,
                        world.tile_at(player.x, player.y).intro_text()
                    ]
                else:
                    return move_description

            elif (noun1 == 'west'):
                [move_status,
                 move_description] = world.check_west(player.x, player.y)
                if (move_status):
                    player.move_west()
                    world.tile_at(player.x, player.y).random_spawn(
                    )  # Randomly spawn enemies if possible.
                    return [
                        move_description,
                        world.tile_at(player.x, player.y).intro_text()
                    ]
                else:
                    return move_description

            else:
                return "I'm not sure where you're trying to go."

        else:
            return "Whatever you are trying to do is too complicated for me to understand. Please try again."

    elif (verb == 'check'):
        if (not noun2):
            if (noun1 == None or noun1 == 'around' or noun1 == 'room'
                    or noun1 == 'surroundings'):
                return world.tile_at(player.x, player.y).intro_text()
            elif (noun1 == 'inventory' or noun1 == 'pockets'):
                player.print_inventory()
                return ''  # No need to return any text because the player.print_inventory() function already did.
            else:
                [status, description] = player.handle_input(verb, noun1, noun2)
                if (status):
                    return description
                else:
                    [status, description, inventory] = world.tile_at(
                        player.x,
                        player.y).handle_input(verb, noun1, noun2,
                                               player.inventory)
                    if (status):
                        return description
                    else:
                        return "I'm not sure what you are trying to look at."
        else:
            return "I think you are trying to look at something, but your phrasing is too complicated. Please try again."

    elif (verb == 'attack'):
        if (not noun2):
            for enemy in world.tile_at(player.x, player.y).enemies:
                if (enemy.name.lower() == noun1):
                    if (player.weapon):
                        [attack_text, damage] = player.weapon.attack()
                        attack_text += " " + enemy.take_damage(damage)
                    else:
                        attack_text = "You try to attack, but you come up empty handed! You should equip something first..."
                    if (enemy.is_alive() and not enemy.agro):
                        attack_text += " The %s retaliated..." % enemy.name
                        attack_text += " " + player.take_damage(enemy.damage)
                    return attack_text
        else:
            return "If you want to attack 'with' a weapon, please equip it first."
        return "I'm not sure what you're trying to attack."

    elif (verb == 'give'):  #Wilkins is at the tile.
        if (noun1):
            if (noun1.lower() == "sparkling gem"):
                tile = world.tile_at(player.x, player.y)
                if (not tile.npcs[0].canGive(items.Sparkling_Gem(),
                                             player.inventory)):
                    print(
                        "You search through your inventory, but you do not find a sparkling gem"
                    )
                    tile.npcs[0].talk()
                else:
                    player.inventory = tile.npcs[0].give(
                        items.Sparkling_Gem(), player.inventory)
                    tile.npcs[0].giveInfo()
                    return "Victory is yours!"
            else:
                return "You can't give that!"
        else:
            return "What would you like to give"

    elif (verb):
        [status, description] = player.handle_input(verb, noun1, noun2)
        if (status):
            return description
        else:
            [status, description, inventory
             ] = world.tile_at(player.x,
                               player.y).handle_input(verb, noun1, noun2,
                                                      player.inventory)
            if (status):
                player.inventory = inventory
                return description
            else:
                return "I'm not sure what you are trying to %s." % verb
    else:
        for npc in world.tile_at(player.x, player.y).npcs:
            if (npc.name.lower() == "riddler"):
                if (npc.riddle()):
                    npc.give(items.Gold_Coins(), Player.inventory)

        return "I have no idea what you are trying to do. Please try again."