Win Loss Logic - UQcsse3200/2024-studio-3 GitHub Wiki

Overview

The Win/Loss logic is an essential mechanic in the game, ensuring players are aware of their success or failure by the conclusion of gameplay. This logic evaluates specific game variables, such as the player’s total money (gold), to determine if a win or loss condition has been met. The mechanic is triggered at the end of each in-game day, checking whether the player has either met their monetary goal (win) or fallen below a minimum threshold (lose). Originally, the check win/loss logic was configured for a one-day game, but it has now been expanded to span multiple days with increasing complexity in gameplay mechanics.

Key Features

CheckWinLoseComponent

The CheckWinLoseComponent is the core class responsible for determining if a player has won or lost. It pulls key variables like the player's gold and compares them against pre-set thresholds.

Win Condition: Triggered if the player's total gold equals or exceeds the win amount.

Lose Condition: Triggered if the player's gold falls below the lose threshold.

Multi-Day Progression

The Win/Loss logic has been extended to support multi-day gameplay. This multi-day structure has been primarily implemented in DayNightService. This new system evaluates the player's progress across five in-game days, with progressively increasing gold thresholds. A loss can be triggered on any day if the player's gold falls below the daily required threshold, while the win condition is only evaluated at the end of Day 5.

Daily Loss Condition: If the player does not meet the required gold (e.g., 55 gold on Day 1, 70 gold on Day 2), they will lose at the end of that day.

Daily Progression: If the player meets or exceeds the daily loss threshold but does not reach the win threshold, they will progress to the next day.

Final Day Win Condition: If the player meets the gold requirement on Day 5, they will win. However, if their gold falls between the win and loss thresholds on Day 5, they will lose.

Game Variables

The system pulls relevant variables such as gold, tracked by the CombatStatsComponent. The player's gold is set in the player.json config, and it updates in real time based on actions like completing an order.

End-of-Day Bonus from High-Quality Meals

The game now includes a feature where high-quality meals contribute to a bonus at the end of each day. This bonus is tallied and applied to the player's gold before the win/loss evaluation.

Bonus Calculation: Each meal with 100% quality will grant an additional 1 gold at the end of the day. For example, three 100%-quality meals will result in a 3-gold bonus.

Bonus Application: This bonus is applied to the player’s total gold before the win/loss condition is evaluated, impacting the final evaluation of the player's status.

Moral Decision Integration

Moral decisions have been integrated into the Win/Loss logic, affecting the final outcome of the game. These decisions are tracked throughout the game but only affect the player at the conclusion, determining whether they receive a good or bad ending if they win.

Effect of Bad Decisions: If the player makes morally "bad" decisions, this is recorded in an array in MoralDecision. If the player wins but has made bad decisions, a bad ending will be triggered.

End-Game Moral Evaluation: If the player wins with only good decisions, they will receive a good ending. If they lose, moral decisions are not factored into the outcome, and a losing cutscene is triggered.

End-of-Day Check

The Win/Loss logic is checked at the end of each day, triggered by the DayNightService. This ensures that players are evaluated daily, allowing them to either progress to the next day or conclude the game based on their gold and decisions. On the final day, both gold thresholds and moral decisions are taken into account for the final win/loss assessment.

Cutscene Integration

Upon triggering a win or lose condition, the system displays the appropriate ending through cutscenes.

Good Ending: Triggered when the player wins and has made only good moral decisions, showing a positive outcome.

Bad Ending: Triggered when the player wins but has made bad moral decisions, showing a negative outcome.

Losing Cutscene (Morality Ignored): If the player loses by failing to meet the gold threshold on any day, a losing cutscene is triggered. In this case, the player's moral decisions are ignored, and the game immediately plays a negative ending cutscene to signify failure.

UML (Core Flow)

win_loss_uml_diagram_updated (1)

Enhanced Integration into Game

In Sprint 4, improvements were made to fully integrate the win/loss system and 5-day game logic, ensuring seamless gameplay progression and evaluation. These changes focused on linking the PlayerStatsDisplay and DayNightService for correct day iteration, resolving bugs related to day progression, and ensuring compatibility with the newly updated moral decision system.

Key Enhancements

Linking PlayerStatsDisplay and DayNightService:The PlayerStatsDisplay and DayNightService systems were previously operating independently, causing inconsistencies in day iteration. This enhancement integrated these systems, ensuring that in-game days increment correctly as the player progresses, and allowing accurate win/loss checks at the end of each day.

Day Iteration Bug Fixes: Several issues were identified where game days did not increment correctly. These were resolved by linking the day iteration logic between PlayerStatsDisplay and DayNightService and updating the associated tests in DayNightServiceTest.java to reflect these changes.

Consultation with Team 8: We worked closely with the Moral System team to adjust for their new approach to the Moral System. Since the MoralDecisionDisplay was previously essential to the end-of-day flow, its removal required reworking the dependencies between the moral decisions and win/loss logic. This ensured the moral decisions were still accounted for in the final game outcome, maintaining the integrity of the win/loss logic.

Summary

This enhanced integration ties together the gameplay systems responsible for day iteration, win/loss evaluation, and moral decisions, ensuring they operate seamlessly as part of the game’s core mechanics. By resolving day iteration issues and aligning with changes to the moral decision system, this update improves both functionality and player experience.