Пример #1
0
    def generate(self, mobiles, immobiles):
        x, y = self.position
        map.nextid += 1
        newMonster = character.Character((x + 32, y), self.monsterType,
                                         map.nextid)
        if not pygame.sprite.spritecollide(newMonster, mobiles, False) and \
           not pygame.sprite.spritecollide(newMonster, immobiles, False):
            return newMonster

        newMonster = character.Character((x, y + 32), self.monsterType,
                                         map.nextid)
        if not pygame.sprite.spritecollide(newMonster, mobiles, False) and \
           not pygame.sprite.spritecollide(newMonster, immobiles, False):
            return newMonster

        newMonster = character.Character((x - 32, y), self.monsterType,
                                         map.nextid)
        if not pygame.sprite.spritecollide(newMonster, mobiles, False) and \
           not pygame.sprite.spritecollide(newMonster, immobiles, False):
            return newMonster

        newMonster = character.Character((x, y - 32), self.monsterType,
                                         map.nextid)
        if not pygame.sprite.spritecollide(newMonster, mobiles, False) and \
           not pygame.sprite.spritecollide(newMonster, immobiles, False):
            return newMonster

        map.nextid -= 1
        return False
Пример #2
0
def generate_char():
    if int(len(my_characters)) != 7:
        itemchance1 = random.randint(1, chance1)
        itemchance2 = random.randint(1, chance2)
        if realtime < newchartime:
            randID = random.randint(0, 1)
        else:
            randID = random.randint(0, 3)
        getID = randIDs[randID]
        if itemchance1 == 7:
            middleID.append(5)
            my_characters.append(
                character.Character(scene=my_scene,
                                    charID=5,
                                    size=20,
                                    x_start=winW // 2,
                                    y_start=100))
        elif itemchance2 == 7:
            middleID.append(6)
            my_characters.append(
                character.Character(scene=my_scene,
                                    charID=6,
                                    size=20,
                                    x_start=winW // 2,
                                    y_start=100))
        else:
            middleID.append(getID)
            my_characters.append(
                character.Character(scene=my_scene,
                                    charID=getID,
                                    size=20,
                                    x_start=winW // 2,
                                    y_start=100))
    if nowtimer != 0:
        window.after(20, generate_char)
Пример #3
0
 def __init__(self, width=1280, height=720):
     ''' Initializes the screen and the introloop'''
     pygame.init()
     self.width = width
     self.height = height
     self.screen = pygame.display.set_mode((self.width, self.height))
     pygame.display.set_caption('Kitty Fight')
     self.introLoop()
     '''Sets the clock so we can control the frame rate later'''
     self.clock = pygame.time.Clock()
     '''Did we check the high score yet? No we didn't, we just started!'''
     self.weCheckedHighScore = False
     '''Loads our AMAZING, NOT SHIT backgrounds'''
     self.background = pygame.Surface(self.screen.get_size()).convert()
     self.backgroundImage = shittyBackground.fuckingBackground(
         "Epic-Sunset.png", [0, 0], (width, height))
     '''This loads the KO animation we'll play later and groups it with itself so we can draw it later.'''
     self.KO = ko.KO("KOspritesheet.png")
     self.KOsprite = pygame.sprite.Group(self.KO)
     '''This load both of the players'''
     self.player1 = character.Character("Skullcrusher", 50, height - 370,
                                        "right")
     self.player2 = character.Character("Demon Slayer", width - 400,
                                        height - 370, "left")
     self.sprites = pygame.sprite.Group((self.player1, self.player2))
Пример #4
0
    def complete_background(self):

        self.addedtraits = []

        i = 1
        while i < self.fbox.count():
            self.addedtraits.append(self.fbox.itemAt(i).widget().text())
            i = i + 2

        #print(self.addedtraits)

        self.traits_object = backgrounds.Traits(
            self.addedtraits[0], self.addedtraits[1], self.addedtraits[2],
            self.addedtraits[3], self.addedtraits[4], self.addedAlignments)
        self.backgrounds_object = backgrounds.Background(
            self.addedSkills, self.other, self.addedLanguages,
            self.addedFeatures, self.traits_object)
        name = self.fbox.itemAt(4).widget().text()
        flaws = self.fbox.itemAt(3).widget().text()
        bonds = self.fbox.itemAt(2).widget().text()
        ideals = self.fbox.itemAt(1).widget().text()
        personality = self.fbox.itemAt(0).widget().text()
        stats = self.tab_window.main_window.stats_object
        race = self.tab_window.main_window.race
        char_class = self.tab_window.main_window.classes

        self.tab_window.main_window.character_object = character.Character(
            name, stats, race, char_class, self.backgrounds_object)

        all_fields = self.tab_window.main_window.character_object.get_form_fields(
        )

        #Create FDF file with these fields
        fdf_data = fdfgen.forge_fdf("", all_fields, [], [], [])
        fdf_file = open("file_fdf.fdf", "w")
        fdf_file.write(fdf_data)
        fdf_file.close()
        #Run pdftk system command to populate the pdf file. The file "file_fdf.fdf" is pushed in to "input_pdf.pdf" thats generated as a new "output_pdf.pdf" file.
        pdftk_cmd = "pdftk ../charsheet.pdf fill_form file_fdf.fdf output ../output_pdf.pdf"
        os.system(pdftk_cmd)

        self.tab_window.main_window.character_object = character.Character(
            name, stats, race, char_class, self.backgrounds_object)

        self.l4.setText("Character outputted to pdf")

        self.tab_window.main_window.character_object = character.Character(
            name, stats, race, char_class, self.backgrounds_object)
        self.l4.setText(self.tab_window.main_window.character_object.__str__())
Пример #5
0
def setup_char():

    setup_global()

    road.draw_scene()

    random.shuffle(list_color)

    curname = config.player_color

    for i in range(5):
        if (config.player_color is list_color[i]):
            curname = config.player_name
        else:
            curname = list_color[i]
        list_char[i] = character.Character(config.player_class, list_color[i],
                                           curname, road.start_point,
                                           road.player_position[i])
        list_char[i].set_animation("stand")
        list_char[i].load_profile()

    setup.play_music("res/ad/Run.mp3", -1)
    race_running()
    turtle.ontimer(random_state, 1000)
    turtle.ontimer(race_clocking, 1000)
Пример #6
0
def rightmatching(master):
    global score
    global combo
    if nowtimer != 0:
        my_arrow.rightbutton()
        if middleID[0] == randIDs[1] or middleID[0] == randIDs[3] or middleID[
                0] == 5 or middleID[0] == 6:
            if middleID[0] == 5:
                itemcount = int(len(my_items))
                if itemcount < 2:
                    my_items.append(5)
                    my_itemlook.append(
                        character.Character(scene=my_scene,
                                            charID=5,
                                            size=20,
                                            x_start=650 + itemcount * 30,
                                            y_start=500))
            elif middleID[0] == 6:
                for i in range(itemsec):
                    plustimer = int(len(my_timers))
                    my_timers.append(
                        gametimer.Gametimer(scene=my_scene, index=plustimer))

            my_characters[0].remove()
            for i in range(0, len(my_characters)):
                my_characters[i].move()
            my_characters.pop(0)
            middleID.pop(0)
            score += 10
            my_scene.draw_score(score)
            combo += 1
            my_scene.draw_combo(combo)
            if (combo > 10):
                score += 100
                my_scene.draw_score(score)
            if (combo > 30):
                score += 1000
                my_scene.draw_score(score)
            if (combo > 50):
                score += 10000
                my_scene.draw_score(score)

            if (combo < 10):
                my_scene.redraw_baseback()
            elif (combo < 30):
                my_scene.redraw_comboback1()
            elif (combo < 50):
                my_scene.redraw_comboback2()
            else:
                my_scene.redraw_comboback3()
        else:
            my_scene.redraw_errorback()
            score += 0
            my_scene.draw_score(score)
            combo = 0
            my_scene.draw_combo(combo)
            minustimer = int(len(my_timers)) - 1
            if minustimer != 0:
                my_timers[minustimer].remove()
                my_timers.pop(minustimer)
Пример #7
0
def new_or_load(slist):
    """Asks the user if they want to load a previous character or create a
    new one. If the user wants to load a previous character, it calls helper
    function loadthis which determines which character the user wants to load.

    slist: list of str"""
    assert is_string_list(slist)

    nlist = []
    for file in slist:
        end = file.find('.json')
        nlist.append(file[:end])

    while (True):
        usersays = input('Enter 1 to make a new character. Enter 2 to load' +\
        'a character.')

        if usersays != '1' or usersays != '2':
            print('Invalid input')
        else:
            break

    if usersays == '1':
        print('loading new character')
        return new_route()

    elif usersays == '2':
        lprompt = 'Enter the number of the character you would like to load.'
        loadfile = slist[pick_number(lprompt, nlist)]
        return character.Character(filename=loadfile)
Пример #8
0
 def generate_direct_child(self, depth=0, max_depth=2):
     for char in character.Color:
         if char == character.Color.NONE:
             continue
         self.board.lockPath(self.lock[0], self.lock[1])
         rooms = self.board.getLinkForRoom(
             self.characters[char.value].position)
         for room in rooms:
             tmp = Node()
             tmp.parent = self
             tmp.depth = self.depth + 1
             for i in range(len(self.characters)):
                 tmp.characters[i] = character.Character(
                     self.characters[i].color, self.characters[i].position,
                     self.characters[i].suspect)
             tmp.playedCharacter = char
             tmp.lightOff = self.lightOff
             tmp.lock = self.lock
             tmp.setPosition(char, room)
             tmp.playLevel = PlayLevel.getNextMove(self.playLevel)
             tmp.ghostColor = self.ghostColor
             if self.ghostColor is not character.Color.NONE:
                 tmp.heuristic = tmp.computeScoreGhost(tmp.ghostColor)
             else:
                 tmp.heuristic = tmp.computeScoreInspector()
             #print("Generating character " + character.characters_string[char.value] + " for room " + str(room) +
             #     " with a depth of " + str(depth) + "(real :)" + str(tmp.depth) + " for turn " + str(self.playLevel) + " with heuristic of "
             #      + str(tmp.heuristic))
             if depth < max_depth:
                 tmp.generate_direct_child(depth=depth + 1)
             self.child.append(tmp)
             self.child.sort(key=lambda n: n.heuristic)
Пример #9
0
def test_stat_str() -> None:
    # # default char
    # defaultStats = character_stats.Stats()
    # defaultCharacter = character.Character()
    # defaultCharacter.stats = defaultStats
    # defaultString = """
    # INT  [0]  REF [0] TECH [0] COOL [0]
    # ATTR [0] LUCK [0]   MA [0] BODY [0]
    # EMP  [0] Humanity [0]
    # Run  [0m] Leap [0m]
    # Lift [0kgs / 0lbs] Carry [0kgs / 0lbs]
    # SAVE [0] BTM [0] Melee Modifier [-2], Very Weak
    # """
    # assert character.stats_to_string(defaultCharacter) == defaultString

    # valid char
    stats1 = character_stats.Stats(5, 3, 9, 1, 2, 4, 6, 8, 7)
    stats1Str = character.serialize_stats(stats1)
    stats1Character = character.Character()
    stats1Character.stats = stats1Str
    stats1Character.handle = "A Character"
    stats1String = """
    A Character
    INT  [5]  REF [3] TECH [9] COOL [1]
    ATTR [2] LUCK [4]   MA [6] BODY [8]
    EMP  [7] Humanity [70]
    Run  [18m] Leap [4.5m]
    Lift [320kgs / 705lbs] Carry [80kgs / 176lbs]
    SAVE [8] BTM [-3] Melee Modifier [1], Strong
    """
    assert character.stats_to_string(stats1Character) == stats1String
Пример #10
0
 def testSurvivalRolls(self):
     """Test the survival rolls."""
     for career, survival, dmstat, dmnum, in ((character.NAVY, 5,
                                               character.INT,
                                               7), (character.MARINES, 6,
                                                    character.END,
                                                    8), (character.ARMY, 5,
                                                         character.EDU, 6),
                                              (character.SCOUTS, 7,
                                               character.END,
                                               9), (character.MERCHANTS, 5,
                                                    character.INT, 7),
                                              (character.OTHER, 5,
                                               character.INT, 9)):
         for statroll in self._getAll2DSums():
             for survivalroll in self._getAll2DSums():
                 statrolls = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
                 statrolls[dmstat * 2:dmstat * 2 + 2] = statroll
                 char = character.Character(fixRolls=statrolls + [6, 6] +
                                            survivalroll)
                 char.selectCareer(career)
                 survivalsum = sum(survivalroll)
                 if sum(statroll) >= dmnum:
                     survivalsum += 2
                 if survivalsum >= survival:
                     self.assertFalse(char.dead)
                 else:
                     self.assertTrue(char.dead)
Пример #11
0
 def testPromotionRolls(self):
     """Test the promotion rolls."""
     for career, promotion, dmstat, dmnum in ((character.NAVY, 8,
                                               character.EDU,
                                               8), (character.MARINES, 9,
                                                    character.SOC, 8),
                                              (character.ARMY, 6,
                                               character.EDU, 7),
                                              (character.MERCHANTS, 10,
                                               character.INT, 9)):
         for statroll in self._getAll2DSums():
             for promotionroll in self._getAll2DSums():
                 statrolls = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
                 statrolls[dmstat * 2:dmstat * 2 + 2] = statroll
                 char = character.Character(fixRolls=statrolls +
                                            [6, 6, 6, 6, 6, 6] +
                                            promotionroll)
                 char.selectCareer(career)
                 promotionsum = sum(promotionroll)
                 if sum(statroll) >= dmnum:
                     promotionsum += 1
                 if promotionsum >= promotion:
                     self.assertEqual(char.rank, 2)
                 else:
                     self.assertEqual(char.rank, 1)
Пример #12
0
 def testCommissionRolls(self):
     """Test the commission rolls."""
     for career, commission, dmstat, dmnum in ((character.NAVY, 10,
                                                character.SOC,
                                                9), (character.MARINES, 9,
                                                     character.EDU, 7),
                                               (character.ARMY, 5,
                                                character.END, 7),
                                               (character.MERCHANTS, 4,
                                                character.INT, 6)):
         for statroll in self._getAll2DSums():
             for commissionroll in self._getAll2DSums():
                 statrolls = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
                 statrolls[dmstat * 2:dmstat * 2 + 2] = statroll
                 char = character.Character(fixRolls=statrolls +
                                            [6, 6, 6, 6] + commissionroll +
                                            [1, 1])
                 char.selectCareer(career)
                 commissionsum = sum(commissionroll)
                 if sum(statroll) >= dmnum:
                     commissionsum += 1
                 if commissionsum >= commission:
                     self.assertEqual(char.rank, 1)
                 else:
                     self.assertEqual(char.rank, 0)
Пример #13
0
 def test_buy_sell_sell(self):
     with mock.patch('database.sqlite3') as mocksql:
         conn = mocksql.connect()
         fake_player = character.Character(1, 'kaz', 5000, [])
         fake_player.buy_sell('Club', 'sell', conn)
         self.assertEqual(fake_player.currency, 5010)
         mocksql.connect().execute.assert_called_with(sql.update_currency(), (5010, 1))
Пример #14
0
 def test00_makeCharacter(self):
     newChar = character.Character(self.magicChar)
     self.assertEqual(newChar.health, 12)
     self.assertEqual(newChar.fatigue, 4)
     self.assertEqual(newChar.armor, 0)
     self.assertEqual(newChar.speed, 5)
     self.assertEqual(newChar.money, 0)
Пример #15
0
def test_fields():

    # test initialization
    c = character.Character(name="char_name",
                            alleg=1,
                            max_damage=10,
                            win_cond=lambda: 5,
                            win_cond_desc="win_desc",
                            special=lambda: 5,
                            special_desc="special_desc",
                            resource_id="r_id")

    # test fields
    assert c.name == "char_name"
    assert c.alleg == 1
    assert c.max_damage == 10
    assert c.win_cond() == 5
    assert c.win_cond_desc == "win_desc"
    assert c.special() == 5
    assert c.special_desc == "special_desc"
    assert c.resource_id == "r_id"

    # test dump
    dump = c.dump()
    assert dump['name'] == "char_name"
    assert dump['alleg'] == "Neutral"
    assert dump['max_damage'] == 10
    assert dump['win_cond_desc'] == "win_desc"
    assert dump['resource_id'] == "r_id"
