forked from bridmoynihan/OldProjectRepo
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbot.js
More file actions
58 lines (48 loc) · 1.68 KB
/
bot.js
File metadata and controls
58 lines (48 loc) · 1.68 KB
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
49
50
51
52
53
54
55
56
57
58
var user = require('./userObject.js');
var prop = require('./properties.js');
function auction(){
//Ints
var auctionPrice = 10;
var amountBidded; //Button with amount bidded
//Booleans
var isAuctionOn = true;
//Setter when player withdraws to set ie to true.
//Player is dequeued
var isWithdrawn = false;
var endTurn = false;
//Queue
var playerCount = new Queue;
while(isAuctionOn){
if(playerCount.size == 1){
alert("You won the auction");
//Pay auction price
prop.Events.buy; //Player buys property
prop.Owner = user.player_id; //Property is given to player
}else if(isWithdrawn == true){
alert("You withdrew from the auction");
playerCount.dequeue();
}else if(auctionPrice > user.capital){
alert("You have been withdrawn from the auction");
playerCount.dequeue();
isWithdrawn = true;
}else{
if(auctionPrice > prop.Price){
alert("The price is above the original price!");
}else{
if(amountBidded == 1){
auctionPrice += 1;
endTurn = true;
playerCount.endTurn();
}else if(amountBidded == 10){
auctionPrice += 10;
endTurn = true;
playerCount.endTurn();
}else if(amountBidded == 100){
auctionPrice += 100;
endTurn = true;
playerCount.endTurn();
}
}
}
}
}