View difference between Paste ID: wMLgncxF and RifHeGcw
SHOW: | | - or go back to the newest paste.
1
engine.onUpdate = function(prevState) {
2
    if (engine.gameState !== prevState.gameState) {
3
        switch (engine.gameState) {
4
            case 'STARTING':
5
                onStarting();
6
                break;
7
            case 'IN_PROGRESS':
8
                onStarted();
9
                break;
10
            case 'ENDED':
11
                onEnded();
12
                break;
13
        }
14
    }
15
};
16
17
let bet = 1;
18
let autoCashOut = 1.1;
19
let betArray = [];
20
let usernameArray = [];
21
let test;
22
23
function onStarting() {
24
    function imGay() {
25
        for (num3 = 0; num3 < usernameArray.length; num3++) {
26
            for (num2 = 0; num2 < engine.players.length; num2++) {
27
					console.log(engine.players[num2].username);
28
					console.log(usernameArray[num3]);
29
                if (engine.players[num2].username == usernameArray[num3]) {
30
					console.log("Epic");
31
        engine.placeBet(bet, autoCashOut).catch(console.error);
32
                    return;
33
                } else {
34
                    console.log("Gay");
35
                }
36
            }
37
        }
38
    }
39
    setTimeout(imGay, 2500);
40
    imGay();
41
42
}
43
44
function onStarted() {
45
    console.log('Game started!');
46
    console.log(engine.players);
47
}
48
49
function onEnded() {
50
    test = engine.players;
51
    test.sort(function(a, b) {
52
        return a.bet - b.bet;
53
    })
54
55
    console.log(test);
56
57
    betArray = [];
58
    for (num = 0; num < engine.players.length; num++) {
59
        betArray.push(engine.players[num].bet);
60
    }
61
    betArray.sort((a, b) => a - b);
62
63
64
    if (betArray[engine.players.length - 1] >= 3) {
65
        if (usernameArray.includes(test[engine.players.length - 1].username)) {
66
            return;
67
        } else {
68
            usernameArray.push(test[engine.players.length - 1].username);
69
        }
70
71
72
    }
73
    console.log(usernameArray);
74
}