Skip to content

Commit

Permalink
GLOBAL LVL - RELEASE 5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronopoldo committed Jan 8, 2022
1 parent 4d12169 commit 212f22a
Show file tree
Hide file tree
Showing 27 changed files with 297 additions and 13 deletions.
Binary file added Images/emptybar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/grandbar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions data/UserData/544902183007813652/DATATRANSFERCONFIRMATION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2022-01-08T05:20:12.000Z
2 changes: 1 addition & 1 deletion data/UserData/544902183007813652/badges/active
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
0
868
892
2 changes: 1 addition & 1 deletion data/UserData/544902183007813652/integers/exp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
99.11999999999998
101.75999999999996
1 change: 1 addition & 0 deletions data/UserData/544902183007813652/integers/grandXp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
13261.808411158761
2 changes: 1 addition & 1 deletion data/UserData/544902183007813652/integers/money
Original file line number Diff line number Diff line change
@@ -1 +1 @@
146852
147933.11757124824
1 change: 1 addition & 0 deletions data/UserData/544902183007813652/integers/totalXp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
13849.852499999963
1 change: 1 addition & 0 deletions data/UserData/544902183007813652/tasks/global
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
17
2 changes: 1 addition & 1 deletion data/UserData/671776348951412819/badges/active
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
0
71
72
2 changes: 1 addition & 1 deletion data/UserData/671776348951412819/integers/exp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.120000000000009
7.230000000000009
2 changes: 1 addition & 1 deletion data/UserData/671776348951412819/integers/money
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6372
6376
2 changes: 1 addition & 1 deletion data/UserData/671776348951412819/integers/voice
Original file line number Diff line number Diff line change
@@ -1 +1 @@
307.80000000000206
308.4000000000021
1 change: 1 addition & 0 deletions data/UserData/899380887282675743/DATATRANSFERCONFIRMATION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2022-01-08T05:20:37.000Z
2 changes: 1 addition & 1 deletion data/UserData/899380887282675743/badges/active
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
0
7
47
2 changes: 1 addition & 1 deletion data/UserData/899380887282675743/integers/exp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.77
5.170000000000002
1 change: 1 addition & 0 deletions data/UserData/899380887282675743/integers/grandXp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
14.18249999999999
2 changes: 1 addition & 1 deletion data/UserData/899380887282675743/integers/money
Original file line number Diff line number Diff line change
@@ -1 +1 @@
172
327
1 change: 1 addition & 0 deletions data/UserData/899380887282675743/integers/totalXp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
41.0625
1 change: 1 addition & 0 deletions data/UserData/899380887282675743/tasks/global
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ const balCommand = require("./src/bal")
const badgesCommand = require("./src/badges")
const setbadgeCommand = require("./src/setbadge")
const setbadge2Command = require("./src/setbadge2")
const transferCommand = require("./src/transfer")
// Обработчик входящих сообщений
client.on('messageCreate', msg => {
calculateUserData.calculateUserData(fs, msg, client, ctx, sharp, canvas, talkedRecently);
Expand Down Expand Up @@ -145,6 +146,9 @@ switch(command) {
case "/badges":
badgesCommand.badgesCommand(msg, fs, args, client)
break;

case "/transfer":
transferCommand.transfer(msg, fs)
}

}catch(err){
Expand Down
88 changes: 88 additions & 0 deletions src/calculateUserData.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,89 @@ let allowedChannels = ['647050821594251264','671026327016701953','64900370894802
fs.writeFileSync('./data/UserData/' + msg.author.id + '/badges/active', ActiveMassive[0] + '\n' + (Number(ActiveMassive[1]) + 1).toString(), 'utf8')
console.log('Внесено: ' + Money.toString())
console.log('Мани: ' + Money)


//////////////////////////СУММАР ЭКСПИ
if (fs.existsSync('./data/UserData/' + msg.author.id + '/DATATRANSFERCONFIRMATION'))
{

let curExpPath = './data/UserData/' + msg.author.id + '/integers/totalXp'
let xp = fs.readFileSync(curExpPath)
let normalXp = fs.readFileSync('./data/UserData/' + msg.author.id + '/integers/grandXp')
let daystreak = fs.readFileSync('./data/UserData/' + msg.author.id + '/badges/lastActve') + ''

let dayStreakClear = Number(daystreak.split(' ')[2])


let multiplier = 4
if (dayStreakClear < 60)
{
multiplier = dayStreakClear * 0.05 + 1
}

multiplier = multiplier * 2.25

normalXp = Number(normalXp) + multiplier
xp = Number(xp) + multiplier
fs.writeFileSync(curExpPath, xp.toString())
fs.writeFileSync('./data/UserData/' + msg.author.id + '/integers/grandXp', normalXp.toString())
// msg.reply(dayStreakClear.toString())
// msg.reply(multiplier.toString())
// msg.reply(xp.toString())




/////УРОВНИ И ДЕНЬГИ

let globalLvl = Number(fs.readFileSync('./data/UserData/' + msg.author.id + '/tasks/global'))


let neededExp = 12
let active1 = true
let counterGlobal = 0
let globalMoney = 25
while (active1 == true)
{
neededExp = neededExp * 1.12
globalMoney = globalMoney * 1.1
counterGlobal = counterGlobal + 1
if (counterGlobal >= globalLvl)
{
active1 = false
}
}

if (neededExp > 450) { neededExp = 450 }
console.log(neededExp + ' - нужный опыт')
if (neededExp < Number(normalXp))
{
let money = fs.readFileSync('./data/UserData/' + msg.author.id + '/integers/money')
money = Number(money) + globalMoney
console.log('МАНИ ' + money)
console.log( Number(money))
console.log(globalMoney)
normalXp = Number(normalXp) - neededExp
globalLvl = globalLvl + 1

fs.writeFileSync('./data/UserData/' + msg.author.id + '/tasks/global', globalLvl.toString()) // Уровень
fs.writeFileSync('./data/UserData/' + msg.author.id + '/integers/money', money.toString()) // Деньги
fs.writeFileSync('./data/UserData/' + msg.author.id + '/integers/grandXp', normalXp.toString()) //Экспи в ноль

msg.reply(':tada:Новый ГЛОБАЛЬНЫЙ уровень!:tada:\nУровень: ' + globalLvl.toString() + '\nТотал опыт: ' + Math.floor(xp) + '\nПолучено монет: ' + Math.floor(globalMoney)).catch(err => {});
}





}else{
msg.reply('Хей! Тебе не добавляется глобальный опыт!\nСрочно перенеси свой текущий командой `/transfer`\n\nPS - команду будет выключена в ближайшее время и те, кто не перенёс опыт, остануться без него')
}




}
}catch(err){console.log(err)}
let levelNeed = fs.readFileSync('./data/UserData/' + msg.author.id + '/integers/lvl', "utf8");
Expand Down Expand Up @@ -194,6 +277,11 @@ let Money1 = fs.readFileSync('./data/UserData/' + msg.author.id + '/integers/mon
msg.reply(':tada:Новый уровень!:tada:\nУровень: ' + (Number(lvl)+1).toString() + '\nТотал опыт: ' + Math.floor(totalXP) + '\nПолучено монет: ' + Math.floor(NewMoney)).catch(err => {});
}
// msg.reply(NeededXP.toString())





}
//ЗАВЕРШИТЬ!!!!!1 upd: красава, завершил

