Пример #1
0
    def test_part_two(self):
        "Test part two example of Dragon object"

        # 1. Create Dragon object from text
        myobj = dragon.Dragon(part2=True, text=aoc_16.from_text(PART_TWO_TEXT))

        # 2. Check the part two result
        self.assertEqual(myobj.part_two(verbose=False), PART_TWO_RESULT)
Пример #2
0
def enter():
    game_world.init_objects()

    app.num_monster = 0
    app.dragon = dragon.Dragon()
    game_world.add_object(app.dragon, 3)
    game_world.add_object(stage.Stage(), 0)
    stage.build_stage('resources\\datas\\round ' + str(app.stage) + '.txt')
Пример #3
0
    def test_part_one(self):
        "Test part one example of Dragon object"

        # 1. Create Dragon object from text
        myobj = dragon.Dragon(text=aoc_16.from_text(PART_ONE_TEXT))

        # 2. Check the part one result
        self.assertEqual(myobj.part_one(verbose=False), PART_ONE_RESULT)
Пример #4
0
    def test_empty_init(self):
        "Test the default Dragon creation"

        # 1. Create default Dragon object
        myobj = dragon.Dragon()

        # 2. Make sure it has the default values
        self.assertEqual(myobj.part2, False)
        self.assertEqual(myobj.text, None)
        self.assertEqual(myobj.seed, "")
Пример #5
0
    def test_text_init(self):
        "Test the Dragon object creation from text"

        # 1. Create Dragon object from text
        myobj = dragon.Dragon(text=aoc_16.from_text(EXAMPLE_TEXT))

        # 2. Make sure it has the expected values
        self.assertEqual(myobj.part2, False)
        self.assertEqual(len(myobj.text), 1)
        self.assertEqual(myobj.seed, "10000")

        # 3. Check methods
        self.assertEqual(myobj.fill_and_check(20), "01100")
Пример #6
0
def part_two(args, input_lines):
    "Process part two of the puzzle"

    # 1. Create the puzzle solver
    solver = dragon.Dragon(part2=True, text=input_lines)

    # 2. Determine the solution for part two
    solution = solver.part_two(verbose=args.verbose, limit=args.limit)
    if solution is None:
        print("There is no solution")
    else:
        print("The solution for part two is %s" % (solution))

    # 3. Return result
    return solution is not None
Пример #7
0
import dragon, character

#Setup the hero and enemy
name = input("What is your name?  ")
role = input("Are you a wizard, rogue, or warrior?  ")
you = character.Character(name, role)
enemy = dragon.Dragon()
#Play the game
print("You encounter an evil dragon!")
while not enemy.isDead():
    ability = input("Do you attack with 'sword', 'magic', or 'sneak'?  ")
    if ability == "sword":
        you.swingSword(enemy)
    elif ability == "magic":
        you.castSpell(enemy)
    elif ability == "sneak":
        you.sneakAttack(enemy)
    else:
        print("What is '" + ability + "'? You seem confused!")
print("\nYou have vanquished the beast!\n")
Пример #8
0
import time

import wizard
import dragon

response = str(input("Hello, what's your name ?\n"))
w1 = wizard.Wizard(response, 500, 500, 100, 100, 200, 3)
d1 = dragon.Dragon(500, 200, 100, 100, 200)
endofWhile = False

w1.showStat()
# d1.showStat()
while endofWhile != True:
    ##Tour du wizard
    goodResponse = False
    while goodResponse == False:
        response = str(
            input(
                "What do you want to do " + w1.name +
                "? \n 1 - Attack ; 2 - Take a potion ; 3 - Launch a fate \n"))
        if response != "1" and response != "2" and response != "3":
            print("Error, this is not a valid choice !!")
        else:
            goodResponse = True
            if response == "1":
                if d1.dragonChoice() == "1":
                    d1.life_pt = d1.life_pt - d1.dragonDefense(w1.atk_pt)
                    d1.showStat()
                elif d1.dragonChoice() == "2":
                    d1.life_pt = d1.life_pt - d1.dragonDodge(w1.atk_pt)
                    d1.showStat()
Пример #9
0
import dragon
import time

print("sender")
sock = dragon.Dragon('localhost', 7000)
sock.bind(('', 6000))

for i in range(3):
    sock.send(b'Hello world')

time.sleep(1)
sock.close()
Пример #10
0
player_mini_img.set_colorkey(black)

bgX = 0
bgX2 = bgOne.get_width()

pygame.display.set_caption("Dragon Shmup!")
clock = pygame.time.Clock()
previous_time = pygame.time.get_ticks()
font_name = pygame.font.match_font("Calibri")

all_sprites = pygame.sprite.Group()
enemies = pygame.sprite.Group()
fireballs = pygame.sprite.Group()
powerups = pygame.sprite.Group()

player = dragon.Dragon()
all_sprites.add(player)


