def check_server(self, message):
        """Helper function that finds character object associated with a user."""

        server = message.server.id
        channel = message.channel.id
        author = message.author.id

        if server in self.servers:
            # check if channel is known
            if channel in self.servers[server]:
                # check if player is known
                if author in self.servers[server][channel]:
                    # update command time and return character
                    self.servers[server][channel][author][1] = datetime.datetime.now()
                    return self.servers[server][channel][author][0]

                else:  # if player not known make new entry
                    char = Character(author)
                    self.servers[server][channel][author] = [char, datetime.datetime.now()]
            else:  # make a new channel entry
                char = Character(author)
                self.servers[server][channel] = {author: [char, datetime.datetime.now()]}

        else:  # make new server entry
            char = Character(author)
            self.servers[server] = {channel: {author: [char, datetime.datetime.now()]}}
        return char
Beispiel #2
0
	def loadLevel(self, filename):
		levelDoc = open(filename)
		mapLine = []
		characterLine = []
		mapDone = False
		for line in levelDoc:
			if line == '\n' or line == '\r\n':
				mapDone = True
			elif mapDone:
				characterLine.append(line.split())
			else:
				mapLine.append(line)

		self.tileMap = np.zeros((len(mapLine[0].split()), len(mapLine))).astype('U256')
		y = 0
		for line in mapLine:
			line = line.split()
			x = 0
			for char in line:
				self.tileMap[x, y] = char
				x+=1
			y+=1

		self.characterArray = []
		for line in characterLine:
			if line[0] == 'player':
				character = Character(line[1], (int(line[2][1]), int(line[2][3])), self.tileSize, line[3])
				self.player = character
				self.tileMap[int(line[2][1]), int(line[2][3])] = character
			elif line[0] == 'npc':
				character = Character(line[1], (int(line[2][1]), int(line[2][3])), self.tileSize, line[3])
				self.characterArray.append(character)
				self.tileMap[int(line[2][1]), int(line[2][3])] = character
def enter():
    gfw.world.init(['bg', 'cloud', 'character', 'ui'])

    for n in range(1, 4):
        bg = Background('forest0%d.png' % n)
        gfw.world.add(gfw.layer.bg, bg)

    cloud = HorzScrollBackground('cloud.png', 20, 130)
    gfw.world.add(gfw.layer.cloud, cloud)

    global soldier, princess
    soldier = Character(400, 300, 'soldier_animation_sheet-tile.png')
    soldier.set_animation(True)
    gfw.world.add(gfw.layer.character, soldier)

    princess = Character(get_canvas_width() - 400, 300,
                         'princess_animation_sheet-tile.png')
    gfw.world.add(gfw.layer.character, princess)

    color = [(0, 0, 0), (255, 255, 255)]
    init = [(100, -365, 200, "select character"),
            (100, -370, 210, "select character"), (50, -305, -305, "soldier"),
            (50, -310, -300, "soldier"), (50, 150, -305, "princess"),
            (50, 145, -300, "princess")]

    for n, (size, pos_x, pos_y, sent) in zip(range(6), init):
        menu = Menu('ThaleahFat.ttf', size, color[n % 2], sent, pos_x, pos_y)
        gfw.world.add(gfw.layer.ui, menu)

    global ret
    ret = 1

    global menu_music
    menu_music = load_wav(res('sound/menu.wav'))
    menu_music.set_volume(10)
Beispiel #4
0
def main():
    seed(datetime.now())

    orcs = [
        Character("Orc-" + str(i + 1),
                  Equipment(uniform(1.1, 1.5), uniform(1.1, 1.3)), 2,
                  randrange(4)) for i in range(5)
    ]
    orcs += [
        Tank("Orc Tank" + str(i + 1),
             Equipment(uniform(1.1, 1.5), uniform(1.1, 1.3)), 2, randrange(4))
        for i in range(5)
    ]
    night_elves = [
        Character("Night Elf" + str(i + 1),
                  Equipment(uniform(1.1, 1.5), uniform(1.1, 1.3)), 3,
                  randrange(3)) for i in range(3)
    ]
    night_elves += [
        Mage("Night Elf Mage" + str(i + 1),
             Equipment(uniform(1.1, 1.5), uniform(1.1, 1.3)), 2, randrange(4))
        for i in range(5)
    ]

    a = Arena(orcs, night_elves)
    a.play()
def getCharacters():
    hero = Character("Daltor", 200, 20)
    sendor = Character("Sendor", 100, 35)
    ghost = Character("Ghost", 50, 7)
    zombifiedBat = Character("Zombified Bat", 50, 12)
    liveRock = Character("Live Rock", 40, 22)

    return hero, sendor, ghost, zombifiedBat, liveRock
Beispiel #6
0
def main():
    computer = Character('Computer')
    user = Character(input('Type name of your character: '))

    # randomly selects a sequence of moves
    turn = choice(['user', 'computer'])

    # the game ends when one of the characters runs out of health points
    while user.health_point > 0 and computer.health_point > 0:
        if turn == 'user':
            print((
                'Select an action:\n1. To deal damage in a mid range(18-25'
                ').\n2. To deal damage in a high range(10-35).\n3. To heal yourse'
                'lf(18-25).'))
            turn = 'computer'
            move = input('Enter choice: ')
            if move == '1':
                damage = user.deal_medium_damage_range(computer)
                print('You inflicted {} damage to the enemy.'.format(damage))
            elif move == '2':
                damage = user.deal_high_damage_range(computer)
                print('You inflicted {} damage to the enemy.'.format(damage))
            elif move == '3':
                heal = user.heal_yourself()
                print('You have restored your character {} health points.'.
                      format(heal))
            else:
                print('Enter a valid selection')
                turn = 'user'
        else:
            turn = 'user'
            list_of_moves = ['1', '2', '3']

            # if the enemy’s health points fall below 35, then the computer
            # increases the chance to restore health points
            if computer.health_point <= 35:
                list_of_moves = ['1', '2', '3', '3', '3']
            move = choice(list_of_moves)
            if move == '1':
                damage = computer.deal_medium_damage_range(user)
                print('The enemy has dealt you {} damage.'.format(damage))
            if move == '2':
                damage = computer.deal_high_damage_range(user)
                print('The enemy has dealt you {} damage.'.format(damage))
            if move == '3':
                heal = computer.heal_yourself()
                print('The enemy has restored his character {} health points.'.
                      format(heal))
        print('{}: {}HP\nComputer: {}HP\n'.format(user.name,\
            user.health_point, computer.health_point))
        sleep(2.0)

    if user.health_point > computer.health_point:
        print('YOU WIN!')
    else:
        print('YOU LOSE :(')
Beispiel #7
0
def main():
    seed(datetime.now())

    orcs = [Character("Orc-" + str(i + 1), 2, randrange(4)) for i in range(5)]
    night_elves = [
        Character("Night-Elf-" + str(i + 1), 3, randrange(3)) for i in range(3)
    ]

    a = Arena(orcs, night_elves)
    a.play()
Beispiel #8
0
 def populate_deck(self):
     for i in range(0, 3):
         self.deck.append(Character(CharacterType.ambassador, Location.deck))
     for i in range(0, 3):
         self.deck.append(Character(CharacterType.assassin, Location.deck))
     for i in range(0, 3):
         self.deck.append(Character(CharacterType.captain, Location.deck))
     for i in range(0, 3):
         self.deck.append(Character(CharacterType.contessa, Location.deck))
     for i in range(0, 3):
         self.deck.append(Character(CharacterType.duke, Location.deck))
Beispiel #9
0
def start_base():
    window_grid = [[0]*(window_width/200) for i in xrange(window_height/200)]
    global c,e, terrains, start_location, end_location, end_sprite
    terrains, start_location, end_location, end_sprite = build_base()
    e = []
    try:
        c = Character(start_location, terrains, e, end_sprite,c)
    except:
        c = Character(start_location, terrains, e, end_sprite)
    c.base = True
    c.area_level = 0
    window.push_handlers(c.key_handler)
Beispiel #10
0
	def __init__(self):
		players = ListProperty([
			Player(1, [
				Character(1, 1, "Phara", characters[1]),
			]),
			Player(2, [
				Character(1, 2, "Op", characters[2]),
			]),
		])
		StringProperty("Setting up game...")
		#self.add_widget(Label(text="Setting up Game.."))
		#self.players = players
		self.is_active = BooleanProperty(True)
		self.turn_count = NumericProperty(0)
