소스 검색

Building tooltips show prod stats

tags/v0.0.1
Fen Dweller 7 년 전
부모
커밋
464a7b277a
No known key found for this signature in database GPG 키 ID: E80B35A6F11C3656
2개의 변경된 파일29개의 추가작업 그리고 1개의 파일을 삭제
  1. +2
    -1
      gorge.css
  2. +27
    -0
      gorge.js

+ 2
- 1
gorge.css 파일 보기

@@ -90,7 +90,8 @@ body.dark {
} }


#building-tooltip-prod { #building-tooltip-prod {
font-size: 20px;
font-size: 14px;
color: #ccc;
margin: 10px; margin: 10px;
} }




+ 27
- 0
gorge.js 파일 보기

@@ -70,6 +70,8 @@ function buyBuilding(type) {
resources.food -= cost; resources.food -= cost;
} }


updateProductivity();

} }
// update stuff // update stuff


@@ -495,6 +497,29 @@ function upgradeTooltipRemove() {
tooltip.style.setProperty("display", "none"); tooltip.style.setProperty("display", "none");
} }


function prodSummary(id) {
let list = [];

list.push(
{"text": "Each " + buildings[id].name + " produces " + round(productivityMultiplierOf(id) * buildings[id].prod,1) + " food/sec"}
);

list.push(
{"text": "Your " + belongings[id].count + " " + (belongings[id].count == 1 ? buildings[id].name + " is": buildings[id].plural + " are") + " producing " + round(productivityOf(id),1) + " food/sec"}
);

let percentage = round(100 * productivityOf(id) / currentProductivity["food"], 2);

if (isNaN(percentage)) {
percentage = 0;
}
list.push(
{"text": "(" + percentage + "% of all food)"}
);

return renderLines(list);
}

function buildingTooltip(id, event) { function buildingTooltip(id, event) {


let tooltip = document.querySelector("#building-tooltip"); let tooltip = document.querySelector("#building-tooltip");
@@ -503,6 +528,8 @@ function buildingTooltip(id, event) {
fillTooltip("building", "name", buildings[id].name); fillTooltip("building", "name", buildings[id].name);
fillTooltip("building", "desc", buildings[id].desc); fillTooltip("building", "desc", buildings[id].desc);
fillTooltip("building", "cost", costOfBuilding(id) + " food"); fillTooltip("building", "cost", costOfBuilding(id) + " food");
fillTooltip("building", "prod", prodSummary(id));

let yOffset = tooltip.parentElement.getBoundingClientRect().y; let yOffset = tooltip.parentElement.getBoundingClientRect().y;


let xPos = tooltip.parentElement.getBoundingClientRect().x - 450; let xPos = tooltip.parentElement.getBoundingClientRect().x - 450;


불러오는 중...
취소
저장