-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmbfunc1.js
More file actions
92 lines (88 loc) · 2.42 KB
/
Copy pathmbfunc1.js
File metadata and controls
92 lines (88 loc) · 2.42 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
function drawcard() {
var scratch, scratch2;
scratch=Math.floor(Math.random()*undrawn.length);
scratch2=undrawn[scratch];
undrawn.splice(scratch,1);
return scratch2;
}
function prepdiscard() {
dodiscard=1-dodiscard;
repaint();
}
function discard(card) {
dodiscard=0;
var scratch, scratch2;
if(hands[turn].length<1) {
console.err("Player "+turn+": Can not discard() -- hand is empty");
return -1;
}
if(card.length<5) {
console.err("Player "+turn+": Can not discard() -- card = ("+card+")");
return -1;
}
scratch2="player "+turn+": discarding card #"+card.substr(4)+" "+SVGDocument.getElementById(card).getAttribute("xlink:href");
console.info(scratch2)
scratch2=hands[turn].indexOf(card);
if(card==hands[turn][scratch2]) {
scratch=hands[turn][scratch2];
discards.push(scratch);
hands[turn].splice(scratch2,1);
endturn();
return 99;
}
return -1;
}
function endturn() {
dodiscard=0;
fakesafeties();
repaint();
assessvictory();
if(mode!=0)
{ return 99; }
while((hands[turn].length<6)&&(undrawn.length>0))
{ hands[turn].push(drawcard()); }
repaint();
turn++;
if(turn>=players)
{ turn=0; }
else
{ compmove(); }
// if(mode==0) {
// clock=setTimeout(function(){compmove();},2000)
// }
}
function fakesafeties() {
var x;
for(x=players-1;x>=0;x--) {
// badly apply safeties to the battle/limit piles
if((peels[x]['limit']=="limit") &&(peels[x]['sgo']!="no")) {
peels[x]['limit']="unlimit";
console.debug("player "+x+": removing limit");
}
if((peels[x]['battle']=="flat") &&(peels[x]['stire']!="no")) {
peels[x]['battle']="stop";
console.debug("player "+x+": removing flat");
}
if((peels[x]['battle']=="empty") &&(peels[x]['sfuel']!="no")) {
peels[x]['battle']="stop";
console.debug("player "+x+": removing empty");
}
if((peels[x]['battle']=="accident") &&(peels[x]['scrash']!="no")) {
peels[x]['battle']="stop";
console.debug("player "+x+": removing crash");
}
if((peels[x]['battle']=="stop") &&(peels[x]['sgo']!="no")) {
peels[x]['battle']="go";
console.debug("player "+x+": removing stop");
}
}
}
function tryextend() {
if(mode==0) {return -1;}
if(extended<extensions.length-1) {
extended++;
G_hid.appendChild(R_vici);
mode=0;
endturn;
}
}