# make the score text
def draw_text(surf, text, fsize, x, y):
    font = pygame.font.Font(font_name, fsize)
    text_surface = font.render(text, True, black)
    text_rect = text_surface.get_rect()
    text_rect.midtop = (x, y)
    surf.blit(text_surface, text_rect)


# spawns new enemy
def new_enemy():
    e = enemy.Enemy()
Пример #11
0
import logger
import weather

import itertools
import time

from typing import List

# Specify number of knights to battle.
BATTLE_COUNT: int = 100

USE_SOLVER: bool = True

game_client = game.Client()
log = logger.Logger()
dragon_object = dragon.Dragon()


def dispatch_dragon(dragon_stats: tuple, knight: List[tuple], relative: bool = False) -> dict:
    """ Helper function for sending off a dragon to battle. """

    global dragon_number
    dragon_number += 1

    if relative:
        dragon_object.set_relative_stats(dragon_stats, knight)
    else:
        if dragon_stats:
            dragon_object.set_stats(*dragon_stats)
        else:
            dragon_object.set_dragon_stays_home()
Пример #12
0
import datetime
import dog, dragon
import call_center, bike, hospital, product

dog1 = dog.Dog("Koka")
dog1.walk().walk().walk().run().run().pet()
dog1.display_health()
print dog1

dragon1 = dragon.Dragon("Draga")
dragon1.walk().walk().walk().run().run().fly()
dragon1.display_health()
print dragon1

caller1 = call_center.call.Call("c1", "Toto", "123-123-1234",
                                datetime.datetime.now(), "Reason1")
caller2 = call_center.call.Call("c2", "Fata", "223-223-2234",
                                datetime.datetime.now(), "Reason2")
caller3 = call_center.call.Call("c3", "TDodo", "323-323-1234",
                                datetime.datetime.now(), "Reason3")
caller4 = call_center.call.Call("c4", "Anama", "443-424-2234",
                                datetime.datetime.now(), "Reason4")
caller5 = call_center.call.Call("c5", "Fnema", "453-524-5234",
                                datetime.datetime.now(), "Reason5")

