Skip to content

Commit ca3539b

Browse files
committed
(Update) New Unity Build, Query Update
1 parent ed69b07 commit ca3539b

5 files changed

Lines changed: 65 additions & 18226 deletions

File tree

Sustainability Software/Assets/Scripts/Managers/ChallengeManager.cs

Lines changed: 58 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ public class ChallengeManager : MonoBehaviour
3535
[SerializeField] private GameObject bossBubble;
3636

3737
[Header("Health Settings")]
38-
[SerializeField] private float maxDeveloperHealth = 100f;
39-
[SerializeField] private float maxBossHealth = 100f;
40-
4138
[SerializeField] private float bossDamage = 25f;
4239
[SerializeField] private float smallPlayerDamage = 20f;
4340
[SerializeField] private float bigPlayerDamage = 30f;
@@ -55,6 +52,12 @@ public class ChallengeManager : MonoBehaviour
5552
private int currentDeveloperIndex = 0;
5653
private int currentQuestionIndex = 0;
5754

55+
private float currentDeveloperHealth;
56+
private float currentBossHealth;
57+
private float maxDeveloperHealth = 100f;
58+
private float maxBossHealth = 100f;
59+
60+
private bool challengeActive = true;
5861
private bool quizLoaded = false;
5962

6063
[Header("Topics")]
@@ -246,73 +249,74 @@ private IEnumerator CheckAnswer(string selectedDeveloper, string selectedStrateg
246249

247250
ApplyOutcome(developerCorrect, strategyCorrect);
248251

249-
developerText.text = "";
250-
developerBubble.SetActive(false);
251-
252-
DialogueManager.Instance.AssignDeveloperUI(bossAnimator, bossAudio);
253-
254-
if (developerCorrect && strategyCorrect)
255-
{
256-
yield return StartCoroutine(DialogueManager.Instance.TypeText(
257-
"Great Idea! " + question.explanation,
258-
questionText
259-
));
260-
}
261-
else
252+
if (challengeActive)
262253
{
263-
string feedback = "I'm not sure on that. ";
254+
developerText.text = "";
255+
developerBubble.SetActive(false);
264256

265-
if (!developerCorrect && !strategyCorrect)
266-
feedback += "I think a different developer and idea could fit for this. ";
267-
else if (!developerCorrect)
268-
feedback += "I think a different developer may be more fit for this question. ";
257+
DialogueManager.Instance.AssignDeveloperUI(bossAnimator, bossAudio);
258+
259+
if (developerCorrect && strategyCorrect)
260+
{
261+
yield return StartCoroutine(DialogueManager.Instance.TypeText(
262+
"Great Idea! " + question.explanation,
263+
questionText
264+
));
265+
}
269266
else
270-
feedback += "Maybe a different strategy could work better here. ";
267+
{
268+
string feedback = "I'm not sure on that. ";
271269

272-
feedback += question.explanation;
270+
if (!developerCorrect && !strategyCorrect)
271+
feedback += "I think a different developer and idea could fit for this. ";
272+
else if (!developerCorrect)
273+
feedback += "I think a different developer may be more fit for this question. ";
274+
else
275+
feedback += "Maybe a different strategy could work better here. ";
273276

274-
yield return StartCoroutine(DialogueManager.Instance.TypeText(feedback, questionText));
275-
}
277+
feedback += question.explanation;
276278

277-
yield return new WaitForSeconds(hearDuration);
279+
yield return StartCoroutine(DialogueManager.Instance.TypeText(feedback, questionText));
280+
}
278281

279-
foreach (var btn in strategyButtons)
280-
btn.interactable = true;
282+
yield return new WaitForSeconds(hearDuration);
281283

282-
StartCoroutine(NextQuestion());
284+
foreach (var btn in strategyButtons)
285+
btn.interactable = true;
286+
287+
yield return StartCoroutine(NextQuestion());
288+
}
283289
}
284290

285-
private void ApplyOutcome(bool developerCorrect, bool strategyCorrect)
291+
private IEnumerator ApplyOutcome(bool developerCorrect, bool strategyCorrect)
286292
{
287-
float newDeveloperHealth = developerBar.value;
288-
float newBossHealth = bossBar.value;
293+
float developerDamage = 0f;
294+
float bossDamageAmount = 0f;
289295

290-
//Correct Developer, Correct Attack
291296
if (developerCorrect && strategyCorrect)
292-
{
293-
newBossHealth -= bossDamage;
294-
}
295-
//Correct Developer, Correct Defend
296-
else if (developerCorrect && !strategyCorrect)
297-
{
298-
newDeveloperHealth -= smallPlayerDamage;
299-
}
300-
//Incorrect Developer, Correct Attack or Defend
297+
bossDamageAmount = bossDamage;
301298
else if (!developerCorrect && strategyCorrect)
302-
{
303-
newDeveloperHealth -= smallPlayerDamage;
304-
}
305-
//Incorrect Developer, Incorrect Attack or Defend
299+
developerDamage = smallPlayerDamage;
300+
else if (developerCorrect && !strategyCorrect)
301+
developerDamage = smallPlayerDamage;
306302
else
307-
{
308-
newDeveloperHealth -= bigPlayerDamage;
309-
}
303+
developerDamage = bigPlayerDamage;
310304

311-
newDeveloperHealth = Mathf.Clamp(newDeveloperHealth, 0, maxDeveloperHealth);
312-
newBossHealth = Mathf.Clamp(newBossHealth, 0, maxBossHealth);
305+
currentDeveloperHealth = Mathf.Clamp(currentDeveloperHealth - developerDamage, 0, maxDeveloperHealth);
306+
currentBossHealth = Mathf.Clamp(currentBossHealth - bossDamageAmount, 0, maxBossHealth);
313307

314-
StartCoroutine(SmoothFill(developerBar, newDeveloperHealth));
315-
StartCoroutine(SmoothFill(bossBar, newBossHealth));
308+
yield return StartCoroutine(SmoothFill(developerBar, currentDeveloperHealth));
309+
yield return StartCoroutine(SmoothFill(bossBar, currentBossHealth));
310+
311+
if (currentDeveloperHealth <= 0)
312+
{
313+
//Failed challenge
314+
challengeActive = false;
315+
yield return StartCoroutine(DialogueManager.Instance.TypeText("I appreciate your help, but I think I might ask another developer for some help. Thanks anyways!", questionText));
316+
yield return new WaitForSeconds(hearDuration);
317+
318+
bossBubble.SetActive(false);
319+
}
316320
}
317321

318322
private IEnumerator NextQuestion()
@@ -325,6 +329,7 @@ private IEnumerator NextQuestion()
325329
}
326330
else
327331
{
332+
//Finished challenge
328333
StartCoroutine(DialogueManager.Instance.TypeText("Great work! Thanks for your help!", questionText));
329334

330335
yield return new WaitForSeconds(hearDuration);

sustainability-vercel/app/api/generate-challenge/route.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ export async function POST(request: Request) {
3939
{
4040
role: "system",
4141
content: `
42-
You are an educational challenge generator for a software sustainability game.
42+
You are an educational challenge generator for a software sustainability game, playing a software engineering company boss.
4343
44-
Your role is to generate boss-style challenges that test strategic understanding of sustainability pillars.
44+
Your role is to generate questions that test strategic understanding of sustainability pillars.
4545
4646
Developers and their pillars:
4747
- environmental: focuses on environmental sustainability
@@ -51,10 +51,10 @@ export async function POST(request: Request) {
5151
5252
Rules:
5353
- Use ONLY the provided context
54-
- Generate conceptual, scenario-based boss questions (not trivia)
55-
- Each question represents a challenge posed by a boss (Use first person)
54+
- Generate conceptual, scenario-based questions (not trivia)
55+
- Each question represents a challenge posed by a software boss (Use first person)
5656
- For each question, generate EXACTLY TWO strategic response options
57-
- Strategies should represent different ways of responding to the boss challenge
57+
- Strategies should represent different ways of responding to the boss question
5858
- The player must choose:
5959
1) ONE developer
6060
2) ONE strategy (A or B)
-37 KB
Binary file not shown.

0 commit comments

Comments
 (0)