Exemplo n.º 1
0
 def no_move_auto_damage(self, grid, tanksHP, controllers):
     Logger.log('in no move auto damage')
     for i in range(controllers.__len__()):
         action = controllers[i].get_action()
         if tanksHP[i] > 0 and action == None:
             self.damage(self.find_tank(i, grid), tanksHP, grid)
             self.grid_history.append(
                 self.make_grid_moment(self.round, self.counter, grid,
                                       tanksHP))
             render.render([grid])
Exemplo n.º 2
0
def texturize(txt):
    analyzeDictionary = analyze(txt)
    output = render(txt
                    ,contacts = analyzeDictionary["contacts"]
                    ,vlpfs = analyzeDictionary["vlpfs"]
                    ,headerSpan = analyzeDictionary["headers"]
                    #,highVlpfs = analyzeDictionary["highVlpfs"]
                    #,leadTile = ...
                    ,newlines = analyzeDictionary["newlines"]
                    ,tiles = analyzeDictionary["segments"]
                    )
    return output
Exemplo n.º 3
0
def texturize(txt):
    analyzeDictionary = analyze(txt)
    output = render(
        txt,
        contacts=analyzeDictionary["contacts"],
        vlpfs=analyzeDictionary["vlpfs"],
        headerSpan=analyzeDictionary["headers"]
        #,highVlpfs = analyzeDictionary["highVlpfs"]
        #,leadTile = ...
        ,
        newlines=analyzeDictionary["newlines"],
        tiles=analyzeDictionary["segments"])
    return output
Exemplo n.º 4
0
def test_can_render_a_state_of_the_board():
    """ def render(board) """
    actual = render([[
        0,
        0,
        0,
    ], [
        0,
        0,
        0,
    ], [
        0,
        0,
        0,
    ]])

    expected = """  A B C 
1 ⬡ ⬡ ⬡ 
2  ⬡ ⬡ ⬡ 
3   ⬡ ⬡ ⬡ 
"""

    print(actual)
    assert expected == actual
Exemplo n.º 5
0
    def move_projectiles(self, grid, tanksHP):
        #two projectiles will destroy each other just if they are on the same y and had different directions
        #in any other case: obstacle / consecutive projectiles -> the possition will not be incresed
        for i in range(self.projectile_active.__len__()):
            act = self.projectile_active[i]
            if act == None:
                continue
            something_changed = False
            if act['act_coord'] != act['dest_coord']:
                x = act['act_coord']['x']
                y = act['act_coord']['y']
                mx = act['act_coord']['x'] + act['dx']
                my = act['act_coord']['y']
                if self.free_cell(grid, mx, my):
                    #the projectile is going to a free cell
                    something_changed = True
                    grid[mx][my] = Projectile(grid[mx][my].type, act['dx'],
                                              act['dest_coord'])
                    if self.projectile_cell(grid, x, y):
                        grid[x][y] = self.new_water_ground_cell(
                            grid[x][y].block_type)

                    self.projectile_active[i]['act_coord'][
                        'x'] = self.projectile_active[i]['act_coord'][
                            'x'] + act['dx']

                elif self.tank_cell(grid, mx, my):
                    #the projectile is going to hit a tank
                    something_changed = True
                    self.damage({'x': mx, 'y': my}, tanksHP, grid)
                    if self.projectile_cell(grid, x, y):
                        grid[x][y] = self.new_water_ground_cell(
                            grid[x][y].block_type)

                    self.delete_projectile(i)
                elif self.projectile_cell(grid, mx, my):
                    #the projectile is going to another projectile
                    direction_m = grid[mx][my].direction
                    direction_a = act['dx']

                    if (direction_a * direction_m < 0):
                        m_projectile = self.find_index_in_projectiles({
                            'x': mx,
                            'y': my
                        })
                        something_changed = True
                        grid[mx][my] = self.new_water_ground_cell(
                            grid[mx][my].block_type)
                        if self.projectile_cell(grid, x, y):
                            grid[x][y] = self.new_water_ground_cell(
                                grid[x][y].block_type)

                        self.delete_projectile(i)
                        self.delete_projectile(m_projectile)
                    else:
                        if self.tank_cell(grid, x, y):
                            something_changed = True
                            self.damage({
                                'x': x,
                                'y': y
                            }, tanksHP, grid)
                            self.delete_projectile(i)

                else:  #the projectile could not be move forward
                    if self.tank_cell(grid, x, y):
                        something_changed = True
                        self.damage({
                            'x': x,
                            'y': y
                        }, tanksHP, grid)
                        self.delete_projectile(i)
            # print(something_changed)
            if something_changed == True:
                self.grid_history.append(
                    self.make_grid_moment(self.round, self.counter, grid,
                                          tanksHP))
                render.render([grid])
Exemplo n.º 6
0
Y = 1080

# create the display surface object
# of specific dimension..e(X, Y).

clock = pygame.time.Clock()

# set the pygame window name
pygame.display.set_caption('Random Weapon')

while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            sys.exit()

    pygame.mouse.set_cursor(*pygame.cursors.arrow)

    # create a font object.
    # 1st parameter is the font file
    # which is present in pygame.
    # 2nd parameter is size of the font
    font = pygame.font.Font('freesansbold.ttf', 32)

    # create weapon object
    main_hand = weapon.weapon()

    # create render_text object
    textrender = render(main_hand.text, main_hand.weapon_image, (X, Y))

    clock.tick(2)
Exemplo n.º 7
0
import sys

from render.render import render
from board.generator import generate
from game.game import clear
from render.coord import get_coord
from board.board import put_stone

path = sys.argv[2]

# Game initialization
board = generate(9)
output = render(board)

still_in_game = True
print(render(board))

while still_in_game:

    position = input("Stone on : ")
    clear()
    print("You put a stone on " + position)

    coords = get_coord(position)

    try:
        board = put_stone(coords, board)
    except ValueError as err:
        print(format(err))

    print(render(board))