Fixes to #501 (#502)
- Commit
bc73a7fe9e0dc325807483bfcf1ac901c8bb9955- Author
- toast <[email protected]>
- When
- 2026-08-13 13:26 UTC (3 months ago)
- Parents
1b28e8b
* unblockjam: add some puzzle utilities * unblockjam: fix support for unmovable blocks * unblockjam: update converter to output json in an order consistent with the original pack * unblockjam: fix hashing function modifying the block array in-place when sorting * unblockjam: fix support for unmovable blocks * unblockjam: update converter to output json in an order consistent with the original pack * unblockjam: fix hashing function modifying the block array in-place when sorting
Diff
games/unblockjam/src/main/java/com/vayunmathur/games/unblockjam/MainActivity.kt
diff --git a/games/unblockjam/src/main/java/com/vayunmathur/games/unblockjam/MainActivity.kt b/games/unblockjam/src/main/java/com/vayunmathur/games/unblockjam/MainActivity.ktindex 6da869f6a6..a5d4833ad6 100644--- a/games/unblockjam/src/main/java/com/vayunmathur/games/unblockjam/MainActivity.kt+++ b/games/unblockjam/src/main/java/com/vayunmathur/games/unblockjam/MainActivity.kt@@ -663,28 +663,31 @@ fun GameBoard( "blockOffset" ) - Box(- modifier = Modifier- .size(blockWidth, blockHeight)- .offset { IntOffset(currentOffsetX.roundToPx(), offsetY.roundToPx()) }- .padding(scaling * 4)- .background(color, shape = RoundedCornerShape(percent = 10))- .blockDragGestures(- block = block,- levelData = levelData,- isLevelWon = isLevelWon,- cellWidth = cellWidth,- cellHeight = cellHeight,- isMainBlock = isMainBlock,- onLevelWon = onLevelWon,- onLevelChanged = onLevelChanged,- index = index,- offsetXProvider = { offsetX },- offsetYProvider = { offsetY },- offsetXUpdater = { offsetX = it },- offsetYUpdater = { offsetY = it }- )- )+ var modifier = Modifier+ .size(blockWidth, blockHeight)+ .offset { IntOffset(currentOffsetX.roundToPx(), offsetY.roundToPx()) }+ .padding(scaling * 4)+ .background(color, shape = RoundedCornerShape(percent = 10))+ + if (!block.fixed) {+ modifier = modifier.blockDragGestures(+ block = block,+ levelData = levelData,+ isLevelWon = isLevelWon,+ cellWidth = cellWidth,+ cellHeight = cellHeight,+ isMainBlock = isMainBlock,+ onLevelWon = onLevelWon,+ onLevelChanged = onLevelChanged,+ index = index,+ offsetXProvider = { offsetX },+ offsetYProvider = { offsetY },+ offsetXUpdater = { offsetX = it },+ offsetYUpdater = { offsetY = it }+ )+ }++ Box(modifier = modifier) } } }
scripts/unblockjam/level_tools/src/cmd/convert_set/main.go
diff --git a/scripts/unblockjam/level_tools/src/cmd/convert_set/main.go b/scripts/unblockjam/level_tools/src/cmd/convert_set/main.goindex 81533782f6..da0ad641d0 100644--- a/scripts/unblockjam/level_tools/src/cmd/convert_set/main.go+++ b/scripts/unblockjam/level_tools/src/cmd/convert_set/main.go@@ -11,6 +11,22 @@ import ( "rush_conv" ) +type Colors struct {+ Primary string `json:"primary"`+ Secondary string `json:"secondary"`+ Tertiary string `json:"tertiary"`+ Background string `json:"background"`+ Surface string `json:"surface"`+ PrimaryContainer string `json:"primaryContainer"`+ SecondaryContainer string `json:"secondaryContainer"`+}++type Pack struct {+ Name string `json:"name"`+ Colors Colors `json:"colors"`+ Levels []rush_conv.Level `json:"levels"`+}+ func main() { if err := run(); err != nil { fmt.Fprintln(os.Stderr, err)@@ -49,18 +65,18 @@ func run() error { return fmt.Errorf("reading stdin: %w", err) } - result := map[string]interface{}{- "name": "Example Pack",- "colors": map[string]string{- "primary": "0x00000000",- "secondary": "0x00000000",- "tertiary": "0x00000000",- "background": "0x00000000",- "surface": "0x00000000",- "primaryContainer": "0x00000000",- "secondaryContainer": "0x00000000",+ result := Pack{+ Name: "Example Pack",+ Colors: Colors{+ Primary: "0x00000000",+ Secondary: "0x00000000",+ Tertiary: "0x00000000",+ Background: "0x00000000",+ Surface: "0x00000000",+ PrimaryContainer: "0x00000000",+ SecondaryContainer: "0x00000000", },- "levels": levels,+ Levels: levels, } encoder := json.NewEncoder(os.Stdout)
scripts/unblockjam/level_tools/src/hash.go
diff --git a/scripts/unblockjam/level_tools/src/hash.go b/scripts/unblockjam/level_tools/src/hash.goindex 44387259f5..12f3906805 100644--- a/scripts/unblockjam/level_tools/src/hash.go+++ b/scripts/unblockjam/level_tools/src/hash.go@@ -4,14 +4,17 @@ import ( "crypto/sha256" "encoding/base64" "fmt"+ "slices" "sort" ) const ID_VERSION = 1 func BoardID(board Board) string {- sort.Slice(board.Blocks, func(i, j int) bool {- a, b := board.Blocks[i], board.Blocks[j]+ blocks := slices.Clone(board.Blocks)++ sort.Slice(blocks, func(i, j int) bool {+ a, b := blocks[i], blocks[j] if a.X != b.X { return a.X < b.X@@ -30,9 +33,14 @@ func BoardID(board Board) string { h := sha256.New() - h.Write([]byte{byte(board.Width), byte(board.Height), byte(board.Exit.X), byte(board.Exit.Y)})+ h.Write([]byte{+ byte(board.Width),+ byte(board.Height),+ byte(board.Exit.X),+ byte(board.Exit.Y),+ }) - for _, b := range board.Blocks {+ for _, b := range blocks { h.Write([]byte{ byte(b.X), byte(b.Y),
scripts/unblockjam/level_tools/src/types.go
diff --git a/scripts/unblockjam/level_tools/src/types.go b/scripts/unblockjam/level_tools/src/types.goindex 22a5362519..f159139c27 100644--- a/scripts/unblockjam/level_tools/src/types.go+++ b/scripts/unblockjam/level_tools/src/types.go@@ -21,7 +21,7 @@ type Board struct { } type Level struct {+ ID string `json:"id"` Board- ID string `json:"id"`- Moves int `json:"c"`+ Moves int `json:"c"` }\ No newline at end of file