1+ using System . Collections . Generic ;
2+
3+ namespace WinFormsApp1 . Events
4+ {
5+ /// <summary>
6+ /// Event published when player moves to a new location
7+ /// </summary>
8+ public class LocationChangedEvent : GameEvent
9+ {
10+ public Player Player { get ; set ; }
11+ public Location PreviousLocation { get ; set ; }
12+ public Location NewLocation { get ; set ; }
13+ public string MovementDirection { get ; set ; }
14+ public bool IsFirstVisit { get ; set ; }
15+
16+ public override int Priority => 10 ; // High priority
17+
18+ public LocationChangedEvent ( Player player , Location previousLocation , Location newLocation , string movementDirection = "" , bool isFirstVisit = false )
19+ {
20+ Player = player ;
21+ PreviousLocation = previousLocation ;
22+ NewLocation = newLocation ;
23+ MovementDirection = movementDirection ;
24+ IsFirstVisit = isFirstVisit ;
25+ Source = "LocationManager" ;
26+ }
27+ }
28+
29+ /// <summary>
30+ /// Event published when a random encounter occurs
31+ /// </summary>
32+ public class RandomEncounterEvent : GameEvent
33+ {
34+ public Player Player { get ; set ; }
35+ public Location Location { get ; set ; }
36+ public Enemy Enemy { get ; set ; }
37+ public double EncounterChance { get ; set ; }
38+ public bool WasTriggered { get ; set ; }
39+
40+ public override int Priority => 9 ; // High priority
41+
42+ public RandomEncounterEvent ( Player player , Location location , Enemy enemy , double encounterChance , bool wasTriggered = true )
43+ {
44+ Player = player ;
45+ Location = location ;
46+ Enemy = enemy ;
47+ EncounterChance = encounterChance ;
48+ WasTriggered = wasTriggered ;
49+ Source = "LocationManager" ;
50+ }
51+ }
52+
53+ /// <summary>
54+ /// Event published when player picks up an item from a location
55+ /// </summary>
56+ public class ItemPickedUpEvent : GameEvent
57+ {
58+ public Player Player { get ; set ; }
59+ public Location Location { get ; set ; }
60+ public Item Item { get ; set ; }
61+ public bool WasSuccessful { get ; set ; }
62+ public string FailureReason { get ; set ; }
63+
64+ public ItemPickedUpEvent ( Player player , Location location , Item item , bool wasSuccessful , string failureReason = "" )
65+ {
66+ Player = player ;
67+ Location = location ;
68+ Item = item ;
69+ WasSuccessful = wasSuccessful ;
70+ FailureReason = failureReason ;
71+ Source = "LocationManager" ;
72+ }
73+ }
74+
75+ /// <summary>
76+ /// Event published when player drops an item at a location
77+ /// </summary>
78+ public class ItemDroppedEvent : GameEvent
79+ {
80+ public Player Player { get ; set ; }
81+ public Location Location { get ; set ; }
82+ public Item Item { get ; set ; }
83+ public bool WasSuccessful { get ; set ; }
84+ public string FailureReason { get ; set ; }
85+
86+ public ItemDroppedEvent ( Player player , Location location , Item item , bool wasSuccessful , string failureReason = "" )
87+ {
88+ Player = player ;
89+ Location = location ;
90+ Item = item ;
91+ WasSuccessful = wasSuccessful ;
92+ FailureReason = failureReason ;
93+ Source = "LocationManager" ;
94+ }
95+ }
96+
97+ /// <summary>
98+ /// Event published when player searches a location
99+ /// </summary>
100+ public class LocationSearchedEvent : GameEvent
101+ {
102+ public Player Player { get ; set ; }
103+ public Location Location { get ; set ; }
104+ public List < Item > ItemsFound { get ; set ; }
105+ public bool WasSuccessful { get ; set ; }
106+ public string SearchResult { get ; set ; }
107+
108+ public LocationSearchedEvent ( Player player , Location location , List < Item > itemsFound , bool wasSuccessful , string searchResult = "" )
109+ {
110+ Player = player ;
111+ Location = location ;
112+ ItemsFound = itemsFound ?? new List < Item > ( ) ;
113+ WasSuccessful = wasSuccessful ;
114+ SearchResult = searchResult ;
115+ Source = "LocationManager" ;
116+ }
117+ }
118+
119+ /// <summary>
120+ /// Event published when movement is attempted but fails
121+ /// </summary>
122+ public class MovementFailedEvent : GameEvent
123+ {
124+ public Player Player { get ; set ; }
125+ public Location CurrentLocation { get ; set ; }
126+ public string AttemptedDirection { get ; set ; }
127+ public string AttemptedLocationKey { get ; set ; }
128+ public string FailureReason { get ; set ; }
129+
130+ public MovementFailedEvent ( Player player , Location currentLocation , string attemptedDirection , string attemptedLocationKey , string failureReason )
131+ {
132+ Player = player ;
133+ CurrentLocation = currentLocation ;
134+ AttemptedDirection = attemptedDirection ;
135+ AttemptedLocationKey = attemptedLocationKey ;
136+ FailureReason = failureReason ;
137+ Source = "LocationManager" ;
138+ }
139+ }
140+
141+ /// <summary>
142+ /// Event published when locations are loaded from data
143+ /// </summary>
144+ public class LocationsLoadedEvent : GameEvent
145+ {
146+ public int LocationCount { get ; set ; }
147+ public bool WasSuccessful { get ; set ; }
148+ public string ErrorMessage { get ; set ; }
149+ public List < string > LoadedLocationKeys { get ; set ; }
150+
151+ public override int Priority => 15 ; // Highest priority
152+
153+ public LocationsLoadedEvent ( int locationCount , bool wasSuccessful , string errorMessage = "" , List < string > loadedLocationKeys = null )
154+ {
155+ LocationCount = locationCount ;
156+ WasSuccessful = wasSuccessful ;
157+ ErrorMessage = errorMessage ;
158+ LoadedLocationKeys = loadedLocationKeys ?? new List < string > ( ) ;
159+ Source = "LocationManager" ;
160+ }
161+ }
162+
163+ /// <summary>
164+ /// Event published when a new location is added to the world
165+ /// </summary>
166+ public class LocationAddedEvent : GameEvent
167+ {
168+ public Location Location { get ; set ; }
169+ public bool WasSuccessful { get ; set ; }
170+ public string FailureReason { get ; set ; }
171+
172+ public LocationAddedEvent ( Location location , bool wasSuccessful , string failureReason = "" )
173+ {
174+ Location = location ;
175+ WasSuccessful = wasSuccessful ;
176+ FailureReason = failureReason ;
177+ Source = "LocationManager" ;
178+ }
179+ }
180+
181+ /// <summary>
182+ /// Event published when a location is removed from the world
183+ /// </summary>
184+ public class LocationRemovedEvent : GameEvent
185+ {
186+ public string LocationKey { get ; set ; }
187+ public Location RemovedLocation { get ; set ; }
188+ public bool WasSuccessful { get ; set ; }
189+ public string FailureReason { get ; set ; }
190+
191+ public LocationRemovedEvent ( string locationKey , Location removedLocation , bool wasSuccessful , string failureReason = "" )
192+ {
193+ LocationKey = locationKey ;
194+ RemovedLocation = removedLocation ;
195+ WasSuccessful = wasSuccessful ;
196+ FailureReason = failureReason ;
197+ Source = "LocationManager" ;
198+ }
199+ }
200+
201+ /// <summary>
202+ /// Event published when encounter chance is modified for a location
203+ /// </summary>
204+ public class EncounterChanceChangedEvent : GameEvent
205+ {
206+ public string LocationKey { get ; set ; }
207+ public double OldChance { get ; set ; }
208+ public double NewChance { get ; set ; }
209+ public string ChangedBy { get ; set ; }
210+
211+ public EncounterChanceChangedEvent ( string locationKey , double oldChance , double newChance , string changedBy = "" )
212+ {
213+ LocationKey = locationKey ;
214+ OldChance = oldChance ;
215+ NewChance = newChance ;
216+ ChangedBy = changedBy ;
217+ Source = "LocationManager" ;
218+ }
219+ }
220+ }
0 commit comments