This commit is contained in:
Ewen 2023-09-22 07:24:53 +02:00
parent 4eea46b26b
commit b2a03b851c
2 changed files with 31 additions and 2 deletions

View file

@ -18,8 +18,8 @@
height: "", height: "",
}, },
validationSchema: yup.object().shape({ validationSchema: yup.object().shape({
width: yup.number().positive().moreThan(0), width: yup.number().positive().moreThan(3),
heigt: yup.number().positive().moreThan(0), heigt: yup.number().positive().moreThan(3),
}), }),
onSubmit: (values) => { onSubmit: (values) => {
submitPopulate(values); submitPopulate(values);

View file

@ -12,6 +12,29 @@ class Word(models.Model):
level = models.ForeignKey(Level, on_delete=models.CASCADE, related_name="words") level = models.ForeignKey(Level, on_delete=models.CASCADE, related_name="words")
def place_word(width, height, placements, words):
# Base case
if placements == []:
return
# Other cases
else:
return
# Helper functions
def get_case(width, height, placements, x, y):
# todo
return None
def print_grid(width, height, placements):
for i in range(0, height):
for j in range(0, width):
print(i, j)
print
class Grid(models.Model): class Grid(models.Model):
level = models.ForeignKey(Level, on_delete=models.CASCADE, related_name="grids") level = models.ForeignKey(Level, on_delete=models.CASCADE, related_name="grids")
words = models.ManyToManyField(Word, through="Placement") words = models.ManyToManyField(Word, through="Placement")
@ -27,10 +50,16 @@ class Grid(models.Model):
print(self.width) print(self.width)
print(self.height) print(self.height)
tmp_placements = []
place_word(self.width, self.height, tmp_placements, Word.objects.all())
class Direction: class Direction:
RIGHT = 1 RIGHT = 1
BOTTOM = 2 BOTTOM = 2
RIGHT_BOTTOM = 3
BOTTOM_RIGHT = 4
class Placement(models.Model): class Placement(models.Model):