feat(js): m05 game and m06 view with fixtures and tests
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
08b462d5cc
commit
b83f94894e
@@ -0,0 +1,348 @@
|
||||
{
|
||||
"function": "update",
|
||||
"cases": [
|
||||
{
|
||||
"name": "tick-moves-the-snake",
|
||||
"args": [
|
||||
{
|
||||
"width": 3,
|
||||
"height": 2,
|
||||
"snake": [
|
||||
{
|
||||
"x": 0,
|
||||
"y": 0
|
||||
}
|
||||
],
|
||||
"dir": "Right",
|
||||
"nextDir": "Right",
|
||||
"apple": {
|
||||
"x": 2,
|
||||
"y": 1
|
||||
},
|
||||
"seed": 0,
|
||||
"score": 0,
|
||||
"status": "Playing",
|
||||
"frame": 0
|
||||
},
|
||||
{
|
||||
"tag": "Tick"
|
||||
}
|
||||
],
|
||||
"expected": {
|
||||
"width": 3,
|
||||
"height": 2,
|
||||
"snake": [
|
||||
{
|
||||
"x": 1,
|
||||
"y": 0
|
||||
}
|
||||
],
|
||||
"dir": "Right",
|
||||
"nextDir": "Right",
|
||||
"apple": {
|
||||
"x": 2,
|
||||
"y": 1
|
||||
},
|
||||
"seed": 0,
|
||||
"score": 0,
|
||||
"status": "Playing",
|
||||
"frame": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "tick-eating-respawns-apple",
|
||||
"args": [
|
||||
{
|
||||
"width": 3,
|
||||
"height": 2,
|
||||
"snake": [
|
||||
{
|
||||
"x": 0,
|
||||
"y": 0
|
||||
}
|
||||
],
|
||||
"dir": "Right",
|
||||
"nextDir": "Right",
|
||||
"apple": {
|
||||
"x": 1,
|
||||
"y": 0
|
||||
},
|
||||
"seed": 0,
|
||||
"score": 0,
|
||||
"status": "Playing",
|
||||
"frame": 0
|
||||
},
|
||||
{
|
||||
"tag": "Tick"
|
||||
}
|
||||
],
|
||||
"expected": {
|
||||
"width": 3,
|
||||
"height": 2,
|
||||
"snake": [
|
||||
{
|
||||
"x": 1,
|
||||
"y": 0
|
||||
},
|
||||
{
|
||||
"x": 0,
|
||||
"y": 0
|
||||
}
|
||||
],
|
||||
"dir": "Right",
|
||||
"nextDir": "Right",
|
||||
"apple": {
|
||||
"x": 1,
|
||||
"y": 1
|
||||
},
|
||||
"seed": 1831565813,
|
||||
"score": 1,
|
||||
"status": "Playing",
|
||||
"frame": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "tick-into-wall-is-game-over",
|
||||
"args": [
|
||||
{
|
||||
"width": 3,
|
||||
"height": 2,
|
||||
"snake": [
|
||||
{
|
||||
"x": 2,
|
||||
"y": 0
|
||||
}
|
||||
],
|
||||
"dir": "Right",
|
||||
"nextDir": "Right",
|
||||
"apple": {
|
||||
"x": 0,
|
||||
"y": 1
|
||||
},
|
||||
"seed": 0,
|
||||
"score": 0,
|
||||
"status": "Playing",
|
||||
"frame": 0
|
||||
},
|
||||
{
|
||||
"tag": "Tick"
|
||||
}
|
||||
],
|
||||
"expected": {
|
||||
"width": 3,
|
||||
"height": 2,
|
||||
"snake": [
|
||||
{
|
||||
"x": 2,
|
||||
"y": 0
|
||||
}
|
||||
],
|
||||
"dir": "Right",
|
||||
"nextDir": "Right",
|
||||
"apple": {
|
||||
"x": 0,
|
||||
"y": 1
|
||||
},
|
||||
"seed": 0,
|
||||
"score": 0,
|
||||
"status": "GameOver",
|
||||
"frame": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "tick-while-paused-does-nothing",
|
||||
"args": [
|
||||
{
|
||||
"width": 3,
|
||||
"height": 2,
|
||||
"snake": [
|
||||
{
|
||||
"x": 0,
|
||||
"y": 0
|
||||
}
|
||||
],
|
||||
"dir": "Right",
|
||||
"nextDir": "Right",
|
||||
"apple": {
|
||||
"x": 2,
|
||||
"y": 1
|
||||
},
|
||||
"seed": 0,
|
||||
"score": 0,
|
||||
"status": "Paused",
|
||||
"frame": 0
|
||||
},
|
||||
{
|
||||
"tag": "Tick"
|
||||
}
|
||||
],
|
||||
"expected": {
|
||||
"width": 3,
|
||||
"height": 2,
|
||||
"snake": [
|
||||
{
|
||||
"x": 0,
|
||||
"y": 0
|
||||
}
|
||||
],
|
||||
"dir": "Right",
|
||||
"nextDir": "Right",
|
||||
"apple": {
|
||||
"x": 2,
|
||||
"y": 1
|
||||
},
|
||||
"seed": 0,
|
||||
"score": 0,
|
||||
"status": "Paused",
|
||||
"frame": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "turn-sets-next-dir",
|
||||
"args": [
|
||||
{
|
||||
"width": 3,
|
||||
"height": 2,
|
||||
"snake": [
|
||||
{
|
||||
"x": 0,
|
||||
"y": 0
|
||||
}
|
||||
],
|
||||
"dir": "Right",
|
||||
"nextDir": "Right",
|
||||
"apple": {
|
||||
"x": 2,
|
||||
"y": 1
|
||||
},
|
||||
"seed": 0,
|
||||
"score": 0,
|
||||
"status": "Playing",
|
||||
"frame": 0
|
||||
},
|
||||
{
|
||||
"tag": "Turn",
|
||||
"dir": "Down"
|
||||
}
|
||||
],
|
||||
"expected": {
|
||||
"width": 3,
|
||||
"height": 2,
|
||||
"snake": [
|
||||
{
|
||||
"x": 0,
|
||||
"y": 0
|
||||
}
|
||||
],
|
||||
"dir": "Right",
|
||||
"nextDir": "Down",
|
||||
"apple": {
|
||||
"x": 2,
|
||||
"y": 1
|
||||
},
|
||||
"seed": 0,
|
||||
"score": 0,
|
||||
"status": "Playing",
|
||||
"frame": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "turn-against-direction-is-ignored",
|
||||
"args": [
|
||||
{
|
||||
"width": 3,
|
||||
"height": 2,
|
||||
"snake": [
|
||||
{
|
||||
"x": 0,
|
||||
"y": 0
|
||||
}
|
||||
],
|
||||
"dir": "Right",
|
||||
"nextDir": "Right",
|
||||
"apple": {
|
||||
"x": 2,
|
||||
"y": 1
|
||||
},
|
||||
"seed": 0,
|
||||
"score": 0,
|
||||
"status": "Playing",
|
||||
"frame": 0
|
||||
},
|
||||
{
|
||||
"tag": "Turn",
|
||||
"dir": "Left"
|
||||
}
|
||||
],
|
||||
"expected": {
|
||||
"width": 3,
|
||||
"height": 2,
|
||||
"snake": [
|
||||
{
|
||||
"x": 0,
|
||||
"y": 0
|
||||
}
|
||||
],
|
||||
"dir": "Right",
|
||||
"nextDir": "Right",
|
||||
"apple": {
|
||||
"x": 2,
|
||||
"y": 1
|
||||
},
|
||||
"seed": 0,
|
||||
"score": 0,
|
||||
"status": "Playing",
|
||||
"frame": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "turn-while-paused-is-ignored",
|
||||
"args": [
|
||||
{
|
||||
"width": 3,
|
||||
"height": 2,
|
||||
"snake": [
|
||||
{
|
||||
"x": 0,
|
||||
"y": 0
|
||||
}
|
||||
],
|
||||
"dir": "Right",
|
||||
"nextDir": "Right",
|
||||
"apple": {
|
||||
"x": 2,
|
||||
"y": 1
|
||||
},
|
||||
"seed": 0,
|
||||
"score": 0,
|
||||
"status": "Paused",
|
||||
"frame": 0
|
||||
},
|
||||
{
|
||||
"tag": "Turn",
|
||||
"dir": "Down"
|
||||
}
|
||||
],
|
||||
"expected": {
|
||||
"width": 3,
|
||||
"height": 2,
|
||||
"snake": [
|
||||
{
|
||||
"x": 0,
|
||||
"y": 0
|
||||
}
|
||||
],
|
||||
"dir": "Right",
|
||||
"nextDir": "Right",
|
||||
"apple": {
|
||||
"x": 2,
|
||||
"y": 1
|
||||
},
|
||||
"seed": 0,
|
||||
"score": 0,
|
||||
"status": "Paused",
|
||||
"frame": 0
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user