Fixes to sunwell and minor improvements

This commit is contained in:
omer
2024-04-15 15:50:41 +02:00
parent 87a4da5882
commit 79ca60d136
46 changed files with 1507 additions and 716 deletions
+1
View File
@@ -0,0 +1 @@
{"cost":7,"type":"SPELL","texture":"CS2_032","id":"CS2_032","text":"Deal $4 damage to all enemy minions.","name":"Flamestrike","rarity":"FREE", "artist":"Zoltan Boros", "set":"CORE", "flavor":"asdf", "playRequirements":{"REQ_TARGET_TO_PLAY":0,"REQ_MINION_TARGET":0}, "collectible":true, "playerClass":"NEUTRAL", "howToEarnGolden":"Unlocked at Level 45.", "howToEarn":"Unlocked at Level 1." }
+37 -30
View File
@@ -1,48 +1,55 @@
var express = require('express');
var express = require("express");
var app = express();
var Sunwell = require('../sunwell');
var Sunwell = require("../sunwell");
var sunwell = new Sunwell({ bodyFontSize: 35 });
app.get('/', function(req, res) {
var width = 400;
app.get("/", function(req, res) {
var width = 400;
var card_name = "";
var card_data = "";
var fs = require('fs');
var card_name = "";
var card_data = "";
var fs = require("fs");
var obj;
fs.readFile(process.cwd() + '/examples/carddata', 'utf8', function (err, data) {
if (err) throw err;
obj = JSON.parse(data);
var obj;
fs.readFile(
process.cwd() + "/examples/carddata",
"utf8",
function(err, data) {
if (err) throw err;
obj = JSON.parse(data);
var card = sunwell.createCard(obj, width, function(err, buffer) {
if (err) next(err);
var card = sunwell.createCard(obj, width, function(err, buffer) {
if (err) next(err);
res.writeHead(200, {
//'Cache-Control': 'max-age=86400',
'Content-Type': 'image/png'
});
res.writeHead(200, {
//'Cache-Control': 'max-age=86400',
"Content-Type": "image/png",
});
res.write(buffer);
res.end();
res.write(buffer);
res.end();
fs.writeFile(process.cwd() + '/../hm_web/static/custom/' + obj['id'] + '.jpg', buffer, function(err) {
if(err) {
return console.log(err);
}
fs.writeFile(
process.cwd() + "/../hm_web/static/custom/" + obj["id"] + ".jpg",
buffer,
function(err) {
if (err) {
return console.log(err);
}
console.log("The file " + obj['id'] + " was saved!");
});
});
});
console.log("The file " + obj["id"] + " was saved!");
}
);
});
}
);
});
app.use(function(err, req, res, next) {
next(err);
next(err);
});
var listener = app.listen(process.env.PORT || 8081, function() {
console.log('Server listening on port', listener.address().port);
console.log("Server listening on port", listener.address().port);
});