fix near updating when not first path

This commit is contained in:
Alexander Wang 2023-02-22 15:34:41 -08:00
parent cb48ebdb81
commit f40350609a
No known key found for this signature in database
GPG key ID: D89FA31966BDBECE
3 changed files with 1536 additions and 1 deletions

View file

@ -1538,7 +1538,7 @@ func updateNear(prevG, g *d2graph.Graph, from, to *string) error {
if len(n.MapKey.Key.Path) == 0 {
continue
}
if n.MapKey.Key.Path[0].Unbox().ScalarString() == "near" {
if n.MapKey.Key.Path[len(n.MapKey.Key.Path)-1].Unbox().ScalarString() == "near" {
k := n.MapKey.Value.ScalarBox().Unbox().ScalarString()
if strings.EqualFold(k, *from) && to == nil {
deleteFromMap(obj.Map, n.MapKey)

View file

@ -3824,6 +3824,37 @@ y
exp: `x
y
`,
},
{
name: "delete_container_of_near",
text: `direction: down
first input -> start game -> game loop
game loop: {
direction: down
input -> increase bird top velocity
move bird -> move pipes -> render
render -> no collision -> wait 16 milliseconds -> move bird
render -> collision detected -> game over
no collision.near: game loop.collision detected
}
`,
key: `game loop`,
exp: `direction: down
first input -> start game
input -> increase bird top velocity
move bird -> move pipes -> render
render -> no collision -> wait 16 milliseconds -> move bird
render -> collision detected -> game over
no collision.near: collision detected
`,
},
{

File diff suppressed because it is too large Load diff