-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathworker.js
48 lines (43 loc) · 1.23 KB
/
worker.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
var request = require("request");
var FileCookieStore = require('tough-cookie-filestore');
var Account = require("./schemas").Account;
// worker is a mongodb account.
// PRECONDITION: worker is valid account
// questions: where do we put jar?
function work(worker) {
while (1) {
if (not logged in) {
log in and store cookies with user in database
} else {
check inventory and update db
check balance and update db
check history of trades and update db (optional)
get all marketable items and try to sell them
where sell is:
get market price for item
list for one cent below market price
}
}
}
// run test on own account
db.once('open', function() {
//if (reformed45 doesnt exist in db) {
//create account and save it
//}
Account.count({username: 'reformed45'}, function(err, count) {
if (!count) {
var account = new Account();
account.save(function(err, reply) {
if (err) return console.error(err);
start_reformed();
});
} else {
start_reformed45();
}
});
});
function start_reformed45() {
Account.findOne({username: 'reformed45'}, function(err, reformed45) {
work(reformed45);
});
}