-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathscriptShop.js
134 lines (105 loc) · 4.14 KB
/
scriptShop.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
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
var totalDesignCount = 8;
var boughtDesigns = 0;
var chosedDesign = 0;
var cost = [
0,
100,
200,
300,
400,
500,
600,
700
];
var names = [
"Classic",
"Nature",
"Simple",
"Dots",
"Planets",
"Freedom?",
"Animals",
"Wizards"
];
function getMoney(){
if(localStorage.getItem("money") === null){
localStorage.setItem("money",0);
}
document.getElementById("moneyContent").innerHTML = localStorage.getItem("money");
}
function getShopInfo(){
if( localStorage.getItem("chosedDesign")===null ){
localStorage.setItem("chosedDesign",0);
}
if( localStorage.getItem("boughtDesigns")===null ){
localStorage.setItem("boughtDesigns",1);
}
boughtDesigns = localStorage.getItem("boughtDesigns");
chosedDesign = localStorage.getItem("chosedDesign");
getMoney();
}
function chooseDes(i){
if(i<boughtDesigns){
localStorage.setItem("chosedDesign",i);
} else if(i==boughtDesigns){
if(localStorage.getItem("money")>=cost[i] ){
boughtDesigns++;
localStorage.setItem("boughtDesigns",boughtDesigns);
localStorage.setItem( "money" , localStorage.getItem("money") - cost[i] );
//--------------------------------------------------------------------------------------ACHIEVMENT-------------------
var ach4 = store.get('ach_4');
var aPro = ach4.progress;
var aTar = ach4.a_target;
aPro=parseInt(aPro);
aPro+=1;
if(aPro == aTar){
store.set('ach_4', { a_id: '3', finished: true, progress: aPro, a_target: 2 });
var curMoney = localStorage.getItem("money");
curMoney = parseInt(curMoney);
localStorage.setItem("money", curMoney+100 );
}else{
store.set('ach_4', { a_id: '3', finished: true, progress: aPro, a_target: 2 });
}
//--------------------------------------------------------------------------------------------------------------------
}
}
//location.reload();
document.getElementById("previewBox").innerHTML = "";
showDesigns();
}
function showDesigns(){
var catalog = "";
//alert("funk.");
getShopInfo();
for(var i = 0; i<totalDesignCount; i++){
var chosedDes = "";
//var underText = "<b style=\"color: darkgreen;\">Choose</b>";
var underText = "<img width=\"30px\" src=\"images/choose.png\">";
if(i==chosedDesign){
chosedDes = " chosedDesCSS";
//underText = "<b style=\"color: darkgreen;\">Current</b>";
underText = "<img width=\"30px\" src=\"images/current.png\">";
}
var haventBoughtClass = "";
if(i>=boughtDesigns){
underText = "<img width=\"15px\" style=\"display:inline;vertical-align: middle;\" src=\"images/sqoin.png\"> " + cost[i];
haventBoughtClass = " hvntBought";
}
if(i==boughtDesigns) {
//underText = "<img width=\"15px\" style=\"display:inline;vertical-align: middle;\" src=\"images/sqoin.png\"> " + cost[i];
haventBoughtClass = " canBuy";
}
var table = "<table><tr><td><img class=\"previewSquane\" src=\" images/pack" + i + "/square-blue.png \"></img> </td><td><img class=\"previewSquane\" src=\" images/pack" + i + "/square-red.png \"></img> </td></tr><tr><td><img class=\"previewSquane\" src=\" images/pack" + i + "/square-green.png \"></img> </td><td><img class=\"previewSquane\" src=\" images/pack" + i + "/square-yellow.png \"></img> </td></tr></table>";
if(i>boughtDesigns){
table = "<img style='display:table;' width='90px' src='images/lock.png'>"
}
var anotherDesign = "<div onclick=\"chooseDes(" + i + ");\" class=\"designPreviewBox" + chosedDes + haventBoughtClass + "\"> <b>" + names[i] + "</b>" + table + " <span>" + underText + "</span> </div>"; catalog = catalog + anotherDesign;
}
document.getElementById("previewBox").innerHTML = catalog;
}
window.onload = function() {
//alert("ieladets");
setBg();
//alert("bg");
showDesigns();
}