Commit Graph

612 Commits

Author SHA1 Message Date
Ondřej Šebek
e85bf806c2
Retire raise command (#407)
- remove `raise` command
- rename `error` to `fail` - should suggest both that it is:
  - recoverable - can be caught with `try`
  - pure - `fail: string -> a` - so it can be used outside `cmd`

---

The problem with `raise` was that it was merely a specialized version of `error` (which was not limited to `cmd a`):
```
let raised: string -> cmd a = error in raised "ha"
```
I noticed this while making the list for #26.

On a meta-level, it also conflicts with the `raise` Haskell function we use to throw an error when a command (like `build`) fails.
2022-06-23 11:25:23 +00:00
Ondřej Šebek
8d07b667a9 Remove Goal entity mention
- remove mention of goal entity
- mention known entity
- explain yeilds and its limits
2022-06-23 08:45:06 +02:00
Ondřej Šebek
12344cd723
Add a few tutorial challenges (#411)
Start designing the tutorial (via challenges) so that we can figure out which new features are necessary.
2022-06-22 20:58:22 +00:00
Ondřej Šebek
a170379c93
Fix reprogram requiring wrong inventory (#464)
- fix the mistake introduces in #373
2022-06-22 15:13:49 +00:00
Tristan de Cacqueray
92c1d86cec
Add available recipes help (#441)
This change adds a new help panel with the list of recently acquired recipes.

Fixes #436
2022-06-22 14:27:45 +00:00
Brent Yorgey
7b9d8421cc
add goal field to scenarios (#450)
If there is a goal, immediately pop up a dialog with the goal, then
allow showing it any time afterwards with ^G.

See #356.
2022-06-22 12:47:14 +00:00
lsmor
23817a51ba
Find in repl (#439)
This PR solves #85. It's still a little bit rough since it only shows the last entry in history with the given text.

The solution if found is making the prompt a sum type. This allow to handle reple events differently depending on which mode the repl is. I've found this more difficult to implement than expected. The main problems I've found are 

- `UIState` is a huge data type. Maybe putting al repl-related stuff within the same record could improve things a little bit
- I think we can define a more complex Lenses, like `promptUpdateL` which can handle many parts of the logic. I think this is better than having a huge `handleREPLEvent` function.

 All of this would imply a big refactor tough.
2022-06-22 11:48:17 +00:00
Ondřej Šebek
077d208b7e
Return the obtained entity in grab (#461)
When grabbing entities that have `yield` property, I want to use what I obtained.
But `t <- grab` would give me "wavy water" instead of "water".

I noticed this because of our hack with known entities, which also use yield (#387).
2022-06-22 10:23:50 +00:00
Brent Yorgey
222a453b3b base should face the same way in classic & creative modes 2022-06-21 11:19:03 -05:00
Tristan de Cacqueray
7c9e46d033
Fix modal toggle to unpause the game (#452)
And also enable modal view toggle using the same key.

* Unpause the game after quitting a modal with Esc
* Handle FKey event before `uiModal` event to enable toggle through Fkey
2022-06-20 16:13:22 -05:00
Tristan de Cacqueray
7f4db06422
Handle mouse click event for robot inventory (#448)
This change makes inventory click select the inventory item.

Fixes #446
2022-06-20 19:16:44 +00:00
Brent Yorgey
8b8c16a71b
switch from U+2591 Light Shade to U+2592 Medium Shade (#449)
Some terminals (*e.g.* `gnome-terminal`) use the character to decide
how dark or light the color should be, rather than showing the
character itself (like *e.g.* `rxvt-unicode`).  Light Shade looks OK
in terminals that display the actual character, but too dark in
terminals that use it as a brightness hint.  Medium Shade seems to
look good (at least, IMO) in both.

See https://github.com/swarm-game/swarm/issues/196#issuecomment-1147298159 .
2022-06-20 17:56:55 +00:00
Brent Yorgey
389e3b7940 progress report blog post 2022-06-20 11:29:14 -05:00
Tristan de Cacqueray
88933d82fb
Handle mouse click event (#437)
This change adds support for mouse event:
- Change panel focus
- Display world location distance to the center

Fixes #203
2022-06-20 14:30:37 +00:00
Brent Yorgey
9fdfeb7554
reset some UI state fields when beginning a new game (#445)
Reset `uiFocusRing`, `uiInventory`, `uiShowFPS`, and `uiShowZero`.

Fixes #444.
2022-06-20 13:27:17 +00:00
Tristan de Cacqueray
bbcdfbcddc
Add knows command (#433)
Fixes #409
2022-06-19 17:01:43 +00:00
Tristan de Cacqueray
7a35efacbc
Exit the game when the previous menu is not set (#432)
This change fixes an issue when the game is started directly using
the `-s` command line argument. The new behavior is to halt the game
when no previous menu is set.
2022-06-19 14:07:29 +00:00
Brent Yorgey
fa207506f9
recipes for treads + tank treads: LaTeX -> rubber + motors + iron (#434)
This doesn't yet prevent normal treads from being installed on the base (see #334).  That will be a separate PR.
2022-06-19 12:16:03 +00:00
Tristan de Cacqueray
04e143d51b
Destroy robot when needed (#429)
This change fixes #428
2022-06-19 01:26:20 +00:00
Tristan de Cacqueray
1eb714db38
Crafting tutorial (#423)
This change adds a new crafting tutorial.
2022-06-18 22:48:10 +00:00
Tristan de Cacqueray
59da90340d
Returns to the scenario menu after winning a game (#422)
This change slightly improves the navigation by saving
the menu position so that the user gets back to the next
tutorial or challenge after winning a game.
2022-06-18 22:40:51 +00:00
Brent Yorgey
32021df8ba
Wordsmithing (#430)
- Expand some entity descriptions
- Improve formatting, grammar, punctuation, wording etc. all around
- Also make big furnaces able to process copper and iron too
2022-06-18 21:47:47 +00:00
Brent Yorgey
af2b3ce799
Add recipe for mirror and make it required for self (#416)
The `whoami` command used to be more interesting back when robot names were used to uniquely identify them.  It seemed fitting to make `mirror` required for `self`, which now plays the same role.  I also added a recipe for `mirror` which we lacked (`glass` + `silver`) and made a new type of `deep mine` where we can mine `gold`, `silver`, and `mithril`.
2022-06-18 02:39:02 +00:00
Ondřej Šebek
6838dfa1aa Add portal challenge to tests 2022-06-18 02:44:22 +02:00
Ondřej Šebek
820f1b067e Recurse integration test discovery 2022-06-18 02:44:22 +02:00
Ondřej Šebek
bb8a31ec4d Test scenarios
- add winning solutions to scenarios
- test the winning solutions
  - fail if any robot has a `Fatal error` in its log
  - timeout in X seconds (default 1)
- add a Testing scenario collection hidden without the `--cheat` flag
  - add a test case for #394

- closes #388
2022-06-18 02:44:22 +02:00
Ondřej Šebek
05e4e08d10 Move test into separate folders
It makes IDE usage easier and allows us to split
main files once they get too big.
2022-06-18 02:44:22 +02:00
Ondřej Šebek
6b36ff04c4 Clean up startup messages 2022-06-18 02:44:22 +02:00
Ondřej Šebek
ab738fcd27 Fix creative mode ignoring scenario inventory 2022-06-18 02:44:22 +02:00
Ondřej Šebek
6d2550bb0f
Add teleport command (#406)
- add command `teleport :: robot -> (int * int) -> cmd ()` requiring god capability

In challenges, it is useful to be able to check the state of some remote position.
This gets you there.
2022-06-17 23:24:32 +00:00
Brent Yorgey
7237a37e65
put base in a 32x32 patch with all necessary starting resources (#412)
Fixes #385 .  Note, we will need to update `TUTORIAL.md` since this changes what world 0 looks like, but I wanted to get some feedback before launching into updating that.
2022-06-17 22:11:02 +00:00
Ondřej Šebek
7fc7051c8d Remove create capability 2022-06-16 14:08:40 +02:00
Ondřej Šebek
83a7b6626e
Add robotNumbered command for debugging (#405)
Sometimes I need a dirty and direct way to get the n-th robot in the world quickly.

The name of the command is longer by design so that it does not get confused with the proposed `child` command or custom user definitions.

- part of #343
2022-06-16 11:17:33 +00:00
Brent Yorgey
221e7ec679
Some new devices and recipes (#395)
- Add quartz and quartz mines
- Add `clock`, `silicon`, and `circuit`
- Add `comparator` device
- Metal drills can now drill through boulders too
- Add pixels to the world, and recipes for `camera` and `scanner`

See discussion at https://github.com/swarm-game/swarm/issues/26#issuecomment-1152743741 and https://github.com/swarm-game/swarm/pull/361 .
2022-06-15 16:06:25 +00:00
Brent Yorgey
7a88bc1db6
copy over known (count 0) items when salvaging (#398)
Fixes #391.
2022-06-15 15:53:16 +00:00
Ondřej Šebek
bda16b79ac
Iron (#373)
- add iron ore, iron mine and iron vein (closes #93)
  - split gear into iron/wooden gear
  - add metal drill
  - add faster recipes with the metal drill
- add compass (closes #341)
- handle multiple entities providing the same capability
  - try to find if the robot has at least one entity providing the capability
  - when no entity could provide the capability rejects it too
- list required devices in the `Incapable` error (closes #342)
2022-06-14 16:13:27 +00:00
Brent Yorgey
7ee8d2458b fix module name in comment 2022-06-13 06:23:18 -05:00
Brent Yorgey
2b5bffc6e0 Delete bound variables from capCtx when recursing into terms
Fixes #389.
2022-06-12 17:03:50 -05:00
Brent Yorgey
54e5e35bbe clean up examples
Closes #325.
2022-06-11 15:15:07 -05:00
Ondřej Šebek
d55c6e8bf6
Add note about create (#381)
- add a note about 'create' to the make command
- also fix spacing before punctuation in error messages
2022-06-11 01:53:47 +00:00
Brent Yorgey
2da8cb06e0 tutorial: remove reference to creative mode hotkey
Fixes #360.
2022-06-10 15:40:54 -05:00
Brent Yorgey
6780254b2f
resolve seed every time a scenario is selected to be played (#379)
Seed resolution used to happen in `loadScenarioFile`, but that was the
wrong place.  Resolution now happens in `playScenario`.  This means that, e.g. if you
select "New Game > Classic" from the menu, then quit back to the menu, then start
a second new game, you will get a different random world each time.

Fixes #369.
2022-06-10 10:24:48 +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
a5a5832afe
add recipe weights and choose randomly among matching recipes (#372)
Recipes can now optionally have a `weight` (with a default weight of
1).  Any time multiple recipes match the criteria by which we are
selecting a recipe, one of the recipes will be chosen randomly, with
probability proportional to its weight.

As a simple example, drilling a boulder now produces 3 rocks with
probability 3/4 and 4 rocks with probability 1/4.

The ultimate purpose of this is to support some things I would like to propose in relation to mines, iron, etc. but it seems like a useful/interesting feature on its own.
2022-06-09 00:42:29 +00:00
Ondřej Šebek
14c5bdbd04 Move HLint to GHC 8.10.7 in CI
The version check only cares about 8/9
and HLint has some trouble installing
in 9.2, so this avoids it for now.
2022-06-09 01:29:05 +02:00
Ondřej Šebek
dabcb21608 Update stack resolver 2022-06-09 01:29:05 +02:00
Ondřej Šebek
ff9ec66711 Add ci flag to CI
- set -Werror in CI
- fix GHC 9.2 warning about TH looking syntax ($e)
2022-06-09 01:29:05 +02:00
Ondřej Šebek
94c876a01a Add GHC 9.2.3 to CI 2022-06-09 01:29:05 +02:00
Brent Yorgey
69929f1b61 Bump dependency bounds
- bump upper bounds on dependencies
- remove special th-extras and depedent-sum deps
- fix problems with new opaque types in Aeson
2022-06-09 01:29:05 +02:00
Ondřej Šebek
b67a0f3ef4
Enable HLint in CI (#371)
- uncomment HLint configuration in Haskell-CI config
- remove unused pragmas
- remove some unnecessary parens
2022-06-08 22:40:29 +00:00