-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
First draft of hexaworld schema #1
Open
andrewosh
wants to merge
14
commits into
master
Choose a base branch
from
first-draft
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
a8838ac
Progress on hexaworld schema. Need to a) split schema into multiple f…
andrewosh f9047fc
Forgot we were in 3D for the polygon definition. Didn't add normals, …
andrewosh b6f9aa8
You can only have two axial coordinates
andrewosh 0f6d757
Added JSON schema and js -> json write function. Fixed some errors in…
andrewosh b07873d
Removed .js.un~ files
andrewosh 703449f
Removed top-level schema.js
andrewosh 67fdea4
Working on tests
andrewosh 333ac35
Changed main in package.json to js/hexaworld.js
andrewosh 29a2d2a
A circle has 360 degrees in it.
andrewosh 46696c2
Camera now specified by tile/section/height
andrewosh 4147761
Removed geometry schemas. Items now specified by name and transformation
andrewosh 1cc507e
Added required properties to some sub-schemas
andrewosh 078c91c
Updated hexaworld schema
andrewosh 4abfb09
Added simple-good test/example and modified schema
andrewosh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,198 @@ | ||
var hexaworld = { | ||
|
||
$schema: 'http://json-schema.org/schema#', | ||
id: 'https://github.com/hexaworld/hexaworld-schema/schema.js', | ||
|
||
definitions: { | ||
|
||
// basic definitions | ||
|
||
pixel: { | ||
type: 'array', | ||
minItems: 2, | ||
maxItems: 3, | ||
items: { type: 'integer'} | ||
}, | ||
|
||
axial: { | ||
type: 'array', | ||
minItems: 2, | ||
maxItems: 2, | ||
items: { type: 'integer' } | ||
}, | ||
|
||
color: { | ||
oneOf: [ | ||
{ type: 'object', | ||
properties: { | ||
hue: { | ||
type: 'number', | ||
minimum: 0, | ||
maximum: 360 | ||
}, | ||
saturation: { | ||
type: 'number', | ||
minimum: 0, | ||
maximum: 100 | ||
}, | ||
value: { | ||
type: 'number', | ||
minimum: 0, | ||
maximum: 100 | ||
} | ||
} | ||
}, | ||
{ type: 'object', | ||
properties: { | ||
r: { | ||
type: 'number', | ||
minimum: 0, | ||
maximum: 255 | ||
}, | ||
g: { | ||
type: 'number', | ||
minimum: 0, | ||
maximum: 255 | ||
}, | ||
b: { | ||
type: 'number', | ||
minimum: 0, | ||
maximum: 255 | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
|
||
// geometric definitions | ||
|
||
scaleFactor: { | ||
type: 'number', | ||
// TODO: do we want to limit the range of allowable scale factors? | ||
minimum: 0, | ||
maximum: 1 | ||
}, | ||
|
||
rotationDegrees: { | ||
type: 'number', | ||
minimum: 0, | ||
maximum: 360 | ||
}, | ||
|
||
transformation: { | ||
position: { | ||
type: 'object', | ||
properties: { | ||
x: { type: 'number' }, | ||
y: { type: 'number' }, | ||
z: { type: 'number' } | ||
} | ||
}, | ||
scale: { | ||
type: 'object', | ||
properties: { | ||
x: { $ref: '#/definitions/scaleFactor' }, | ||
y: { $ref: '#/definitions/scaleFactor' }, | ||
z: { $ref: '#/definitions/scaleFactor' }, | ||
} | ||
}, | ||
rotation: { | ||
type: 'object', | ||
properties: { | ||
x: { $ref: '#/definitions/rotationDegrees' }, | ||
y: { $ref: '#/definitions/rotationDegrees' }, | ||
z: { $ref: '#/definitions/rotationDegrees' }, | ||
} | ||
} | ||
}, | ||
|
||
object: { | ||
type: 'object', | ||
properties: { | ||
name: { type : 'string' }, | ||
color: { $ref: '#/definitions/color' }, | ||
transformation: { $ref: '#/definitions/transformation' }, | ||
}, | ||
required: ['name'] | ||
}, | ||
|
||
path: { | ||
type: 'object', | ||
properties: { | ||
rotation: { | ||
type: 'integer', | ||
multipleOf: 60 | ||
} | ||
} | ||
}, | ||
|
||
// game-specific definitions | ||
|
||
tile: { | ||
type: 'object', | ||
properties: { | ||
position: { $ref: '#/definitions/axial' }, | ||
objects: { | ||
type: 'array', | ||
items: { | ||
'oneOf': [ | ||
{ type: 'object', | ||
properties: { | ||
path: { $ref: '#/definitions/path' } | ||
}, | ||
required: ['path'] | ||
}, | ||
{ type: 'object', | ||
properties: { | ||
object: { $ref: '#/definitions/object' } | ||
}, | ||
required: ['object'] | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
required: ['position'] | ||
}, | ||
|
||
player: { | ||
type: 'object', | ||
properties: { | ||
position: { $ref: '#/definitions/pixel' } | ||
}, | ||
required: ['position'] | ||
}, | ||
|
||
camera: { | ||
type: 'object', | ||
properties: { | ||
position: { $ref: '#/definitions/pixel' }, | ||
height: { | ||
type: 'number', | ||
minimum: 0 | ||
} | ||
}, | ||
required: ['position', 'height'] | ||
} | ||
}, | ||
|
||
type: 'object', | ||
properties: { | ||
world: | ||
{ type: 'array', | ||
items: { | ||
type: 'object', | ||
properties: { | ||
tile: { $ref: '#/definitions/tile' } | ||
}, | ||
required: ['tile'] | ||
} | ||
}, | ||
player: { $ref: '#/definitions/player' }, | ||
camera: { $ref: '#/definitions/camera' } | ||
// additional metadata? | ||
}, | ||
required: ['world', 'player', 'camera'] | ||
} | ||
|
||
module.exports = hexaworld |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
var fs = require('fs'), | ||
path = require('path') | ||
|
||
var hexaworld = require('./hexaworld.js') | ||
|
||
var writeSchema = function (dir) { | ||
var file = path.join(dir, 'hexaworld.json') | ||
fs.writeFileSync(file, JSON.stringify(hexaworld, null, 2)) | ||
console.log('schema files written to: ' + dir) | ||
} | ||
|
||
module.exports = writeSchema |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "hexaworld-schema", | ||
"version": "0.0.0", | ||
"description": "A schema and validation functions for hexaworld levels ", | ||
"main": "js/hexaworld.js", | ||
"scripts": { | ||
"test": "node test/all.js" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/hexaworld/hexaworld-schema" | ||
}, | ||
"author": "Andrew Osheroff <[email protected]> (http://andrewosh.com/)", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/hexaworld/hexaworld-schema/issues" | ||
}, | ||
"homepage": "https://github.com/hexaworld/hexaworld-schema", | ||
"dependencies": { | ||
"jsonschema": "^1.0.2", | ||
"lodash": "^3.10.1" | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't position be added into transformation too