Fix kills

This commit is contained in:
Mimi 2022-11-12 20:38:09 +08:00
parent 7044b67cb0
commit 69ed3e56e2
4 changed files with 11 additions and 13 deletions

2
bot.js
View File

@ -259,7 +259,7 @@ client.setRenderer({
const dt = (endFrame - startFrame);
startFrame = -1;
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);
const mutation = Math.min(10, Math.pow(2, calcFavorability(params)));

View File

@ -197,7 +197,7 @@ client.setRenderer({
startFrame = -1;
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);
},
removePlayer: function(player) {

View File

@ -3,7 +3,7 @@ import { consts } from "../config.js";
let running = false;
let user, socket, frame;
let players, allPlayers;
let _kills;
let kills;
let timeout = undefined;
let dirty = false;
let deadFrames = 0;
@ -231,7 +231,7 @@ function reset() {
grid.reset();
players = [];
allPlayers = [];
_kills = 0;
kills = 0;
invokeRenderer("reset");
}
@ -243,7 +243,7 @@ function setUser(player) {
function update() {
const dead = [];
updateFrame(grid, players, dead, (killer, other) => { //addKill
if (players[killer] === user && killer !== other) _kills++;
if (players[killer] === user && killer !== other) kills++;
});
dead.forEach(val => {
console.log((val.name || "Unnamed") + " is dead");
@ -261,8 +261,12 @@ function setAllowAnimation(allow) {
_allowAnimation = allow;
}
function getKills() {
return kills;
}
// Export stuff
export { connectGame, changeHeading, getUser, getPlayers, getOthers, disconnect, setRenderer, setAllowAnimation };
export { connectGame, changeHeading, getUser, getPlayers, getOthers, disconnect, setRenderer, setAllowAnimation, getKills };
export const allowAnimation = {
get: function() {
return _allowAnimation;
@ -273,9 +277,3 @@ export const allowAnimation = {
enumerable: true
};
export { grid };
export const kills = {
get: function() {
return _kills;
},
enumerable: true
};

View File

@ -170,7 +170,7 @@ function paintUIBar(ctx) {
ctx.fillText((userPortions * 100).toFixed(3) + "%", 5 + barOffset, consts.CELL_WIDTH - 5);
//Number of kills
const killsText = "Kills: " + client.kills;
const killsText = "Kills: " + client.getKills();
const killsOffset = 20 + BAR_WIDTH + barOffset;
ctx.fillText(killsText, killsOffset, consts.CELL_WIDTH - 5);