Skip to content

Commit 20ea094

Browse files
committed
Version 0.0.3
1 parent d0cc5d8 commit 20ea094

11 files changed

+151
-61
lines changed

.gitignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
node_modules
1+
node_modules/
22
*.log
33
log
44
*~
55
.DS_Store
66
out/
77
*.dat
8-
*.spr
8+
*.spr

.jshintrc

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"curly": true,
3+
"eqeqeq": true,
4+
"immed": true,
5+
"latedef": true,
6+
"newcap": true,
7+
"noarg": true,
8+
"sub": true,
9+
"undef": true,
10+
"unused": true,
11+
"boss": true,
12+
"eqnull": true,
13+
"node": true
14+
}

.travis.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
language: node_js
2+
node_js:
3+
- '0.10'

Gruntfile.js

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
'use strict';
2+
module.exports = function (grunt) {
3+
// Show elapsed time at the end
4+
require('time-grunt')(grunt);
5+
// Load all grunt tasks
6+
require('load-grunt-tasks')(grunt);
7+
8+
grunt.initConfig({
9+
jshint: {
10+
options: {
11+
jshintrc: '.jshintrc',
12+
reporter: require('jshint-stylish')
13+
},
14+
gruntfile: {
15+
src: ['Gruntfile.js']
16+
},
17+
js: {
18+
src: ['src/**/*.js']
19+
},
20+
test: {
21+
src: ['test/**/*.js']
22+
}
23+
},
24+
mochacli: {
25+
options: {
26+
reporter: 'nyan',
27+
bail: true
28+
},
29+
all: ['test/*.js']
30+
},
31+
watch: {
32+
gruntfile: {
33+
files: '<%= jshint.gruntfile.src %>',
34+
tasks: ['jshint:gruntfile']
35+
},
36+
js: {
37+
files: '<%= jshint.js.src %>',
38+
tasks: ['jshint:js', 'mochacli']
39+
},
40+
test: {
41+
files: '<%= jshint.test.src %>',
42+
tasks: ['jshint:test', 'mochacli']
43+
}
44+
}
45+
});
46+
47+
grunt.registerTask('default', ['jshint', 'mochacli']);
48+
};

README.md

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Sprite Sheet Extractor
2+
# [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-url]][daviddm-image] [![Code Climate][coverge-image]][coverge-url] [![Test Coverge][test-image]][coverge-url]
23

3-
Sprite Sheet Extractor for Open Tibia written in JavaScript and powered by Node.js.
4+
> CLI Tool to extract SpriteSheet from Tibia Spr & Dat files
45
56
## Getting Started
67

