mirror of
https://github.com/ION606/selmerBot.git
synced 2026-05-14 21:26:54 +00:00
Fixed the problem with the hp overwrite
This commit is contained in:
@@ -45,7 +45,7 @@ function attack(client, user_dbo, other_dbo, bot, thread, command, mongouri, ite
|
|||||||
if (new_hp <= 0) {
|
if (new_hp <= 0) {
|
||||||
winGame(client, bot, client.db(user_dbo.s.namespace.db), user_dbo, xp_collection, interaction.message);
|
winGame(client, bot, client.db(user_dbo.s.namespace.db), user_dbo, xp_collection, interaction.message);
|
||||||
} else {
|
} else {
|
||||||
other_dbo.updateOne({'equipped': {$exists: true}}, { $set: { hp :new_hp }}); //THIS DOES NOT WORK (OVERWRITES HPMP MAP WITH ONE VALUE)
|
other_dbo.updateOne({'equipped': {$exists: true}}, { $set: { 'hpmp.hp' :new_hp }}); //THIS DOES NOT WORK (OVERWRITES HPMP MAP WITH ONE VALUE)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ function loseGame(user_dbo, xp_collection, message, bot = null) {
|
|||||||
|
|
||||||
//Update the player's xp
|
//Update the player's xp
|
||||||
addxp(message, user_dbo, Math.ceil((BASE.XP * doc.rank)/2),xp_collection)
|
addxp(message, user_dbo, Math.ceil((BASE.XP * doc.rank)/2),xp_collection)
|
||||||
user_dbo.updateOne({"game": {$exists: true}}, { $set: { game: null, opponent: null, state: STATE.IDLE, hp: doc.hpmp.maxhp, mp: doc.hpmp.maxmp }});
|
user_dbo.updateOne({"game": {$exists: true}}, { $set: { game: null, opponent: null, state: STATE.IDLE, 'hpmp.hp': doc.hpmp.maxhp, 'hpmp.mp': doc.hpmp.maxmp }});
|
||||||
|
|
||||||
resolve(addbal);
|
resolve(addbal);
|
||||||
});
|
});
|
||||||
@@ -51,7 +51,7 @@ function winGame(client, bot, db, user_dbo, xp_collection, message) {
|
|||||||
|
|
||||||
|
|
||||||
//Update the player with xp
|
//Update the player with xp
|
||||||
user_dbo.updateOne({"game": {$exists: true}}, { $set: { game: null, opponent: null, state: STATE.IDLE, xp: doc.xp + (BASE.XP * doc.rank), hp: doc.hpmp.maxhp, mp: doc.hpmp.maxmp }});
|
user_dbo.updateOne({"game": {$exists: true}}, { $set: { game: null, opponent: null, state: STATE.IDLE, xp: doc.xp + (BASE.XP * doc.rank), 'hpmp.hp': doc.hpmp.maxhp, 'hpmp.mp': doc.hpmp.maxmp }});
|
||||||
|
|
||||||
message.channel.delete();
|
message.channel.delete();
|
||||||
});
|
});
|
||||||
|
|||||||
+3
-3
@@ -117,14 +117,14 @@ function acceptIsValid(bot, other_discord, message, msg, tag_len) {
|
|||||||
|
|
||||||
|
|
||||||
function hpmp(message, command, dbo) {
|
function hpmp(message, command, dbo) {
|
||||||
throw 'THIS HAS NOT BEEN UPDATED WITH THE MOST RECENT VERSION OF THE MONGODB STRUCTURE!';
|
// throw 'THIS HAS NOT BEEN UPDATED WITH THE MOST RECENT VERSION OF THE MONGODB STRUCTURE!';
|
||||||
if (command == 'hp') {
|
if (command == 'hp') {
|
||||||
dbo.find({"hp": {$exists: true}}).toArray(function(err, doc) {
|
dbo.find({"hp": {$exists: true}}).toArray(function(err, doc) {
|
||||||
return message.reply(`You have ${String(doc[0].hp)} hp left!`);
|
return message.reply(`You have ${String(doc[0].hpmp.hp)} hp left!`);
|
||||||
});
|
});
|
||||||
} else if (command == 'mp') {
|
} else if (command == 'mp') {
|
||||||
dbo.find({"mp": {$exists: true}}).toArray(function(err, doc) {
|
dbo.find({"mp": {$exists: true}}).toArray(function(err, doc) {
|
||||||
return message.reply(`You have ${String(doc[0].hp)} mp left!`);
|
return message.reply(`You have ${String(doc[0].hpmp.hp)} mp left!`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user