Expand Down
74 changes: 72 additions & 2 deletions src/card.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,63 @@ sharp('./tasks/voiceBar.png')



///////////////АКТИВ ГЛОБАЛ
ctx.font = '20px "ArialRound"'
ctx.strokeStyle = 'white';
ctx.lineWidth = 1;
ctx.fillStyle = 'black';
ctx.textAlign = 'left'

let fontsize = 45


let grandPath = './Images/Blank.png'
let barSize = 1

if (fs.existsSync('./data/UserData/' + pingedUser + '/DATATRANSFERCONFIRMATION'))
{
let currentGlobalLvl = fs.readFileSync('./data/UserData/' + pingedUser + '/tasks/global')
let currentGlobalExp = fs.readFileSync('./data/UserData/' + pingedUser + '/integers/grandXp')
grandPath = './Images/grandbar.png'
barSize =
ctx.fillText(Math.floor((Number(currentGlobalExp)).toString()), 132,255)

let neededExp = 12
let active1 = true
let counterGlobal = 0
let globalMoney = 25
while (active1 == true)
{
neededExp = neededExp * 1.12
counterGlobal = counterGlobal + 1
if (counterGlobal >= currentGlobalLvl+1)
{
active1 = false
}


}
barSize = Math.floor(neededExp / currentGlobalExp)

if ((barSize >=520) || (barSize == 0)) { barSize = 519 }


}


sharp(grandPath)


