hunting Logic
parent
1eb158ac10
commit
d87b2e296e
|
@ -33,7 +33,7 @@ class GameFlow {
|
||||||
break;
|
break;
|
||||||
case PHASE_ENUM.HUNT:
|
case PHASE_ENUM.HUNT:
|
||||||
// Handle hunting logic
|
// Handle hunting logic
|
||||||
await this.handleHunt();
|
await this.handleHunt(userInput);
|
||||||
break;
|
break;
|
||||||
case PHASE_ENUM.EATING:
|
case PHASE_ENUM.EATING:
|
||||||
break;
|
break;
|
||||||
|
@ -392,9 +392,21 @@ class GameFlow {
|
||||||
console.log("userInput", userInput);
|
console.log("userInput", userInput);
|
||||||
switch (userInput) {
|
switch (userInput) {
|
||||||
case "1": // Hunt
|
case "1": // Hunt
|
||||||
|
if (this.gameState.amountSpentOnAmmunition < 40) {
|
||||||
|
responseMessage = `You do not have enough ammunition to hunt. Purchase more ammunition first.\n\n`;
|
||||||
|
if (this.gameState.fortOptionFlag) {
|
||||||
|
responseMessage += `Do you want to:\n2. Continue\n3. Stop at the Next Fort\n\n`
|
||||||
|
} else {
|
||||||
|
responseMessage += `Do you want to:\n2. Continue\n\n`
|
||||||
|
}
|
||||||
|
await this.statusUpdate(responseMessage)
|
||||||
|
} else {
|
||||||
this.gameState.phase = PHASE_ENUM.HUNT;
|
this.gameState.phase = PHASE_ENUM.HUNT;
|
||||||
|
this.gameState.totalMileageWholeTrip -= 45;
|
||||||
await this.gameState.save()
|
await this.gameState.save()
|
||||||
this.executeCurrentPhase()
|
this.executeCurrentPhase()
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
break;
|
break;
|
||||||
case "2": // Continue
|
case "2": // Continue
|
||||||
|
@ -461,8 +473,28 @@ class GameFlow {
|
||||||
// Logic for interacting at the fort, such as purchasing supplies
|
// Logic for interacting at the fort, such as purchasing supplies
|
||||||
}
|
}
|
||||||
|
|
||||||
private async handleHunt(): Promise<void> {
|
private async handleHunt(userInput?: string | number): Promise<void> {
|
||||||
// Logic for the hunt phase, possibly determining success based on gameState attributes
|
// Logic for the hunt phase, determining success based on gameState attributes
|
||||||
|
let responseMessage = "";
|
||||||
|
if (!userInput) {
|
||||||
|
responseMessage += this.handleShooting()
|
||||||
|
await this.statusUpdate(responseMessage)
|
||||||
|
} else {
|
||||||
|
responseMessage += this.handleShooting(userInput.toString());
|
||||||
|
if (this.gameState.actualResponseTimeForBang <= 1) {
|
||||||
|
responseMessage += `RIGHT BETWEEN THE EYES---YOU GOT A BIG ONE!!!!\n\n`
|
||||||
|
responseMessage += `FULL BELLIES TONIGHT!\n\n`
|
||||||
|
this.gameState.amountSpentOnFood += 52 + (Math.random() * 6)
|
||||||
|
this.gameState.amountSpentOnAmmunition -= 10 - (Math.random() * 4)
|
||||||
|
await this.statusUpdate(responseMessage)
|
||||||
|
} else if (100 * Math.random() > (13 * this.gameState.actualResponseTimeForBang)) {
|
||||||
|
responseMessage += `NICE SHOT--RIGHT ON TARGET--GOOD EATIN' TONIGHT!!\n\n`
|
||||||
|
this.gameState.amountSpentOnFood += 48 - (2 * this.gameState.actualResponseTimeForBang)
|
||||||
|
this.gameState.amountSpentOnAmmunition -= 10 - (3 * this.gameState.actualResponseTimeForBang)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async handleEncounter(): Promise<void> {
|
private async handleEncounter(): Promise<void> {
|
||||||
|
@ -484,7 +516,7 @@ class GameFlow {
|
||||||
];
|
];
|
||||||
|
|
||||||
// Simulating the shooting subroutine
|
// Simulating the shooting subroutine
|
||||||
private async handleShootingSubRoutine(userInput?: string): Promise<void> {
|
private handleShooting(userInput?: string): string {
|
||||||
|
|
||||||
let responseMessage = ''
|
let responseMessage = ''
|
||||||
|
|
||||||
|
@ -494,8 +526,8 @@ class GameFlow {
|
||||||
this.gameState.shootingWordSelector = this.shootingWordVariations[shootingWordSelector];
|
this.gameState.shootingWordSelector = this.shootingWordVariations[shootingWordSelector];
|
||||||
this.gameState.clockTimeAtStartOfBang = Math.floor(new Date().getTime() / 1000);
|
this.gameState.clockTimeAtStartOfBang = Math.floor(new Date().getTime() / 1000);
|
||||||
//prompt the user to type !!Oregon shootingWord
|
//prompt the user to type !!Oregon shootingWord
|
||||||
responseMessage += `\nQuick! TYPE !!Oregon ${this.gameState.shootingWordSelector} within the next few minutes to hunt the animal. Hurry, time is ticking!\n`;
|
responseMessage += `\nQuick! TYPE !!Oregon ${this.gameState.shootingWordSelector} within the next few minutes. Hurry, time is ticking!\n\n`;
|
||||||
await this.statusUpdate(responseMessage);
|
return responseMessage;
|
||||||
} else {
|
} else {
|
||||||
// Check user input against shooting word
|
// Check user input against shooting word
|
||||||
if (userInput.toUpperCase() === this.gameState.shootingWordSelector) {
|
if (userInput.toUpperCase() === this.gameState.shootingWordSelector) {
|
||||||
|
@ -508,8 +540,10 @@ class GameFlow {
|
||||||
// Update the game state with the actual response time
|
// Update the game state with the actual response time
|
||||||
this.gameState.actualResponseTimeForBang = actualResponseTimeForBang;
|
this.gameState.actualResponseTimeForBang = actualResponseTimeForBang;
|
||||||
} else {
|
} else {
|
||||||
|
responseMessage += `Your Word was ${this.gameState.shootingWordSelector}. Better luck next time!\n\n`
|
||||||
this.gameState.actualResponseTimeForBang = 9; // Set a high time to indicate a miss
|
this.gameState.actualResponseTimeForBang = 9; // Set a high time to indicate a miss
|
||||||
}
|
}
|
||||||
|
return responseMessage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue