загружаю фичи
This commit is contained in:
parent
3db797a56d
commit
2342bea194
|
@ -19,6 +19,23 @@ class ShipField:
|
|||
self.ship_size = 4
|
||||
self.ship_direction = 0
|
||||
|
||||
def action(self, row, col):
|
||||
if self.field_mode == 0:
|
||||
if self.check_possible(row, col):
|
||||
self.set_ship(row, col)
|
||||
|
||||
elif self.field_mode == 1:
|
||||
self.shoot(row, col)
|
||||
|
||||
def target(self, row, col):
|
||||
if self.field_mode == 0:
|
||||
self.clear_marker()
|
||||
|
||||
def clear_marker(self):
|
||||
for i in range(0, len(self.field)):
|
||||
if self.field[i] == "p":
|
||||
self.field[i] = ""
|
||||
|
||||
def set_ship(self, row, col):
|
||||
if row < 0 or row > self.field_size:
|
||||
return
|
||||
|
@ -53,7 +70,7 @@ class ShipField:
|
|||
else:
|
||||
return ShootResult.UNDEFINED
|
||||
|
||||
def check_possible(self, row, col, ship_size, ship_direction):
|
||||
def check_possible(self, row, col, ship_direction):
|
||||
# Функция должна возвращать True, если можно поставить сюда корабль,
|
||||
# в противном случае - False
|
||||
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -217,16 +217,8 @@ def button_enter(field, buttons, row, col):
|
|||
other_field = my_field
|
||||
other_buttons = my_buttons
|
||||
|
||||
for i in range(0, len(other_field)):
|
||||
if other_field[i] == "p":
|
||||
other_field[i] = ''
|
||||
|
||||
colorize(other_field, other_buttons)
|
||||
|
||||
if field_mode == 0:
|
||||
for i in range(0, len(field)):
|
||||
if field[i] == "p":
|
||||
field[i] = ''
|
||||
|
||||
if check_possible(field, row, col,ship_size, ship_direction):
|
||||
if ship_direction == 0:
|
||||
|
@ -240,6 +232,7 @@ def button_enter(field, buttons, row, col):
|
|||
colorize(field, buttons)
|
||||
|
||||
|
||||
|
||||
def check_possible(field, row, col, ship_size, ship_direction):
|
||||
# Функция должна возвращать True, если можно поставить сюда корабль,
|
||||
# в противном случае - False
|
||||
|
|
Loading…
Reference in New Issue