Skip to content

Commit

Permalink
Add pipes. Also some data file additions.
Browse files Browse the repository at this point in the history
  • Loading branch information
KirkMcDonald committed Oct 4, 2024
1 parent 37ee79b commit 86e4b55
Show file tree
Hide file tree
Showing 9 changed files with 115 additions and 15 deletions.
12 changes: 10 additions & 2 deletions belt.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class Belt {
}
}

export function getBelts(data) {
function _getBeltsImpl(d) {
let belts = new Map()
for (let belt of data.belts) {
for (let belt of d) {
belts.set(belt.key_name, new Belt(
belt.key_name,
belt.name,
Expand All @@ -34,3 +34,11 @@ export function getBelts(data) {
}
return belts
}

export function getBelts(data) {
return _getBeltsImpl(data.belts)
}

export function getPipes(data) {
return _getBeltsImpl(data.pipes)
}
8 changes: 4 additions & 4 deletions calc.css
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ div#miner_settings, div#alt_recipe_settings {
input.prec {
width: 4em;
}
#belt_selector input[type="radio"] {
.belt-setting input[type="radio"] {
display: none;
}
#belt_selector input[type="radio"] + label {
.belt-setting input[type="radio"] + label {
cursor: pointer;
background: var(--light);
border-radius: 4px;
Expand All @@ -130,10 +130,10 @@ input.prec {
margin: 2px;
padding: 2px;
}
#belt_selector input[type="radio"] + label:hover {
.belt-setting input[type="radio"] + label:hover {
background: var(--bright);
}
#belt_selector input[type="radio"]:checked + label {
.belt-setting input[type="radio"]:checked + label {
background: var(--accent);
}
#recipe_toggles .toggle {
Expand Down
7 changes: 6 additions & 1 deletion calc.html
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,12 @@

<tr class="setting-row">
<td class="setting-label">Belt:</td>
<td><span id="belt_selector"></span></td>
<td><span id="belt_selector" class="belt-setting"></span></td>
</tr>

<tr class="setting-row">
<td class="setting-label">Pipe:</td>
<td><span id="pipe_selector" class="belt-setting"></span></td>
</tr>
</table>
</div>
Expand Down
40 changes: 39 additions & 1 deletion data/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,89 +31,115 @@
"rate": 1200
}
],
"pipes": [
{
"name": "Pipeline Mk.1",
"key_name": "pipe1",
"rate": 300
},
{
"name": "Pipeline Mk.2",
"key_name": "pipe2",
"rate": 600
}
],
"buildings": [
{
"name": "Constructor",
"key_name": "constructor",
"category": "crafting1",
"power": 4,
"somersloop_slots": 1,
"max": 1
},
{
"name": "Assembler",
"key_name": "assembler",
"category": "crafting2",
"power": 15,
"somersloop_slots": 2,
"max": 2
},
{
"name": "Manufacturer",
"key_name": "manufacturer",
"category": "crafting3",
"power": 55,
"somersloop_slots": 4,
"max": 4
},
{
"name": "Smelter",
"key_name": "smelter",
"category": "smelting1",
"power": 4,
"somersloop_slots": 1,
"max": 1
},
{
"name": "Foundry",
"key_name": "foundry",
"category": "smelting2",
"power": 16,
"somersloop_slots": 2,
"max": 2
},
{
"name": "Refinery",
"key_name": "oil-refinery",
"category": "refining",
"power": 30,
"somersloop_slots": 2,
"max": 1
},
{
"name": "Packager",
"key_name": "packager",
"category": "packaging",
"power": 10,
"somersloop_slots": null,
"max": 2
},
{
"name": "Blender",
"key_name": "blender",
"category": "blending",
"power": 75,
"somersloop_slots": 4,
"max": 4
},
{
"name": "Particle Accelerator",
"key_name": "accelerator",
"category": "accelerating",
"power": 0,
"somersloop_slots": 4,
"max": 3
},
{
"name": "Converter",
"key_name": "converter",
"category": "converting",
"power": 0,
"power_range": [100, 400],
"somersloop_slots": 2,
"max": 2
},
{
"name": "Quantum Encoder",
"key_name": "quantum-encoder",
"category": "encoding",
"power": 0,
"power_range": [0, 2000],
"somersloop_slots": 4,
"max": 4
},
{
"name": "Nuclear Power Plant",
"key_name": "nuclear-power-plant",
"category": "nuke-reacting",
"power": 0,
"somersloop_slots": null,
"max": 2
}
],
Expand Down Expand Up @@ -3063,6 +3089,7 @@
"key_name": "plutonium-pellet",
"category": "accelerating",
"time": 60,
"power_range": [250, 750],
"ingredients": [
["non-fissile-uranium", 100],
["uranium-waste", 25]
Expand All @@ -3089,6 +3116,7 @@
"key_name": "alt-plutonium-cell",
"category": "accelerating",
"time": 120,
"power_range": [250, 750],
"ingredients": [
["non-fissile-uranium", 150],
["aluminum-casing", 20]
Expand Down Expand Up @@ -3874,6 +3902,7 @@
"key_name": "nuclear-pasta",
"category": "accelerating",
"time": 120,
"power_range": [500, 1500],
"ingredients": [
["copper-powder", 200],
["pressure-conversion-cube", 1]
Expand Down Expand Up @@ -3978,6 +4007,7 @@
"key_name": "diamonds",
"category": "accelerating",
"time": 2,
"power_range": [250, 750],
"ingredients": [
["coal", 20]
],
Expand All @@ -3990,6 +4020,7 @@
"key_name": "alt-diamonds-petroleum",
"category": "accelerating",
"time": 2,
"power_range": [250, 750],
"ingredients": [
["petroleum-coke", 24]
],
Expand All @@ -4002,6 +4033,7 @@
"key_name": "alt-diamonds-turbo",
"category": "accelerating",
"time": 3,
"power_range": [250, 750],
"ingredients": [
["coal", 30],
["packaged-turbofuel", 2]
Expand All @@ -4015,6 +4047,7 @@
"key_name": "alt-diamonds-oil",
"category": "accelerating",
"time": 3,
"power_range": [250, 750],
"ingredients": [
["crude-oil", 10]
],
Expand All @@ -4027,6 +4060,7 @@
"key_name": "alt-diamonds-cloudy",
"category": "accelerating",
"time": 3,
"power_range": [250, 750],
"ingredients": [
["coal", 12],
["limestone", 24]
Expand All @@ -4038,7 +4072,7 @@
{
"name": "Alternate: Pink Diamonds",
"key_name": "alt-diamonds-pink",
"category": "accelerating",
"category": "converting",
"time": 4,
"ingredients": [
["coal", 8],
Expand Down Expand Up @@ -4139,6 +4173,7 @@
"key_name": "dark-matter-crystal",
"category": "accelerating",
"time": 2,
"power_range": [500, 1500],
"ingredients": [
["diamonds", 1],
["dark-matter-residue", 5]
Expand All @@ -4152,6 +4187,7 @@
"key_name": "alt-dark-matter-crystal",
"category": "accelerating",
"time": 3,
"power_range": [500, 1500],
"ingredients": [
["dark-matter-residue", 10]
],
Expand All @@ -4164,6 +4200,7 @@
"key_name": "alt-dark-matter-trap",
"category": "accelerating",
"time": 2,
"power_range": [500, 1500],
"ingredients": [
["time-crystal", 1],
["dark-matter-residue", 5]
Expand All @@ -4177,6 +4214,7 @@
"key_name": "ficsonium",
"category": "accelerating",
"time": 6,
"power_range": [500, 1500],
"ingredients": [
["plutonium-waste", 1],
["singularity-cell", 1],
Expand Down
11 changes: 9 additions & 2 deletions display.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,18 @@ export function displayItems(spec, totals) {
})
itemRow.selectAll("tt.surplus-rate")
.text(d => spec.format.alignRate(totals.surplus.has(d.item) ? totals.surplus.get(d.item) : zero))
itemRow.selectAll("img.belt-icon")
let beltRow = itemRow.filter(d => d.item.phase === "solid")
beltRow.selectAll("img.belt-icon")
.attr("src", spec.belt.icon.path())
.attr("title", spec.belt.name)
itemRow.selectAll("tt.belt-count")
beltRow.selectAll("tt.belt-count")
.text(d => spec.format.alignCount(spec.getBeltCount(totals.items.get(d.item))))
let pipeRow = itemRow.filter(d => d.item.phase === "fluid")
pipeRow.selectAll("img.belt-icon")
.attr("src", spec.pipe.icon.path())
.attr("title", spec.pipe.name)
pipeRow.selectAll("tt.belt-count")
.text(d => spec.format.alignCount(spec.getPipeCount(totals.items.get(d.item))))
let buildingRow = row.filter(d => d.building !== null)
let buildingCell = buildingRow.selectAll("td.building-icon")
buildingCell.selectAll("*").remove()
Expand Down
9 changes: 8 additions & 1 deletion factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export let resourcePurities = [
export let DEFAULT_PURITY = resourcePurities[1]

export let DEFAULT_BELT = "belt1"
export let DEFAULT_PIPE = "pipe1"

const OVERCLOCK_POWER_EXPONENT = Math.log2(2.5)

Expand All @@ -45,6 +46,7 @@ class FactorySpecification {
this.recipes = null
this.buildings = null
this.belts = null
this.pipes = null

this.itemTiers = []

Expand Down Expand Up @@ -73,7 +75,7 @@ class FactorySpecification {
this.lastMetadata = null
this.lastSolution = null
}
setData(items, recipes, buildings, belts) {
setData(items, recipes, buildings, belts, pipes) {
this.items = items
let tierMap = new Map()
this.defaultDisable = new Set()
Expand Down Expand Up @@ -139,6 +141,8 @@ class FactorySpecification {
}
this.belts = belts
this.belt = belts.get(DEFAULT_BELT)
this.pipes = pipes
this.pipe = belts.get(DEFAULT_PIPE)
this.initMinerSettings()
this.defaultPriority = this.getDefaultPriorityArray()
this.priority = null
Expand Down Expand Up @@ -391,6 +395,9 @@ class FactorySpecification {
getBeltCount(rate) {
return rate.div(this.belt.rate)
}
getPipeCount(rate) {
return rate.div(this.pipe.rate)
}
getPowerUsage(recipe, rate) {
let building = this.getBuilding(recipe)
if (building === null) {
Expand Down
5 changes: 4 additions & 1 deletion fragment.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License.*/
import { DEFAULT_RATE, DEFAULT_RATE_PRECISION, DEFAULT_COUNT_PRECISION } from "./align.js"
import { DEFAULT_TAB, currentTab, DEFAULT_VISUALIZER, visualizerType, DEFAULT_RENDER, visualizerRender } from "./events.js"
import { spec, DEFAULT_PURITY, DEFAULT_BELT } from "./factory.js"
import { spec, DEFAULT_PURITY, DEFAULT_BELT, DEFAULT_PIPE } from "./factory.js"
import { Rational } from "./rational.js"

export function formatSettings() {
Expand All @@ -33,6 +33,9 @@ export function formatSettings() {
if (spec.belt.key !== DEFAULT_BELT) {
settings += "belt=" + spec.belt.key + "&"
}
if (spec.pipe.key !== DEFAULT_PIPE) {
settings += "pipe=" + spec.pipe.key + "&"
}
if (visualizerType !== DEFAULT_VISUALIZER) {
settings += "vt=" + visualizerType + "&"
}
Expand Down
5 changes: 3 additions & 2 deletions init.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.*/
import { getBelts } from "./belt.js"
import { getBelts, getPipes } from "./belt.js"
import { getBuildings } from "./building.js"
import { spec } from "./factory.js"
import { loadSettings } from "./fragment.js"
Expand All @@ -25,7 +25,8 @@ function loadData(settings) {
let recipes = getRecipes(data, items)
let buildings = getBuildings(data)
let belts = getBelts(data)
spec.setData(items, recipes, buildings, belts)
let pipes = getPipes(data)
spec.setData(items, recipes, buildings, belts, pipes)

renderSettings(settings)

Expand Down
Loading

0 comments on commit 86e4b55

Please sign in to comment.