Skip to content

Commit 6b5932e

Browse files
author
geno
committed
Fix purchasing and display miner licenses and total cps
1 parent 638b786 commit 6b5932e

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/main.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ fn read_inputs(
285285
let mut wals = wallets.lock().unwrap();
286286
for w in wals.iter_mut() {
287287
if w.id == c.miner.wallet_id {
288-
if w.idlecoin < 1024 {
288+
if w.idlecoin < 1024 && w.supercoin < 1 {
289289
c.updates.push(
290290
"You need at least 1024 idlecoin to be able to purchase Cps\n"
291291
.to_string(),
@@ -325,7 +325,7 @@ fn read_inputs(
325325
continue;
326326
}
327327
let cost = u64::MAX / (100000 >> (w.max_miners - 5));
328-
if w.idlecoin > cost {
328+
if w.idlecoin > cost || w.supercoin > 0 {
329329
let t: DateTime<Local> = Local::now();
330330
msg.insert(0, format!(" [{}] Wallet 0x{:016x} bought a new miner license with {} idlecoin\n", t, c.miner.wallet_id, cost));
331331
sub_idlecoins(w, cost);
@@ -370,11 +370,12 @@ fn print_wallets(
370370
}
371371
}
372372
let wal = &format!(
373-
"[{:03}] Wallet 0x{:016x} Coins: {}:{} Total Cps: {}\n",
373+
"[{:03}] Wallet 0x{:016x} Coins: {}:{} Miner Licenses: {} Total Cps: {}\n",
374374
gens.len() - i,
375375
g.id,
376376
g.supercoin,
377377
g.idlecoin,
378+
g.max_miners,
378379
total_cps,
379380
)
380381
.to_owned();
@@ -557,7 +558,7 @@ fn sub_idlecoins(mut wallet: &mut Wallet, less: u64) {
557558
None => {
558559
if wallet.supercoin > 0 {
559560
wallet.supercoin = wallet.supercoin.saturating_sub(1);
560-
(u128::from(less) - u128::from(wallet.idlecoin) - u128::from(u64::MAX))
561+
(u128::from(u64::MAX) - u128::from(less) + u128::from(wallet.idlecoin))
561562
.try_into()
562563
.unwrap()
563564
} else {

0 commit comments

Comments
 (0)