Commit Graph

38 Commits

Author SHA1 Message Date
Ondřej Šebek
e13dced169
Fallback to XDG data directory (#678)
- when `datadir` is not available, try using the XDG data directory

This way the game can be installed as an executable and data files unpacked to  `~/.local/share/swarm/data`.
Notice that the XDG data folder is  `~/.local/share/swarm`; inside it is the unpacked `data`.

The alternative approach is to use the environment variable `swarm_datadir` and set that to the unpacked data folder.
That works (even after this change) but is not very beginner friendly.

Ideally, we would like to set this in Cabal when building executable, for example to `/usr/share/swarm/<version>`.
Reading through haskell/cabal#5997, it looks like that is not supported.
2022-10-01 20:40:56 +00:00
Brent Yorgey
f003c6773e
A few updates related to speedrunning (#695)
I've updated the Swarm speedrunning wiki page at https://github.com/swarm-game/swarm/wiki/Speedrunning .  Here are a few related cleanups/links.  I'm also planning to fix #694 as part of this PR.
2022-09-25 19:30:18 +00:00
Ondřej Šebek
8366135ae1
Notify user about newer version (#652)
- query GitHub Releases for a new version
- add `swarm version` command
- show the version notification in the main menu
- add a new app-wide logging queue
- show the app-wide logs in the main menu as Messages
- catch and show the web API failure in the Messages
- closes #66
- closes #627
2022-09-06 07:32:24 +00:00
Tristan de Cacqueray
e9fb04691a
Add debug web service (#623)
This change introduce a new web API for the game.
The initial goal is to expose the internal state using the
`/robots` and `/robot/$id` endpoint to query the json representation
of the robots.

A new command line argument is added:
- When `--port 0` is set, the web service is disabled.
- When `--web port` is set, the game won't start if the web service fail to bind the port.
- Otherwise, when `--web` is not set, the service may start on 5357 if the port is available.

Example usage:

```
 swarm --web 5357
 curl localhost:5357/robots | jq
```

Future improvement may include:

- Ability to load program to the base (to send command from external text editor)
- Serve a html interface for alternative visualization
2022-08-06 19:34:23 +00:00
Ondřej Šebek
f2ad1322c9
Generate command table (#531)
Generate table for [Commands Cheat Sheet](https://github.com/swarm-game/swarm/wiki/Commands-Cheat-Sheet) Wiki.

- part of #344
2022-07-04 08:47:55 +00:00
Ondřej Šebek
3872c11509
Generate editor keywords (#526)
- part of #344
2022-07-01 18:44:09 +00:00
Ondřej Šebek
8652440607
Make GHC2021 extensions default (#520)
- closes #419
2022-07-01 09:07:41 +00:00
Ondřej Šebek
9b6eaef37b
Add generator for recipe dependencies (#476)
- add `generate` subparser to the executable
- create a generator for a Graphviz entity dependencies graph
- part of #344 

You can interactively test this with:
```bash
$ cabal run swarm:swarm -- generate recipes \
 | sed -n '/^digraph/,$p' > docs/recipes.dot
$ xdot docs/recipes.dot
```
2022-06-24 21:50:32 +00:00
Brent Yorgey
597d1c6853
require --cheat flag to allow toggling creative mode with m key (#368)
Closes #360.
2022-06-10 00:38:00 +00:00
Brent Yorgey
8961d03a1a
Generalize challenges + classic/creative modes to scenarios (#337)
Generalize challenges + various modes to all be "scenarios" which are described by `.yaml` files in `data/scenarios`.  

- Both challenges and classic/creative modes are now subsumed under the more general notion of "scenarios".
- A scenario describes how to set up the world etc. when starting a game; all scenarios are stored in a `.yaml` file in `data/scenarios`.
- "New game" menu item now lets the user choose a scenario.
- Some small improvements to the way seeds are handled.

See #296.  This will enable #35 and #25 .
2022-06-04 13:20:49 +00:00
Brent Yorgey
d36a89af18
deal gracefully with absence of git repo (#329) 2022-04-29 05:19:04 -05:00
Brent Yorgey
667f001c8b print git branch and hash in --help menu
Not super useful on its own.  This is mostly just to figure out the
`githash` library (which wasn't hard) in initial preparation for #66.
2022-04-27 08:01:45 -05:00
Brent Yorgey
008d4000a5
Add a --run flag to run the contents of a program on startup (#312)
Fixes #82.

Right now it only works in classic mode.  It wouldn't be too hard to
make it work with challenge mode as well, but that would require some
more careful thinking about whether every challenge is required to
have a 'base' and how we identify which robot that is, so that we run
the given file on the right robot.
2022-03-07 05:56:15 -06:00
Brent Yorgey
b1f0e316fd
Challenge mode (#285)
Add a "challenge mode" where the player tries to achieve some specified goal from specific starting conditions.
2022-01-27 17:00:00 -06:00
Ondřej Šebek
77c7fd686d
Add seed option to CLI (#170)
- adds CLI option `--seed` and propagates it to `testWorld2` (Closes #14)
- moves the base in the tree shade (Closes #90)
- makes the `random` command depend on initial seed (Closes #13)
2021-10-05 19:43:52 +00:00
Tristan de Cacqueray
28885afd65
Add stdin support for swarm format (#141)
This change enables reading code from stdin to simplify editor integration.

Fixes #140
2021-10-03 02:21:48 +00:00
Tristan de Cacqueray
a23212ae9d
Reformat the haskell code with fourmolu (#146)
This PR was generated using `find src/ app/ test/ -name "*.hs" | xargs fourmolu --mode=inplace`.

Fixes #103
2021-10-02 18:40:24 +00:00
Tristan de Cacqueray
c7baf13efe
Add basic editor integration with LSP (#108)
This change improves the user experience when editing swarm code outside of the REPL with:

- CLI for a `format` command to quickly parse and type check a file.
- Basic LSP server to provide IDE feedback on save, e.g. visual squiggly for errors.
- Initial emacs mode.

Fixes #82 #110
2021-10-01 20:11:08 +00:00
Brent Yorgey
95f6ac28d4 factor out remaining UI + app stuff 2021-08-23 16:52:40 -05:00
Brent Yorgey
f046b2b43c factor out more UI code 2021-08-23 16:39:56 -05:00
Brent Yorgey
dda0aafc93 factor out Swarm.Game.Resource 2021-08-23 16:30:41 -05:00
Brent Yorgey
65917c2ae4 split out Swarm.UI.Attr 2021-08-23 16:27:51 -05:00
Brent Yorgey
4efea30df2 factor out more code into separate modules 2021-08-23 16:24:54 -05:00
Brent Yorgey
319b36ace8 fix refactoring, split UIState out of GameState into top-level AppState 2021-08-23 16:13:25 -05:00
Brent Yorgey
9526392d26 WIP 2021-08-23 15:01:09 -05:00
Brent Yorgey
eb832d366c refactor: split out Swarm.AST 2021-08-23 13:31:57 -05:00
Brent Yorgey
4bb87983ec factor out handleREPLEvent 2021-08-23 13:18:08 -05:00
Brent Yorgey
381a49e5d6 refactor and add REPL history 2021-08-23 11:44:25 -05:00
Brent Yorgey
79bbf4de76 add repeat command 2021-08-22 22:02:01 -05:00
Brent Yorgey
7ea09880bd clean up 2021-08-22 22:01:50 -05:00
Brent Yorgey
44897c6535 decrease delay between ticks 2021-08-22 22:01:38 -05:00
Brent Yorgey
f82b4cc071 build just takes a Command 2021-08-22 21:49:51 -05:00
Brent Yorgey
7fdccbbc14 add a bunch of stuff!
enhanced 'turn' command
blocks
build command
real-time syntax checking for REPL inputs
error message dialog for parse errors
2021-08-22 21:47:39 -05:00
Brent Yorgey
2f8e13eebe add focus ring for panels
Tab key cycles the focus.
Also clean up a few warnings.
2021-08-22 14:20:04 -05:00
Brent Yorgey
7c0a2bfd75 test with larger, randomly generated world 2021-08-22 08:08:09 -05:00
Brent Yorgey
0c73122d2a tweaks 2021-08-22 06:48:23 -05:00
Brent Yorgey
81fe71f3bb draw interface with three full-size panels, and improve visuals 2021-08-22 06:36:56 -05:00
Brent Yorgey
479b10e986 initial exploration 2021-08-21 18:18:07 -05:00