code refactor

This commit is contained in:
matixezor 2021-03-30 11:47:30 +02:00
parent 85993ddec5
commit 7a39af0081
6 changed files with 19 additions and 19 deletions

View File

@ -1,6 +1,5 @@
#anti-personnel mine
from src.mine import Mine
from mine import Mine
class AP_Mine(Mine):
pass
class APMine(Mine):
pass

View File

@ -1,6 +1,5 @@
#anti-tank mine
from src.mine import Mine
from mine import Mine
class AT_Mine(Mine):
pass
class ATMine(Mine):
pass

View File

@ -1,13 +1,14 @@
from typing import List
from random import choices
from fieldsFactory import FieldsFactory
from field import Field
from fieldsFactory import FieldsFactory
def generate_field () -> List[List[Field]]:
fieldsFactory = FieldsFactory()
fieldsList = fieldsFactory.getFieldsList()
return [choices(fieldsList, weights=[10, 10, 4, 4, 4, 4, 4, 4, 4, 4, 4], k=10) for _ in range(10)]
fields_factory = FieldsFactory()
fields_list = fields_factory.get_fields_list()
return [choices(fields_list, weights=[10, 10, 4, 4, 4, 4, 4, 4, 4, 4, 4], k=10) for _ in range(10)]
class Environment:

View File

@ -1,4 +1,4 @@
class Field:
def __init__(self, number, isMined):
def __init__(self, number: int, is_mined: bool):
self.number = number
self.isMined = isMined
self.is_mined = is_mined

View File

@ -1,13 +1,14 @@
from typing import List
from field import Field
class FieldsFactory:
def createField(self, number) -> Field:
def create_field(self, number: int) -> Field:
if number > 3:
return Field(number, True)
else:
return Field(number, False)
def getFieldsList(self) -> List[Field]:
return [self.createField(i) for i in range(11)]
def get_fields_list(self) -> List[Field]:
return [self.create_field(i) for i in range(11)]

View File

@ -1,3 +1,3 @@
class Mine:
def __init__(self, isArmed):
self.isArmed = isArmed
def __init__(self, is_armed: bool):
self.is_armed = is_armed