ResourcesLib - Docs
With lib we can manage any resources in bot.
Such resource can be:
- balance (in USD, BTC or any other)
- any game resources: gold, woods, stone, etc
- etc, any float values

Resource can be user's resource:
let res = Libs.ResourcesLib.userRes("money");
Bot.sendMessage("Cur your money: " + res.value());
One user can have same chats with bot. For example: private and group chat.
But anywhere he have simular resources
Resource can be chat's resource:
let res = Libs.ResourcesLib.chatRes("money");
Bot.sendMessage("Cur your money: " + res.value());
One user can have same chats with bot. For example: private and group chat.
But he have diffent resources for each chats.
Methots for user's and chat resources:
res.name - current res name.
For example Libs.ResourcesLib.chatRes("BTC").name is "BTC"
res.value() - current res amount
res.set(amount) - set amount for this res
for example: Libs.ResourcesLib.userRes("wood").set(10);
res.add(amount) - add amount for this res
res.have(amount) - if res value equal amount or more return true
res.remove(amount) - take away amount from resource if have it
res.removeAnyway(amount) - take away amount anyway.
Also can access to another user's resources:
// telegramid - it is telegram id for another user
let res = Libs.ResourcesLib.anotherUserRes("money", telegramid);
Bot.sendMessage("Cur your money: " + res.value());
or for another chat's resources:
// chatid - it is telegram id for another chat
let res = Libs.ResourcesLib.anotherChatRes("money", chatid);
Bot.sendMessage("Cur your money: " + res.value());
Resource transfering

Transfering simular resources with users "gold for gold"
let res = Libs.ResourcesLib.userRes("gold");
// telegramid - it is telegram id for another user
let anotherRes = Libs.ResourcesLib.anotherUserRes("gold", telegramid);
if have resource:
res.takeFromAnother(anotherRes, amount)
res.transferTo(anotherRes, amount)
or anyway, even resource is not enough:
res.takeFromAnotherAnyway(anotherRes, amount)
res.transferToAnyway(anotherRes, amount)
Can exchange different resources, for example "gold" for "wood"
res.exchangeTo(anotherRes, { remove_amount: 10, add_amount:23 } )
Resource can have growht.

For example simple growht - add 5 every 10 secs to res
let health = Libs.ResourcesLib.userRes("health");
health.set(1);
health.growth.add({value: 5, interval:10 });
Interval - it is value in seconds. Value is added every interval
Add 5 every hour. Max value: 100
let secs_in_hour = 60 * 60;
health.growth.add({value: 5, interval: secs_in_hour, max: 100 });
Value can be negative.
Remove 5 every 30 hours. Min value: -20
let secs_in_30hours = 60 * 60 * 30;
health.growth.add({value: 5, interval: secs_in_30hours, min: -20 });
Can limit max iteration count:
health.growth.add({value: 5, interval: secs_in_30hours, max_iterations_count: 3 });
Can growh by percent.
For example add 15% every month for 100 USD
let usd = Libs.ResourcesLib.userRes("usd");
usd.set(100);
let secs_in_month = 60 * 60 * 24 * 31;
usd.growth.addPercent({percent: 15, interval: secs_in_month });
percent - it is value on percent %.
Can grow by compound interest.
For example add 0.8% every day for 0.5 BTC with reinvest
let btc = Libs.ResourcesLib.userRes("BTC");
btc.set(0.5);
let secs_in_day = 60 * 60 * 24;
usd.growth.addCompoundInterest({percent: 0.8, interval: secs_in_day });
percent - it is value on percent %.
Other methods for res.growth:
res.growth.info() - get info for current growth
res.growth.title() - get title. For example "add 5 once at 15 secs"
res.growth.isEnabled() - return true if is enabled
res.growth.stop() - stop growth
res.growth.progress() - current progress for next iteration
res.growth.willCompletedAfter() - will completed iteration after this time in seconds