Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51,050 changes: 27,776 additions & 23,274 deletions bin/r.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion browserquest-infra/docs/infra.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ docker run -p 8080:8080 -p 8000:8000 browserquest
For pull :

`
docker pull maxbdk/browserquest:test
docker pull jeck0v/browserquest:test
`
### Minikube launch documentation:

Expand Down
2 changes: 1 addition & 1 deletion browserquest-infra/manifests/base/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ spec:
spec:
containers:
- name: browserquest
image: maxbdk/browserquest:test
image: jeck0v/browserquest:test
ports:
- containerPort: 8080
name: http
Expand Down
1 change: 0 additions & 1 deletion client/js/audio.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ define(["area"], function (Area) {
"canplaythrough",
function (e) {
this.removeEventListener("canplaythrough", arguments.callee, false);
console.debug(path + " is ready to play.");
if (loaded_callback) {
loaded_callback();
}
Expand Down
11 changes: 0 additions & 11 deletions client/js/camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ define(function () {
return;
}

console.log("Focusing camera on entity at", entity.gridX, entity.gridY);

// Direct approach - center camera on entity
this.lookAt(entity);

Expand All @@ -98,15 +96,6 @@ define(function () {
y = Math.floor((entity.gridY - 1) / h) * h;

this.setGridPosition(x, y);

console.log(
"Camera position after focus:",
this.x,
this.y,
"grid:",
this.gridX,
this.gridY
);
},
});

Expand Down
3 changes: 2 additions & 1 deletion client/js/character.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,8 @@ define(["entity", "transition", "timer"], function (Entity, Transition, Timer) {
if (this.isAttackedBy(character)) {
delete this.attackers[character.id];
} else {
console.error(this.id + " is not attacked by " + character.id);
// See if user isnt attacking a dead entmy
// console.error(this.id + " is not attacked by " + character.id);
}
},

Expand Down
67 changes: 21 additions & 46 deletions client/js/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -1193,12 +1193,10 @@ define([
});

self.player.onDeath(function () {
console.info(self.playerId + " is dead");

self.player.stopBlinking();
self.player.setSprite(self.sprites["death"]);
self.player.animate("death", 120, 1, function () {
console.info(self.playerId + " was removed");

self.removeEntity(self.player);
self.removeFromRenderingGrid(
Expand Down Expand Up @@ -1249,21 +1247,20 @@ define([
});

self.client.onSpawnItem(function (item, x, y) {
console.info(
"Spawned " +
Types.getKindAsString(item.kind) +
" (" +
item.id +
") at " +
x +
", " +
y
);
// console.info(
// "Spawned " +
// Types.getKindAsString(item.kind) +
// " (" +
// item.id +
// ") at " +
// x +
// ", " +
// y
// );
self.addItem(item, x, y);
});

self.client.onSpawnChest(function (chest, x, y) {
console.info("Spawned chest (" + chest.id + ") at " + x + ", " + y);
chest.setSprite(self.sprites[chest.getSpriteName()]);
chest.setGridPosition(x, y);
chest.setAnimation("idle_down", 150);
Expand All @@ -1273,7 +1270,6 @@ define([
chest.stopBlinking();
chest.setSprite(self.sprites["death"]);
chest.setAnimation("death", 120, 1, function () {
console.info(chest.id + " was removed");
self.removeEntity(chest);
self.removeFromRenderingGrid(chest, chest.gridX, chest.gridY);
self.previousClickPosition = {};
Expand All @@ -1298,16 +1294,16 @@ define([

self.addEntity(entity);

console.debug(
"Spawned " +
Types.getKindAsString(entity.kind) +
" (" +
entity.id +
") at " +
entity.gridX +
", " +
entity.gridY
);
// console.debug(
// "Spawned " +
// Types.getKindAsString(entity.kind) +
// " (" +
// entity.id +
// ") at " +
// entity.gridX +
// ", " +
// entity.gridY
// );

if (entity instanceof Character) {
entity.onBeforeStep(function () {
Expand Down Expand Up @@ -1384,7 +1380,7 @@ define([
});

entity.onDeath(function () {
console.info(entity.id + " is dead");
// console.info(entity.id + " is dead");

if (entity instanceof Mob) {
// Keep track of where mobs die in order to spawn their dropped items
Expand All @@ -1400,7 +1396,6 @@ define([
self.sprites[entity instanceof Mobs.Rat ? "rat" : "death"]
);
entity.animate("death", 120, 1, function () {
console.info(entity.id + " was removed");

self.removeEntity(entity);
self.removeFromRenderingGrid(
Expand Down Expand Up @@ -1468,13 +1463,6 @@ define([
var entity = self.getEntityById(entityId);

if (entity) {
console.info(
"Despawning " +
Types.getKindAsString(entity.kind) +
" (" +
entity.id +
")"
);

if (
entity.gridX === self.previousClickPosition.x &&
Expand Down Expand Up @@ -1533,7 +1521,6 @@ define([
} else {
self.removeEntity(entity);
}
console.debug("Entity was destroyed: " + entity.id);
}
});

Expand All @@ -1555,7 +1542,6 @@ define([
target = self.getEntityById(targetId);

if (attacker && target && attacker.id !== self.playerId) {
console.debug(attacker.id + " attacks " + target.id);

if (
attacker &&
Expand Down Expand Up @@ -2679,17 +2665,6 @@ define([
self.removeEntity(entity);
}
});
console.debug(
"Removed " +
nb +
" entities: " +
_.pluck(
_.reject(this.obsoleteEntities, function (id) {
return id === self.player.id;
}),
"id"
)
);
this.obsoleteEntities = null;
}
},
Expand Down
3 changes: 0 additions & 3 deletions client/js/gameclient.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ define(["player", "entityfactory"], function (Player, EntityFactory) {
this.connection.emit("dispatch", true);

this.connection.on("dispatched", function (reply) {
console.log("Dispatched: ");
console.log(reply);
if (reply.status === "OK") {
self.dispatched_callback(reply.host, reply.port);
} else if (reply.status === "FULL") {
Expand Down Expand Up @@ -128,7 +126,6 @@ define(["player", "entityfactory"], function (Player, EntityFactory) {

receiveMessage: function (message) {
if (this.isListening) {
console.debug("data: " + message);

if (message instanceof Array) {
if (message[0] instanceof Array) {
Expand Down
1 change: 0 additions & 1 deletion client/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ define(["character", "exceptions"], function (Character, Exceptions) {
}
}

console.info("Player " + this.id + " has looted " + item.id);
if (Types.isArmor(item.kind) && this.invincible) {
this.stopInvincibility();
}
Expand Down
52 changes: 27 additions & 25 deletions client/js/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,10 @@ define(["camera", "item", "character", "player", "timer"], function (
var Renderer = Class.extend({
init: function (game, canvas, background, foreground) {
this.game = game;
this.context =
canvas && canvas.getContext ? canvas.getContext("2d") : null;
this.background =
background && background.getContext
? background.getContext("2d")
: null;
this.foreground =
foreground && foreground.getContext
? foreground.getContext("2d")
: null;
this.context = canvas.getContext("2d");
this.background = background.getContext("2d");
this.foreground = foreground.getContext("2d");


this.canvas = canvas;
this.backcanvas = background;
Expand Down Expand Up @@ -77,14 +71,14 @@ define(["camera", "item", "character", "player", "timer"], function (
return scale;
},

rescale: function (factor) {
rescale: function () {
this.scale = this.getScaleFactor();

this.createCamera();

this.context.mozImageSmoothingEnabled = false;
this.background.mozImageSmoothingEnabled = false;
this.foreground.mozImageSmoothingEnabled = false;
this.setSmoothing(this.context, false);
this.setSmoothing(this.background, false);
this.setSmoothing(this.foreground, false);

this.initFont();
this.initFPS();
Expand All @@ -97,27 +91,37 @@ define(["camera", "item", "character", "player", "timer"], function (
}
},

setSmoothing: function (ctx, enabled) {
if (!ctx) return;
ctx.mozImageSmoothingEnabled = enabled;
ctx.imageSmoothingEnabled = enabled;
},

createCamera: function () {
this.camera = new Camera(this);
this.camera.rescale();

this.canvas.width = this.camera.gridW * this.tilesize * this.scale;
this.canvas.height = this.camera.gridH * this.tilesize * this.scale;

const width = this.camera.gridW * this.tilesize * this.scale
const height = this.camera.gridH * this.tilesize * this.scale

this.canvas.width = width;
this.canvas.height = height;
console.debug(
"#entities set to " + this.canvas.width + " x " + this.canvas.height
);

this.backcanvas.width = this.canvas.width;
this.backcanvas.height = this.canvas.height;
this.backcanvas.width = width;
this.backcanvas.height = height;
console.debug(
"#background set to " +
this.backcanvas.width +
" x " +
this.backcanvas.height
);

this.forecanvas.width = this.canvas.width;
this.forecanvas.height = this.canvas.height;
this.forecanvas.width = width;
this.forecanvas.height = height;
console.debug(
"#foreground set to " +
this.forecanvas.width +
Expand Down Expand Up @@ -147,10 +151,10 @@ define(["camera", "item", "character", "player", "timer"], function (
},

setFontSize: function (size) {
var font = size + "px GraphicPixel";
var font = `${size}px GraphicPixel`;

this.context.font = font;
this.background.font = font;
if (this.context) this.context.font = font;
if (this.background) this.background.font = font;
},

drawText: function (text, x, y, centered, color, strokeColor) {
Expand Down Expand Up @@ -848,8 +852,6 @@ define(["camera", "item", "character", "player", "timer"], function (
this.drawHighTiles(this.foreground);
this.foreground.restore();
}

console.log("Static canvases (terrain, background) have been rendered");
},

renderFrame: function () {
Expand Down
2 changes: 1 addition & 1 deletion client/js/sprite.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ define(["jquery", "animation", "sprites"], function ($, Animation, sprites) {
height: this.height,
};
} catch (e) {
console.error("Error getting image data for sprite : " + this.name);
// Add error logs not using console.log (later)
}
},

Expand Down
33 changes: 15 additions & 18 deletions server/js/formulas.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@

var Utils = require("./utils");

var Formulas = {};

Formulas.dmg = function(weaponLevel, armorLevel) {
var dealt = weaponLevel * Utils.randomInt(5, 10),
absorbed = armorLevel * Utils.randomInt(1, 3),
dmg = dealt - absorbed;

//console.log("abs: "+absorbed+" dealt: "+ dealt+" dmg: "+ (dealt - absorbed));
if(dmg <= 0) {
return Utils.randomInt(0, 3);
} else {
return dmg;
}
Formulas.dmg = function (weaponLevel, armorLevel) {
var dealt = weaponLevel * Utils.randomInt(5, 10),
absorbed = armorLevel * Utils.randomInt(1, 3),
dmg = dealt - absorbed;
if (dmg <= 0) {
return Utils.randomInt(0, 3);
} else {
return dmg;
}
};

Formulas.hp = function(armorLevel) {
var hp = 80 + ((armorLevel - 1) * 30);
return hp;
Formulas.hp = function (armorLevel) {
var hp = 80 + (armorLevel - 1) * 30;
return hp;
};

if(!(typeof exports === 'undefined')) {
module.exports = Formulas;
}
if (!(typeof exports === "undefined")) {
module.exports = Formulas;
}
Loading