Skip to content

Commit 1c0ef9d

Browse files
Rmojarro1LifeHckr
andauthored
Added relic/note/money to rob text (#233)
* Added relic/note/money to rob text The text should display the name of the relic/note/money taken from the player in paraenthesis. EventTemplate was slightly tweaked to include extra func OutcomeResolver. Adjusted EventDatabase and Event Scene accordingly. * Drastic Simplification One shortcoming with the and the previous version is if locale is changed while these messages are displayed they don't auto change. Doesn't seem to be a good way to accomplish this regardless. * Added support for the wheel results Should work correctly * Finalize Event 2 Text --------- Co-authored-by: LifeHckr <jarodthereal@gmail.com>
1 parent a88abf1 commit 1c0ef9d

2 files changed

Lines changed: 58 additions & 12 deletions

File tree

Classes/Events/EventDatabase.cs

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
/// <summary>
55
/// Holds all game events and their associated logic.
66
/// </summary>
7+
78
public class EventDatabase
89
{
910
public const int EventDatabaseSize = 3;
@@ -22,19 +23,41 @@ public class EventDatabase
2223
0,
2324
StageProducer.PlayerStats.CurNotes.Length - 1
2425
);
26+
var note = StageProducer.PlayerStats.CurNotes[randIndex];
27+
string name = note.Name.ToUpper().Replace(" ", "");
28+
string localizedName = TranslationServer.Translate("NOTE_" + name + "_NAME");
2529
StageProducer.PlayerStats.RemoveNote(randIndex);
30+
31+
self.OutcomeDescriptions[0] = string.Format(
32+
TranslationServer.Translate("EVENT_EVENT1_OUTCOME1"),
33+
localizedName
34+
);
2635
},
2736
(self, node) =>
2837
{
2938
int randIndex = StageProducer.GlobalRng.RandiRange(
3039
0,
3140
StageProducer.PlayerStats.CurRelics.Length - 1
3241
);
42+
var relic = StageProducer.PlayerStats.CurRelics[randIndex];
43+
string name = relic.Name.ToUpper().Replace(" ", "");
44+
string localizedName = TranslationServer.Translate("RELIC_" + name + "_NAME");
3345
StageProducer.PlayerStats.RemoveRelic(randIndex);
46+
47+
self.OutcomeDescriptions[1] = string.Format(
48+
TranslationServer.Translate("EVENT_EVENT1_OUTCOME2"),
49+
localizedName
50+
);
3451
},
3552
(self, node) =>
3653
{
54+
string stolenMoney = (StageProducer.PlayerStats.Money / 2).ToString();
3755
StageProducer.PlayerStats.Money /= 2;
56+
57+
self.OutcomeDescriptions[2] = self.OutcomeDescriptions[0] = string.Format(
58+
TranslationServer.Translate("EVENT_EVENT1_OUTCOME3"),
59+
stolenMoney
60+
);
3861
},
3962
],
4063
GD.Load<Texture2D>("res://Classes/Events/Assets/Bandit_Event.png"),
@@ -68,14 +91,19 @@ public class EventDatabase
6891
.SetEase(Tween.EaseType.Out);
6992