.extract({ left: 0, top: 0, width: barSize, height: 7 })
.toBuffer()
.then(function(grandBuffer) {









ctx.strokeStyle = 'black';
Expand Down Expand Up @@ -262,7 +319,13 @@ console.log('Адоптация:' + fontsize)

//Юзер
let Money = fs.readFileSync('./data/UserData/' + pingedUser + '/integers/money', "utf8");
let Level = fs.readFileSync('./data/UserData/' + pingedUser + '/integers/lvl', "utf8");

let Level = '0'

if (fs.existsSync('./data/UserData/' + pingedUser + '/tasks/global'))
{
Level = fs.readFileSync('./data/UserData/' + pingedUser + '/tasks/global', "utf8");
}
let Themes = fs.readdirSync('./data/UserData/' + pingedUser + '/themes', "utf8");


Expand Down Expand Up @@ -397,6 +460,9 @@ sharp.cache(false);
{input: outputBufferAct, top: 345, left: 185},
{input: outputBufferAct1, top: 345, left: 689},
{input: outputBufferAct2, top: 532, left: 185},
{input: './Images/emptybar.png', top: 230, left: 132},
{input: grandBuffer, top: 230, left: 132},

{ input: out, top: 0, left: 0}])
.toBuffer()
.then(function(outputBuffer) {
Expand All @@ -416,6 +482,7 @@ sharp.cache(false);
{ input: activeImg, top: 286, left: 61}, //11
{ input: "./Images/circler.png", top: 76, left: 76},
{input: outputBufferAct, top: 345, left: 185},
// {input: grandBuffer, top: 10, left: 10},
{ input: out, top: 0, left: 0}])
.toBuffer()
.then(function(outputBuffer) {
Expand All @@ -435,14 +502,17 @@ sharp.cache(false);

})
.catch(err => { msg.reply('Сожалеем, но произошла ошибка при загрузке карточки!\nКод: ' + err) });

});




})


})
.catch(err => { msg.reply('Сожалеем, но произошла ошибка при загрузке карточки!\nКод: ' + err) });

})
.catch(err => { msg.reply('Сожалеем, но произошла ошибка при загрузке карточки!\nКод: ' + err) });
})
Expand Down
10 changes: 10 additions & 0 deletions src/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ function startCommand(fs, msg) {
if (err) throw err;
console.log('Данные были добавлены в конец файла!');
});

fs.writeFileSync('./data/UserData/' + msg.author.id + '/integers/totalXp', '0')
fs.writeFileSync('./data/UserData/' + msg.author.id + '/integers/grandXp', '0')
fs.writeFileSync('./data/UserData/' + msg.author.id + '/tasks/global', '0')
fs.writeFileSync('./data/UserData/' + msg.author.id + '/DATATRANSFERCONFIRMATION', 'ПОЛУЧЕНО ПРИ РЕГИСТРАЦИИ')





fs.writeFileSync(filepath + '/integers/exp', '0', 'utf8', (err) => {
if (err) throw err;
console.log('Данные были добавлены в конец файла!');
Expand Down
2 changes: 1 addition & 1 deletion src/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function test(msg, fs,args) {
// console.log(element + ' written')
// });

msg.channel.send('/start')
msg.channel.send('/transfer')

// if (msg.author.id == '544902183007813652')
// {
Expand Down
27 changes: 27 additions & 0 deletions src/transfer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
function transfer(msg, fs) {

if (fs.existsSync('./data/UserData/' + msg.author.id))
{
if (fs.existsSync('./data/UserData/' + msg.author.id + '/DATATRANSFERCONFIRMATION'))
{
msg.reply('Йоу! Твои данные не нуждаются в переносе ^^')
}else{
let VOICEXP = Number(fs.readFileSync('./data/UserData/' + msg.author.id + '/integers/voice'))
let TEXTXP = Number(fs.readFileSync('./data/UserData/' + msg.author.id + '/integers/SummarXP')) * 2.25
let TEXTXPALPHA = Number(fs.readFileSync('./data/UserData/' + msg.author.id + '/integers/exp')) * 2.25


let CurrentDate = new Date(new Date().toLocaleString("en-US", {timeZone: "Europe/Moscow"})).toJSON();

fs.writeFileSync('./data/UserData/' + msg.author.id + '/integers/totalXp', (VOICEXP + TEXTXP + TEXTXPALPHA).toString())
fs.writeFileSync('./data/UserData/' + msg.author.id + '/integers/grandXp', (VOICEXP + TEXTXP + TEXTXPALPHA).toString())
fs.writeFileSync('./data/UserData/' + msg.author.id + '/tasks/global', '0')
fs.writeFileSync('./data/UserData/' + msg.author.id + '/DATATRANSFERCONFIRMATION', CurrentDate)


msg.reply('ХЕЙ! Данные успешно перенесены! Проверь их командой `/card`\nПеренёс тебе ' + (Math.floor(VOICEXP + TEXTXP + TEXTXPALPHA)).toString() + ' опыта :Р')
}
}
}
module.exports = { transfer }

Loading

0 comments on commit 212f22a

Please sign in to comment.