refactore to new project structure

This commit is contained in:
2026-07-19 11:18:16 +02:00
parent 1ff0efb557
commit 9a69d4610c
12 changed files with 108 additions and 81 deletions
+10
View File
@@ -43,6 +43,12 @@ func (n *Notes) Remove(field *Field, cell *Cell, note int, trigger string, marks
}
}
func (n *Notes) Get() []int {
copySlice := make([]int, len(n.numbers))
copy(copySlice, n.numbers)
return copySlice
}
// ────────────────────────────────────────────────────────────────────────────── //
// CELL STRUCTURE //
// ────────────────────────────────────────────────────────────────────────────── //
@@ -98,3 +104,7 @@ func (c *Cell) RemoveNumber(field *Field, trigger string, marks []Mark) {
c.number = 0
}
func (c *Cell) GetNumber() int {
return c.number
}
+14 -1
View File
@@ -17,7 +17,7 @@ func (m *Mark) GetColor() color.Color {
}
// ────────────────────────────────────────────────────────────────────────────── //
// CHANGE STRUCTURE //
// CHANGE_ACTION TYPE //
// ────────────────────────────────────────────────────────────────────────────── //
type ChangeAction int
@@ -33,6 +33,19 @@ const (
// CHANGE STRUCTURE //
// ────────────────────────────────────────────────────────────────────────────── //
type ExternalChange struct {
Cell *Cell
Marks []Mark
Action ChangeAction
Value int
From int
TriggerdBy string //strategy or manuell
}
// ────────────────────────────────────────────────────────────────────────────── //
// CHANGE STRUCTURE //
// ────────────────────────────────────────────────────────────────────────────── //
type Change struct {
Cell *Cell
marks []Mark
+7 -7
View File
@@ -145,14 +145,14 @@ func (f *Field) ForEachCell(fn func(cell *Cell)) {
// MODIFIER //
// ────────────────────────────────────────────────────────────────────────────── //
func (f *Field) AddChange(cell *Cell, action ChangeAction, value, from int, trigger string, marks []Mark) {
func (f *Field) AddChange(eChange *ExternalChange) {
change := Change{
Cell: cell,
marks: marks,
action: action,
value: value,
from: from,
triggerdBy: trigger,
Cell: eChange.Cell,
marks: eChange.Marks,
action: eChange.Action,
value: eChange.Value,
from: eChange.From,
triggerdBy: eChange.TriggerdBy,
}
change.do()
+6 -6
View File
@@ -8,23 +8,23 @@ import (
)
type Parser interface {
parse(data []byte) error
getField(i int) *Field
getAllFields() []Field
Parse(data []byte) error
GetField(i int) *Field
GetAllFields() []Field
}
type parserHelper struct {
fields []Field
}
func (ph *parserHelper) getField(i int) *Field {
func (ph *parserHelper) GetField(i int) *Field {
if i < 0 || i >= len(ph.fields) {
return &Field{}
}
return &ph.fields[i]
}
func (ph *parserHelper) getAllFields() []Field {
func (ph *parserHelper) GetAllFields() []Field {
if len(ph.fields) == 0 {
return nil
}
@@ -36,7 +36,7 @@ type PuzzleBank struct {
parserHelper
}
func (pb *PuzzleBank) parse(data []byte) error {
func (pb *PuzzleBank) Parse(data []byte) error {
lines := bytes.Split(data, []byte("\n"))
for _, line := range lines {