Merged
Conversation
…st of all pink zones and their owners, can be used to plan the dropping of a bomb
✅ Deploy Preview for dfares-plugins ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
deuchainn
reviewed
Feb 2, 2024
| let lastWorldCoords = null; | ||
| let pzHoveringInList = null; | ||
|
|
||
| import { getPlayerColor } from "https://cdn.skypack.dev/@darkforest_eth/procedural"; |
There was a problem hiding this comment.
Suggested change
| import { getPlayerColor } from "https://cdn.skypack.dev/@darkforest_eth/procedural"; | |
| import { getPlayerColor } from "https://cdn.skypack.dev/@dfares/procedural"; |
- imports should be at the top of the file
- import the from
@dfaresrather than the@darkforest_ethregistry.
deuchainn
reviewed
Feb 2, 2024
Comment on lines
80
to
98
| function FullButtonLine(buttons) { | ||
| let table = document.createElement("table"); | ||
| table.style.textAlign = "center"; | ||
| table.style.width = "100%"; | ||
| table.style.tableLayout = "fixed"; // to make all buttons the same width | ||
| for (let i=0; i < buttons.length; ++i) { | ||
| let b = buttons[i]; | ||
| let td = document.createElement("td"); | ||
| let ele = b.element ? b.element : b; | ||
| ele.style.border = "1px solid white"; | ||
| ele.style.width = "100%"; | ||
| td.style.width = "100%"; // to make all buttons the same width | ||
| td.style.padding = "5px"; | ||
| if (i !== 0) td.style.paddingLeft = "0px"; | ||
| td.append(ele); | ||
| table.append(td); | ||
| } | ||
| return table; | ||
| } |
There was a problem hiding this comment.
Suggested change
| function FullButtonLine(buttons) { | |
| let table = document.createElement("table"); | |
| table.style.textAlign = "center"; | |
| table.style.width = "100%"; | |
| table.style.tableLayout = "fixed"; // to make all buttons the same width | |
| for (let i=0; i < buttons.length; ++i) { | |
| let b = buttons[i]; | |
| let td = document.createElement("td"); | |
| let ele = b.element ? b.element : b; | |
| ele.style.border = "1px solid white"; | |
| ele.style.width = "100%"; | |
| td.style.width = "100%"; // to make all buttons the same width | |
| td.style.padding = "5px"; | |
| if (i !== 0) td.style.paddingLeft = "0px"; | |
| td.append(ele); | |
| table.append(td); | |
| } | |
| return table; | |
| } | |
| function FullButtonLine(buttons) { | |
| const table = document.createElement("table"); | |
| table.style.textAlign = "center"; | |
| table.style.width = "100%"; | |
| table.style.tableLayout = "fixed"; // to make all buttons the same width | |
| let first = true; | |
| for (const button of buttons) { | |
| const td = document.createElement("td"); | |
| const ele = b.element ? b.element : b; | |
| ele.style.border = "1px solid white"; | |
| ele.style.width = "100%"; | |
| td.style.width = "100%"; // to make all buttons the same width | |
| td.style.padding = "5px"; | |
| if (!first) { | |
| td.style.paddingLeft = "0px"; | |
| } | |
| td.append(ele); | |
| table.append(td); | |
| first = false; | |
| } | |
| return table; | |
| } |
deuchainn
reviewed
Feb 2, 2024
Comment on lines
101
to
103
| var tr = document.createElement('tr'); | ||
| for (var str of strArr) { | ||
| var th = document.createElement('th'); |
There was a problem hiding this comment.
Suggested change
| var tr = document.createElement('tr'); | |
| for (var str of strArr) { | |
| var th = document.createElement('th'); | |
| const tr = document.createElement('tr'); | |
| for (const str of strArr) { | |
| const th = document.createElement('th'); |
deuchainn
reviewed
Feb 2, 2024
Comment on lines
112
to
119
| var td = document.createElement('td'); | ||
| td.style.border = "1px solid white"; | ||
| td.innerHTML = text; | ||
| if (width) td.width = width+"px"; | ||
| if (color) td.style.color = color; | ||
| if (center) td.style["text-align"] = "center"; | ||
| tr.appendChild(td); | ||
| return td; |
There was a problem hiding this comment.
Suggested change
| var td = document.createElement('td'); | |
| td.style.border = "1px solid white"; | |
| td.innerHTML = text; | |
| if (width) td.width = width+"px"; | |
| if (color) td.style.color = color; | |
| if (center) td.style["text-align"] = "center"; | |
| tr.appendChild(td); | |
| return td; | |
| const td = document.createElement('td'); | |
| td.style.border = "1px solid white"; | |
| td.innerHTML = text; | |
| if (width) td.width = `${width}px`; | |
| if (color) td.style.color = color; | |
| if (center) td.style["text-align"] = "center"; | |
| tr.appendChild(td); | |
| return td; |
deuchainn
reviewed
Feb 2, 2024
Comment on lines
126
to
127
| } | ||
| function percentToStrHexColor(percent) { |
There was a problem hiding this comment.
Suggested change
| } | |
| function percentToStrHexColor(percent) { | |
| } | |
| function percentToStrHexColor(percent) { |
deuchainn
reviewed
Feb 2, 2024
Comment on lines
129
to
130
| } | ||
| function getPlanetRingRadius(planet, multiplier=1.3, min=minDrawPlanetRadius) { |
There was a problem hiding this comment.
Suggested change
| } | |
| function getPlanetRingRadius(planet, multiplier=1.3, min=minDrawPlanetRadius) { | |
| } | |
| function getPlanetRingRadius(planet, multiplier=1.3, min=minDrawPlanetRadius) { |
spacing between functions
deuchainn
reviewed
Feb 2, 2024
Comment on lines
132
to
135
| let radius = viewport.worldToCanvasDist(ui.getRadiusOfPlanetLevel(planet.planetLevel)); | ||
| radius *= multiplier; | ||
| if (radius < min) radius = min; | ||
| return radius; |
There was a problem hiding this comment.
Suggested change
| let radius = viewport.worldToCanvasDist(ui.getRadiusOfPlanetLevel(planet.planetLevel)); | |
| radius *= multiplier; | |
| if (radius < min) radius = min; | |
| return radius; | |
| const radius = viewport.worldToCanvasDist(ui.getRadiusOfPlanetLevel(planet.planetLevel)) * multiplier; | |
| return radius < min | |
| ? min | |
| : radius; |
nitpick could be simplifed like this.
deuchainn
reviewed
Feb 2, 2024
Comment on lines
141
to
151
| let radius = getPlanetRingRadius(planet); | ||
|
|
||
| let animationDuration = 1500; | ||
| animationDuration *= (1 - level*0.1); | ||
|
|
||
| var millis = Date.now(); | ||
|
|
||
| for (var i=0; i<=level; ++i) { | ||
| drawRingAnimation(ctx, planetX, planetY, radius, millis, animationDuration, color, reverse); | ||
| millis += animationDuration / (level+1); | ||
| } |
There was a problem hiding this comment.
Suggested change
| let radius = getPlanetRingRadius(planet); | |
| let animationDuration = 1500; | |
| animationDuration *= (1 - level*0.1); | |
| var millis = Date.now(); | |
| for (var i=0; i<=level; ++i) { | |
| drawRingAnimation(ctx, planetX, planetY, radius, millis, animationDuration, color, reverse); | |
| millis += animationDuration / (level+1); | |
| } | |
| const radius = getPlanetRingRadius(planet); | |
| const animationDuration = 1500 * (1 - level * 0.1); | |
| let millis = Date.now(); | |
| for (let i = 0; i <= level; ++i) { | |
| drawRingAnimation(ctx, planetX, planetY, radius, millis, animationDuration, color, reverse); | |
| millis += animationDuration / (level+1); | |
| } |
- both
radiusandanimationDurationare constants that never changed - Don't mind the
++istill thei++could also be used. - rather use
letovervarkeyword.
deuchainn
reviewed
Feb 2, 2024
Comment on lines
193
to
194
| let selectedPlanet = ui.getSelectedPlanet(); | ||
| // if (selectedPlanet && pzHoveringInList.locationId === selectedPlanet.locationId) return; |
There was a problem hiding this comment.
Suggested change
| let selectedPlanet = ui.getSelectedPlanet(); | |
| // if (selectedPlanet && pzHoveringInList.locationId === selectedPlanet.locationId) return; |
The selectedPlanet is not used here for anything.
deuchainn
reviewed
Feb 2, 2024
| if (!pzHoveringInList) return; | ||
| let selectedPlanet = ui.getSelectedPlanet(); | ||
| // if (selectedPlanet && pzHoveringInList.locationId === selectedPlanet.locationId) return; | ||
| let color = "hsla(300, 100%, 40%, 0.7)"; |
There was a problem hiding this comment.
Suggested change
| let color = "hsla(300, 100%, 40%, 0.7)"; | |
| const color = "hsla(300, 100%, 40%, 0.7)"; |
immutable variable here.
chore: cleanup
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Features: