Skip to content

Commit

Permalink
Fixed an issue with unnecessary egg widget details
Browse files Browse the repository at this point in the history
Health, experience and status are no longer displayed for eggs.
  • Loading branch information
varkor committed Feb 28, 2016
1 parent db9f2d0 commit 33e4b82
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 34 deletions.
2 changes: 1 addition & 1 deletion battle/imports.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var paths = [
"scripts/functions/Sound.js",
"scripts/functions/Font.js",
"scripts/objects/unique/FileData.js",
"scripts/data/letants.js",
"scripts/data/constants.js",
"scripts/objects/unique/Input.js",
"scripts/objects/unique/Types.js",
"scripts/objects/unique/Move.js",
Expand Down
2 changes: 1 addition & 1 deletion battle/scripts/objects/unique/Move.js
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ Move.targets = {
noone : [],
closeBy : [Move.target.self, Move.target.directOpponent, Move.target.adjacentAlly, Move.target.adjacentOpponent],

// Special letants
// Special constants
party : {},
opposingSide : {},
alliedSide : {},
Expand Down
64 changes: 32 additions & 32 deletions battle/scripts/objects/unique/Widgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,40 +42,40 @@ Widgets.FlowGrid = {
context.textBaseline = "top";
context.setFontHD("Arial", 8);
context.fillTextHD("Lv. " + poke.level, position.x + size.width / 2, position.y + 4);
}
// Health
var radius, startAngle = 3 / 4 * Math.PI, endAngle;
var percentageHealth = poke.health / poke.maximumHealth();
radius = { outer : 22, inner : 19 };
endAngle = startAngle + percentageHealth * 2 * Math.PI;
context.fillStyle = (percentageHealth > 0.5 ? "hsl(110, 100%, 40%)" : percentageHealth > 0.2 ? "hsl(40, 100%, 50%)" : "hsl(0, 100%, 50%)");
context.beginPath();
context.arcHD(position.x + size.width / 2, position.y + size.height / 2, radius.inner, 2 * Math.PI - startAngle, 2 * Math.PI - endAngle, true);
context.arcHD(position.x + size.width / 2, position.y + size.height / 2, radius.outer, 2 * Math.PI - endAngle, 2 * Math.PI - startAngle, false);
context.fill();
// Experience
var percentageExperience = poke.experience / poke.experienceFromLevelToNextLevel();
radius = { outer : 17, inner : 15 };
endAngle = startAngle + percentageExperience * 2 * Math.PI;
context.fillStyle = poke.health > 0 ? "hsl(190, 100%, 50%)" : "hsl(190, 0%, 50%)";
context.beginPath();
context.arcHD(position.x + size.width / 2, position.y + size.height / 2, radius.inner, 2 * Math.PI - startAngle, 2 * Math.PI - endAngle, true);
context.arcHD(position.x + size.width / 2, position.y + size.height / 2, radius.outer, 2 * Math.PI - endAngle, 2 * Math.PI - startAngle, false);
context.fill();
// Status
if (poke.status !== "none") {
var offset = 2, cornerRadius = 4;
// Health
var radius, startAngle = 3 / 4 * Math.PI, endAngle;
var percentageHealth = poke.health / poke.maximumHealth();
radius = { outer : 22, inner : 19 };
endAngle = startAngle + percentageHealth * 2 * Math.PI;
context.fillStyle = (percentageHealth > 0.5 ? "hsl(110, 100%, 40%)" : percentageHealth > 0.2 ? "hsl(40, 100%, 50%)" : "hsl(0, 100%, 50%)");
context.beginPath();
context.lineToHD(position.x, position.y + size.height / 4);
for (var angle = 0; angle <= 1; angle += 1 / 8) {
context.lineToHD(
position.x + size.width / 2 + (size.width / 2 - cornerRadius) * Math.sign(Math.cos((offset + 0.5) * Math.PI / 2)) + cornerRadius * Math.cos((angle + offset) * Math.PI / 2),
position.y + size.height / 2 + (size.height / 2 - cornerRadius) * Math.sign(Math.sin((offset + 0.5) * Math.PI / 2)) + cornerRadius * Math.sin((angle + offset) * Math.PI / 2)
);
}
context.lineToHD(position.x + size.width / 4, position.y);
context.fillStyle = "hsl(" + ["0, 50%, 50%", "185, 50%, 70%", "55, 70%, 50%", "280, 50%, 50%", "265, 70%, 50%", "0, 0%, 70%"][["burned", "frozen", "paralysed", "poisoned", "badly poisoned", "asleep"].indexOf(poke.status)] + ")";
context.arcHD(position.x + size.width / 2, position.y + size.height / 2, radius.inner, 2 * Math.PI - startAngle, 2 * Math.PI - endAngle, true);
context.arcHD(position.x + size.width / 2, position.y + size.height / 2, radius.outer, 2 * Math.PI - endAngle, 2 * Math.PI - startAngle, false);
context.fill();
// Experience
var percentageExperience = poke.experience / poke.experienceFromLevelToNextLevel();
radius = { outer : 17, inner : 15 };
endAngle = startAngle + percentageExperience * 2 * Math.PI;
context.fillStyle = poke.health > 0 ? "hsl(190, 100%, 50%)" : "hsl(190, 0%, 50%)";
context.beginPath();
context.arcHD(position.x + size.width / 2, position.y + size.height / 2, radius.inner, 2 * Math.PI - startAngle, 2 * Math.PI - endAngle, true);
context.arcHD(position.x + size.width / 2, position.y + size.height / 2, radius.outer, 2 * Math.PI - endAngle, 2 * Math.PI - startAngle, false);
context.fill();
// Status
if (poke.status !== "none") {
var offset = 2, cornerRadius = 4;
context.beginPath();
context.lineToHD(position.x, position.y + size.height / 4);
for (var angle = 0; angle <= 1; angle += 1 / 8) {
context.lineToHD(
position.x + size.width / 2 + (size.width / 2 - cornerRadius) * Math.sign(Math.cos((offset + 0.5) * Math.PI / 2)) + cornerRadius * Math.cos((angle + offset) * Math.PI / 2),
position.y + size.height / 2 + (size.height / 2 - cornerRadius) * Math.sign(Math.sin((offset + 0.5) * Math.PI / 2)) + cornerRadius * Math.sin((angle + offset) * Math.PI / 2)
);
}
context.lineToHD(position.x + size.width / 4, position.y);
context.fillStyle = "hsl(" + ["0, 50%, 50%", "185, 50%, 70%", "55, 70%, 50%", "280, 50%, 50%", "265, 70%, 50%", "0, 0%, 70%"][["burned", "frozen", "paralysed", "poisoned", "badly poisoned", "asleep"].indexOf(poke.status)] + ")";
context.fill();
}
}
// Icon
var redrawOnceLoaded = path => {
Expand Down

0 comments on commit 33e4b82

Please sign in to comment.