Skip to content

Commit

Permalink
app update & github pages deployment action
Browse files Browse the repository at this point in the history
  • Loading branch information
NesCafe62 committed Mar 5, 2024
1 parent eef84d7 commit d5c3789
Show file tree
Hide file tree
Showing 6 changed files with 196 additions and 27 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Deploy to github pages

on:
push:
branches: [main]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

env:
BUILD_PATH: "."

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
version: "20"
cache: npm
cache-dependency-path: ./package-lock.json

- name: Setup Pages
id: pages
uses: actions/configure-pages@v4

- name: Install dependencies
run: npm ci

- name: Build
run: npm run build

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./dist

deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
needs: build
runs-on: ubuntu-latest
name: Deploy
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
# HiveMind
# HiveMind

Web appllication for creating and sharing StarCraft II build orders

Built with [Pozitron](https://github.com/NesCafe62/vite-pozitron-starter) reactive library

[Try HiveMind app online](https://nescafe62.github.io/HiveMind/)



## Authors

Application ideas and testing by TerYmaX. Developed by NesCafe (U-238)
57 changes: 41 additions & 16 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ function ProductionColumnsData(validateRequirement, columnRemoved, getUnitData,
const [trackColumns, notifyColumns] = voidSignal();

const [trackColumnsData, notifyColumnsData] = voidSignal();
const [trackInvalidItems, notifyInvalidItems] = voidSignal();

const [workersCount, setWorkersCount] = signal(0);

Expand All @@ -59,7 +60,6 @@ function ProductionColumnsData(validateRequirement, columnRemoved, getUnitData,
const timeScale = getTimeScale();

const incomeWidthScale = 4;
let minedMinerals = 50;

const workerIncome = 60;

Expand All @@ -72,7 +72,7 @@ function ProductionColumnsData(validateRequirement, columnRemoved, getUnitData,
color: undefined, id: undefined,
isSpent: false, reminder: INITIAL_MINERALS * INCOME_SCALE_DIV,
isPrevSpent: false,
// spendingHigher: true, spendingPrevHigher: false,
spHigher: false, spNextHigher: false, spLower: true, spNextLower: false,
// key: '', itemsId: ['I'],
}];

Expand Down Expand Up @@ -101,6 +101,7 @@ function ProductionColumnsData(validateRequirement, columnRemoved, getUnitData,
color: undefined, id: undefined,
isSpent: false, reminder: 0,
isPrevSpent: false,
spHigher: false, spNextHigher: false, spLower: true, spNextLower: false,
// spendingHigher: false, spendingPrevHigher: false,
// key: '', itemsId: [itemId],
});
Expand All @@ -113,7 +114,6 @@ function ProductionColumnsData(validateRequirement, columnRemoved, getUnitData,

for (let i = incomeItems.length - 1; i >= 0; i--) {
const incomeItem = incomeItems[i];
// console.log(incomeItem.reminder, incomeItem.time, insertTimeEnd);
if (incomeItem.time > insertTimeEnd) {
continue;
}
Expand Down Expand Up @@ -146,15 +146,15 @@ function ProductionColumnsData(validateRequirement, columnRemoved, getUnitData,
const incomePerMin = incomeItem.incomePerMin;
const available = incomePerMin * (insertTimeEnd - incomeItem.time);

if (available === 0) {
/* if (available === 0) {
console.log('zero height!');
console.log({
insertTimeEnd,
isSpent: incomeItem.isSpent,
incomeItem: {...incomeItem},
incomeItemTime: incomeItem.time,
});
}
} */

let insertTime, unspentReminder = 0;
if (remaining >= available) {
Expand All @@ -176,6 +176,7 @@ function ProductionColumnsData(validateRequirement, columnRemoved, getUnitData,
color: undefined, id: undefined,
isSpent: false, reminder: 0,
isPrevSpent: false,
spHigher: false, spNextHigher: false, spLower: true, spNextLower: false,
});
// need to increment 'i' after
}
Expand All @@ -187,6 +188,7 @@ function ProductionColumnsData(validateRequirement, columnRemoved, getUnitData,
color, id: itemId,
isSpent: true, reminder: unspentReminder,
isPrevSpent: false,
spHigher: false, spNextHigher: false, spLower: true, spNextLower: false,
});

const isLast = (i === incomeItems.length - 1);
Expand All @@ -198,6 +200,7 @@ function ProductionColumnsData(validateRequirement, columnRemoved, getUnitData,
color: undefined, id: undefined,
isSpent: false, reminder: 0,
isPrevSpent: false,
spHigher: false, spNextHigher: false, spLower: true, spNextLower: false,
});
}

Expand All @@ -212,17 +215,15 @@ function ProductionColumnsData(validateRequirement, columnRemoved, getUnitData,
break;
}
}
if (remaining > 0) {
console.log(`Not enough minerals! ${-remaining}`);
}
return remaining;
}

for (const column of columns) {
for (const item of column.items) {
const unitData = getUnitData(item.typeId);
if (unitData.mineralIncome > 0) {
if (unitData.lifeTime > 0) { // temporary income (MULE)
insertIncomeDelta(item.time, unitData.mineralIncome, item.id);
insertIncomeDelta(item.time, unitData.mineralIncome, item.id,);
insertIncomeDelta(item.endTime, -unitData.mineralIncome, -item.id);
} else { // permanent income (workers, SCV-s ...)
insertIncomeDelta(item.endTime, unitData.mineralIncome, item.id);
Expand Down Expand Up @@ -276,7 +277,13 @@ function ProductionColumnsData(validateRequirement, columnRemoved, getUnitData,
workers++;
}
if (unitData.mineralCost > 0) {
insertSpending(item.time, unitData.mineralCost, item.id, Color[unitData.category]);
const remaining = insertSpending(item.time, unitData.mineralCost, item.id, Color[unitData.category]);
if (remaining > 0) {
item.invalid = true;
// console.log(`Not enough minerals! ${-divideInt(remaining, INCOME_SCALE_DIV)}`);
} else {
item.invalid = false;
}
// console.log('insertSpending', item.time, unitData.mineralCost, item.id, Color[unitData.category]);
}
}
Expand All @@ -290,17 +297,30 @@ function ProductionColumnsData(validateRequirement, columnRemoved, getUnitData,
income.isSpent &&
income.id !== lastItem.id
);
income.spHigher = (income.width > lastItem.width); // || isFirst
income.spLower = (
income.width < lastItem.width &&
income.id === lastItem.id
);
lastItem.spNextLower = (
income.width < lastItem.width
);
lastItem.spNextHigher = (
income.width > lastItem.width &&
income.id === lastItem.id
);
lastItem = income;
}
lastItem.isLast = true;
// incomeItems[incomeItems.length - 1].isLast = true;

incomeItems[0].spendingHigher = true;
incomeItems[0].spendingPrevHigher = false;
incomeItems[0].spHigher = true;
// incomeItems[0].spPrevHigher = false;

// console.log(incomeItems);

setWorkersCount(workers);
notifyInvalidItems();

return incomeItems;
}
Expand All @@ -315,6 +335,7 @@ function ProductionColumnsData(validateRequirement, columnRemoved, getUnitData,
item.endTime = endTime;
item.dragging = false;
item.visible = true;
item.invalid = false;
item.fixed = item.fixed || false;
nextItemId++;
return item;
Expand Down Expand Up @@ -370,6 +391,7 @@ function ProductionColumnsData(validateRequirement, columnRemoved, getUnitData,
height: unitData.buildTime * timeScale,
isWide: unitData.isWide || false,
fixed: item.fixed,
invalid: item.invalid,
dragging: item.dragging,
roundedTop: !item.fixed && (!nextItem || (nextItem.time > lastTime)),
roundedBottom: false,
Expand Down Expand Up @@ -481,12 +503,14 @@ function ProductionColumnsData(validateRequirement, columnRemoved, getUnitData,
const item = {
id: nextItemId,
typeId, productionTypeId,
visible, fixed: false,
visible, fixed: false, invalid: false,
name: unitData.name,
time, endTime: time + unitData.buildTime,
dragging: false,
};
nextItemId++;

notifyColumnsData();
column.items.push(item);
column.notify();
if (column.items.length === 1 && isLastColumn(column)) {
Expand All @@ -512,8 +536,6 @@ function ProductionColumnsData(validateRequirement, columnRemoved, getUnitData,
insertColumnAfter(column.secondaryCol, column);
}
}

notifyColumnsData();
}

function deleteElement(items, fn) {
Expand Down Expand Up @@ -883,6 +905,8 @@ function ProductionColumnsData(validateRequirement, columnRemoved, getUnitData,
// };

return {
trackInvalidItems,

workersCount,
columnsData,
getEconomyItems,
Expand Down Expand Up @@ -1072,7 +1096,7 @@ function App() {
[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],
]; */

const { workersCount, columnsData, getEconomyItems, getPrimaryColumn, appendItem, removeItem, dragStartItem, dragMoveItem, dragFinishItem } = ProductionColumnsData(
const { workersCount, columnsData, getEconomyItems, getPrimaryColumn, trackInvalidItems, appendItem, removeItem, dragStartItem, dragMoveItem, dragFinishItem } = ProductionColumnsData(
validateRequirement,
columnRemoved,
getUnitData,
Expand Down Expand Up @@ -1184,6 +1208,7 @@ function App() {
render(ProductionColumns, document.getElementById('production-columns'), {
columns: columnsData,
getPrimaryColumn,
trackInvalidItems,
removeItem: handleRemoveItem,
dragStartItem,
dragMoveItem,
Expand Down
34 changes: 27 additions & 7 deletions src/components/PanelIncome.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,31 @@ function PanelIncome({ getEconomyItems, workersCount }) {
let economyItems;

function setupItems(itemsEl) {
let i = 0;
/* let i = 0;
for (const itemEl of itemsEl) {
const item = economyItems[i];
if (item.spendingHigher) {
if (item.spHigher) {
itemEl.classList.add('spending-item-higher');
} else {
itemEl.classList.remove('spending-item-higher');
}
if (item.spendingPrevHigher) {
itemEl.classList.add('spending-item-prev-higher');
if (item.spLower) {
itemEl.classList.add('spending-item-lower');
} else {
itemEl.classList.remove('spending-item-prev-higher');
itemEl.classList.remove('spending-item-lower');
}
if (item.spNextHigher) {
itemEl.classList.add('spending-item-next-higher');
} else {
itemEl.classList.remove('spending-item-next-higher');
}
if (item.spNextLower) {
itemEl.classList.add('spending-item-next-lower');
} else {
itemEl.classList.remove('spending-item-next-lower');
}
i++;
}
} */
}

const _economyItems = () => (
Expand All @@ -36,12 +46,22 @@ function PanelIncome({ getEconomyItems, workersCount }) {
if (item.isLast) {
return <div
class="spending-item-space-infinite"
classList={{
'spending-item-higher': item.spHigher,
'spending-item-lower': item.spLower,
}}
style={{ flex: '1', width: item.width + 'px' }}
/>;
} else {
return <div
class="spending-item-space"
classList={{ 'spending-item-next': item.isPrevSpent }}
classList={{
'spending-item-next': item.isPrevSpent,
'spending-item-higher': item.spHigher,
'spending-item-lower': item.spLower,
'spending-item-next-higher': item.spNextHigher,
'spending-item-next-lower': item.spNextLower,
}}
style={{
'min-height': item.height + 'px',
width: item.width + 'px',
Expand Down
Loading

0 comments on commit d5c3789

Please sign in to comment.