-
Notifications
You must be signed in to change notification settings - Fork 0
/
myEstate.html
126 lines (124 loc) · 4.28 KB
/
myEstate.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<link rel="stylesheet" href="style.css" />
</head>
<nav>
<button id="backbtn" onclick="window.location.href = 'menu.html' ">
<svg class="svg-icon" viewBox="0 0 20 20">
<path
fill="none"
d="M8.388,10.049l4.76-4.873c0.303-0.31,0.297-0.804-0.012-1.105c-0.309-0.304-0.803-0.293-1.105,0.012L6.726,9.516c-0.303,0.31-0.296,0.805,0.012,1.105l5.433,5.307c0.152,0.148,0.35,0.223,0.547,0.223c0.203,0,0.406-0.08,0.559-0.236c0.303-0.309,0.295-0.803-0.012-1.104L8.388,10.049z"
></path>
</svg>
</button>
<div class="ye">
<p>My real Estate</p>
<p id="count" style="font-size: x-small; color: gray">10.000.000.000</p>
</div>
</nav>
<body>
<p style="height: 10vh"></p>
<div id="myModal" class="modal">
<!-- Modal content -->
<div class="modal-content">
<img id="houseImg" src="" alt="" />
<p id="houseName">houseName</p>
<p id="housePrice">for NaN$?</p>
<p>Rent per minute:</p>
<p id="houseRent"></p>
<br />
<button onclick="upgradeHome()" id="buybtn">Upgrade</button>
<button onclick="lastEstate('-1')">back</button>
</div>
</div>
</body>
<script>
document.getElementById("count").innerHTML =
parseInt(localStorage.getItem("money")).toLocaleString() + "$";
refresh();
function refresh() {
let availableRE;
availableRE = JSON.parse(localStorage.getItem("ownedEstate"));
for (let i = 0; i < availableRE.length; i++) {
btn = document.createElement("div");
btn.innerHTML = `<button id="${i}" onclick="lastEstate(this.id)">
<p style="float: left;">${i}</p>${
availableRE[i].name +
" " +
availableRE[i].price +
"$. Rent per minute: " +
availableRE[i].rentIncome +
"$"
}</button>`;
document.body.appendChild(btn);
}
}
let lastid;
function upgradeHome() {
estates = JSON.parse(localStorage.getItem("ownedEstate"));
if (
parseInt(localStorage.getItem("money")) >=
estates[lastid].rentIncome * 50
) {
localStorage.setItem(
"money",
parseInt(localStorage.getItem("money")) -
estates[lastid].rentIncome * 50
);
estates[lastid].rentIncome = estates[lastid].rentIncome * 1.2;
localStorage.setItem("ownedEstate", JSON.stringify(estates));
document.getElementById("houseRent").innerHTML =
estates[lastid].rentIncome.toLocaleString() + "$";
document.getElementById("buybtn").innerHTML =
"Upgrade " +
upgrades[Math.floor(Math.random() * upgrades.length)] +
" " +
estates[lastid].rentIncome * 50 +
"$";
} else {
alert("insufficient funds!");
}
}
let upgrades = [
"Floor heating",
"Lights",
"Windows",
"TV's",
"Door handles",
"Door mats",
"painting on the wall",
"Furniture",
"some stuff",
"clients",
"Kitchen",
"walls",
];
function lastEstate(id) {
if (document.getElementById("myModal").style.display == "block") {
document.getElementById("myModal").style.display = "none";
} else {
document.getElementById("myModal").style.display = "block";
document.getElementById("myModal").style.display = "block";
estates = JSON.parse(localStorage.getItem("ownedEstate"));
document.getElementById("houseName").innerHTML = estates[id].name;
document.getElementById("houseRent").innerHTML =
estates[id].rentIncome.toLocaleString() + "$";
document.getElementById("housePrice").innerHTML =
"Value: " + estates[id].price.toLocaleString() + "$";
document.getElementById("houseImg").src = estates[id].img;
document.getElementById("buybtn").innerHTML =
"Upgrade " +
upgrades[Math.floor(Math.random() * upgrades.length)] +
" " +
estates[id].rentIncome * 15 +
"$";
lastid = id;
}
}
</script>
</html>