Fix kills
This commit is contained in:
parent
7044b67cb0
commit
69ed3e56e2
2
bot.js
2
bot.js
@ -259,7 +259,7 @@ client.setRenderer({
|
|||||||
const dt = (endFrame - startFrame);
|
const dt = (endFrame - startFrame);
|
||||||
startFrame = -1;
|
startFrame = -1;
|
||||||
console.log(`[${new Date()}] I died... (survived for ${dt} frames.)`);
|
console.log(`[${new Date()}] I died... (survived for ${dt} frames.)`);
|
||||||
console.log(`[${new Date()}] I killed ${client.kills} player(s).`);
|
console.log(`[${new Date()}] I killed ${client.getKills()} player(s).`);
|
||||||
console.log("Coefficients: " + coeffs);
|
console.log("Coefficients: " + coeffs);
|
||||||
|
|
||||||
const mutation = Math.min(10, Math.pow(2, calcFavorability(params)));
|
const mutation = Math.min(10, Math.pow(2, calcFavorability(params)));
|
||||||
|
@ -197,7 +197,7 @@ client.setRenderer({
|
|||||||
startFrame = -1;
|
startFrame = -1;
|
||||||
|
|
||||||
console.log(`[${new Date()}] I died... (survived for ${dt} frames.)`);
|
console.log(`[${new Date()}] I died... (survived for ${dt} frames.)`);
|
||||||
console.log(`[${new Date()}] I killed ${client.kills} player(s).`);
|
console.log(`[${new Date()}] I killed ${client.getKills()} player(s).`);
|
||||||
setTimeout(connect, 5000);
|
setTimeout(connect, 5000);
|
||||||
},
|
},
|
||||||
removePlayer: function(player) {
|
removePlayer: function(player) {
|
||||||
|
@ -3,7 +3,7 @@ import { consts } from "../config.js";
|
|||||||
let running = false;
|
let running = false;
|
||||||
let user, socket, frame;
|
let user, socket, frame;
|
||||||
let players, allPlayers;
|
let players, allPlayers;
|
||||||
let _kills;
|
let kills;
|
||||||
let timeout = undefined;
|
let timeout = undefined;
|
||||||
let dirty = false;
|
let dirty = false;
|
||||||
let deadFrames = 0;
|
let deadFrames = 0;
|
||||||
@ -231,7 +231,7 @@ function reset() {
|
|||||||
grid.reset();
|
grid.reset();
|
||||||
players = [];
|
players = [];
|
||||||
allPlayers = [];
|
allPlayers = [];
|
||||||
_kills = 0;
|
kills = 0;
|
||||||
invokeRenderer("reset");
|
invokeRenderer("reset");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,7 +243,7 @@ function setUser(player) {
|
|||||||
function update() {
|
function update() {
|
||||||
const dead = [];
|
const dead = [];
|
||||||
updateFrame(grid, players, dead, (killer, other) => { //addKill
|
updateFrame(grid, players, dead, (killer, other) => { //addKill
|
||||||
if (players[killer] === user && killer !== other) _kills++;
|
if (players[killer] === user && killer !== other) kills++;
|
||||||
});
|
});
|
||||||
dead.forEach(val => {
|
dead.forEach(val => {
|
||||||
console.log((val.name || "Unnamed") + " is dead");
|
console.log((val.name || "Unnamed") + " is dead");
|
||||||
@ -261,8 +261,12 @@ function setAllowAnimation(allow) {
|
|||||||
_allowAnimation = allow;
|
_allowAnimation = allow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getKills() {
|
||||||
|
return kills;
|
||||||
|
}
|
||||||
|
|
||||||
// Export stuff
|
// Export stuff
|
||||||
export { connectGame, changeHeading, getUser, getPlayers, getOthers, disconnect, setRenderer, setAllowAnimation };
|
export { connectGame, changeHeading, getUser, getPlayers, getOthers, disconnect, setRenderer, setAllowAnimation, getKills };
|
||||||
export const allowAnimation = {
|
export const allowAnimation = {
|
||||||
get: function() {
|
get: function() {
|
||||||
return _allowAnimation;
|
return _allowAnimation;
|
||||||
@ -273,9 +277,3 @@ export const allowAnimation = {
|
|||||||
enumerable: true
|
enumerable: true
|
||||||
};
|
};
|
||||||
export { grid };
|
export { grid };
|
||||||
export const kills = {
|
|
||||||
get: function() {
|
|
||||||
return _kills;
|
|
||||||
},
|
|
||||||
enumerable: true
|
|
||||||
};
|
|
||||||
|
@ -170,7 +170,7 @@ function paintUIBar(ctx) {
|
|||||||
ctx.fillText((userPortions * 100).toFixed(3) + "%", 5 + barOffset, consts.CELL_WIDTH - 5);
|
ctx.fillText((userPortions * 100).toFixed(3) + "%", 5 + barOffset, consts.CELL_WIDTH - 5);
|
||||||
|
|
||||||
//Number of kills
|
//Number of kills
|
||||||
const killsText = "Kills: " + client.kills;
|
const killsText = "Kills: " + client.getKills();
|
||||||
const killsOffset = 20 + BAR_WIDTH + barOffset;
|
const killsOffset = 20 + BAR_WIDTH + barOffset;
|
||||||
ctx.fillText(killsText, killsOffset, consts.CELL_WIDTH - 5);
|
ctx.fillText(killsText, killsOffset, consts.CELL_WIDTH - 5);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user