cc1 = call_center.CallCenter()
cc1.add(caller1).add(caller5).add(caller2).add(caller3).add(caller4)
cc1.info()
cc1.remove()
cc1.remove_by_phone("323-323-1234")
cc1.remove_by_phone("555-553-1234")  # Do nothing
Пример #13
0
class BossFight:
    __main_riderf = rider.Rider()
    __main_dragon = dragon.Dragon()
    defs.isbossfight = True

    def print_board(self):
        print("", end="\033[0;0f")
        for i in range(int(defs.rows)):
            for j in range(int(defs.columns)):
                val = ""
                if (i in stats.Stats.rangey) and (j in stats.Stats.rangex):
                    if defs.oncePrinted:
                        print("\033[1C", end='')
                        continue
                    else:
                        ix = stats.Stats.rangey.index(i)
                        iy = stats.Stats.rangex.index(j)
                        val = stats.Stats.score_board[ix][iy][0]\
                                +stats.Stats.score_board[ix][iy][1]\
                                +stats.Stats.score_board[ix][iy][2]\
                                +stats.Stats.score_board[ix][iy][3]
                        val += defs.bg + defs.fg
                        print(val, end="")
                elif (i in self.__main_riderf.art_areay) and (
                        j in self.__main_riderf.art_areax):
                    ix = self.__main_riderf.art_areay.index(i)
                    iy = self.__main_riderf.art_areax.index(j)
                    if self.__main_riderf.rider[ix][iy][4] == 1:
                        for x in self.__main_riderf.rider[ix][iy]:
                            if (type(x) != int):
                                val += x
                    else:
                        val = self.__main_riderf.rider[ix][iy][0]\
                                +defs.board[i][j][1]\
                                +self.__main_riderf.rider[ix][iy][2]\
                                +self.__main_riderf.rider[ix][iy][3]
                    val += defs.bg + defs.fg
                    print(val, end="")
                elif (i in self.__main_dragon.art_areay) and (
                        j in self.__main_dragon.art_areax):
                    ix = self.__main_dragon.art_areay.index(i)
                    iy = self.__main_dragon.art_areax.index(j)
                    if self.__main_dragon.dragon[ix][iy][2] != ' ':
                        defs.board_check[i][j] = 1
                    if self.__main_dragon.dragon[ix][iy][4] == 1:
                        for x in self.__main_dragon.dragon[ix][iy]:
                            if (type(x) != int):
                                val += x
                    else:
                        val = self.__main_dragon.dragon[ix][iy][0]\
                                +defs.board[i][j][1]\
                                +self.__main_dragon.dragon[ix][iy][2]\
                                +self.__main_dragon.dragon[ix][iy][3]
                    val += defs.bg + defs.fg
                    print(val, end="")
                elif defs.board_check[i][j] in [9, 30]:
                    b = bullet.Bullet.fill_in(defs.board_check[i][j])
                    print(b[0] + defs.board[i][j][1] + b[2] + b[3], end="")
                else:
                    for x in defs.board[i][j]:
                        val += x
                    print(val, end="")
            if i != int(defs.rows) - 1 and j != int(defs.columns) - 1:
                print()
            else:
                print("", end="")
        print(defs.reset_color, end="", flush=True)
        if not defs.oncePrinted:
            defs.oncePrinted = True
        self.print_values()

    def print_values(self):
        pos1x = int(defs.columns) // 2 - (3 * stats.valx) // 8
        pos1y = 4
        print("",
              end="\033[" + str(pos1y) + ";" + str(pos1x) + "f" + stats.wb +
              stats.bf)
        print("Lives:\x1B[31m", '❤ ' * defs.livesleft, end='       ')
        pos1y += 2
        print("",
              end="\033[" + str(pos1y) + ";" + str(pos1x) + "f" + stats.wb +
              stats.bf)
        print("Time left:",
              defs.total_time - int(time.time() - defs.start_time),
              end='  ')
        pos1x = int(defs.columns) // 2 + (stats.valx) // 8
        pos1y = 4
        print("",
              end="\033[" + str(pos1y) + ";" + str(pos1x) + "f" + stats.wb +
              stats.bf)
        print("Boss:", defs.dragonlivesleft, end='')
        pos1y += 2
        print("",
              end="\033[" + str(pos1y) + ";" + str(pos1x) + "f" + stats.wb +
              stats.bf)
        print("Score:", defs.coinsCollected + 2 * defs.enemiesKilled, end='')
        print("", end=defs.reset_color + "\033[0;0f", flush=True)

    def create_board(self):
        board = list()
        for i in range(int(defs.rows)):
            temp_list = list()
            for _ in range(int(defs.columns)):
                if (i == 0):
                    add_element(temp_list, fn=34)
                elif (i == int(defs.rows) - 1):
                    add_element(temp_list, fn=32)
                else:
                    add_element(temp_list, cont=1)
            board.append(temp_list)
        return board

    def create_check(self):
        board_check = list()
        for _ in range(int(defs.rows)):
            temp_list = list()
            for _ in range(int(defs.columns)):
                temp_list.append(0)
            board_check.append(temp_list)
        return board_check

    def gameplay(self):
        if defs.start_time == -5:
            defs.start_time = time.time()
        start_time = time.time()
        grav_time = time.time()
        while defs.dragonlivesleft >= 0 and defs.livesleft >= 0:
            defs.board_check = copy.deepcopy(self.create_check())
            self.__main_riderf.move('s', val=defs.down)
            self.__main_dragon.move('s', val=defs.down)
            if time.time() - grav_time > defs.def_speed:
                defs.down += 1
                grav_time = time.time()
            if time.time() - start_time > 0.3:
                bullet.Bullet(self.__main_dragon.xpos_left,\
                    self.__main_riderf.ypos_top,2*int(defs.columns),True,30)
                bullet.Bullet(self.__main_dragon.xpos_left-3,\
                    self.__main_riderf.ypos_top,2*int(defs.columns),True,30)
                bullet.Bullet(self.__main_dragon.xpos_left-2,\
                    self.__main_riderf.ypos_top+1,2*int(defs.columns),True,30)
                bullet.Bullet(self.__main_dragon.xpos_left-5,\
                    self.__main_riderf.ypos_top+2,2*int(defs.columns),True,30)
                start_time = time.time()
            self.print_board()
            time.sleep(defs.speed)

    def __init__(self):
        defs.board = self.create_board()
        defs.board_check = copy.deepcopy(self.create_check())
        defs.board_start = 0
        stats.Stats.create_board()
        defs.speed = defs.def_speed
        self.__main_riderf.ypos_top = int(defs.rows) - 4
        thread1 = threading.Thread(target=self.gameplay, daemon=True)
        thread1.start()
        while defs.dragonlivesleft >= 0 and defs.livesleft >= 0:
            getch = Get()
            chbuff = input_to(getch)
            if chbuff:
                if chbuff == 'q':
                    exit(0)
                elif chbuff in ['w', 's']:
                    self.__main_riderf.move(chbuff)
                    self.__main_dragon.move(chbuff)
                    if chbuff == 'w':
                        defs.down = 0
                elif chbuff in ['a', 'd']:
                    self.__main_riderf.move(chbuff)
                elif chbuff == 'j':
                    bullet.Bullet(self.__main_riderf.xpos_left+len(self.__main_riderf.rider[0]),\
                        self.__main_riderf.ypos_top,int(defs.columns))
                elif chbuff == ' ':
                    self.__main_riderf.sheild()
            elif not self.__main_riderf._isSheilded:
                self.__main_riderf.change_rider(0)
            self.__main_riderf.check_pos()
        if defs.livesleft >= 0:
            inp.pr_result(1)
        else:
            inp.pr_result(2)
        print('\033[' + defs.rows + ';' + defs.columns + 'f' +
              defs.reset_color)