mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-19 14:13:48 +01:00
fix any in CotMG helper
This commit is contained in:
parent
55c5190986
commit
7455b80466
@ -13,18 +13,18 @@ export function loadStaneksGift(saveString: string): void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function zeros(dimensions: number[]): any {
|
export function zeros(width: number, height: number): number[][] {
|
||||||
const array = [];
|
const array = [];
|
||||||
|
|
||||||
for (let i = 0; i < dimensions[0]; ++i) {
|
for (let i = 0; i < width; ++i) {
|
||||||
array.push(dimensions.length == 1 ? 0 : zeros(dimensions.slice(1)));
|
array.push(Array(height).fill(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function calculateGrid(gift: IStaneksGift): number[][] {
|
export function calculateGrid(gift: IStaneksGift): number[][] {
|
||||||
const newgrid = zeros([gift.width(), gift.height()]) as unknown as number[][];
|
const newgrid = zeros(gift.width(), gift.height()) as unknown as number[][];
|
||||||
for (let i = 0; i < gift.width(); i++) {
|
for (let i = 0; i < gift.width(); i++) {
|
||||||
for (let j = 0; j < gift.height(); j++) {
|
for (let j = 0; j < gift.height(); j++) {
|
||||||
const fragment = gift.fragmentAt(i, j);
|
const fragment = gift.fragmentAt(i, j);
|
||||||
|
@ -13,7 +13,7 @@ interface IProps {
|
|||||||
|
|
||||||
export function DummyGrid(props: IProps): React.ReactElement {
|
export function DummyGrid(props: IProps): React.ReactElement {
|
||||||
const gift = new DummyGift(props.width, props.height, props.fragments);
|
const gift = new DummyGift(props.width, props.height, props.fragments);
|
||||||
const ghostGrid = zeros([props.width, props.height]);
|
const ghostGrid = zeros(props.width, props.height);
|
||||||
return (
|
return (
|
||||||
<Box>
|
<Box>
|
||||||
<Table sx={{ width: props.width, height: props.height }}>
|
<Table sx={{ width: props.width, height: props.height }}>
|
||||||
|
@ -18,7 +18,7 @@ interface IProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function MainBoard(props: IProps): React.ReactElement {
|
export function MainBoard(props: IProps): React.ReactElement {
|
||||||
const [ghostGrid, setGhostGrid] = React.useState(zeros([props.gift.width(), props.gift.height()]));
|
const [ghostGrid, setGhostGrid] = React.useState(zeros(props.gift.width(), props.gift.height()));
|
||||||
const [pos, setPos] = React.useState([0, 0]);
|
const [pos, setPos] = React.useState([0, 0]);
|
||||||
const [rotation, setRotation] = React.useState(0);
|
const [rotation, setRotation] = React.useState(0);
|
||||||
const [selectedFragment, setSelectedFragment] = React.useState(NoneFragment);
|
const [selectedFragment, setSelectedFragment] = React.useState(NoneFragment);
|
||||||
@ -26,7 +26,7 @@ export function MainBoard(props: IProps): React.ReactElement {
|
|||||||
function moveGhost(worldX: number, worldY: number, rotation: number): void {
|
function moveGhost(worldX: number, worldY: number, rotation: number): void {
|
||||||
setPos([worldX, worldY]);
|
setPos([worldX, worldY]);
|
||||||
if (selectedFragment.type === FragmentType.None || selectedFragment.type === FragmentType.Delete) return;
|
if (selectedFragment.type === FragmentType.None || selectedFragment.type === FragmentType.Delete) return;
|
||||||
const newgrid = zeros([props.gift.width(), props.gift.height()]);
|
const newgrid = zeros(props.gift.width(), props.gift.height());
|
||||||
for (let y = 0; y < selectedFragment.height(rotation); y++) {
|
for (let y = 0; y < selectedFragment.height(rotation); y++) {
|
||||||
for (let x = 0; x < selectedFragment.width(rotation); x++) {
|
for (let x = 0; x < selectedFragment.width(rotation); x++) {
|
||||||
if (!selectedFragment.fullAt(x, y, rotation)) continue;
|
if (!selectedFragment.fullAt(x, y, rotation)) continue;
|
||||||
@ -61,7 +61,7 @@ export function MainBoard(props: IProps): React.ReactElement {
|
|||||||
|
|
||||||
function updateSelectedFragment(fragment: Fragment): void {
|
function updateSelectedFragment(fragment: Fragment): void {
|
||||||
setSelectedFragment(fragment);
|
setSelectedFragment(fragment);
|
||||||
const newgrid = zeros([props.gift.width(), props.gift.height()]);
|
const newgrid = zeros(props.gift.width(), props.gift.height());
|
||||||
setGhostGrid(newgrid);
|
setGhostGrid(newgrid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user