package game import ( p "aeternalis/server/internal/protocol" "math" "testing" "time" ) func TestIndoorMovementCollisionJumpAndReturn(t *testing.T) { w, c := fixture(t) w.Kind = "hub" w.Phase = "hub" house := ID() c.View.HouseID = &house c.HouseRoom = &p.HouseScene{ID: house, Size: 12, Furniture: []p.RoomFurniture{{ID: ID(), Width: 2, Depth: 2, Height: .8}}} pos := p.Vec3{X: -3} c.View.HousePosition = &pos hub := c.View.Entity.Position xp := c.View.Experience if e := w.Intent(c.View.Entity.ID, p.Intent{Seq: 1, Op: "move", X: 1}); e != nil { t.Fatal(e) } for range 40 { w.moveHouse(c, .05) } if c.View.HousePosition.X > -1.34 || c.View.HousePosition.X < -1.5 { t.Fatal("walked through table", *c.View.HousePosition) } if e := w.Intent(c.View.Entity.ID, p.Intent{Seq: 2, Op: "jump"}); e != nil { t.Fatal(e) } if e := w.Intent(c.View.Entity.ID, p.Intent{Seq: 3, Op: "jump"}); e == nil { t.Fatal("air jump accepted") } top := 0. for range 12 { w.moveHouse(c, .05) top = math.Max(top, c.View.HousePosition.Y) } if top < .8 || c.View.HousePosition.X < -.8 { t.Fatal("could not jump onto furniture", top, *c.View.HousePosition) } for range 100 { w.moveHouse(c, .05) } if c.View.HousePosition.X > 6-w.Balance.Housing.PlayerRadius || c.View.HousePosition.Y != 0 { t.Fatal("room boundary or landing failed", *c.View.HousePosition) } if e := w.Intent(c.View.Entity.ID, p.Intent{Seq: 4, Op: "attack"}); e == nil { t.Fatal("house combat accepted") } if c.View.Entity.Position != hub || c.View.Experience != xp { t.Fatal("indoor movement changed hub position or XP") } c.LastMove = w.now.Add(-time.Second) w.Advance(w.now, .05) if c.MoveX != 0 { t.Fatal("stale indoor move did not stop") } LeaveHouse(c) if c.View.HousePosition != nil || c.HouseRoom != nil || c.View.Entity.Position != hub || c.JumpVelocity != 0 { t.Fatal("exit did not clear room state") } }