end_of_eden/game
2023-04-23 22:04:24 +02:00
..
actor.go Added basic game save. 2023-04-22 20:43:09 +02:00
artifact_test.go Fix tests. 2023-04-20 12:27:41 +02:00
artifact.go Renamed project to 'End of Eden' 2023-04-23 22:04:24 +02:00
callbacks.go Face generator and merchant base code. 2023-04-20 23:43:06 +02:00
card_test.go Fix tests. 2023-04-20 12:27:41 +02:00
card.go Renamed project to 'End of Eden' 2023-04-23 22:04:24 +02:00
checkpoint.go Code for enabling save files. 2023-04-22 12:56:09 +02:00
debug.go Renamed project to 'End of Eden' 2023-04-23 22:04:24 +02:00
enemy.go Renamed project to 'End of Eden' 2023-04-23 22:04:24 +02:00
event.go Renamed project to 'End of Eden' 2023-04-23 22:04:24 +02:00
guid.go Initial commit. 2023-04-10 13:41:59 +02:00
log.go Initial commit. 2023-04-10 13:41:59 +02:00
lua.go Renamed project to 'End of Eden' 2023-04-23 22:04:24 +02:00
mod.go Update. 2023-04-15 21:44:38 +02:00
README.md Renamed project to 'End of Eden' 2023-04-23 22:04:24 +02:00
resources.go Renamed project to 'End of Eden' 2023-04-23 22:04:24 +02:00
saved_state.go Code for enabling save files. 2023-04-22 12:56:09 +02:00
session_test.go Code for enabling save files. 2023-04-22 12:56:09 +02:00
session.go Renamed project to 'End of Eden' 2023-04-23 22:04:24 +02:00
status_effect.go Renamed project to 'End of Eden' 2023-04-23 22:04:24 +02:00
story_teller.go Renamed project to 'End of Eden' 2023-04-23 22:04:24 +02:00
string_set.go Renamed project to 'End of Eden' 2023-04-23 22:04:24 +02:00

Game

This is the core implementation of end_of_eden. This doesn't contain any ui code, as the base game logic and ui is fully seperated in this project.

Session

The Session type is the core of a running game session. It exposes a multitude of methods that are able to mutate the game state. By only exposing methods, calling them should mutate the session from one valid game state to another valid game state. The session will (with a few exceptions) only return copies of data and no pointer so that the consumer can't mutate the state without going through the right method call.

At the moment access to a Session is expected to be single-threaded!

session := game.NewSession(/* options */)

// interact with the session

Types

  • Artifact: Base definition for an artifact
  • Card: Base definition for a card
  • StatusEffect: Base definition for a status effect
  • Event: Base definition for an event
  • Enemy: Base definition for an enemy
  • StoryTeller: Base definition for an story teller
  • ArtifactInstance: Instance of an artifact that is owned by an Actor and references its base definition via the TypeID
  • CardInstance: Instance of a card that is owned by an Actor and references its base definition via the TypeID
  • StatusEffectInstance: Instance of a status effect that is owned by an Actor and references its base definition via the TypeID
  • Actor: Instance of either the player or an enemy. If it's an enemy the TypeID references its base definition

Checkpointing

Although the game code doesn't contain any ui there is a mechanism that helps ui and animations to react to events in the game. It is possible to create checkpoints of the game state, execute one or more operations that alter the game state and then get a diff of what happened.

In case we want to see if the enemy turn resulted in damage to the player we could use checkpoints:

// Store state checkpoint before operation
before := session.MarkState()

// Finish the player turn, which means that enemies are allowed to act
session.FinishPlayerTurn()

// Check if any damage was triggered
damages := before.DiffEvent(m.Session, game.StateEventDamage)
for i := range damages {
	// Do something with the damage data -> queue animation, play audio
}

This also makes it really easy to keep track of everything that happened in a fight, so that a re-cap screen can be shown. We just need to store the state at the beginning of the fight and diff it when it ends.