Beispiel #11
0
    def key_action(event):
        if event.key == "<LEFT>":
            isaac_newton.move(-ISAAC_XVEL, ISAAC_YVEL)
        elif event.key == "<RIGHT>":
            isaac_newton.move(ISAAC_XVEL, ISAAC_YVEL)

        if isaac_newton.getX() >= (GWINDOW_WIDTH - ISAAC_WIDTH):
            isaac_newton.setLocation(GWINDOW_WIDTH - ISAAC_WIDTH,
                                     Character().ypos)
            gw.addEventListener("key", key_action)

        if isaac_newton.getX() <= 0:
            isaac_newton.setLocation(0, Character().ypos)
            gw.addEventListener("key", key_action)
Beispiel #12
0
    def __init__(self):
        super().__init__()
        for i in range(0, 3):
            character = Character()
            character.gain_card(Cultist("Cultist " + 'I' * (i + 1)))
            character.gain_card(cards.Berserk())
            self.characters.append(character)

        character = Character()
        character.gain_card(Cultist("Cultist " + 'I' * 4))
        character.gain_card(cards.RitualDagger())
        self.characters.append(character)

        self.loot_table = {cards.RitualDagger(): 1.0, cards.Berserk(): 1.0}
Beispiel #13
0
def create_char_relation(df_bibleTA_distilled):
    """This function will create all character and relationobjects from the distilled csv
    we will use a csv which was generated in the distillDataFrame function, which is located in the eval_graph.py function.The CSV has following form:
    ,character_A,character_B,emotion
    0, God,Abraham,0.0
    1, God,ye,0.0
    One thing to remeber, is that the relations are distinct, so we will not have the same relationship in two seperate rows."""
    """each time we save a character or a relation we do have to do expensive operations in I/O a .pkl file."""
    character_list = []
    character_name_list = []
    relation_list = []
    for _, row in df_bibleTA_distilled.iterrows():
        character_A_name, character_B_name, emotion = (
            row["character_A"].lstrip(),
            row["character_B"].lstrip(),
            row["emotion"],
        )
        """check if we already encountered the character in a previous loop process"""
        if character_A_name in character_name_list:
            """get the character from the character_list"""
            for character in character_list:
                if character.get_name() == character_A_name:
                    character_A = character
            character_A_exists = False
        else:
            character_A = Character(character_A_name)
            character_name_list.append(character_A_name)
            character_list.append(character_A)
            character_A_exists = True

        if character_B_name in character_name_list:
            """get the character from the character_list"""
            for character in character_list:
                if character.get_name() == character_B_name:
                    character_B = character
            character_B_exists = False
        else:
            character_B = Character(character_B_name)
            character_name_list.append(character_B_name)
            character_list.append(character_B)
            character_B_exists = True

        relation = Relation(character_A, character_B, emotion)
        character_A.add_relation(relation)
        character_B.add_relation(relation)
        relation_list.append(relation)
    picklehandler = PickleHandler()
    picklehandler.save_override_character_list(character_list)
    picklehandler.save_override_relation_list(relation_list)
Beispiel #14
0
def main():
    seed(datetime.now())
    orcs = [
        Character("Orc-" + str(i + 1),
                  Equipment(uniform(1.1, 1.5), uniform(1.1, 1.3)), 2,
                  randrange(4)) for i in range(5)
    ]
    night_elves = [
        Character("Night-Elf-" + str(i + 1),
                  Equipment(uniform(1.1, 1.5), uniform(1.1, 1.3)), 3,
                  randrange(3)) for i in range(5)
    ]

    arena = Arena(orcs, night_elves)
    arena.play()
Beispiel #15
0
def game_loop(specs):
    me = Character(*specs)
    inv = Inventory()

    print("\nI hope this turns into something, but who knows?")

    print("Nothing to see here...yet. Move Along!")
Beispiel #16
0
    def setUp(self):
        wep_list = [
            'normal',
            'normal2',
            'unknown',
            'strength',
            'magna',
            'magna',
            'magna',
            'magna',
            ('bahamut', 'sword'),
            ('hl_bahamut', 'dagger'),
        ]
        self.weapon_pool = self._create_pool_from_list(wep_list)

        self.summon_none = Summon("none", 'elemental', 0.0)
        self.summon_elemental = Summon("elemental", 'elemental', 0.5)
        self.summon_magna = Summon('magna', 'magna', 0.5)
        self.summon_ranko = Summon('ranko', 'ranko', 0.5)
        self.summon_primal = Summon('primal', 'primal', 0.5)
        self.summon_character = Summon('character', 'character', 0.5)

        self.normal_mod = self.weapon_pool.normal_modifier
        self.magna_mod = self.weapon_pool.magna_modifier
        self.unknown_mod = self.weapon_pool.unknown_modifier
        self.strength_mod = self.weapon_pool.strength_modifier
        self.bahamut_mod = self.weapon_pool.bahamut_modifier

        self.character = Character("test", [], 'unknown')

        pass
    def readServers(self):
        servers = {}

        try:
            dom = etree.parse("details.xml")
        except ParseError:
            self.servers = {}
            return
        except FileNotFoundError:
            self.servers = {}
            return

        servs = dom.findall('server')

        for server in servs:
            servname = server.find('name').text
            servers[servname] = {}
            channels = server.findall('channel')

            for channel in channels:
                channelname = channel.find('name').text
                servers[servname][channelname] = {}
                users = channel.findall('user')

                for user in users:
                    username = user.find('name').text
                    lasttime = user.find('time').text
                    lasttime = datetime.datetime.strptime(lasttime, "%Y-%m-%d %H:%M:%S.%f")
                    flavour = user.find('flavour').text

                    servers[servname][channelname][username] = [Character(username, bool(flavour)), lasttime]

        self.servers = servers
Beispiel #18
0
    def new_game(self):

        self.character = Character(self.screen, self)

        self.level = 1

        self.golds = []
        self.food = [
        ]  ## TODO Add classes (i.e. which character ? Also fix room gen Add trap)
        self.trap = []
        self.paths = []
        self.stairs = []
        self.monsters = []
        self.stack = [
            Room(self.screen, -7, -5, 10, 20),
        ]

        while len(self.stack) != 3:
            self.randomRoom()
            pass

        self.panel = 0
        self.turns = 0
        self.rest = 0
        self.help = 0
        self.death = 0
        self.get_screen_offset()
        self.offset = [0, 0]
        self.logger = ['Hello World']
Beispiel #19
0
    def create_character(self):
        list_file = Path('characters/character_list.yaml')
        if not list_file.is_file():
            is_new = True
        else:
            is_new = False

        if is_new == True:
            character_list = {}
            id = 1
        else:
            pass
            with open(list_file, 'r') as file:
                character_list = yaml.load(file)
            id = int(sorted(character_list.keys())[-1])
            id += 1
        character_list.update({id: {'id': id, 'name': self.character['name']}})
        self.character['id'] = id
        self.character['is_new'] = True
        with open(list_file, 'w+') as file:
            yaml.dump(character_list, file, default_flow_style=False)
        with open('characters/character-' + str(id) + '.yaml',
                  'w+') as character_dict:
            yaml.dump(self.character, character_dict, default_flow_style=False)
        Character(id)
Beispiel #20
0
 def setup(self):
     print('=' * 60)
     print("Hack 'n Slash: The ultimate battle between human and monster!")
     print('=' * 60)
     self.player = Character()
     self.monsters = [Goblin(), Troll(), Dragon()]
     self.monster = self.get_next_monster()
Beispiel #21
0
    def getItemObj(self, itemStr, id1, id2=""):
        """ given return an existing object, or None if it doesn't exist """
        if isRoomFactoryType(itemStr.lower()):
            itemObj = RoomFactory(itemStr, id1)
        elif itemStr.lower() == "character":
            itemObj = Character(None, id2)
            itemObj.setName(id1)
        elif itemStr.lower() == "creature":
            itemObj = Creature(id1)
        elif isObjectFactoryType(itemStr.lower()):
            itemObj = ObjectFactory(itemStr, id1)
        elif itemStr.lower() == "account":
            itemObj = Account()
            itemObj.email = id1
        else:
            print("Can not determine object type.")
            return None

        if not itemObj:
            msg = "Object doesn't exist.  Aborting..."
            print(msg + "\n")
            logger.warning(msg)
            return None
        if not itemObj.load():
            if itemObj.getId() == 0:
                msg = "Couldn't load object and ID is 0.  Aborting..."
                print(msg + "\n")
                logger.warning(msg)
                return None
            else:
                itemObj._isNew = True
        return itemObj
    def __init__(self, fullscreen, sceneName=None):
        # Start Panda
        preSetWindowIcon("media/heavy_destruction.ico")
        ShowBase()

        # Some non-gameplay setup.
        self.name = "Heavy Destruction"
        self.version = 1.0
        base.setBackgroundColor(0, 0, 0)
        centerWindow()
        render.setAntialias(AntialiasAttrib.MAuto)
        if fullscreen: toggleFullscreen()
        self.setupKeys()
        self.setupFps()
        self.setupTitle()

        # Setup game objects.
        self.world = World(self)
        self.character = Character(self.world)
        self.cameraHandler = CameraHandler(self.character)
        self.shooter = Shooter(self.character)

        # Select a scene.
        if sceneName == "balls":
            self.scene = scene.FallingBalls(self.world, render,
                                            self.cameraHandler, self.character)
        else:
            self.scene = scene.BasicWall(self.world, render,
                                         self.cameraHandler, self.character)
Beispiel #23
0
 def __init__(self, first_name, last_name, race):
     if type(first_name) is str and type(last_name) is str and type(
             race) is str:
         self.character = Character(first_name, last_name, race)
         self.inventory = Inventory(10, 100)
         self.experience = 0
         self.level = 0
 def draft_character(self):
     character = Character()
     character.gain_card(self.pick_from_draw("Character"))
     character.gain_card(self.pick_from_draw("Technique"))
     character.gain_card(self.pick_from_draw("Equipment"))
     self.pick_character_rank(character)
     return character
 def test_character_saving_throws_with_changes(self):
     attributes = {"dex": 12}
     pc = Character(name="Shan")
     pc.provide_attributes(attributes)
     pc.get_saving_throws()
     pc.saving_throws.base_mods.reflex = 2
     assert pc.saving_throws.reflex == 3
Beispiel #26
0
 def test_run_away_take_damage(self, mock_rolldie, mock_stdout):
     test_character = Character('Chi', 10, [1, 2], 0)
     test_enemy = Child(5)
     combat.run_away(test_character, test_enemy)
     expected_stdout = "You have escaped, but have taken " + str(test_enemy.get_escape_damage()) + " points of "
     "damage in the process. You now have " + str(test_character.get_health()) + " health points remaining."
     self.assertIn(expected_stdout, mock_stdout.getvalue())
Beispiel #27
0
	def build(self):
		
		if False:
			players_count = int(raw_input("How many players are there? "))
			players = []
			for p in range(1, players_count+1):
				
				#player_characters_count = int(raw_input("How many characters does player %r have? " % p))
				player_characters = []
				#for c in range(1, player_characters_count+1):
				c = 1
				character_name = ""
				
				while character_name != "done":
					character_name = raw_input("Enter name for Player %s's character #%s (or type 'done' if you are finished adding characters): " % (p, c))
					
					if character_name != "done":
						character_id = raw_input("Enter character id for %s: " % character_name)
						if character_id in characters:
							new_character = Character(c, character_id, character_name, characters[character_id])
							player_characters.append(new_character)
							c = c + 1
					
				players.append(Player(p, player_characters))
		
		
		
			
		
		global current_game
		current_game = Game()
		
		while current_game.is_active:
			pass
Beispiel #28
0
    async def create_character(self, ctx, *args):
        """Creates a new character for the player if they don't have one"""
        player = ctx.message.author.id
        msg = ''

        if player in _characters:
            msg = 'You already have a character named {}.'.format(
                _characters[player]._name)
        elif len(args) == 0:
            msg = 'You must name your character.'
        elif len(args[0]) > 30:
            msg = 'Don\'t be a troll. Think of a name with a max of 30 characters.'
        else:
            name = args[0]
            # create the new char and store in the db
            c = Character(name, player)
            database.session.add(c)
            database.session.commit()
            database.session.expunge(c)

            self.__init_character(c)
            msg = 'Created character {}!'.format(name)
            self._public_messages.append(
                '{} has entered the world!'.format(name))

        await discord_output.private(self._bot, ctx.message.author, msg)
Beispiel #29
0
def main():
    ''' Main function to generate a simple character '''

    # Build Character
    name = "Yin"  # TODO: Input character name
    PC = Character(name)
    PC.generate()
Beispiel #30
0
def cacheCharacter(name, datFile=None):
    if name in characters:
        return characters[name]
    else:
        c = Character(datFile or name + '.dat')
        characters[name] = c
        return c