@@ -19,6 +20,7 @@ Please submit all issues and pull requests to the [TibiaJS/spritesheet-extractor
1920
If you have any problem or suggestion please open an issue [here](https://github.com/TibiaJS/spritesheet-extractor/issues).
2021

2122
## License
23+
2224
The BSD License
2325

2426
Copyright (c) 2015, TibiaJS Community
@@ -32,3 +34,14 @@ Redistribution and use in source and binary forms, with or without modification,
3234
*Neither the name of the TibiaJS Community nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
3335

3436
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37+
38+
39+
[npm-url]: https://npmjs.org/package/tibia-spritesheet-extractor
40+
[npm-image]: https://badge.fury.io/js/tibia-spritesheet-extractor.svg
41+
[travis-url]: https://travis-ci.org/TibiaJS/spritesheet-extractor
42+
[travis-image]: https://travis-ci.org/TibiaJS/spritesheet-extractor.svg?branch=master
43+
[daviddm-url]: https://david-dm.org/TibiaJS/spritesheet-extractor.svg?theme=shields.io
44+
[daviddm-image]: https://david-dm.org/TibiaJS/spritesheet-extractor
45+
[test-image]: https://codeclimate.com/github/TibiaJS/spritesheet-extractor/badges/coverage.svg
46+
[coverge-image]: https://codeclimate.com/github/TibiaJS/spritesheet-extractor/badges/gpa.svg
47+
[coverge-url]: https://codeclimate.com/github/TibiaJS/spritesheet-extractor

index.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
"use strict";
1+
#!/usr/bin/env node
2+
'use strict';
23

34
// Process
45
var datFile = process.argv[2],
@@ -10,8 +11,8 @@ var datFile = process.argv[2],
1011
// Require
1112
var fs = require('fs'),
1213
PNGImage = require('pngjs-image'),
13-
Metadata = require('./lib/Metadata.js'),
14-
Sprites = require('./lib/Sprites.js');
14+
Metadata = require('./src/Metadata'),
15+
Sprites = require('./src/Sprites');
1516

1617
// Checking extension of datFile.
1718
if(datFile.substring((datFile.length - 4), datFile.length) != '.dat') {

package.json

+32-22
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,41 @@
11
{
2-
"name": "spritesheet-extrator",
3-
"version": "0.0.2",
4-
"description": "Exports a client graphic as sprite sheet.",
5-
"main": "index.js",
6-
"scripts": {
7-
"test": "echo \"Error: no test specified\" && exit 1"
8-
},
9-
"repository": {
10-
"type": "git",
11-
"url": "https://github.com/TibiaJS/spritesheet-extractor"
12-
},
13-
"keywords": [
14-
"open tibia",
15-
"sprite sheet"
16-
],
2+
"name": "tibia-spritesheet-extractor",
3+
"version": "0.0.3",
4+
"description": "CLI Tool to extract SpriteSheet from Tibia Spr & Dat files",
5+
"homepage": "https://github.com/TibiaJS/spritesheet-extractor",
176
"author": {
187
"name": "Nailson Santos",
19-
"email" : "[email protected]",
20-
"url" : "https://github.com/Mignari"
21-
},
22-
"license": "BSD",
23-
"bugs": {
24-
"url": "https://github.com/TibiaJS/spritesheet-extractor/issues"
8+
"email": "[email protected]",
9+
"url": "https://github.com/Mignari"
2510
},
26-
"homepage": "https://github.com/TibiaJS/spritesheet-extractor",
11+
"repository": "TibiaJS/tibia-spritesheet-extractor",
12+
"license": "BSD",
13+
"keywords": [
14+
"tibia-spritesheet-extractor",
15+
"tibia",
16+
"spritesheet",
17+
"extractor",
18+
"cipsoft",
19+
"tibiajs"
20+
],
2721
"dependencies": {
2822
"buffer-reader": "0.0.2",
2923
"pngjs-image": "^0.9.3"
24+
},
25+
"devDependencies": {
26+
"grunt-cli": "^0.1.13",
27+
"grunt-contrib-jshint": "^0.10.0",
28+
"grunt-contrib-nodeunit": "^0.4.1",
29+
"grunt-contrib-watch": "^0.6.1",
30+
"load-grunt-tasks": "^1.0.0",
31+
"time-grunt": "^1.0.0",
32+
"grunt-mocha-cli": "^1.11.0",
33+
"jshint-stylish": "^1.0.0"
34+
},
35+
"scripts": {
36+
"test": "grunt"
37+
},
38+
"bin": {
39+
"tibia-spritesheet-extractor": "index.js"
3040
}
3141
}

lib/Metadata.js renamed to src/Metadata.js

+25-25
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"use strict";
1+
'use strict';
22

33
var fs = require('fs');
44
var BufferReader = require('buffer-reader');
@@ -13,19 +13,19 @@ function Metadata(file, cb) {
1313
}
1414

1515
// Setupping variables
16-
this.signature = 0,
17-
this.items = [],
18-
this.outfits = [],
19-
this.effects = [],
20-
this.missiles = [],
21-
this.itemCount = 0,
22-
this.outfitCount = 0,
23-
this.effectCount = 0,
16+
this.signature = 0;
17+
this.items = [];
18+
this.outfits = [];
19+
this.effects = [];
20+
this.missiles = [];
21+
this.itemCount = 0;
22+
this.outfitCount = 0;
23+
this.effectCount = 0;
2424
this.missileCount = 0;
2525

2626
var self = this;
2727
fs.readFile(file, function(err, buffer) {
28-
if (err) throw err;
28+
if (err) { throw err; }
2929

3030
self._readLists(buffer);
3131

@@ -54,46 +54,46 @@ Metadata.prototype.getMissileCount = function() {
5454
};
5555

5656
Metadata.prototype.hasThingType = function(category, id) {
57-
if (category == 'item') {
57+
if (category === 'item') {
5858
return (id >= 100 && id <= this.itemCount);
59-
} else if (category == 'outfit') {
59+
} else if (category === 'outfit') {
6060
return (id >= 1 && id <= this.outfitCount);
61-
} else if (category == 'effect') {
61+
} else if (category === 'effect') {
6262
return (id >= 1 && id <= this.effectCount);
63-
} else if (category == 'missile') {
63+
} else if (category === 'missile') {
6464
return (id >= 1 && id <= this.missileCount);
6565
}
6666
return false;
6767
};
6868

6969
Metadata.prototype.getThingType = function(category, id) {
70-
if (category == 'item') {
70+
if (category === 'item') {
7171
return this.getItem(id);
72-
} else if (category == 'outfit') {
72+
} else if (category === 'outfit') {
7373
return this.getOutfit(id);
74-
} else if (category == 'effect') {
74+
} else if (category === 'effect') {
7575
return this.getEffect(id);
76-
} else if (category == 'missile') {
76+
} else if (category === 'missile') {
7777
return this.getMissile(id);
7878
}
7979
return null;
8080
};
8181

8282
Metadata.prototype.getMinId = function(category) {
83-
if (category == 'item') {
83+
if (category === 'item') {
8484
return 100;
8585
}
8686
return 1;
8787
};
8888

8989
Metadata.prototype.getMaxId = function(category) {
90-
if (category == 'item') {
90+
if (category === 'item') {
9191
return this.itemCount;
92-
} else if (category == 'outfit') {
92+
} else if (category === 'outfit') {
9393
return this.outfitCount;
94-
} else if (category == 'effect') {
94+
} else if (category === 'effect') {
9595
return this.effectCount;
96-
} else if (category == 'missile') {
96+
} else if (category === 'missile') {
9797
return this.missileCount;
9898
}
9999
return 0;
@@ -151,7 +151,7 @@ Metadata.prototype._readLists = function(buffer) {
151151
for (id = 1; id <= this.missileCount; id++) {
152152
this.missiles[id] = this._readThing(id, 'missile');
153153
}
154-
}
154+
};
155155

156156
Metadata.prototype._readThing = function(id, category) {
157157

@@ -256,6 +256,6 @@ Metadata.prototype._readThing = function(id, category) {
256256
thing.groups[groupType] = group;
257257
}
258258
return thing;
259-
}
259+
};
260260

261261
module.exports = Metadata;

lib/Sprites.js renamed to src/Sprites.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"use strict";
1+
'use strict';
22

33
var fs = require('fs');
44
var BufferReader = require('buffer-reader');
@@ -12,12 +12,12 @@ function Sprites(file, cb) {
1212
}
1313

1414
// Setupping variables
15-
this.signature = 0,
15+
this.signature = 0;
1616
this.spriteCount = 0;
1717

1818
var self = this;
1919
fs.readFile(file, function(err, buffer) {
20-
if (err) throw err;
20+
if (err) { throw err; }
2121

2222
reader = new BufferReader(buffer);
2323
self.signature = reader.nextUInt32LE();
@@ -29,18 +29,18 @@ function Sprites(file, cb) {
2929

3030
Sprites.prototype.getSignature = function() {
3131
return this.signature;
32-
}
32+
};
3333

3434
Sprites.prototype.getSpriteCount = function() {
3535
return this.spriteCount;
36-
}
36+
};
3737

3838
Sprites.prototype.copyPixels = function(spriteId, image, x, y) {
3939
var formula = 8 + (spriteId - 1) * 4;
4040
reader.seek(formula);
4141

4242
var address = reader.nextUInt32LE();
43-
if (address == 0) { // Address 0 always is an empty sprite.
43+
if (address === 0) { // Address 0 always is an empty sprite.
4444
return;
4545
}
4646
reader.seek(address);
@@ -65,6 +65,6 @@ Sprites.prototype.copyPixels = function(spriteId, image, x, y) {
6565
currentPixel++;
6666
}
6767
}
68-
}
68+
};
6969

7070
module.exports = Sprites;

lib/ThingType.js renamed to src/ThingType.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ function ThingType(id, category) {
22
this.id = id;
33
this.category = category;
44
this.groups = [];
5-
};
5+
}
66

77
ThingType.prototype.getFrameGroup = function(type) {
88
if (type < this.groups.length) {

test/test.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// TODO!

0 commit comments

Comments
 (0)