瀏覽代碼

Building button costs turn green/red

tags/v0.0.1
Fen Dweller 7 年之前
父節點
當前提交
802d681b4d
沒有發現已知的金鑰在資料庫的簽署中 GPG 金鑰 ID: E80B35A6F11C3656
共有 2 個檔案被更改,包括 17 行新增4 行删除
  1. +10
    -2
      gorge.css
  2. +7
    -2
      gorge.js

+ 10
- 2
gorge.css 查看文件

@@ -126,7 +126,7 @@ button {
color: #999; color: #999;
} }


.building-button .building-button-name {
.building-button-name {
font-size: 24px; font-size: 24px;
position: absolute; position: absolute;
left: 10%; left: 10%;
@@ -135,13 +135,21 @@ button {
-moz-user-select: none; -moz-user-select: none;
} }


.building-button .building-button-cost {
.building-button-cost {
font-size: 18px; font-size: 18px;
position: absolute; position: absolute;
left: 10%; left: 10%;
bottom: 15%; bottom: 15%;
} }


.building-button-cost-invalid {
color: #f22;
}

.building-button-cost-valid {
color: #1a1;
}

.building-button:hover { .building-button:hover {
background-color: #333; background-color: #333;
} }


+ 7
- 2
gorge.js 查看文件

@@ -142,13 +142,18 @@ function displayBuildings() {


let button = document.querySelector("#building-" + key); let button = document.querySelector("#building-" + key);


document.querySelector("#building-" + key + " > .building-button-name").innerText = value.count + " " + (value.count == 1 ? buildings[key].name : buildings[key].plural);
document.querySelector("#building-" + key + " > .building-button-cost").innerText = costOfBuilding(key) + " food";
let name = document.querySelector("#building-" + key + " > .building-button-name");
let cost = document.querySelector("#building-" + key + " > .building-button-cost");

name.innerText = value.count + " " + (value.count == 1 ? buildings[key].name : buildings[key].plural);
cost.innerText = render(costOfBuilding(key)) + " food";


if (costOfBuilding(key) > resources.food) { if (costOfBuilding(key) > resources.food) {
button.classList.add("building-button-disabled"); button.classList.add("building-button-disabled");
cost.classList.add("building-button-cost-invalid");
} else { } else {
button.classList.remove("building-button-disabled"); button.classList.remove("building-button-disabled");
cost.classList.add("building-button-cost-valid");
} }
} }
} }


Loading…
取消
儲存