Giter Site home page Giter Site logo

bigjk / end_of_eden Goto Github PK

View Code? Open in Web Editor NEW
130.0 5.0 7.0 50.84 MB

"Slay the Spire"-like roguelite fully in console.

Home Page: https://bigjk.itch.io/end-of-eden

License: MIT License

Go 72.94% Lua 22.71% Shell 1.29% Dockerfile 0.12% HTML 1.26% TypeScript 1.59% JavaScript 0.08%
deckbuilder lua roguelike terminal game gamedev open-source-game terminal-game

end_of_eden's Introduction

Discord Go Report Card GitHub release (latest by date)

Welcome to a world 500 years in the future, ravaged by climate change and nuclear wars. The remaining humans have become few and far between, replaced by mutated and plant-based creatures. In this gonzo-fantasy setting, you find yourself awakening from cryo sleep in an underground facility, long forgotten and alone. With all other cryosleep capsules broken, it's up to you to navigate this strange and dangerous world and uncover the secrets that led to your isolation...

End of Eden...

  • Is a "Slay the Spire"-like, roguelite deck-builder game running fully in console
  • Collect Artifacts that give you new cards or various passive effects
  • Clash with strange beings and try to survive as long as possible
  • Use the base engine to create your own mods and content

Screenshots

Screenshot Screenshot

Terminal Version Screenshots

Screenshot Screenshot

Status

The game is still in early development. There are still a lot of content missing and the game is not balanced at all. It mostly contians test content at the moment. If you want to help out, feel free to open a issue or pull request or even better join the discord.

๐ŸŽฎ How to play

Quickstart:

  • You just want to test the game: Download the _gl version
  • You don't want to leave your terminal: Download the _term version

Long Answer:

The game can be played in two ways. You can download the _term or _gl version. You can see which type you download from the file name (end_of_eden_term vs end_of_eden_gl). The _term version is the base game and runs in your terminal. The _gl version is the same game but running in a dedicated window, so no console magic is needed just a plain old game window. If you are not familiar with the terminal, you can try out the _gl version. It also comes with a optional crt shader to give the game a more retro look. Check out the Settings section for more information.

๐Ÿ“ Download

๐Ÿณ Docker

If you are an advanced user you can also run the game through docker.

Docker Guide

Pull Image

docker pull ghcr.io/bigjk/end_of_eden:master

Base Game

You can run the base game through docker, but audio is not supported. You also have to specify the terminal capabilities via environment flags. The following example uses the xterm-256color terminal and enables true color support.

docker run --name end_of_eden -e TERM=xterm-256color -e COLORTERM=truecolor -it ghcr.io/bigjk/end_of_eden:master /app/end_of_eden --audio=false

Possible options for the TERM environment variable are:

  • xterm-256color
  • xterm
  • screen-256color
  • screen
  • vt100 and more...

COLORTERM defines if the terminal supports true color. If you are using a modern terminal its probably safe to set this to truecolor. Other options are 24bit, 16mil and 8bit.

SSH Server

docker run --name end_of_eden -p 8275:8273 -it ghcr.io/bigjk/end_of_eden:master /app/end_of_eden_ssh

๐Ÿ“‘ Settings

Both versions have separate settings files. The settings files are located in the same directory as the game executable. The settings files are automatically created on the first game start. You can modify the settings in the settings file or in game via the settings menu.

_term Version

  • The settings file is called settings_term.toml
  • The settings can be modified in game via the settings menu
Available settings in settings.toml
# Audio volume
#
volume = 1.0

# Mods that should be loaded (can be edited in game)
#
mods = [ "example_mod", "other_mod" ]

_gl Version

  • The settings file is called settings_gl.toml
  • The settings can be modified in game via the settings menu
Available settings in settings_gl.toml
# Audio volume
#
volume = 1.0

# Mods that should be loaded (can be edited in game)
#
mods = [ "example_mod", "other_mod" ]

# Enable or disable audio
#
audio = true

# Enable or disable the crt shader
#
crt = true

# Enable or disable the grain shader
#
grain = true

# DPI scaling
#
dpi = 1

# Font to be used for normal, italic and bold text.
# The font needs to be relative to ./assets/fonts.
# Using a nerd font is recommended: https://www.nerdfonts.com/font-downloads
#
font_normal = 'BigBlueTermPlusNerdFont-Regular.ttf'
font_italic = 'BigBlueTermPlusNerdFont-Regular.ttf'
font_bold = 'BigBlueTermPlusNerdFont-Regular.ttf'

# Font size
#
font_size = 12

# Max fps
#
fps = 30

# Window size
#
height = 800
width = 1100

๐Ÿ“บ Console

A modern console is required to support all the features like full mouse control in the _term version. Just start the end_of_eden(.exe) executable in your terminal.

Tested Terminals

Terminal OS Status Note
terminal windows โœ… recommended on windows
cmd windows โš ๏ธ no mouse motion support, mouse clicks and everything else works
iterm2 osx โœ…

๐Ÿ“š Lua & Modding

Lua is used to define artifacts, cards, enemies and everything else that is dynamic in the game. This makes End of Eden easily extendable. If you want to create mods or learn more about lua:

๐Ÿ“ Interesting bits and pieces

Here are some interesting bits and pieces about the game that I like to share as it was great fun to build them.

The game got its own terminal emulator

While the game can run in the terminal perfectly fine, I wanted to provide non-terminal users with a way to play the game without having to deal with the terminal themselves. So, I thought, "How hard can it be to write a simple terminal emulator in Go?" To my surprise, it wasn't that difficult. I had a lot of fun while writing CRT. A nice side effect is the possibility of including CRT shaders that give the game an even more retro feeling.

The game has a fuzzy tester

I had a bunch of problems when I integrated the Lua scripting at the beginning. From simple nil dereference to Lua exploding on me, debugging the Lua code isn't as straightforward as debugging Go itself. I ran into a bunch of edge cases in my game's code where a certain chain of events would cause a panic. To counter that, I implemented a small fuzzy tester that throws operations at the game in random order, hoping to trigger a panic. If a panic happens, the fuzzy tester shows which chain of operations, together with which values, resulted in the panic.

Here is an example operation that will try to cast a card with a random target. It also picks values like empty strings or IDs of other objects. A fuzzy tester wouldn't be a fuzzy tester if it only threw nice input at the system ;)

func castCardOp(rnd *rand.Rand, s *game.Session) string {
    guid := Shuffle(rnd, lo.Flatten([][]string{{""}, s.GetInstances(), s.GetActors()}))[0]
    target := Shuffle(rnd, lo.Flatten([][]string{{""}, s.GetInstances(), s.GetActors()}))[0]
    s.CastCard(guid, target)
    return fmt.Sprintf("Cast card with guid '%s' on '%s'", guid, target)
}

This is also integrated into the CI of this game. Each time a commit is pushed that changes Lua or Go, the fuzzy tester will be run for 30 seconds on 2 cores. If it fails, the CI pipeline fails.

Check the code out in /cmd/internal/fuzzy_tester.

The games content can be unit tested

Testing game content by hand or ensuring that it works as expected can be annoying. The most straightforward way is to go into the game, use whatever debugging terminal it has, and give yourself whatever items you need to test it. Fortunately, "End of Eden" is a rather simple game, turn-based, and has no complex 3D shenanigans. So, why not test cards, artifacts, etc., with unit tests? Testing game content in isolation might not help with finding certain edge cases that only happen in combination with each other, but it does a good job of validating the basic behavior and makes it easy to iterate quickly without having to start the game a bunch of times to see if everything works.

So, I wrote a small testing utility that executes the test function on all the registered game content. Here you can see the test function for the BLOCK status effect. For each test, a clean game state will be created, and the given game content is given to the player. In this test, we assert that the player has one status effect of the BLOCK type. Then we let an enemy damage the player and check if the damage is negated as expected.

register_status_effect("BLOCK", {
    name = "Block",
    description = "Decreases incoming damage for each stack",
    -- ...
    test = function()
        return assert_chain({
            function() return assert_status_effect_count(1) end,
            function() return assert_status_effect("BLOCK", 1) end,
            function ()
                local dummy = add_actor_by_enemy("DUMMY")
                local damage = deal_damage(dummy, PLAYER_ID, 1)
                if damage ~= 0 then
                    return "Expected 0 damage, got " .. damage
                end

                damage = deal_damage(dummy, PLAYER_ID, 2)
                if damage ~= 2 then
                    return "Expected 2 damage, got " .. damage
                end
            end
        })
    end
})

Integrating this into the normal Go testing was easy, so you can use go test to test the content or use the standalone testing binary. Here is an example output when using go test:

=== RUN   TestGame
=== RUN   TestGame/Artifact:COMBAT_GLOVES
=== RUN   TestGame/Artifact:COMBAT_GLASSES
=== RUN   TestGame/Card:ENERGY_DRINK
=== RUN   TestGame/Card:ARM_MOUNTED_GUN
=== RUN   TestGame/Card:CROWBAR
=== RUN   TestGame/Card:VIBRO_KNIFE
=== RUN   TestGame/Card:ENERGY_DRINK_3
=== RUN   TestGame/Card:NANO_CHARGER
=== RUN   TestGame/Card:STIM_PACK
=== RUN   TestGame/Card:MELEE_HIT
=== RUN   TestGame/Card:ENERGY_DRINK_2
=== RUN   TestGame/Card:LZR_PISTOL
=== RUN   TestGame/Card:HAR_II
=== RUN   TestGame/StatusEffect:NANO_CHARGER
=== RUN   TestGame/StatusEffect:ULTRA_FLASH_SHIELD
=== RUN   TestGame/StatusEffect:BLOCK
=== RUN   TestGame/StatusEffect:BOUNCE_SHIELD
=== RUN   TestGame/StatusEffect:FLASH_BANG
=== RUN   TestGame/StatusEffect:FLASH_SHIELD

This is also integrated into the CI of this game. Each time a commit is pushed that changes Lua or Go, the tester will be run. If it fails, the CI pipeline fails.

Check the code out in /cmd/internal/tester.

The game generates its own lua documentation + autocomplete

I'm not a huge fan of Lua and its syntax, but I like how easily it can be embedded into nearly any language. Because it is used in so many places, especially games, there is a lot of information and libraries available. So, in my opinion, these facts outweighed my personal cons about the syntax. The only thing that I was missing was nice auto-complete for the game's API. That's when I learned about the lua-language-server and its great support for definitions. So, I wrote the basic definitions of things that don't change in the game, and the rest is generated dynamically by the game.

Currently, there is a utility to generate markdown-based documentation and the annotations for the language server. You can find the Lua docs here and definitions here. The docs are defined in code where I define Lua functions and constants. That way, I write the docs at the same moment that I define the Lua objects.

d.Global("PLAYER_ID", "Player actor id for use in functions where the guid is needed, for example: ``deal_damage(PLAYER_ID, enemy_guid, 10)``.") // <- docs
l.SetGlobal("PLAYER_ID", lua.LString(PlayerActorID)) // <- lua

d.Function("guid", "returns a new random guid.", "guid") // <- docs
l.SetGlobal("guid", l.NewFunction(func(state *lua.LState) int {
    state.Push(lua.LString(NewGuid("LUA")))
    return 1
})) // <- lua

This results in lua definitions like:

--- Player actor id for use in functions where the guid is needed, for example: ``deal_damage(PLAYER_ID, enemy_guid, 10)``.
PLAYER_ID = ""

--- returns a new random guid.
---@return guid
function guid() end

And if you open the /assets/scripts folder with Visual Studio Code and the Lua extension, you will get nice autocomplete with typing (for the most part), which makes the scripting experience so much nicer!

lua autocomplete

Check the code out in /cmd/internal/docs.

Building

Automatic

You can use the ./build.sh script to build all the binaries. The script will create a bin folder and put all the binaries and assets in there. If go is not installed on your system, the script will prompt to automatically fetch and run go via pkgx. pkgx is a package managment tool to run various programs without needing to install them yourself.

Manual

  • You need golang >= 1.20 installed
  • Build binary:
    • go build -o end_of_eden ./cmd/game/ (terminal version)
    • go build -o end_of_eden ./cmd/game_win/ (gl version)
  • Now a end_of_eden(.exe) binary should be available in your current directory
  • To run without building binaries use run instead of build (e.g. go run ./cmd/game/)
  • Important: The games working directory needs to be where the ./assets folder is available!

Versioning

The game uses versioning similar to Semantic Versioning to define the version number. This is also in accordance with the Go Modules versioning scheme.

vMajor.Minor.Patch

  • Major: Major version represents a major milestone in the games development. A major version of 0 represents the early development phase of the game, where nothing is set in stone yet and everything can change.
  • Minor: Minor version represents a new feature or a significant change.
  • Path: Smaller changes, bug fixes and improvements.

Socials

Credits

License

  • Code: licensed under MIT
  • Assets: See README.md in corresponding folder

end_of_eden's People

Contributors

bigjk avatar tomholford avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

end_of_eden's Issues

Outdated dependencies

Hi! I'm trying to package this for pkgsrc.
I have two bigger problems:

github.com/hajimehoshi/oto
# github.com/hajimehoshi/oto
../.gopath/pkg/mod/github.com/hajimehoshi/[email protected]/context.go:69:12: undefined: newDriver

oto 0.7.1 does not support NetBSD. The current version is 3.2.0, versions from 2.0.0 do support NetBSD.

github.com/caarlos0/sshmarshal
# github.com/caarlos0/sshmarshal
../.gopath/pkg/mod/github.com/caarlos0/[email protected]/marshal.go:29:6: MarshalPrivateKey already declared through dot-import of package ssh ("golang.org/x/crypto/ssh")
        ../.gopath/pkg/mod/golang.org/x/[email protected]/ssh/keys.go:302:6: other declaration of MarshalPrivateKey
../.gopath/pkg/mod/github.com/caarlos0/[email protected]/marshal.go:35:6: MarshalPrivateKeyWithPassphrase already declared through dot-import of package ssh ("golang.org/x/crypto/ssh")
        ../.gopath/pkg/mod/golang.org/x/[email protected]/ssh/keys.go:308:6: other declaration of MarshalPrivateKeyWithPassphrase
*** Error code 1

This project is dead. Its github page says:

This is now merged into x/crypto!

which explains the error message quite well.

Consider building ARM64 releases and containers

Just stumbled upon this today. I am enjoying taking a look at what you have done.

Since everything appears to build perfectly on an arm64 (Apple silicon) Mac, it would be really nice to have pre-built binaries in the GH releases, for both Linux and Darwin arm64 (via setting GOOS and GOARCH).

And from my initial tests something like the following should also build and push the image for both Linux architectures as well.

docker buildx build --file ./Dockerfile --platform linux/amd64,linux/arm64 --tag ghcr.io/bigjk/end_of_eden:master --push .

Keep up the good work!

[bug] crashed on terminal while trying to play an unselected card

Hello, I've seen this repo super recently downloaded the executable for the first time from the releases at
end_of_eden_term-v0.1.10-macos-amd64.zip
while playing I noticed it crashed a few times. I am on Mac14 + iTerm2.

I was just instinctively using 'enter' to select the cards and click the end turn by mouse. This error seem to happen when the card is not selected as default, so when i click enter it logged"runtime error: index out of range [-1]". full log below:

s.mp4
End Of Eden
Initializing Settings. Please wait...
Done!
Initializing Audio. Please wait...
Done!
Initializing Proc-Gen. Please wait...
Done!
Initializing Localization. Please wait...
Done!

Caught panic:

runtime error: index out of range [-1]

Restoring terminal...

goroutine 1 [running]:
runtime/debug.Stack()
	/Users/runner/go/pkg/mod/golang.org/[email protected]/src/runtime/debug/stack.go:24 +0x5e
runtime/debug.PrintStack()
	/Users/runner/go/pkg/mod/golang.org/[email protected]/src/runtime/debug/stack.go:16 +0x13
github.com/charmbracelet/bubbletea.(*Program).Run.func1()
	/Users/runner/go/pkg/mod/github.com/!big!jk/[email protected]/tea.go:478 +0x91
panic({0x10110cd00?, 0xc004b90108?})
	/Users/runner/go/pkg/mod/golang.org/[email protected]/src/runtime/panic.go:920 +0x270
github.com/BigJk/end_of_eden/ui/menus/gameview.Model.tryCast({{{0xc8, 0x33}, {0xb5, 0x31, 0x0, 0x0, 0x0, 0x2, 0x0, 0xb}, ...}, ...})
	/Users/runner/work/end_of_eden/end_of_eden/ui/menus/gameview/gameview.go:431 +0x4b2
github.com/BigJk/end_of_eden/ui/menus/gameview.Model.Update({{{0xc8, 0x33}, {0xb5, 0x31, 0x0, 0x0, 0x0, 0x2, 0x0, 0xb}, ...}, ...}, ...)
	/Users/runner/work/end_of_eden/end_of_eden/ui/menus/gameview/gameview.go:100 +0x479
github.com/BigJk/end_of_eden/ui/root.Model.Update({0xc000440310, {0xc00045a240, 0x2, 0x4}, {0xc8, 0x33}, 0xc002619740, 0x0}, {0x1010e8a80, 0xc002618030})
	/Users/runner/work/end_of_eden/end_of_eden/ui/root/root.go:86 +0x5d8
github.com/charmbracelet/bubbletea.(*Program).eventLoop(0xc00036d930, {0x101bcde18?, 0xc00041c040?}, 0xc00146dc70?)
	/Users/runner/go/pkg/mod/github.com/!big!jk/[email protected]/tea.go:411 +0x75a
github.com/charmbracelet/bubbletea.(*Program).Run(0xc00036d930)
	/Users/runner/go/pkg/mod/github.com/!big!jk/[email protected]/tea.go:543 +0x86e
main.main()
	/Users/runner/work/end_of_eden/end_of_eden/cmd/game/main.go:138 +0x1465

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.