7093
// Defer execution of the outcome until the tween finishes
94+
string eventEffect = "";
7195
tween.TweenCallback(
7296
Callable.From(() =>
7397
{
7498
switch (spinOutcome)
7599
{
76100
case 0:
101+
eventEffect = (StageProducer.PlayerStats.Money / 2).ToString();
77102
StageProducer.PlayerStats.Money /= 2;
78-
self.OutcomeDescriptions[0] = "EVENT_EVENT2_OUTCOME2";
103+
self.OutcomeDescriptions[0] = string.Format(
104+
TranslationServer.Translate("EVENT_EVENT2_OUTCOME2"),
105+
eventEffect
106+
);
79107
break;
80108
case 1:
81109
self.OutcomeDescriptions[0] = "EVENT_EVENT2_OUTCOME3";
@@ -89,22 +117,40 @@ public class EventDatabase
89117
StageProducer.PlayerStats.Money += 50;
90118
break;
91119
case 3:
92-
self.OutcomeDescriptions[0] = "EVENT_EVENT2_OUTCOME5";
93120
StageProducer.PlayerStats.AddNote(
94121
Scribe.GetRandomRewardNotes(1, StageProducer.CurRoom + 10)[
95122
0
96123
]
97124
);
125+
var note = StageProducer.PlayerStats.CurNotes[^1];
126+
string name = note.Name.ToUpper().Replace(" ", "");
127+
eventEffect = TranslationServer.Translate(
128+
"NOTE_" + name + "_NAME"
129+
);
130+
131+
self.OutcomeDescriptions[0] = string.Format(
132+
TranslationServer.Translate("EVENT_EVENT2_OUTCOME5"),
133+
eventEffect
134+
);
98135
break;
99136
case 4:
100-
self.OutcomeDescriptions[0] = "EVENT_EVENT2_OUTCOME6";
101137
StageProducer.PlayerStats.AddRelic(
102138
Scribe.GetRandomRelics(
103139
1,
104140
StageProducer.CurRoom + 10,
105141
StageProducer.PlayerStats.RarityOdds
106142
)[0]
107143
);
144+
145+
var relic = StageProducer.PlayerStats.CurRelics[^1];
146+
string name1 = relic.Name.ToUpper().Replace(" ", "");
147+
eventEffect = TranslationServer.Translate(
148+
"NOTE_" + name1 + "_NAME"
149+
);
150+
self.OutcomeDescriptions[0] = string.Format(
151+
TranslationServer.Translate("EVENT_EVENT2_OUTCOME6"),
152+
eventEffect
153+
);
108154
break;
109155
case 5:
110156
self.OutcomeDescriptions[0] = "EVENT_EVENT2_OUTCOME7";

Globals/Translations/Translations.csv

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -144,19 +144,19 @@ EVENT_EVENT1_DESC,A bandit approaches you.,一个强盗拦住了你。
144144
EVENT_EVENT1_OPTION1,Give them a random note,给他一个随机音符
145145
EVENT_EVENT1_OPTION2,Give them a random relic,给他一件随机遗物
146146
EVENT_EVENT1_OPTION3,Give them half your gold,给他你一半的金币
147-
EVENT_EVENT1_OUTCOME1,You got robbed of a random note.,你被抢走了一个随机音符
148-
EVENT_EVENT1_OUTCOME2,You got robbed of a random relic.,你被抢走了一件随机遗物
149-
EVENT_EVENT1_OUTCOME3,You got robbed of half your gold.,你被抢走了一半金币
147+
EVENT_EVENT1_OUTCOME1,You got robbed of a random note. ({0}),你被抢走了一个随机音符 ({0})
148+
EVENT_EVENT1_OUTCOME2,You got robbed of a random relic.({0}),你被抢走了一件随机遗物 ({0})
149+
EVENT_EVENT1_OUTCOME3,You got robbed of half your gold. ({0}),你被抢走了一半金币 ({0})
150150
EVENT_EVENT2_DESC,There is a wheel with different outcomes.,这里有一个转盘,结果各不相同。
151151
EVENT_EVENT2_OPTION1,Spin the wheel,转动转盘
152152
EVENT_EVENT2_OPTION2,Ignore the cool wheel,忽略这个酷炫的转盘
153153
EVENT_EVENT2_OUTCOME1,You decided not to spin the wheel.,你决定不转动转盘。
154-
EVENT_EVENT2_OUTCOME2,You lost half your money.,你损失了一半的金币。
155-
EVENT_EVENT2_OUTCOME3,You took some damage.,你受到了一些伤害。
156-
EVENT_EVENT2_OUTCOME4,You won a lot of money!,你赢得了很多金币!
157-
EVENT_EVENT2_OUTCOME5,You gained a random note!,你获得了一个随机音符!
158-
EVENT_EVENT2_OUTCOME6,You gained a random relic!,你获得了一件随机遗物!
159-
EVENT_EVENT2_OUTCOME7,You gained some health!,你恢复了一些生命值!
154+
EVENT_EVENT2_OUTCOME2,You lost half your money. ({0}),你损失了一半的金币。({0})
155+
EVENT_EVENT2_OUTCOME3,You took some damage. (10),你受到了一些伤害。(10)
156+
EVENT_EVENT2_OUTCOME4,You won a lot of money! (50),你赢得了很多金币!(50)
157+
EVENT_EVENT2_OUTCOME5,You gained a random note! ({0}),你获得了一个随机音符!({0})
158+
EVENT_EVENT2_OUTCOME6,You gained a random relic ({0})!,你获得了一件随机遗物!({0})
159+
EVENT_EVENT2_OUTCOME7,You gained some health! (20),你恢复了一些生命值!(20)
160160
EVENT_EVENT3_DESC,There is a field medic on the side of the road.,路边有一名战地医生。
161161
EVENT_EVENT3_OPTION1,Receive a bit of healing,接受一些治疗
162162
EVENT_EVENT3_OPTION2,Increase bar charge rate.,提高能量条充能速度

0 commit comments

Comments
 (0)