Addtl Attack Logic
parent
80fe797bf7
commit
040954027d
|
@ -454,7 +454,8 @@ class GameFlow {
|
||||||
} else {
|
} else {
|
||||||
responseMessage += `Do you want to:\n1. Hunt\n2. Continue\n\n`
|
responseMessage += `Do you want to:\n1. Hunt\n2. Continue\n\n`
|
||||||
}
|
}
|
||||||
await this.statusUpdate(responseMessage)
|
await this.statusUpdate(this.gameState.lastPrompt + responseMessage)
|
||||||
|
this.gameState.lastPrompt = responseMessage;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -522,7 +523,9 @@ class GameFlow {
|
||||||
let responseMessage = ''
|
let responseMessage = ''
|
||||||
this.gameState.lastPrompt = responseMessage;
|
this.gameState.lastPrompt = responseMessage;
|
||||||
|
|
||||||
if (!userInput || userInput === "") {
|
switch (this.gameState.subPhase) {
|
||||||
|
|
||||||
|
case 0: //Initial Logic
|
||||||
// Check for random encounter
|
// Check for random encounter
|
||||||
// Calculate a factor based on total mileage to adjust encounter likelihood.
|
// Calculate a factor based on total mileage to adjust encounter likelihood.
|
||||||
const mileageFactor = this.gameState.totalMileageWholeTrip / 100 - 4;
|
const mileageFactor = this.gameState.totalMileageWholeTrip / 100 - 4;
|
||||||
|
@ -539,24 +542,21 @@ class GameFlow {
|
||||||
this.gameState.save();
|
this.gameState.save();
|
||||||
return this.executeCurrentPhase();
|
return this.executeCurrentPhase();
|
||||||
}
|
}
|
||||||
|
this.gameState.hostileRiders = false;
|
||||||
|
if (Math.random() < 0.8) this.gameState.hostileRiders = true;
|
||||||
this.gameState.hostilityOfRiders = false;
|
|
||||||
if (Math.random() < 0.8) this.gameState.hostilityOfRiders = true;
|
|
||||||
}
|
|
||||||
if (!userInput || userInput === "" || userInput.toString().toLowerCase() === "start") {
|
|
||||||
responseMessage += `RIDERS AHEAD. THEY`
|
responseMessage += `RIDERS AHEAD. THEY`
|
||||||
if (!this.gameState.hostilityOfRiders) responseMessage += ` DON'T`
|
if (!this.gameState.hostileRiders) responseMessage += ` DON'T`
|
||||||
responseMessage += ` LOOK HOSTILE`;
|
responseMessage += ` LOOK HOSTILE`;
|
||||||
responseMessage += "\n\nTACTICS\n(1) RUN\n(2) ATTACK\n(3) CONTINUE\n(4) CIRCLE WAGONS";
|
responseMessage += "\n\nTACTICS\n(1) RUN\n(2) ATTACK\n(3) CONTINUE\n(4) CIRCLE WAGONS";
|
||||||
|
|
||||||
this.gameState.tacticsChoiceWhenAttacked = 0
|
this.gameState.tacticsChoiceWhenAttacked = 0
|
||||||
this.gameState.lastPrompt = responseMessage;
|
this.gameState.lastPrompt = responseMessage;
|
||||||
|
this.gameState.subPhase = 1;
|
||||||
this.gameState.save();
|
this.gameState.save();
|
||||||
await this.statusUpdate(responseMessage);
|
await this.statusUpdate(responseMessage);
|
||||||
} else {
|
break;
|
||||||
//check if its a valid interger between 1 and 4 inclusive
|
case 1: // Choice
|
||||||
if (isNaN(Number(userInput)) || +userInput < 1 && +userInput > 4) {
|
if (!userInput || isNaN(Number(userInput)) || +userInput < 1 && +userInput > 4) {
|
||||||
|
|
||||||
responseMessage = "Invalid input. Please enter a number between 1-4.\n\n";
|
responseMessage = "Invalid input. Please enter a number between 1-4.\n\n";
|
||||||
responseMessage += this.gameState.lastPrompt;
|
responseMessage += this.gameState.lastPrompt;
|
||||||
|
@ -566,45 +566,100 @@ class GameFlow {
|
||||||
// Convert to integer in case it's not
|
// Convert to integer in case it's not
|
||||||
this.gameState.tacticsChoiceWhenAttacked = Math.floor(+userInput);
|
this.gameState.tacticsChoiceWhenAttacked = Math.floor(+userInput);
|
||||||
// Random chance to flip hostility
|
// Random chance to flip hostility
|
||||||
if (Math.random() > 0.2) this.gameState.hostilityOfRiders = !this.gameState.hostilityOfRiders;
|
if (Math.random() > 0.2) this.gameState.hostileRiders = !this.gameState.hostileRiders;
|
||||||
// Check tactics choice and resolve encounter
|
|
||||||
|
|
||||||
|
// Handle tactics choice
|
||||||
switch (this.gameState.tacticsChoiceWhenAttacked) {
|
switch (this.gameState.tacticsChoiceWhenAttacked) {
|
||||||
case 1: // RUN
|
case 1: // RUN
|
||||||
this.gameState.totalMileageWholeTrip += this.gameState.hostilityOfRiders ? 15 : 20;
|
this.gameState.totalMileageWholeTrip += this.gameState.hostileRiders ? 20 : 15;
|
||||||
this.gameState.amountSpentOnAnimals -= this.gameState.hostilityOfRiders ? 10 : 40;
|
this.gameState.amountSpentOnAnimals -= this.gameState.hostileRiders ? 40 : 10;
|
||||||
this.gameState.amountSpentOnMiscellaneousSupplies -= 15;
|
this.gameState.amountSpentOnMiscellaneousSupplies -= this.gameState.hostileRiders ? 15 : 0;
|
||||||
this.gameState.amountSpentOnAmmunition -= 150;
|
this.gameState.amountSpentOnAmmunition -= this.gameState.hostileRiders ? 150 : 0;
|
||||||
|
|
||||||
this.gameState.phase = PHASE_ENUM.EVENT;
|
this.gameState.phase = PHASE_ENUM.EVENT;
|
||||||
|
this.gameState.subPhase = 0;
|
||||||
this.gameState.save();
|
this.gameState.save();
|
||||||
return this.executeCurrentPhase();
|
return this.executeCurrentPhase();
|
||||||
case 2: // ATTACK
|
case 2: // ATTACK
|
||||||
// Placeholder for attack logic, potentially involving a call to handleShooting()
|
this.gameState.subPhase = 2;
|
||||||
this.handleShooting();
|
this.gameState.save()
|
||||||
// Adjust resources based on the outcome of handleShooting()
|
return this.executeCurrentPhase()
|
||||||
break;
|
|
||||||
case 3: // CONTINUE
|
case 3: // CONTINUE
|
||||||
if (this.gameState.hostilityOfRiders) {
|
if (this.gameState.hostileRiders) {
|
||||||
|
//Penalize lost initiative if riders are hostile
|
||||||
|
this.gameState.lastPrompt = "You continue on cautiously, keeping your guard up. THE RIDERS ATTACK!\n\n";
|
||||||
this.gameState.totalMileageWholeTrip -= 5;
|
this.gameState.totalMileageWholeTrip -= 5;
|
||||||
this.gameState.amountSpentOnAmmunition -= 100;
|
this.gameState.amountSpentOnAmmunition -= 100;
|
||||||
|
this.gameState.subPhase = 2;
|
||||||
|
this.gameState.save()
|
||||||
|
return this.executeCurrentPhase()
|
||||||
}
|
}
|
||||||
// No additional action if riders are friendly
|
// No additional action if riders are friendly
|
||||||
break;
|
this.gameState.lastPrompt = "The riders continue on their way without incident.\n\n";
|
||||||
|
this.gameState.phase = PHASE_ENUM.EVENT;
|
||||||
|
this.gameState.subPhase = 0;
|
||||||
|
this.gameState.save();
|
||||||
|
return this.executeCurrentPhase();
|
||||||
case 4: // CIRCLE WAGONS
|
case 4: // CIRCLE WAGONS
|
||||||
if (this.gameState.hostilityOfRiders) {
|
if (!this.gameState.hostileRiders) {
|
||||||
this.gameState.totalMileageWholeTrip -= 20;
|
this.gameState.totalMileageWholeTrip -= 20;
|
||||||
} else {
|
this.gameState.lastPrompt = "You formed a defensive circle with your wagons. The riders continue on their way without incident.\n\n";
|
||||||
// Possibly a smaller penalty or no action if riders are friendly
|
this.gameState.phase = PHASE_ENUM.EVENT;
|
||||||
this.gameState.totalMileageWholeTrip -= 10;
|
this.gameState.subPhase = 0;
|
||||||
|
this.gameState.save();
|
||||||
|
return this.executeCurrentPhase()
|
||||||
}
|
}
|
||||||
break;
|
this.gameState.subPhase = 4;
|
||||||
|
this.gameState.lastPrompt = "You formed a defensive circle with your wagons.THE RIDERS ATTACK!\n\n"
|
||||||
|
this.gameState.save()
|
||||||
|
return this.executeCurrentPhase()
|
||||||
default:
|
default:
|
||||||
// Handle unexpected input (should be unreachable due to prior validation)
|
// Handle unexpected input (should be unreachable due to prior validation)
|
||||||
console.log("Unexpected tactics choice.");
|
console.log("Unexpected tactics choice.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case 2: // Resolve fight logic
|
||||||
|
responseMessage = this.gameState.lastPrompt
|
||||||
|
responseMessage += this.handleShooting()
|
||||||
|
this.gameState.lastPrompt = responseMessage
|
||||||
|
this.gameState.subPhase = 3
|
||||||
|
await this.statusUpdate(responseMessage)
|
||||||
|
await this.gameState.save()
|
||||||
|
break;
|
||||||
|
case 3: // Resolve fight outcome
|
||||||
|
if (!userInput) {
|
||||||
|
responseMessage = "Invalid input.\n\n"
|
||||||
|
responseMessage += this.gameState.lastPrompt
|
||||||
|
await this.statusUpdate(responseMessage)
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
responseMessage += this.handleShooting(userInput.toString());
|
||||||
|
if (this.gameState.shootResponseTime <= 1) {
|
||||||
|
responseMessage += `NICE SHOOTING---YOU DROVE THEM OFF!!!\n\n`
|
||||||
|
await this.statusUpdate(responseMessage)
|
||||||
|
} else if (this.gameState.shootResponseTime <= 4) {
|
||||||
|
responseMessage += `KINDA SLOW WITH YOUR GUN\n\n`
|
||||||
|
} else {
|
||||||
|
responseMessage += `LOUSY SHOT---YOU GOT KNIFED\nYOU HAVE TO SEE OL' DOC GARY CHESS\n\n`
|
||||||
|
this.gameState.injuryFlag = true
|
||||||
|
}
|
||||||
|
this.gameState.phase = PHASE_ENUM.ACTION_CHOICE;
|
||||||
|
await this.gameState.save();
|
||||||
|
await this.executeCurrentPhase();
|
||||||
|
return;
|
||||||
|
case 4: // Resolve wagon logic
|
||||||
|
responseMessage = this.gameState.lastPrompt
|
||||||
|
responseMessage += this.handleShooting()
|
||||||
|
this.gameState.lastPrompt = responseMessage
|
||||||
|
this.gameState.subPhase = 5
|
||||||
|
await this.statusUpdate(responseMessage)
|
||||||
|
await this.gameState.save()
|
||||||
|
break;
|
||||||
|
case 5: // Resolve wagon outcome
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -615,22 +670,23 @@ class GameFlow {
|
||||||
if (!userInput || userInput.toString().toLowerCase() === "start") {
|
if (!userInput || userInput.toString().toLowerCase() === "start") {
|
||||||
responseMessage += this.handleShooting()
|
responseMessage += this.handleShooting()
|
||||||
await this.statusUpdate(responseMessage)
|
await this.statusUpdate(responseMessage)
|
||||||
|
await this.gameState.save();
|
||||||
} else {
|
} else {
|
||||||
responseMessage += this.handleShooting(userInput.toString());
|
responseMessage += this.handleShooting(userInput.toString());
|
||||||
if (this.gameState.actualResponseTimeForBang <= 1) {
|
if (this.gameState.shootResponseTime <= 1) {
|
||||||
responseMessage += `RIGHT BETWEEN THE EYES---YOU GOT A BIG ONE!!!!\n\n`
|
responseMessage += `RIGHT BETWEEN THE EYES---YOU GOT A BIG ONE!!!!\n\n`
|
||||||
responseMessage += `FULL BELLIES TONIGHT!\n\n`
|
responseMessage += `FULL BELLIES TONIGHT!\n\n`
|
||||||
this.gameState.amountSpentOnFood += 52 + (Math.random() * 6)
|
this.gameState.amountSpentOnFood += 52 + (Math.random() * 6)
|
||||||
this.gameState.amountSpentOnAmmunition -= 10 - (Math.random() * 4)
|
this.gameState.amountSpentOnAmmunition -= 10 - (Math.random() * 4)
|
||||||
await this.statusUpdate(responseMessage)
|
} else if (100 * Math.random() > (13 * this.gameState.shootResponseTime)) {
|
||||||
} else if (100 * Math.random() > (13 * this.gameState.actualResponseTimeForBang)) {
|
|
||||||
responseMessage += `NICE SHOT--RIGHT ON TARGET--GOOD EATIN' TONIGHT!!\n\n`
|
responseMessage += `NICE SHOT--RIGHT ON TARGET--GOOD EATIN' TONIGHT!!\n\n`
|
||||||
this.gameState.amountSpentOnFood += 48 - (2 * this.gameState.actualResponseTimeForBang)
|
this.gameState.amountSpentOnFood += 48 - (2 * this.gameState.shootResponseTime)
|
||||||
this.gameState.amountSpentOnAmmunition -= 10 - (3 * this.gameState.actualResponseTimeForBang)
|
this.gameState.amountSpentOnAmmunition -= 10 - (3 * this.gameState.shootResponseTime)
|
||||||
} else {
|
} else {
|
||||||
responseMessage += `Better luck next time! Maybe practice your aim some more.\n\n`
|
responseMessage += `Better luck next time! Maybe practice your aim some more.\n\n`
|
||||||
this.gameState.amountSpentOnAmmunition -= 50
|
this.gameState.amountSpentOnAmmunition -= 50
|
||||||
}
|
}
|
||||||
|
this.gameState.lastPrompt = responseMessage;
|
||||||
this.gameState.phase = PHASE_ENUM.ACTION_CHOICE;
|
this.gameState.phase = PHASE_ENUM.ACTION_CHOICE;
|
||||||
await this.gameState.save();
|
await this.gameState.save();
|
||||||
await this.executeCurrentPhase();
|
await this.executeCurrentPhase();
|
||||||
|
@ -681,10 +737,10 @@ class GameFlow {
|
||||||
actualResponseTimeForBang = 0;
|
actualResponseTimeForBang = 0;
|
||||||
}
|
}
|
||||||
// Update the game state with the actual response time
|
// Update the game state with the actual response time
|
||||||
this.gameState.actualResponseTimeForBang = actualResponseTimeForBang;
|
this.gameState.shootResponseTime = actualResponseTimeForBang;
|
||||||
} else {
|
} else {
|
||||||
responseMessage += `Your Word was ${this.gameState.shootingWordSelector}. Better luck next time!\n\n`
|
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.shootResponseTime = 9; // Set a high time to indicate a miss
|
||||||
}
|
}
|
||||||
return responseMessage;
|
return responseMessage;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue