Skip to content

Commit ffb119b

Browse files
cornerloanLifeHckr
authored andcommitted
2 events, events now have self reference 🍝
Added parmesan to the spaghetti
1 parent 67ebf13 commit ffb119b

4 files changed

Lines changed: 84 additions & 8 deletions

File tree

Classes/Events/EventDatabase.cs

Lines changed: 66 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,23 @@ public partial class EventDatabase
1515
["EVENT_EVENT1_OPTION1", "EVENT_EVENT1_OPTION2", "EVENT_EVENT1_OPTION3"],
1616
["EVENT_EVENT1_OUTCOME1", "EVENT_EVENT1_OUTCOME2", "EVENT_EVENT1_OUTCOME3"],
1717
[
18-
() =>
18+
(self) =>
1919
{
2020
int randIndex = StageProducer.GlobalRng.RandiRange(
2121
0,
2222
StageProducer.PlayerStats.CurNotes.Length
2323
);
2424
StageProducer.PlayerStats.RemoveNote(randIndex);
2525
},
26-
() =>
26+
(self) =>
2727
{
2828
int randIndex = StageProducer.GlobalRng.RandiRange(
2929
0,
3030
StageProducer.PlayerStats.CurRelics.Length
3131
);
3232
StageProducer.PlayerStats.RemoveRelic(randIndex);
3333
},
34-
() =>
34+
(self) =>
3535
{
3636
StageProducer.PlayerStats.Money /= 2;
3737
},
@@ -43,5 +43,68 @@ public partial class EventDatabase
4343
() => StageProducer.PlayerStats.Money > 0,
4444
]
4545
),
46+
new EventTemplate(
47+
1,
48+
"EVENT_EVENT2_DESC",
49+
["EVENT_EVENT2_OPTION1", "EVENT_EVENT2_OPTION2"],
50+
["", "EVENT_EVENT1_OUTCOME1"],
51+
[
52+
(self) =>
53+
{
54+
StageProducer.PlayerStats.Money -= 20;
55+
// [do nothing, get money back, win money, get note, get relic, heal]
56+
int spinOutcome = (int)
57+
StageProducer.GlobalRng.RandWeighted([13, 8, 5, 5, 3, 3]);
58+
switch (spinOutcome)
59+
{
60+
case 0: //do nothing AKA lose
61+
GD.Print("owned lol");
62+
self.OutcomeDescriptions[0] = "EVENT_EVENT1_OUTCOME2";
63+
break;
64+
case 1: // get money back
65+
GD.Print("refund");
66+
self.OutcomeDescriptions[0] = "EVENT_EVENT1_OUTCOME3";
67+
StageProducer.PlayerStats.Money += 20;
68+
break;
69+
case 2: // get triple money
70+
GD.Print("triple money");
71+
self.OutcomeDescriptions[0] = "EVENT_EVENT1_OUTCOME4";
72+
StageProducer.PlayerStats.Money += 60;
73+
break;
74+
case 3: // get random note
75+
GD.Print("random note");
76+
self.OutcomeDescriptions[0] = "EVENT_EVENT1_OUTCOME5";
77+
StageProducer.PlayerStats.AddNote(
78+
Scribe.GetRandomRewardNotes(1, StageProducer.CurRoom + 10)[0]
79+
);
80+
break;
81+
case 4: // get random relic
82+
GD.Print("random relic");
83+
self.OutcomeDescriptions[0] = "EVENT_EVENT1_OUTCOME6";
84+
StageProducer.PlayerStats.AddRelic(
85+
Scribe.GetRandomRelics(
86+
1,
87+
StageProducer.CurRoom + 10,
88+
StageProducer.PlayerStats.RarityOdds
89+
)[0]
90+
);
91+
break;
92+
case 5:
93+
GD.Print("heal");
94+
self.OutcomeDescriptions[0] = "EVENT_EVENT1_OUTCOME7";
95+
StageProducer.PlayerStats.CurrentHealth = Math.Max(
96+
StageProducer.PlayerStats.CurrentHealth + 20,
97+
StageProducer.PlayerStats.MaxHealth
98+
);
99+
break;
100+
}
101+
},
102+
(self) => {
103+
//does nothing
104+
},
105+
],
106+
GD.Load<Texture2D>("res://Classes/Events/Assets/TEMP.png"),
107+
[() => StageProducer.PlayerStats.Money > 20, () => true]
108+
),
46109
};
47110
}

Classes/Events/EventTemplate.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using FunkEngine;
33
using Godot;
44

5-
public delegate void EventAction();
5+
public delegate void EventAction(EventTemplate self);
66
public delegate bool EventCondition();
77

88
public partial class EventTemplate

Globals/Translations/Translations.csv

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,4 +134,14 @@ EVENT_EVENT1_OPTION2,"Give them a random relic",(TODO)
134134
EVENT_EVENT1_OPTION3,"Give them half your gold",(TODO)
135135
EVENT_EVENT1_OUTCOME1,"You got robbed of a random note.",(TODO)
136136
EVENT_EVENT1_OUTCOME2,"You got robbed of a random relic.",(TODO)
137-
EVENT_EVENT1_OUTCOME3,"You got robbed of half your gold.",(TODO)
137+
EVENT_EVENT1_OUTCOME3,"You got robbed of half your gold.",(TODO)
138+
EVENT_EVENT2_DESC,"There is a slot machine.",(TODO)
139+
EVENT_EVENT2_OPTION1,"Pay 20g to spin",(TODO)
140+
EVENT_EVENT2_OPTION2,"Ignore the machine",(TODO)
141+
EVENT_EVENT1_OUTCOME1,"You saved your money and moved on.",(TODO)
142+
EVENT_EVENT1_OUTCOME2,"You lost your money.",(TODO)
143+
EVENT_EVENT1_OUTCOME3,"You refunded your money.",(TODO)
144+
EVENT_EVENT1_OUTCOME4,"You tripled your money.",(TODO)
145+
EVENT_EVENT1_OUTCOME5,"You gained a random note.",(TODO)
146+
EVENT_EVENT1_OUTCOME6,"You gained a random relic.",(TODO)
147+
EVENT_EVENT1_OUTCOME7,"You gained some health.",(TODO)

Scenes/EventScene/EventScene.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,11 @@ public override void _Ready()
3939
_player = GD.Load<PackedScene>(PlayerPuppet.LoadPath).Instantiate<PlayerPuppet>();
4040
PlayerMarker.AddChild(_player);
4141

42-
//int eventIndex = StageProducer.GlobalRng.RandiRange(0, EventDatabase.EventDictionary.Length);
43-
_eventReference = EventDatabase.EventDictionary[0];
42+
int eventIndex = StageProducer.GlobalRng.RandiRange(
43+
0,
44+
EventDatabase.EventDictionary.Length - 1
45+
);
46+
_eventReference = EventDatabase.EventDictionary[eventIndex];
4447
DisplayEvent();
4548
}
4649

@@ -82,7 +85,7 @@ public void DisplayEvent()
8285
button.Pressed += () =>
8386
{
8487
GD.Print($"Selected option: {_eventReference.ButtonDescriptions[capturedIndex]}");
85-
_eventReference.OptionActions[capturedIndex]?.Invoke();
88+
_eventReference.OptionActions[capturedIndex]?.Invoke(_eventReference);
8689
AnyButtonPressed(capturedIndex);
8790
};
8891

0 commit comments

Comments
 (0)