-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
240 lines (231 loc) · 7.18 KB
/
index.html
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
<!DOCTYPE html>
<html>
<head>
<title>Machi Koro</title>
</head>
<style>
html, body {
background-color: #01ADDD;
overflow: hidden;
}
#bank {
height:0;
transition:0.3s;
overflow: auto;
overflow-y:hidden;
white-space: nowrap;
}
#playerOne, #playerTwo {
overflow: auto;
white-space: nowrap;
}
.shop {
background-color: #01ADDD;
border: none;
width:100px;
height: 140px;
}
.shopImg {
width:100px;
height:140px;
}
#openBtn {
position:absolute;
top:0;
right:0;
background-color: #01ADDD;
border:none;
}
#open {
position:absolute;
top:5px;
right:5px;
width:40px;
height:40px;
transition:0.2s;
transtion-delay:0.1s;
}
::-webkit-scrollbar {
width: 5px;
}
::-webkit-scrollbar-track {
box-shadow: inset 0 0 10px white;
border-radius: 10px;
}
::-webkit-scrollbar-thumb {
background: white;
border-radius: 10px;
}
</style>
<body>
<div id="dice">
<canvas id="diceRoll" height="120" width="2000"></canvas>
</div>
<div id="bank">
<button id="wheatBtn" class = "shop" type="button" onclick="buy(0)">
<img id="wheat" class="shopImg" src="images/wheatField.png" alt="Wheat Field">
</button>
<button id="ranchBtn" class="shop" type="button" onclick="buy(1)">
<img id="ranch" class="shopImg" src="images/ranch.png" alt="Ranch">
</button>
<button id="bakeBtn" class="shop" type="button" onclick="buy(2)">
<img id="bakery" class="shopImg" src="images/bakery.png" alt="Bakery">
</button>
<button id="cafeBtn" class="shop" type="button" onclick="buy(3)">
<img id="cafe" class="shopImg" src="images/cafe.png" alt="Cafe">
</button>
<button id="convenienceBtn" class="shop" type="button" onclick="buy(4)">
<img id="convStore" class="shopImg" src="images/convenienceStore.png" alt="Convenience Store">
</button>
<button id="forestBtn" class="shop" type="button" onclick="buy(5)">
<img id="forest" class="shopImg" src="images/forest.png" alt="Forest">
</button>
<button id="stadiumBtn" class="shop" type="button" onclick="buy(6)">
<img id="stadium" class="shopImg" src="images/stadium.png" alt="Stadium">
</button>
<button id="tvBtn" class="shop" type="button" onclick="buy(7)">
<img id="tvStation" class="shopImg" src="images/tvStation.png" alt="TV Station">
</button>
<button id="businessBtn" class="shop" type="button" onclick="buy(8)">
<img id="busCenter" class="shopImg" src="images/businessCenter.png" alt="Business Center">
</button>
<button id="cheeseBtn" class="shop" type="button" onclick="buy(9)">
<img id="cheeseFac" class="shopImg" src="images/cheeseFactory.png" alt="Cheese Factory">
</button>
<button id="furnitureBtn" class="shop" type="button" onclick="buy(10)">
<img id="furnitureFac" class="shopImg" src="images/furnitureFactory.png" alt="Furniture Factory">
</button>
<button id="mineBtn" class="shop" type="button" onclick="buy(11)">
<img id="mine" class="shopImg" src="images/mine.png" alt="Mine">
</button>
<button id="familyBtn" class="shop" type="button" onclick="buy(12)">
<img id="familyRstnt" class="shopImg" src="images/familyRestaurant.png" alt="Family Restaurant">
</button>
<button id="appleBtn" class="shop" type="button" onclick="buy(13)">
<img id="appleOrchard" class="shopImg" src="images/appleOrchard.png" alt="Apple Orchard">
</button>
<button id="fruitBtn" class="shop" type="button" onclick="buy(14)">
<img id="fruitVgtblMkt" class="shopImg" src="images/fruitAndVegetableMarket.png" alt="Fruit and Vegetable Market">
</button>
<button id="trainBtn" class="shop" type="button" onclick="landmark(0)">
<img id="train" class="shopImg" src="images/trainStation.png" alt="Train Station">
</button>
<button id="shoppingBtn" class="shop" type="button" onclick="landmark(1)">
<img id="shopping" class="shopImg" src="images/shoppingMall.png" alt="Shopping Mall">
</button>
<button id="amusementBtn" class="shop" type="button" onclick="landmark(2)">
<img id="amusement" class="shopImg" src="images/amusementPark.png" alt="Amusement Park">
</button>
<button id="radioBtn" class="shop" type="button" onclick="landmark(3)">
<img id="radio" class="shopImg" src="images/radioTower.png" alt="Radio Tower">
</button>
<button id="closeBtn" class="shop" type="button" onclick="closeMenu()">
<img id="closeMenu" class="shopImg" src="images/menuClose.png" alt="Close">
</button>
</div>
<button id="openBtn" type="button" onclick="openMenu()">
<img id="open" src="images/menuOpen.png" alt="Open">
</button>
<div id="playerOne">
<canvas id="myCanvas" width="2000" height="240"></canvas>
</div>
<div id="playerTwo">
<canvas id="twoCanvas" width="2000" height="240"></canvas>
</div>
<img class="diceImg" src="diceImg/one.png" style="display:none">
<img class="diceImg" src="diceImg/two.png" style="display:none">
<img class="diceImg" src="diceImg/three.png" style="display:none">
<img class="diceImg" src="diceImg/four.png" style="display:none">
<img class="diceImg" src="diceImg/five.png" style="display:none">
<img class="diceImg" src="diceImg/six.png" style="display:none">
<script>
var c = document.getElementById("myCanvas");
var c2 = document.getElementById("twoCanvas");
var c3 = document.getElementById("diceRoll");
var ctx = [c.getContext("2d"), c2.getContext("2d")];
var ctxDice = c3.getContext("2d");
var img = document.getElementsByClassName("shopImg");
var playerDeck = [[],[]];
var p = 0;
window.onload = function(){
for (var j=0; j<ctx.length; j++){
ctx[j].strokeStyle = "red";
for (var i=0; i<=3; i++){
ctx[j].drawImage(img[i+15], 10+105*i, 10, 100, 140);
ctx[j].lineWidth = 5;
ctx[j].moveTo(10+105*i, 10);
ctx[j].lineTo(110+105*i, 150);
ctx[j].stroke();
}
}
buy(0);
buy(2);
advance();
buy(0);
buy(2);
advance();
}
function advance(){
if (p === 1){
p = 0;
}
else {
p++;
}
}
function buy(z){
index = 0;
for (var i=0; i<playerDeck[p].length; i++){
if (playerDeck[p][i][0] < z){
index++;
}
else if (playerDeck[p][i][0] === z){
index = i;
}
}
if (index === playerDeck[p].length){
playerDeck[p].push([z,0]);
}
if (playerDeck[p][index][0] === z){
playerDeck[p][index][1]++;
ctx[p].drawImage(img[z], 10 + 105*(index+4), -10+20*playerDeck[p][index][1], 100, 140);
}
else {
for (var i=index; i<playerDeck[p].length; i++){
ctx[p].clearRect(10+105*(i+4), 10, 100, 140+20*playerDeck[p][i][1]);
}
playerDeck[p].splice(index, 0, [z,1]);
for (var i=index; i<playerDeck[p].length; i++){
for (var j=0; j<playerDeck[p][i][1]; j++){
ctx[p].drawImage(img[playerDeck[p][i][0]], 10+105*(i+4), 10+20*j, 100, 140);
}
}
}
advance();
}
function landmark(z){
ctx[p].clearRect(8+105*z, 8, 104, 144);
ctx[p].drawImage(img[z+15],10+105*z, 10, 100, 140);
}
function closeMenu(){
document.getElementById("bank").style.height = "0";
document.getElementById("open").style.width = "40px";
document.getElementById("dice").style.height = "120px";
}
function openMenu(){
document.getElementById("bank").style.height = "162px";
document.getElementById("open").style.width = "0";
document.getElementById("dice").style.height = "0";
}
function rollDice(){
dice = [Math.floor(Math.random()*6), Math.floor(Math.random()*6)];
total = dice[0] + dice[1];
diceImg = document.getElementsByClassName("diceImg");
for (var i=0; i<dice.length; i++){
ctxDice.clearRect(50+150*i, 10, 100, 100);
ctxDice.drawImage(diceImg[dice[i]], 50+150*i, 10, 100, 100);
}
}
</script>
</body>
</html>