DEV-765 pipeline refactor (#64)
Refactor rulesets into smaller composable operations In order to mix up the functionality from different rulesets like Solo, Royale, etc. the code in these classes needs to be broken up into small functions that can be composed in a pipeline to make a custom game mode.
This commit is contained in:
parent
5e629e9e93
commit
397d925110
25 changed files with 1475 additions and 222 deletions
10
cli/commands/testdata/snake_request_body.json
vendored
10
cli/commands/testdata/snake_request_body.json
vendored
|
|
@ -11,13 +11,13 @@
|
|||
"hazardMap": "",
|
||||
"hazardMapAuthor": "",
|
||||
"royale": {
|
||||
"shrinkEveryNTurns": 25
|
||||
"shrinkEveryNTurns": 0
|
||||
},
|
||||
"squad": {
|
||||
"allowBodyCollisions": true,
|
||||
"sharedElimination": true,
|
||||
"sharedHealth": true,
|
||||
"sharedLength": true
|
||||
"allowBodyCollisions": false,
|
||||
"sharedElimination": false,
|
||||
"sharedHealth": false,
|
||||
"sharedLength": false
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
108
cli/commands/testdata/snake_request_body_constrictor.json
vendored
Normal file
108
cli/commands/testdata/snake_request_body_constrictor.json
vendored
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
{
|
||||
"game": {
|
||||
"id": "",
|
||||
"ruleset": {
|
||||
"name": "constrictor",
|
||||
"version": "cli",
|
||||
"settings": {
|
||||
"foodSpawnChance": 11,
|
||||
"minimumFood": 7,
|
||||
"hazardDamagePerTurn": 19,
|
||||
"hazardMap": "hz_spiral",
|
||||
"hazardMapAuthor": "altersaddle",
|
||||
"royale": {
|
||||
"shrinkEveryNTurns": 0
|
||||
},
|
||||
"squad": {
|
||||
"allowBodyCollisions": false,
|
||||
"sharedElimination": false,
|
||||
"sharedHealth": false,
|
||||
"sharedLength": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"timeout": 500,
|
||||
"source": ""
|
||||
},
|
||||
"turn": 0,
|
||||
"board": {
|
||||
"height": 11,
|
||||
"width": 11,
|
||||
"snakes": [
|
||||
{
|
||||
"id": "one",
|
||||
"name": "ONE",
|
||||
"latency": "0",
|
||||
"health": 0,
|
||||
"body": [
|
||||
{
|
||||
"x": 3,
|
||||
"y": 3
|
||||
}
|
||||
],
|
||||
"head": {
|
||||
"x": 3,
|
||||
"y": 3
|
||||
},
|
||||
"length": 1,
|
||||
"shout": "",
|
||||
"squad": "",
|
||||
"customizations": {
|
||||
"color": "#123456",
|
||||
"head": "safe",
|
||||
"tail": "curled"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "two",
|
||||
"name": "TWO",
|
||||
"latency": "0",
|
||||
"health": 0,
|
||||
"body": [
|
||||
{
|
||||
"x": 4,
|
||||
"y": 3
|
||||
}
|
||||
],
|
||||
"head": {
|
||||
"x": 4,
|
||||
"y": 3
|
||||
},
|
||||
"length": 1,
|
||||
"shout": "",
|
||||
"squad": "",
|
||||
"customizations": {
|
||||
"color": "#654321",
|
||||
"head": "silly",
|
||||
"tail": "bolt"
|
||||
}
|
||||
}
|
||||
],
|
||||
"food": [],
|
||||
"hazards": []
|
||||
},
|
||||
"you": {
|
||||
"id": "one",
|
||||
"name": "ONE",
|
||||
"latency": "0",
|
||||
"health": 0,
|
||||
"body": [
|
||||
{
|
||||
"x": 3,
|
||||
"y": 3
|
||||
}
|
||||
],
|
||||
"head": {
|
||||
"x": 3,
|
||||
"y": 3
|
||||
},
|
||||
"length": 1,
|
||||
"shout": "",
|
||||
"squad": "",
|
||||
"customizations": {
|
||||
"color": "#123456",
|
||||
"head": "safe",
|
||||
"tail": "curled"
|
||||
}
|
||||
}
|
||||
}
|
||||
108
cli/commands/testdata/snake_request_body_royale.json
vendored
Normal file
108
cli/commands/testdata/snake_request_body_royale.json
vendored
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
{
|
||||
"game": {
|
||||
"id": "",
|
||||
"ruleset": {
|
||||
"name": "royale",
|
||||
"version": "cli",
|
||||
"settings": {
|
||||
"foodSpawnChance": 11,
|
||||
"minimumFood": 7,
|
||||
"hazardDamagePerTurn": 19,
|
||||
"hazardMap": "hz_spiral",
|
||||
"hazardMapAuthor": "altersaddle",
|
||||
"royale": {
|
||||
"shrinkEveryNTurns": 17
|
||||
},
|
||||
"squad": {
|
||||
"allowBodyCollisions": false,
|
||||
"sharedElimination": false,
|
||||
"sharedHealth": false,
|
||||
"sharedLength": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"timeout": 500,
|
||||
"source": ""
|
||||
},
|
||||
"turn": 0,
|
||||
"board": {
|
||||
"height": 11,
|
||||
"width": 11,
|
||||
"snakes": [
|
||||
{
|
||||
"id": "one",
|
||||
"name": "ONE",
|
||||
"latency": "0",
|
||||
"health": 0,
|
||||
"body": [
|
||||
{
|
||||
"x": 3,
|
||||
"y": 3
|
||||
}
|
||||
],
|
||||
"head": {
|
||||
"x": 3,
|
||||
"y": 3
|
||||
},
|
||||
"length": 1,
|
||||
"shout": "",
|
||||
"squad": "",
|
||||
"customizations": {
|
||||
"color": "#123456",
|
||||
"head": "safe",
|
||||
"tail": "curled"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "two",
|
||||
"name": "TWO",
|
||||
"latency": "0",
|
||||
"health": 0,
|
||||
"body": [
|
||||
{
|
||||
"x": 4,
|
||||
"y": 3
|
||||
}
|
||||
],
|
||||
"head": {
|
||||
"x": 4,
|
||||
"y": 3
|
||||
},
|
||||
"length": 1,
|
||||
"shout": "",
|
||||
"squad": "",
|
||||
"customizations": {
|
||||
"color": "#654321",
|
||||
"head": "silly",
|
||||
"tail": "bolt"
|
||||
}
|
||||
}
|
||||
],
|
||||
"food": [],
|
||||
"hazards": []
|
||||
},
|
||||
"you": {
|
||||
"id": "one",
|
||||
"name": "ONE",
|
||||
"latency": "0",
|
||||
"health": 0,
|
||||
"body": [
|
||||
{
|
||||
"x": 3,
|
||||
"y": 3
|
||||
}
|
||||
],
|
||||
"head": {
|
||||
"x": 3,
|
||||
"y": 3
|
||||
},
|
||||
"length": 1,
|
||||
"shout": "",
|
||||
"squad": "",
|
||||
"customizations": {
|
||||
"color": "#123456",
|
||||
"head": "safe",
|
||||
"tail": "curled"
|
||||
}
|
||||
}
|
||||
}
|
||||
108
cli/commands/testdata/snake_request_body_solo.json
vendored
Normal file
108
cli/commands/testdata/snake_request_body_solo.json
vendored
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
{
|
||||
"game": {
|
||||
"id": "",
|
||||
"ruleset": {
|
||||
"name": "solo",
|
||||
"version": "cli",
|
||||
"settings": {
|
||||
"foodSpawnChance": 11,
|
||||
"minimumFood": 7,
|
||||
"hazardDamagePerTurn": 19,
|
||||
"hazardMap": "hz_spiral",
|
||||
"hazardMapAuthor": "altersaddle",
|
||||
"royale": {
|
||||
"shrinkEveryNTurns": 0
|
||||
},
|
||||
"squad": {
|
||||
"allowBodyCollisions": false,
|
||||
"sharedElimination": false,
|
||||
"sharedHealth": false,
|
||||
"sharedLength": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"timeout": 500,
|
||||
"source": ""
|
||||
},
|
||||
"turn": 0,
|
||||
"board": {
|
||||
"height": 11,
|
||||
"width": 11,
|
||||
"snakes": [
|
||||
{
|
||||
"id": "one",
|
||||
"name": "ONE",
|
||||
"latency": "0",
|
||||
"health": 0,
|
||||
"body": [
|
||||
{
|
||||
"x": 3,
|
||||
"y": 3
|
||||
}
|
||||
],
|
||||
"head": {
|
||||
"x": 3,
|
||||
"y": 3
|
||||
},
|
||||
"length": 1,
|
||||
"shout": "",
|
||||
"squad": "",
|
||||
"customizations": {
|
||||
"color": "#123456",
|
||||
"head": "safe",
|
||||
"tail": "curled"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "two",
|
||||
"name": "TWO",
|
||||
"latency": "0",
|
||||
"health": 0,
|
||||
"body": [
|
||||
{
|
||||
"x": 4,
|
||||
"y": 3
|
||||
}
|
||||
],
|
||||
"head": {
|
||||
"x": 4,
|
||||
"y": 3
|
||||
},
|
||||
"length": 1,
|
||||
"shout": "",
|
||||
"squad": "",
|
||||
"customizations": {
|
||||
"color": "#654321",
|
||||
"head": "silly",
|
||||
"tail": "bolt"
|
||||
}
|
||||
}
|
||||
],
|
||||
"food": [],
|
||||
"hazards": []
|
||||
},
|
||||
"you": {
|
||||
"id": "one",
|
||||
"name": "ONE",
|
||||
"latency": "0",
|
||||
"health": 0,
|
||||
"body": [
|
||||
{
|
||||
"x": 3,
|
||||
"y": 3
|
||||
}
|
||||
],
|
||||
"head": {
|
||||
"x": 3,
|
||||
"y": 3
|
||||
},
|
||||
"length": 1,
|
||||
"shout": "",
|
||||
"squad": "",
|
||||
"customizations": {
|
||||
"color": "#123456",
|
||||
"head": "safe",
|
||||
"tail": "curled"
|
||||
}
|
||||
}
|
||||
}
|
||||
108
cli/commands/testdata/snake_request_body_squad.json
vendored
Normal file
108
cli/commands/testdata/snake_request_body_squad.json
vendored
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
{
|
||||
"game": {
|
||||
"id": "",
|
||||
"ruleset": {
|
||||
"name": "squad",
|
||||
"version": "cli",
|
||||
"settings": {
|
||||
"foodSpawnChance": 11,
|
||||
"minimumFood": 7,
|
||||
"hazardDamagePerTurn": 19,
|
||||
"hazardMap": "hz_spiral",
|
||||
"hazardMapAuthor": "altersaddle",
|
||||
"royale": {
|
||||
"shrinkEveryNTurns": 0
|
||||
},
|
||||
"squad": {
|
||||
"allowBodyCollisions": true,
|
||||
"sharedElimination": false,
|
||||
"sharedHealth": true,
|
||||
"sharedLength": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"timeout": 500,
|
||||
"source": ""
|
||||
},
|
||||
"turn": 0,
|
||||
"board": {
|
||||
"height": 11,
|
||||
"width": 11,
|
||||
"snakes": [
|
||||
{
|
||||
"id": "one",
|
||||
"name": "ONE",
|
||||
"latency": "0",
|
||||
"health": 0,
|
||||
"body": [
|
||||
{
|
||||
"x": 3,
|
||||
"y": 3
|
||||
}
|
||||
],
|
||||
"head": {
|
||||
"x": 3,
|
||||
"y": 3
|
||||
},
|
||||
"length": 1,
|
||||
"shout": "",
|
||||
"squad": "",
|
||||
"customizations": {
|
||||
"color": "#123456",
|
||||
"head": "safe",
|
||||
"tail": "curled"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "two",
|
||||
"name": "TWO",
|
||||
"latency": "0",
|
||||
"health": 0,
|
||||
"body": [
|
||||
{
|
||||
"x": 4,
|
||||
"y": 3
|
||||
}
|
||||
],
|
||||
"head": {
|
||||
"x": 4,
|
||||
"y": 3
|
||||
},
|
||||
"length": 1,
|
||||
"shout": "",
|
||||
"squad": "",
|
||||
"customizations": {
|
||||
"color": "#654321",
|
||||
"head": "silly",
|
||||
"tail": "bolt"
|
||||
}
|
||||
}
|
||||
],
|
||||
"food": [],
|
||||
"hazards": []
|
||||
},
|
||||
"you": {
|
||||
"id": "one",
|
||||
"name": "ONE",
|
||||
"latency": "0",
|
||||
"health": 0,
|
||||
"body": [
|
||||
{
|
||||
"x": 3,
|
||||
"y": 3
|
||||
}
|
||||
],
|
||||
"head": {
|
||||
"x": 3,
|
||||
"y": 3
|
||||
},
|
||||
"length": 1,
|
||||
"shout": "",
|
||||
"squad": "",
|
||||
"customizations": {
|
||||
"color": "#123456",
|
||||
"head": "safe",
|
||||
"tail": "curled"
|
||||
}
|
||||
}
|
||||
}
|
||||
108
cli/commands/testdata/snake_request_body_standard.json
vendored
Normal file
108
cli/commands/testdata/snake_request_body_standard.json
vendored
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
{
|
||||
"game": {
|
||||
"id": "",
|
||||
"ruleset": {
|
||||
"name": "standard",
|
||||
"version": "cli",
|
||||
"settings": {
|
||||
"foodSpawnChance": 11,
|
||||
"minimumFood": 7,
|
||||
"hazardDamagePerTurn": 19,
|
||||
"hazardMap": "hz_spiral",
|
||||
"hazardMapAuthor": "altersaddle",
|
||||
"royale": {
|
||||
"shrinkEveryNTurns": 0
|
||||
},
|
||||
"squad": {
|
||||
"allowBodyCollisions": false,
|
||||
"sharedElimination": false,
|
||||
"sharedHealth": false,
|
||||
"sharedLength": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"timeout": 500,
|
||||
"source": ""
|
||||
},
|
||||
"turn": 0,
|
||||
"board": {
|
||||
"height": 11,
|
||||
"width": 11,
|
||||
"snakes": [
|
||||
{
|
||||
"id": "one",
|
||||
"name": "ONE",
|
||||
"latency": "0",
|
||||
"health": 0,
|
||||
"body": [
|
||||
{
|
||||
"x": 3,
|
||||
"y": 3
|
||||
}
|
||||
],
|
||||
"head": {
|
||||
"x": 3,
|
||||
"y": 3
|
||||
},
|
||||
"length": 1,
|
||||
"shout": "",
|
||||
"squad": "",
|
||||
"customizations": {
|
||||
"color": "#123456",
|
||||
"head": "safe",
|
||||
"tail": "curled"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "two",
|
||||
"name": "TWO",
|
||||
"latency": "0",
|
||||
"health": 0,
|
||||
"body": [
|
||||
{
|
||||
"x": 4,
|
||||
"y": 3
|
||||
}
|
||||
],
|
||||
"head": {
|
||||
"x": 4,
|
||||
"y": 3
|
||||
},
|
||||
"length": 1,
|
||||
"shout": "",
|
||||
"squad": "",
|
||||
"customizations": {
|
||||
"color": "#654321",
|
||||
"head": "silly",
|
||||
"tail": "bolt"
|
||||
}
|
||||
}
|
||||
],
|
||||
"food": [],
|
||||
"hazards": []
|
||||
},
|
||||
"you": {
|
||||
"id": "one",
|
||||
"name": "ONE",
|
||||
"latency": "0",
|
||||
"health": 0,
|
||||
"body": [
|
||||
{
|
||||
"x": 3,
|
||||
"y": 3
|
||||
}
|
||||
],
|
||||
"head": {
|
||||
"x": 3,
|
||||
"y": 3
|
||||
},
|
||||
"length": 1,
|
||||
"shout": "",
|
||||
"squad": "",
|
||||
"customizations": {
|
||||
"color": "#123456",
|
||||
"head": "safe",
|
||||
"tail": "curled"
|
||||
}
|
||||
}
|
||||
}
|
||||
108
cli/commands/testdata/snake_request_body_wrapped.json
vendored
Normal file
108
cli/commands/testdata/snake_request_body_wrapped.json
vendored
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
{
|
||||
"game": {
|
||||
"id": "",
|
||||
"ruleset": {
|
||||
"name": "wrapped",
|
||||
"version": "cli",
|
||||
"settings": {
|
||||
"foodSpawnChance": 11,
|
||||
"minimumFood": 7,
|
||||
"hazardDamagePerTurn": 19,
|
||||
"hazardMap": "hz_spiral",
|
||||
"hazardMapAuthor": "altersaddle",
|
||||
"royale": {
|
||||
"shrinkEveryNTurns": 0
|
||||
},
|
||||
"squad": {
|
||||
"allowBodyCollisions": false,
|
||||
"sharedElimination": false,
|
||||
"sharedHealth": false,
|
||||
"sharedLength": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"timeout": 500,
|
||||
"source": ""
|
||||
},
|
||||
"turn": 0,
|
||||
"board": {
|
||||
"height": 11,
|
||||
"width": 11,
|
||||
"snakes": [
|
||||
{
|
||||
"id": "one",
|
||||
"name": "ONE",
|
||||
"latency": "0",
|
||||
"health": 0,
|
||||
"body": [
|
||||
{
|
||||
"x": 3,
|
||||
"y": 3
|
||||
}
|
||||
],
|
||||
"head": {
|
||||
"x": 3,
|
||||
"y": 3
|
||||
},
|
||||
"length": 1,
|
||||
"shout": "",
|
||||
"squad": "",
|
||||
"customizations": {
|
||||
"color": "#123456",
|
||||
"head": "safe",
|
||||
"tail": "curled"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "two",
|
||||
"name": "TWO",
|
||||
"latency": "0",
|
||||
"health": 0,
|
||||
"body": [
|
||||
{
|
||||
"x": 4,
|
||||
"y": 3
|
||||
}
|
||||
],
|
||||
"head": {
|
||||
"x": 4,
|
||||
"y": 3
|
||||
},
|
||||
"length": 1,
|
||||
"shout": "",
|
||||
"squad": "",
|
||||
"customizations": {
|
||||
"color": "#654321",
|
||||
"head": "silly",
|
||||
"tail": "bolt"
|
||||
}
|
||||
}
|
||||
],
|
||||
"food": [],
|
||||
"hazards": []
|
||||
},
|
||||
"you": {
|
||||
"id": "one",
|
||||
"name": "ONE",
|
||||
"latency": "0",
|
||||
"health": 0,
|
||||
"body": [
|
||||
{
|
||||
"x": 3,
|
||||
"y": 3
|
||||
}
|
||||
],
|
||||
"head": {
|
||||
"x": 3,
|
||||
"y": 3
|
||||
},
|
||||
"length": 1,
|
||||
"shout": "",
|
||||
"squad": "",
|
||||
"customizations": {
|
||||
"color": "#123456",
|
||||
"head": "safe",
|
||||
"tail": "curled"
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue