Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Event structure #20

Closed
Turtyo opened this issue Dec 15, 2023 · 11 comments · Fixed by #29
Closed

Event structure #20

Turtyo opened this issue Dec 15, 2023 · 11 comments · Fixed by #29
Assignees
Labels
confirmed Has been approved to make code based on this new feature Ask for a new feature

Comments

@Turtyo
Copy link
Collaborator

Turtyo commented Dec 15, 2023

Feature Description

An Event is a description of the content in each Room. It tells us what the encounter is (mystery encounter, mob, boss, shop etc...). Depending on the type of the encounter, it gives more information, for example for mobs it gives the mobs that are in the room. For a random encounter, it gives the chosen encounter.

Motivation

This would be useful to have a place to hold the data of the different encounters. We could put it directly in the room in itself, but i think it's better to have separated, since it will probably be easier to test and debug that way.

Acceptance Criteria

  • The Event can be modified at runtime (due to dependence to the light level)
  • We can easily differentiate between different possible events
  • Hierarchy between events depending on light level is clear
  • A room event can't change anymore once the player went above the level of the room containing the event

Proposed Solution

The Event class in itself is the parent of possible events. So we would have Event_mob, Event_shop, Event_heal etc... as extending from the Event class.
The event is only chosen when it enters player view (because they used a torch or just that they are next to it). The Event holds an array of the level depending on light value.
For example if at light 0 we have a mob, at light 1 we have a random event and at light 2 we have a shop, it looks like this [Event_mob, Event_random, Event_shop].

Note that this doesn't mean we will necessarily have a mob at light level 0, it just explains which event you go to when light increases/decreases. We could have a random event at light 0, thus when we get to light level 1 we get a shop (because it's the next one in the list).

The choice of the event will probably be handled at map level, because it will have a global vision and can distribute events better.

Additional Context

In link with #6 and #10

@Turtyo Turtyo added the new feature Ask for a new feature label Dec 15, 2023
This was referenced Dec 15, 2023
@cheesefrycook
Copy link
Collaborator

So each Event would contain an array of Events? I think it makes more sense to store that array in the Room, since the Room knows about the light level.

Other than that this looks good to me. I think Event can extend from Resource, then each child Event could do whatever logic it wants. I imagine each Event type will load a unique type of scene with some data passed in from the Event (like Scene_Encounter, Scene_Shop, Scene_Heal, etc)

@Turtyo
Copy link
Collaborator Author

Turtyo commented Dec 15, 2023

No, only the base Event class would hold an array. This array is meant as a way to make a link before the different possible rooms depending on the light level. If the light level changes, you ask the Event class for the corresponding sub event_class (ie Event_mob, Event_shop etc...). Each event would only be one event in itself, but if there are changes we have a table that tells us which event we should get next.

Each event will indeed have a unique type of scene (or multiple type of scene if we want different backgrounds depending on where we are in the tree, having different background at the bottom and at the top).

@cheesefrycook
Copy link
Collaborator

Sorry, I'm still not really understanding. So the structure looks like this
Event
| -- Event_Mob
| -- Event_Shop
| -- Event_Heal
| -- ...

Then Event looks like this:

extends Resource
class_name Event

var events: Array[Event] = []

Then the events array is populated by the Map at the start of the run with some generation algorithm. Would be something like this:

events: Array[Event] = [Event_Mob, Event_Shop, Event_Heal]

Then the event is chosen based on the light level in the associated Room? What do you mean by "Each event would only be one event in itself"?

@Turtyo
Copy link
Collaborator Author

Turtyo commented Dec 17, 2023

Structure looks like this

Correct

Event looks like this

Nope, it would be:

extends Resource
class_name Event

const EVENTS_CLASSIFICATION: Array[Event] = [Event_Mob, Event_Random, Event_Shop, Event_Heal]

Then at the Map level we choose an event for each room (and we assume all the rooms are in the dark to start).
Let's start with the level 1 (the level just above the spawn). We have the following events : Mob, Mob and Random.

When the game starts, the start node has a light, so the light level rises by 1 for the rooms of level 1. We check EVENTS_CLASSIFICATION. I see that starting from a Mob level threat, if the light rises by 1 we get a Random event (because it's the next in the list). And if I start from a Random, I get a Shop. So the map updates and the new events for the level 1 rooms are: Random, Random, Shop (instead of Mob, Mob, Random).

If the light was risen by 1 level again, it would become Shop, Shop, Heal.

The EVENTS_CLASSIFICATION is a way to tell us how the events change based on light level. Here it's a bit simplified, because there would probably be more steps to change a mob to a random event (otherwise it would be too simple to never fight), but that's so you get the idea. The way the map is updated depending on light level will probably be discussed in more details later with the map generation issues.

What do you mean by "Each event would only be one event in itself"?

It was to answer your previous question "So each Event would contain an array of Events?" -> No each event would only be an event, it would not contain an array of events. Only the parent class has an array of events to tell us how to change based on the level of light.

@cheesefrycook
Copy link
Collaborator

Okay I see what you mean now

@Turtyo
Copy link
Collaborator Author

Turtyo commented Dec 17, 2023

If it's clear enough for you, put a confirmed tag. Otherwise ask me other questions if you have them, or if you want to change something.

@cheesefrycook cheesefrycook added the confirmed Has been approved to make code based on this label Dec 17, 2023
@Tysterman74 Tysterman74 self-assigned this Dec 18, 2023
@Tysterman74
Copy link
Collaborator

Need some clarification here about the

const EVENTS_CLASSIFICATION: Array[Event] = [Event_Mob, Event_Random, Event_Shop, Event_Heal]

The way we want this defined is essentially Index 0 being Light Level 1 and Index 3 being the max Level of Light?

@Turtyo
Copy link
Collaborator Author

Turtyo commented Dec 18, 2023

This array is not meant as a direct translation to light level. The way we might change depending on light level is more complex than a linear progression (because of the example I gave, where something pretty challenging like Mob, Mob and Random becomes Random, Random, Shop which is much simpler in a linear progression).
The way the light changes the event in each room will be discussed in further details later, and it will probably take into account the general distribution of events in the radius of light as well as adjacency considerations.

The Array in itself is in one line "IF we decide to make a change, HOW do we make this change".

So to answer the question, no index 0 is not light level 1 and index 3 is not max level of light. Note that this list I gave above is not exhaustive and more events might be added in the future.

You might want to read #20 (comment) again because I think that's the most detailed explanation I gave. If you want me to explain again after then i'll try to do so in a different way (like a drawing for example, it might help)

@Tysterman74
Copy link
Collaborator

The Array in itself is in one line "IF we decide to make a change, HOW do we make this change".

If I'm understanding correctly that array will be subject to change once we hash out the details for light better then. I'll leave it as that array for now, feel free to light it up in the PR.

A drawing would help as well! Thanks in advance.

@Turtyo
Copy link
Collaborator Author

Turtyo commented Dec 18, 2023

I will see if I have some time after reviewing PR and finishing code on my side. If not today, then tomorrow.

@Tysterman74
Copy link
Collaborator

Created a Draft PR with some suggested changes! Feedback is 10000% welcomed, wasn't too sure if I was picking up what Turtyo was throwing down 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed Has been approved to make code based on this new feature Ask for a new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants