Improve trading logic
This commit is contained in:
parent
91f9641665
commit
25b5b9090c
|
@ -171,26 +171,36 @@
|
|||
|
||||
defer.joe = () => {
|
||||
furball.toggle("joe", true, false);
|
||||
furball.set("joe", "time", minutes(5), false);
|
||||
furball.set("joe", "time", minutes(10), false);
|
||||
furball.set("joe", "amt", 5);
|
||||
|
||||
const races = game.diplomacy.races;
|
||||
let idx = 0;
|
||||
|
||||
setInterval(() => {
|
||||
const race = races[idx];
|
||||
|
||||
if(should_run("joe") && race.unlocked) {
|
||||
game.diplomacy.tradeMultiple(race, furball.conf.joe.amt);
|
||||
log_msg(`did a trade with ${race.name} ${furball.conf.joe.amt} times`);
|
||||
game.village.huntAll();
|
||||
log_msg("hunted all the things on the way back");
|
||||
if(should_run("joe")) {
|
||||
const race = races[idx];
|
||||
|
||||
if(idx === races.length - 1) {
|
||||
idx = 0;
|
||||
} else {
|
||||
idx += 1;
|
||||
}
|
||||
|
||||
if(race.unlocked) {
|
||||
let amt = game.diplomacy.getMaxTradeAmt(race);
|
||||
|
||||
if(amt > 0) {
|
||||
if(amt > furball.conf.joe.amt) {
|
||||
amt = furball.conf.joe.amt;
|
||||
}
|
||||
|
||||
game.diplomacy.tradeMultiple(race, amt);
|
||||
log_msg(`did a trade with ${race.name} ${amt} times`);
|
||||
game.village.huntAll();
|
||||
log_msg("hunted all the things on the way back");
|
||||
}
|
||||
}
|
||||
}
|
||||
}, furball.conf.joe.time);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue