erago

package module
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2023 License: BSD-3-Clause Imports: 19 Imported by: 0

README

Erago

Erago is a clone of the Emuera, which is the platform for creating and playing a text-based simulation game. Erago is written by pure Go and you can run Erago on multi platforms, Windows, Linux and MacOS!

Erago is a unofficial product. Please don't ask any issues about Erago to the maintainers of the original software.

Motivation

  • To use powerful script language (relative to the original one) to develop more complex game.
  • To learn how to build Desktop application on Go.

Features

Erago is not compatibible with the original in some specification.

  • Use Lua5.1 as scripting language
  • Resizable window
  • Single binary and Cross platforms

Getting started

If you just play the Erago, you can download pre-build binaries from Release page (not yet). If you are developer or want to build manually, see next section.

Starting Game

To start Game

  1. prepare extra resources, user scripts on ELA and game data schema table on CSV.
  2. run the executable binary (click .exe file on Windows) on direcotry with above.

Build binary from source

Requires Go 1.15 or higher.

You can use go get to fetch the repository.

go get -u github.com/mzki/erago

Prepare dependencies for building.

cd $GOPATH/src/github.com/mzki/erago
go mod download

Build binary.

cd $GOPATH/src/github.com/mzki/erago/app/cmd
make linux # for windows use "windows" instead of "linux"

For Mobile development

Supports Android only.

Because UI for Mobile and Desktop are optimized for each platform, Erago for mobile supplies only Model-level library, containing the script runtime and IO ports, not containing any UI. Each mobile platform might implements UI with the Model library.

Build model library for mobile.

To build Model-level library for mobile, gomobile and Android NDK are required. Once prepared the build environment, run below to build the Model library.

cd $GOPATH/src/github.com/mzki/erago/mobile/model
bash build.sh

You can prepare the build environment using Docker and Dockerfile. See erago/dockerfiles/mobile/Dockerfile. Warning: This docker image is large, up to 3.6GB

License

Erago is licensed under BSD 3-Clause license, the same as Go. See LICENSE file.

Documentation

Index

Constants

View Source
const (
	DefaultSaveFileDir     = "sav"
	DefaultCSVDir          = "CSV"
	DefaultCSVCharaPattern = "Chara/Chara*"
	DefaultScriptDir       = "ELA"
)
View Source
const DefaultBaseDir = "./"

by default, use current dir of running main.

View Source
const DefaultTestingTimeout = 60 * time.Second

DefaultTestingTimeout is default value for testing timeout. test will fail when execution time exceed this time.

Variables

This section is empty.

Functions

func Testing

func Testing(conf Config, script_files []string, timeout time.Duration) error

Run testing flow.

It runs script files with Config and returns these execution error. nil means all test scripts are passed. In script execution, input function returns no sense values, so the test scripts requiring user input can not be tested.

Types

type Config

type Config struct {
	SceneConfig  scene.Config  `toml:"scene"`
	RepoConfig   repo.Config   `toml:"save"`
	CSVConfig    csv.Config    `toml:"csv"`
	ScriptConfig script.Config `toml:"script"`
}

Config holds parameters associating with Game running. It might be constructed by NewConfig, not Config{}.

func NewConfig

func NewConfig(baseDir string) Config

construct default Config with the base directory.

type Game

type Game struct {
	// contains filtered or unexported fields
}

Game is entry point of the application. It implements Sender interface to send user event from external. Sender is valid after Game.Init(), so accsessing it causes panic before initializing.

Game object is invalid after retruned from Game.Main() or calling Game.Quit(). To reuse it, you must call Game.Init() first, then call Main().

func NewGame

func NewGame() *Game

Constructs game object with config. If nil config is given use default config insteadly.

func (*Game) Init

func (g *Game) Init(ui uiadapter.UI, config Config) error

Initialize game by UserInterface and game config. It returns error of initializing game. The empty game config is ok in which use default game Config.

After this, Game.Sender is available.

func (Game) InputPort

func (g Game) InputPort() uiadapter.Sender

It return input port which is used to send user event. But game implements Sender interface, so using this may be special case.

func (*Game) Main

func (g *Game) Main() error

Run game main flow. It blocks until causing something of error in the flow. So you should use it in the other thread.

Example:

go func() {
	game.Main(ctx)
}()

It returns nil if game quits correctly, otherwise return erorr containing any panic in the flow.

func (*Game) Quit

func (g *Game) Quit()

implements uiadapter.Sender interface. quit game by external.

func (*Game) RegisterAllRequestObserver added in v0.5.0

func (g *Game) RegisterAllRequestObserver(obs uiadapter.RequestObserver)

helper function to register handler for all of input request type.

func (*Game) RegisterRequestObserver added in v0.5.0

func (g *Game) RegisterRequestObserver(typ uiadapter.InputRequestType, obs uiadapter.RequestObserver)

implements uiadapter.Sender interface. add input request chaged ovserver which can be used asynchrobously.

func (*Game) Send

func (g *Game) Send(ev input.Event)

implements uiadapter.Sender interface. send input event to game running. it can be used asynchrobously. For more detail for input event, see input package.

func (*Game) UnregisterAllRequestObserver added in v0.5.0

func (g *Game) UnregisterAllRequestObserver()

helper function to unregister handler for all of input request type.

func (*Game) UnregisterRequestObserver added in v0.5.0

func (g *Game) UnregisterRequestObserver(typ uiadapter.InputRequestType)

remove input request chaged ovserver which can be used asynchrobously.

Directories

Path Synopsis
app
cmd
package attribute contains property for view interface.
package attribute contains property for view interface.
infra
mobile
model
package model is a Go interface for the mobile devices on the Model level.
package model is a Go interface for the mobile devices on the Model level.
csv
Package csv provides csv-parser for game parameter names.
Package csv provides csv-parser for game parameter names.
package uiadapter converts UI interface to model interface
package uiadapter converts UI interface to model interface
macro
macro syntax is that 1.
macro syntax is that 1.
errutil
Package errutil provides utilty of errors.
Package errutil provides utilty of errors.
log
package log defines strict logger types, which is referenced from https://dave.cheney.net/2015/11/05/lets-talk-about-logging.
package log defines strict logger types, which is referenced from https://dave.cheney.net/2015/11/05/lets-talk-about-logging.
view
exp/text
package text provides contents holder cotaining plain-text, clickable-text-button, ...
package text provides contents holder cotaining plain-text, clickable-text-button, ...
exp/text/pubdata
package pubdata intended for exporting data structure for other platforms such as mobile, wasm and so on.
package pubdata intended for exporting data structure for other platforms such as mobile, wasm and so on.
exp/text/publisher/mock
Package mock_publisher is a generated GoMock package.
Package mock_publisher is a generated GoMock package.
exp/theme
package theme defines custom theme for UI.
package theme defines custom theme for UI.
package width provides methods to get text width defined by unicode east asisn width.
package width provides methods to get text width defined by unicode east asisn width.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL