mirror of
https://github.com/tcsenpai/fluffles.git
synced 2025-06-03 01:20:03 +00:00
type declaration semantic fixes
This commit is contained in:
parent
d3a19c7989
commit
4c84792f3b
@ -258,7 +258,7 @@ export class Fluffles extends Animal {
|
|||||||
];
|
];
|
||||||
|
|
||||||
// Check each adjacent position for food
|
// Check each adjacent position for food
|
||||||
let bestFoodPosition = null;
|
let bestFoodPosition: Position | null = null;
|
||||||
let bestFoodValue = 0;
|
let bestFoodValue = 0;
|
||||||
|
|
||||||
for (const pos of adjacentPositions) {
|
for (const pos of adjacentPositions) {
|
||||||
@ -309,7 +309,7 @@ export class Fluffles extends Animal {
|
|||||||
|
|
||||||
if (nearbyAnimals.length > 0) {
|
if (nearbyAnimals.length > 0) {
|
||||||
// Find the closest fluffles
|
// Find the closest fluffles
|
||||||
let closestFluffles = null;
|
let closestFluffles: Animal | null = null;
|
||||||
let closestDistance = Infinity;
|
let closestDistance = Infinity;
|
||||||
|
|
||||||
for (const animal of nearbyAnimals) {
|
for (const animal of nearbyAnimals) {
|
||||||
@ -368,7 +368,7 @@ export class Fluffles extends Animal {
|
|||||||
|
|
||||||
if (potentialTargets.length > 0) {
|
if (potentialTargets.length > 0) {
|
||||||
// Find the closest target
|
// Find the closest target
|
||||||
let closestTarget = null;
|
let closestTarget: Animal | null = null;
|
||||||
let closestDistance = Infinity;
|
let closestDistance = Infinity;
|
||||||
|
|
||||||
for (const animal of potentialTargets) {
|
for (const animal of potentialTargets) {
|
||||||
|
@ -181,9 +181,10 @@ export class Rabbit extends Animal {
|
|||||||
private seekCompany(): void {
|
private seekCompany(): void {
|
||||||
const nearbyAnimals = this.world.getAnimalsInRadius(this.position, 3);
|
const nearbyAnimals = this.world.getAnimalsInRadius(this.position, 3);
|
||||||
|
|
||||||
|
let closestRabbit: Animal | null = null;
|
||||||
|
|
||||||
if (nearbyAnimals.length > 0) {
|
if (nearbyAnimals.length > 0) {
|
||||||
// Find the closest rabbit
|
// Find the closest rabbit
|
||||||
let closestRabbit = null;
|
|
||||||
let closestDistance = Infinity;
|
let closestDistance = Infinity;
|
||||||
|
|
||||||
for (const animal of nearbyAnimals) {
|
for (const animal of nearbyAnimals) {
|
||||||
@ -214,6 +215,8 @@ export class Rabbit extends Animal {
|
|||||||
private searchForMates(): void {
|
private searchForMates(): void {
|
||||||
const nearbyAnimals = this.world.getAnimalsInRadius(this.position, 2);
|
const nearbyAnimals = this.world.getAnimalsInRadius(this.position, 2);
|
||||||
|
|
||||||
|
let closestRabbit: Animal | null = null;
|
||||||
|
|
||||||
for (const animal of nearbyAnimals) {
|
for (const animal of nearbyAnimals) {
|
||||||
if (animal.getId() !== this.id) { // Not self
|
if (animal.getId() !== this.id) { // Not self
|
||||||
const pos = animal.getPosition();
|
const pos = animal.getPosition();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user