Manuel missle fire

This commit is contained in:
aronmal 2022-08-16 11:03:12 +02:00
parent 2ebaccfb2d
commit 4e8de6d7e0
Signed by: aronmal
GPG key ID: 816B7707426FC612
4 changed files with 50 additions and 59 deletions

View file

@ -1,5 +1,28 @@
import { HitType, HitDispatchType } from "./interfaces";
export const borderCN = (count: number, x: number, y: number) => {
if (x === 0)
return 'left';
if (y === 0)
return 'top';
if (x === count+1)
return 'right';
if (y === count+1)
return 'bottom';
return '';
};
export const cornerCN = (count: number, x: number, y: number) => {
if (x === 0 && y === 0)
return 'left-top-corner';
if (x === count+1 && y === 0)
return 'right-top-corner';
if (x === 0 && y === count+1)
return 'left-bottom-corner';
if (x === count+1 && y === count+1)
return 'right-bottom-corner';
return '';
};
export const fieldIndex = (count: number, x: number, y: number) => y*(count+2)+x;
export const hitReducer = (formObject: HitType[], action: HitDispatchType) => {
switch (action.type) {
@ -12,29 +35,6 @@ export const hitReducer = (formObject: HitType[], action: HitDispatchType) => {
return formObject;
}
}
export const fieldIndex = (count: number, x: number, y: number) => y*(count+2)+x;
export const cornerCN = (count: number, x: number, y: number) => {
if (x === 0 && y === 0)
return 'left-top-corner';
if (x === count+1 && y === 0)
return 'right-top-corner';
if (x === 0 && y === count+1)
return 'left-bottom-corner';
if (x === count+1 && y === count+1)
return 'right-bottom-corner';
return '';
};
export const borderCN = (count: number, x: number, y: number) => {
if (x === 0)
return 'left';
if (y === 0)
return 'top';
if (x === count+1)
return 'right';
if (y === count+1)
return 'bottom';
return '';
};
export const initlialTarget = {
show: false,
x: 0,
@ -49,4 +49,5 @@ export const initlialTargetPreview = {
show: false,
x: 0,
y: 0
};
};
export const isHit = (hits: HitType[], x: number, y: number) => hits.filter(h => h.x === x && h.y === y);