Пример #16
0
def create(mode='basic', **kwargs):
    """Character creation function

    Args:
        **kwargs (dict, optional): Optionally include kwargs. Defaults to {}.
        mode (str, optional): 'full' for every value, 'basic' for important values. Defaults to 'basic'.
    """

    # if you want full control you can edit each value
    if mode == 'full':
        things = list(character.characterCreationDefaults.items())
    if mode == 'basic':
        things = list(character.characterCreationDefaults.items())[:9]

    for k,v in things:
        # manually enter each value that data doesn't have
        if k not in kwargs.keys():
            try:
                s = input(str(k)+' ? ')
                if s == '':
                    continue
                # Dynamic type casting is apparently supported by python
                # you just slap a class object in front of another object
                kwargs[k] = type(v)(s)
                print(k+' data assigned')

            except (TypeError, ValueError):
                # TODO: continue statement, but from the same iteration instead of the next
                print(" invalid parameter")
    return character.Character(kwargs)
Пример #17
0
def load():
    """builds factions, a dict of {name,characterList}s. don't use mid-session"""

    if 'factions' in locals() or 'factions' in globals():
        print("load() was used while factions var exists; exiting to prevent overwrite")
        return
    else:
        factions = {}

    for faction in os.listdir("./factions"):

        factions[faction] = []

        for char in os.listdir("./factions/" + faction):

            with open(
                "./factions/" + faction + "/" + char,
                "r",
                encoding="utf-8",
                errors="ignore",
            ) as f:
                data = json.load(f)
                factions[faction].append(character.Character(data))

    return factions
Пример #18
0
 def __init__(self, path=None, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.label = pyglet.text.Label("",
                                    x=0,
                                    y=self.height - 10,
                                    font_name="Courier New",
                                    font_size=10,
                                    multiline=True,
                                    width=2000)
     self.char_label = pyglet.text.Label("",
                                         x=0,
                                         y=self.height - 10,
                                         font_name="Courier New",
                                         font_size=10,
                                         multiline=True,
                                         width=2000,
                                         color=(255, 0, 0, 255))
     self.meta_label = pyglet.text.Label("",
                                         x=720,
                                         y=self.height - 10,
                                         font_name="Courier New",
                                         font_size=10,
                                         multiline=True,
                                         width=2000)
     self.notifications_label = pyglet.text.Label("No notifications yet\n",
                                                  x=0,
                                                  y=self.height - 720,
                                                  font_name="Courier New",
                                                  font_size=10,
                                                  multiline=True,
                                                  width=2000)
     self.mg = mapgen.MapGenerator(path)
     self.pos = list(reversed(self.mg.start))
     self.Character = character.Character(*self.pos, "Maiq")
     self.enemies = [enemy.Enemy(*p) for p in self.mg.enemies]
Пример #19
0
 def addNewCharacter(self):
     # Create a new default instance of a character
     newCharacter = character.Character()
     # Create a new CharacterFrame for the new character object
     newCharacterFrame = CharacterFrame(newCharacter, self)
     # Create a new tab to display the information about the new character
     self.tabs.add(newCharacterFrame, text=newCharacter.name)
Пример #20
0
def create_sades(screen, events):
    return character.Character(
        config.SADES['id'], config.SADES['left_images'],
        config.SADES['right_images'], config.SADES['up_images'],
        config.SADES['down_images'], config.SADES['x'], config.SADES['y'],
        config.SADES['speed'], config.SADES['boundaries_image_filename'],
        screen, config.SADES['main_character'], [e for e in events if e.clue])
Пример #21
0
async def on_message(message):
    roller = dice_roller.DiceRoller()
    manipulator = threshold_manipulator.ThresholdManipulator()
    if message_starts_with(message, 'podręcznik') or message_starts_with(
            message, 'podrecznik'):
        await client.send_message(message.channel, manual.show_help())
    if message_starts_with(message, 'reset'):
        await client.send_message(message.channel,
                                  reset_roll_parameters(roller, manipulator))
    if message_starts_with(message, 'sukcesy'):
        print('Nowy próg sukcesu')
        result = manipulator.change_success_threshold(extract_content(message))
        await client.send_message(message.channel, result)
    if message_starts_with(message, 'rzuc') or message_starts_with(
            message, 'rzuć'):
        print('Stół do rzucania kośćmi gotowy!')
        result = roller.roll_dice(extract_content(message))
        await client.send_message(message.channel, result)
    if message_starts_with(message, 'drama'):
        print('Używamy dramy!')
        result = roller.roll_drama()
        await client.send_message(message.channel, result)
    if message_starts_with(message, 'postac'):
        print('tymczasowo wyświetlam Lwa')
        char = character.Character()
        await client.send_message(message.channel, char.display_character())
    if message_starts_with(message, 'manewry'):
        maneuvers_list = maneuvers_database.display_maneuvers()
        await client.send_message(message.channel, maneuvers_list)
Пример #22
0
    def __init__(self):
        Game.universal = self
        pygame.init()
        self._screen = pygame.display.set_mode((800,600), \
            pygame.DOUBLEBUF+pygame.HWSURFACE)

        audio.mySongs["ambient"].play(-1) #loop
        self.time = gametime.GameTime()
        self.tstobj = animatedobject.createAnimatedObject('../assets/tigger','object.ini')
        self.tstobj.setTag('tiger')
        #self.tiger = animatedobject.AnimationState(self.tstobj)
        self.tiger = character.Character(self.tstobj, self, 10, 10)
        self.tiger.setPosVec((40,80))
        self.tiger.stashPos=(40,80)

        self.gpobj = animatedobject.createAnimatedObject('../assets/tigger','groundpound.ini')
        self.gpobj.setTag('groundpound')
        self.groundpound = animationstate.AnimationState(self.gpobj)
        self.gpactive=False
        self.pobj = animatedobject.createAnimatedObject('../assets/tigger','punch.ini')
        self.pobj.setTag('punch')
        self.punch = animationstate.AnimationState(self.pobj)
        self.pactive=False
        
        #self.tiger.setAnimation('move')
        #self.tiger.setDirection(0)

        #self.pigobj = animatedobject.createAnimatedObject('../assets/piglet','object.ini')
        #self.pigobj.setTag('pig')
        #self.pig = animatedobject.AnimationState(self.pigobj)
        #self.pig = character.Character(self.pigobj, self, 10, 10)
        #self.pig.setAnimation('stopped')
        #self.pig.setDirection(0)
        #self.pig.setPos(300,200)

        self.stuffobj = animatedobject.createAnimatedObject('../assets/static/', 'object.ini')
        self.stuffobj.setTag('stuffing')
        self.stuffing = animationstate.AnimationState(self.stuffobj)
        self.stuffing.setAnimation('stuffing')
        self.stuffing.setDirection(0)

        # handler for keyboard inputs, maps them to movements
        self.iohandler = ioprocess.IOFunctions(self)
        
        self.enemies = enemies.Enemies(self)
        #self.enemies.spawnTiglet()
        #self.enemies.spawnBeefy()
        
        self.world = terrain.createWorld('../assets/terrain','world.ini')
        self.objects = list()
        #self.lettermap = terrain.createLetterMap('../assets/terrain','terrainObjects.ini')
        #self.tilemap = terrain.createCSVMap(self.lettermap,'../assets/terrain','test.csv',['overlay.csv'])
        #self._screen.blit(self.tilemap.surface,(0,0))

        # handler for projectiles
        self.bullets = projectile.Projectiles(self)
        
        self.roomChange()

        interactions.registerCallbacks()
Пример #23
0
    def test_character_movement(self):
        """ Test A Character moves, and the data of movement to disk """
        self.reset_repo()

        locationJson = recordable.Recordable('mock-data', 'location')
        roomJson = recordable.Recordable('mock-data', 'worldRooms')
        recordables = [locationJson]
        testPlayer = character.Character(recordables)
        rooms = cavemap.Map(roomJson)

        testPlayer.move('north', rooms)
        self.assertEqual(testPlayer.location['location'], "Git Crystal")

        testPlayer.move('east', rooms)
        self.assertEqual(testPlayer.location['location'], "Mine Entrance")

        changedLocationJson = recordable.Recordable('mock-data', 'location')

        testPlayer.move('invalid Direction', rooms)
        self.assertEqual(testPlayer.location['location'], "Mine Entrance")

        testPlayer.move('west', rooms)
        testPlayer.move('south', rooms)

        originalLocationJson = recordable.Recordable('mock-data', 'location')

        self.assertNotEqual(locationJson, changedLocationJson)
        self.assertEqual(locationJson, originalLocationJson)
Пример #24
0
 def test_move_character_impossible(self):
     g = game_state.GameState()
     g.pathfinding_grid = graph_2d.SquareGraph(3, 3)
     c = character.Character("Bob")
     g.characters[0] = c
     r = g.move_character(0, (2, 3))
     self.assertFalse(r.is_success)
    def __init__(self, width=800, height=600):
        """
        Initializes a Controller object

        Args:
            self (Controller): a Controller object
            width (int): the display's width
            height (int): the display's height

        Returns:
            (None): None
        """

        pygame.font.init()
        self.width = width
        self.height = height
        self.windowSurface = pygame.display.set_mode((self.width, self.height))
        pygame.display.set_caption("Skeleton Eats Three Apples Then Dies")
        self.background = pygame.Surface(self.windowSurface.get_size())
        self.running = True
        self.player = character.Character((self.width / 2, self.height / 2),
                                          self.windowSurface)
        self.obstacles = pygame.sprite.Group()
        self.buttons = [
            button.Button("Play Game",
                          (self.width / 2 - 35, self.height / 2 - 15), 70, 30,
                          (0, 0, 0), (0, 255, 0)),
            button.Button("Play Again?",
                          (self.width / 2 - 35, self.height / 2 - 15), 70, 30,
                          (0, 0, 0), (255, 0, 0))
        ]
        self.setGame()
Пример #26
0
 def test05_takeEnoughDamageToKill(self):
     newChar = character.Character(self.magicChar)
     conquest = newChar.takeDamage(12)
     self.assertEqual(conquest, 2)
     self.assertEqual(newChar.health, 12)
     self.assertEqual(newChar.fatigue, 4)
     self.assertEqual(newChar.money, 0)
     self.assertEqual(newChar.mapLocation, 'town')
Пример #27
0
def create_rei(screen):
    return character.Character(config.REI['id'], config.REI['left_images'],
                               config.REI['right_images'],
                               config.REI['up_images'],
                               config.REI['down_images'], config.REI['x'],
                               config.REI['y'], config.REI['speed'],
                               config.REI['boundaries_image_filename'], screen,
                               config.REI['main_character'])
Пример #28
0
def realtimeflow():
    global realtime
    realtime += 1
    #print("r=",realtime)
    if realtime == newchartime:
        left_chararcter2 = character.Character(scene=my_scene,
                                               charID=randIDs[2],
                                               size=40,
                                               x_start=200,
                                               y_start=winH // 2 - 100)
        right_chararcter2 = character.Character(scene=my_scene,
                                                charID=randIDs[3],
                                                size=40,
                                                x_start=800,
                                                y_start=winH // 2 - 100)
    if nowtimer != 0:
        window.after(1000, realtimeflow)
Пример #29
0
def main():
    race = character.genRace(random.randint(0, 100))
    align = character.genAlign(random.randint(0, 100))
    classes = character.genClass(random.randint(0, 100))
    bGround = character.genBackground(random.randint(0, 100))

    player = character.Character(race, classes, align, bGround)

    print(player.toString())
Пример #30
0
    def addCustom(self, plaintext, morse):
        """
        Adds a character to the dictionary of custom characters for a decoder object

        Arguments:
            plaintext: The plaintext character to be added.
            morse: The morse code version of the character.
        """
        self.customs.update({morse: character.Character(plaintext, morse)})