Commit graph

67 commits

Author SHA1 Message Date
Griffin Smith
af31da8cfc feat(grfn/xanthous): Use dual-wielding to calculate damage
When dual-wielding weapons, do damage from both weapons and use both
weapons' attack messages.

Change-Id: I3c404946d0167c9b5c2bcf58ab5c3429cc5269fc
Reviewed-on: https://cl.tvl.fyi/c/depot/+/5605
Autosubmit: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
2022-05-14 16:02:47 +00:00
Griffin Smith
b510503479 fix(grfn/xanthous): Don't remove items on cancel
Only remove items selected to wield from the inventory once they're
actually going to be wielded, to avoid cancelling the hand selection
from causing the item to disappear

Change-Id: I3c4010058ae18b205a68b035d5e189a10ffbd12c
Reviewed-on: https://cl.tvl.fyi/c/depot/+/5510
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
Autosubmit: grfn <grfn@gws.fyi>
2022-05-14 15:59:44 +00:00
Griffin Smith
1ce67611b5 feat(grfn/xanthous): Describe items in hand when wielding
Describe the items already in the hand when prompting for which hand to
wield an item in

Change-Id: Ifdf2703e8695aae5cbf06a3195fb790428954012
Reviewed-on: https://cl.tvl.fyi/c/depot/+/5509
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
Autosubmit: grfn <grfn@gws.fyi>
2022-05-14 15:59:44 +00:00
sterni
60bce4045b chore(users/grfn): cargo update
I believe this should take care of all advisories.

Change-Id: I20984caa20897c0d0541f427a657990dc9b156fb
Reviewed-on: https://cl.tvl.fyi/c/depot/+/5584
Autosubmit: sterni <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
2022-05-13 14:37:48 +00:00
Griffin Smith
632c4280b5 feat(xanthous): Allow selecting hand for wielding
When wielding items, allow selecting which hand the item should be
wielded in.

Currently this has no actual effect on the mechanics of combat - that'll
come next.

Change-Id: Ic289ca2d8fa6f5fc0ad5bd0b012818a3acd8599e
Reviewed-on: https://cl.tvl.fyi/c/depot/+/5470
Reviewed-by: grfn <grfn@gws.fyi>
Autosubmit: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
2022-04-16 20:30:42 +00:00
Griffin Smith
8da2fce9ef fix(grfn/xanthous): Use correct ghc version for shell pkgs
Not having this causes haskell-language-server to complain about a
mismatch between its and the project's GHC versions.

Change-Id: Ie7584ad96532ca34a85430aa1a2211c2b91db872
Reviewed-on: https://cl.tvl.fyi/c/depot/+/5465
Reviewed-by: grfn <grfn@gws.fyi>
Reviewed-by: sterni <sternenseemann@systemli.org>
Autosubmit: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
2022-04-16 20:30:42 +00:00
Griffin Smith
3c294fbabd feat(grfn/xanthous): Add a help panel
Change-Id: I581a37df0a20fa54878da4446007dbe677e057da
Reviewed-on: https://cl.tvl.fyi/c/depot/+/5444
Autosubmit: grfn <grfn@gws.fyi>
Reviewed-by: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
2022-04-14 14:22:28 +00:00
Griffin Smith
79aceaec17 feat(grfn/xanthous): Load keybindings from a data file
Change-Id: I62ac54543da5c855c86d39956e611fd44515e9a9
Reviewed-on: https://cl.tvl.fyi/c/depot/+/5443
Autosubmit: grfn <grfn@gws.fyi>
Reviewed-by: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
2022-04-14 14:22:28 +00:00
sterni
11f9306b9a chore(3p/sources): Bump channels & overlays
Use nixos-unstable-small which fixes CVE-2018-25032
(out of bounds write while compressing).

* //users/grfn/xanthous:

  - Supporting random-fu 0.3 requires considerable changes and patching
    random-extras (https://github.com/aristidb/random-extras/pull/5).

    For now we downgrade random-fu and its dependency rvar to 0.2.*,
    forcing us to build xanthous with GHC 8.10.7, due to random-fu 0.2.*
    not supporting that version.

    Nix expressions for the downgraded packages are checked in to avoid
    the potential need to compile Haskell at pipeline eval time.

  - generic-arbitrary exposes a GenericArbitrary newtype now.
    This means we no longer have to implement it in xanthous
    downstream and patch generic-arbitrary to expose the
    GArbitrary type class.

  - Minor adjustments for lens 5.0:

    Xanthous.Game.Memo: clear needs to use ASetter' instead of Lens'

    Xanthous.Data.EntityMap: TraversableWithIndex no longer has an
    itraversed function.

  - Xanthous.Orphans: adjust for aeson's KeyMap, use KM.size explicitly
    instead of relying on MonoTraversable's length

* //nix/buildLisp: the CCL issue has resurfaced, disabling the
  implementation once again.

* //3p/arion: remove, as depot uses the nixpkgs package of it anyways.

* //users/wpcarro: accomodate GHC 9.0.1's stricter parsing of operators.

* //users/tazjin: disable rustfmt as it stopped respecting settings

* //3p/overlays: upgrade home-manager until fix for serivce generation
  has landed upstream

* //users/grfn/system: remove rr override, as the pinned commit is part
  of the 5.5.0 release shipped by nixpkgs.

Change-Id: If229e7317ba48498f85170b57ee9053f6997ff8a
Reviewed-on: https://cl.tvl.fyi/c/depot/+/5428
Tested-by: BuildkiteCI
Autosubmit: sterni <sternenseemann@systemli.org>
Reviewed-by: grfn <grfn@gws.fyi>
Reviewed-by: tazjin <tazjin@tvl.su>
Reviewed-by: wpcarro <wpcarro@gmail.com>
2022-04-11 19:37:01 +00:00
Vincent Ambo
3d8ee62087 style(rust): Format all Rust code with rustfmt
Change-Id: Iab7e00cc26a4f9727d3ab98691ef379921a33052
Reviewed-on: https://cl.tvl.fyi/c/depot/+/5240
Tested-by: BuildkiteCI
Reviewed-by: kanepyork <rikingcoding@gmail.com>
Reviewed-by: Profpatsch <mail@profpatsch.de>
Reviewed-by: grfn <grfn@gws.fyi>
Reviewed-by: tazjin <tazjin@tvl.su>
2022-02-08 12:06:39 +00:00
Vincent Ambo
aa122cbae7 style: format entire depot with nixpkgs-fmt
This CL can be used to compare the style of nixpkgs-fmt against other
formatters (nixpkgs, alejandra).

Change-Id: I87c6abff6bcb546b02ead15ad0405f81e01b6d9e
Reviewed-on: https://cl.tvl.fyi/c/depot/+/4397
Tested-by: BuildkiteCI
Reviewed-by: sterni <sternenseemann@systemli.org>
Reviewed-by: lukegb <lukegb@tvl.fyi>
Reviewed-by: wpcarro <wpcarro@gmail.com>
Reviewed-by: Profpatsch <mail@profpatsch.de>
Reviewed-by: kanepyork <rikingcoding@gmail.com>
Reviewed-by: tazjin <tazjin@tvl.su>
Reviewed-by: cynthia <cynthia@tvl.fyi>
Reviewed-by: edef <edef@edef.eu>
Reviewed-by: eta <tvl@eta.st>
Reviewed-by: grfn <grfn@gws.fyi>
2022-01-31 16:11:53 +00:00
Griffin Smith
604319850c feat(gs/xanthous): Creatures drop their items when they die
When a creature is killed, it now drops all the contents of its
inventory on the ground.

Change-Id: Ie95c397308ba2c9861f10e58b99c91c9cc759c56
2021-11-25 17:31:01 +00:00
Griffin Smith
a3d220b631 feat(gs/xanthous): Creatures use their weapons to attack
If a creature has a weapon wielded, then they now use that weapon to
attack the player *instead of* their natural attacks. This uses a new
`creatureAttackMessage` field on the Item raw for the message to use.

Change-Id: I73614f33dbf88dd4c68081f15710fa27b7b21ba2
2021-11-25 17:31:01 +00:00
Griffin Smith
4b11859d04 feat(gs/xanthous): Allow generating creatures with items
Add an `equippedItems` field to the CreatureType raw, which provides a
chance for generating that creature with an item equipped, which goes
into a new `inventory` field on the creature entity itself. Currently
the creature doesn't actually *use* this equipped item, but it's a step.

This commit also adds a broken-dagger equipped 90% of the time to the
"husk" creature.

Change-Id: I6416c0678ba7bc1b002c5ce6119f7dc97dd86437
2021-11-25 17:31:01 +00:00
Griffin Smith
95ee86225b refactor(gs/xanthous): Break out inventory into a common module
Creatures are going to have an inventory too now in addition to
characters, so all the data types and lenses and stuff that define
inventory need to be broken out into a separate module so the Creature
entity can use them.

Change-Id: I83f1c70d316afaaf2e75901f9dc28f79fd2cd31f
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3901
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
2021-11-22 19:12:56 +00:00
Griffin Smith
3a01398672 refactor(gs/xanthous): Define local field lens aliases in AI
This slightly improves how the module reads imo

Change-Id: Ib1efcbbd5392ece6b46461e8075162f03846d421
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3886
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
2021-11-22 19:12:56 +00:00
Griffin Smith
21c218542c fix(gs/xanthous): Check for reaching destination in AI
Because floating points, it's possible that a creature has reached their
destination even if the *progress* to that destination is at 0 - if that
happens, they should pick a new destination regardless. This fixes the
issue where creatures would occasionally get "stuck" and never move
after wandering around for a bit.

Change-Id: I01a11ce4bd448c25a818c886825e4fad56dffe03
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3885
Reviewed-by: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
2021-11-20 21:49:30 +00:00
Griffin Smith
608e6e778e feat(gs/xanthous): Allow moving with the arrow keys
some... *ahem*... very insistent people have been asking for this,
despite the fact that it doesn't allow for diagonal movement.

Change-Id: Ic58e2435b34e27e3ed399c7b8f3bcbc1f634f6b3
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3870
Reviewed-by: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
2021-11-13 15:57:18 +00:00
Griffin Smith
1af67d9ca7 feat(gs/xanthous): Add a Husk creature, with limited generation
Add a new "husk" creature raw, limited to only being generated on levels
>= 1, including support for actually doing that limiting.

These guys are gonna get daggers next!

Change-Id: Ic4b58dc7ee36b50ced60fec6912cd1b46269d55c
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3868
Reviewed-by: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
2021-11-13 15:57:18 +00:00
Griffin Smith
e2f8939a9e feat(gs/xanthous): Add a broken dagger raw
The plan is to use this as a test bed for generating creatures wielding
items, but for know it just shows up on the ground in places.

Change-Id: I8b292606f425cd41bff9e52727f1094886777102
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3867
Reviewed-by: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
2021-11-13 15:57:18 +00:00
Griffin Smith
2833104708 chore(gs/xanthous): Don't include docs in source closure
Change-Id: Ib6f2604096fa519f37ec4a2ce762229abca16b26
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3866
Reviewed-by: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
2021-11-13 15:57:18 +00:00
Griffin Smith
98397b8515 docs(gs/xanthous): Start documenting raw types
Start documenting the fields of the raw type YAML files and what they
mean, to make it easier to write new raw types.

Change-Id: I9672b757e89f1cc665d7e90078d83cfd87173d7f
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3865
Reviewed-by: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
2021-11-13 15:57:18 +00:00
Griffin Smith
3c33a2c756 fix(xanthous/server): Mount the key into the docker image
mount the host key in as a single-file volume, so the server can
actually read it.

Change-Id: I5fb58536717c91480d1f4610b6fb3258a36169e0
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3864
Reviewed-by: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
2021-11-13 14:47:02 +00:00
Griffin Smith
33f29d081d fix(xanthous/server): Fix decoding secret key
The actual function we want for the format we're using is
decode_secret_key, not decode_openssh, apparently - covered this with a
toneest to make sure.

Change-Id: I659226169f213b8464b96aec6b94bf13fd80aac8
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3863
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
2021-11-13 14:12:25 +00:00
Griffin Smith
0d1980f2d6 feat(xanthous/server): Load host secret key from disk
Rather than randomly generating a new host key every time we run the
server, load the host's secret key from a file on disk at startup, so
that clients don't have to disable host key verification to connect
every time we restart.

Change-Id: I4d283bc919f4825789f686a98c174a71929087a6
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3819
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
2021-11-08 17:01:14 +00:00
Griffin Smith
7d1ebe996c chore(gs/xanthous): Gitignore more state files
Gitignore:

- *.save, which I use for save-games I want to use as test case
  reproductions
- .tasty-rerun-log, which tasty-rerun uses to save which tests failed on
  the last run
- cabal.project.local-*, since I've got a file on my machine called
  cabal.project.local~0 so apparently that's a thing now

Change-Id: I07c391fa25a84e96efca6771997f280ff12826b5
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3818
Reviewed-by: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
2021-11-08 15:29:13 +00:00
Griffin Smith
5b4c4f0701 feat(gs/xanthous): Enable tasty-rerun
Rerunning only failed tests is nice! To use this, run `cabal new-run
test -- --rerun`

Change-Id: I9dc4d69749c3e3d5ba8d1661a2fdf73e49cd8ad5
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3816
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
2021-11-08 15:29:05 +00:00
Griffin Smith
56718d14b1 fix(gs/xanthous): Don't take up half-width for prompts
txtWrap takes up half the available width in the viewport, causing
the input for prompts to display way too far to the right of the actual
prompt. I'm not aware of any actual mutiline prompts, so using txt here
makes way more sense.

Change-Id: I7f62066f1b07b5d6ba2c7ffed77c87ae33b1dfa5
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3814
Reviewed-by: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
2021-11-08 03:31:51 +00:00
Griffin Smith
e9c3d2f6d9 feat(gs/mugwump): Run xanthous server
Add a nixos module for running the xanthous server in a docker
container, and install it on mugwump including a prometheus scrape
config.

Change-Id: Ifeb315845b7eef2ee33af98fa3f71acdd3d9fe6b
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3812
Reviewed-by: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
2021-11-07 23:02:23 +00:00
Griffin Smith
5327d238e3 feat(xanthous/server): Add simple prometheus metrics
Add a prometheus exporter and some simple prometheus metrics, so that I
can look at dashboards and get alerts for things like lots of
connections

Change-Id: Ic1e0568200299dc852b74da647a6354267ee7576
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3811
Reviewed-by: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
2021-11-07 21:18:39 +00:00
Griffin Smith
77f0d62a2c feat(xanthous/server): Add derivation for docker image
This appears to work pretty nicely!

Change-Id: Icf52f58225ee2837b30ba6187ae3ba3c539de9df
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3810
Reviewed-by: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
2021-11-07 21:05:39 +00:00
Griffin Smith
f9f5b0b199 feat(xanthous/server): Run with --disable-saving
Don't write to my disk, please, random internet people.

Change-Id: I1d199fc3675f6ec7630f598bbc33dc7ef7e02e68
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3809
Reviewed-by: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
2021-11-07 21:05:39 +00:00
Griffin Smith
9577d97a8f feat(gs/xanthous): Allow disabling saving
Add a command-line parameter to disable the Save command, so people
don't save and fill up my disk when I'm running this on the internet.

Change-Id: I2408e60de2d99764ac53c21c3ea784282576d400
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3808
Reviewed-by: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
2021-11-07 21:05:39 +00:00
Griffin Smith
e3724448a2 fix(xanthous/server): Accept password authentication
Accept password authentication in addition to public key authentication,
but ignore the actual password, so that clients without ssh keys
configured (or configured to send no ssh keys) can authenticate.

Change-Id: I86130b9725d1928ac45b5db55f18c09687ee0fd5
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3807
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
2021-11-07 21:05:39 +00:00
Griffin Smith
94be8ad755 feat(gs/xanthous): Add SSH server application
Add the start of an ssh-compatible server application for playing
Xanthous over ssh. The idea here is that the user can ssh with whatever
username they like (defaulting obviously to their login username) and
then that gets passed as the --name flag to xanthous as they play.

Change-Id: I39eec288ac8e22a165e859479888d78158a58818
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3806
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
2021-11-07 21:05:39 +00:00
Griffin Smith
b68414c66b fix(gs/xanthous): Fix numAliveNeighbors{,M} on the edge
numAliveNeighbors was doing bounds checks too aggressively, resulting in
always returning 8 for points on the edge, meaning walls weren't getting
properly created for those points, making edges of the map open to walk
through.

Change-Id: Iada6be46ce7cc77ce99a320b7310008898b89273
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3805
Reviewed-by: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
2021-11-06 17:34:46 +00:00
Griffin Smith
eeafd0fa0e fix(gs/xanthous): Don't gen dupe tutorial messages
Don't generate tutorial messages on levels other than the first.

Change-Id: I7681377461b92f5d5015931b0088bef9d358d2e4
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3804
Reviewed-by: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
2021-11-06 17:34:46 +00:00
Griffin Smith
580e37ff64 refactor(gs/xanthous): Use a Word for the level number
Using a signed Int here is a little silly, since we can never have
negative levels.

Change-Id: Ibe03be5014226e07dfa6f78d8360301bc1b7c9b1
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3803
Reviewed-by: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
2021-11-06 17:34:46 +00:00
Griffin Smith
e0bec49b39 fix(gs/xanthous): Update hie.yaml for new app/ directory
Change-Id: I87c82f22313285085ac53485613b7d9f91b52ed2
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3802
Reviewed-by: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
2021-11-06 15:52:02 +00:00
Griffin Smith
ff6c008d78 feat(gs/xanthous): Default to the current save file
When saving, default to the save file that was loaded for the game if
any. To support this, this also makes text prompts support a default,
which will be used if no value is input.

Change-Id: I72a826499d6e987b939e3465a2d29167e53416be
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3801
Reviewed-by: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
2021-11-06 15:52:02 +00:00
Griffin Smith
18315b2fb6 fix(gs/xanthous): Preserve character state when going up stairs
Carry over everything except the character's position when going up
stairs, so that eg the character doesn't lose everything they picked up
and instantly heal to full when going up a level.

Change-Id: I08513578a72f2410a363bbadbb273d95826a3f1b
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3766
Reviewed-by: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
2021-10-30 17:16:21 +00:00
Griffin Smith
61802fe106 feat(gs/xanthous): Allow throwing rocks
Implement a first pass at a "fire" command, which allows throwing rocks,
the max distance and the damage of which is based on the weight of the
item and the strength of the player.

Currently the actual numbers here likely need some tweaking, as the
rocks are easily throwable at good distances but don't really deal any
damage.

Change-Id: Ic6ad0599444af44d8438b834237a1997b67f220f
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3764
Reviewed-by: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
2021-10-30 17:16:21 +00:00
Griffin Smith
352c75630d feat(gs/xanthous): Send message when resting
Change-Id: Ib1e7ae6dfcbc2d2e86a28b401e67cd5dd22d6281
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3763
Reviewed-by: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
2021-10-30 17:16:21 +00:00
sterni
2f750e4a14 refactor(grfn/xanthous): avoid unnecessary recompilation
hpack is a bit dumb when generating the list of modules for a cabal
file's component if multiple of them live in the same directory.
Specifically it seems to assume that all modules in the source-dirs
of a particular component are also necessary for its compilation.

This is quite bad in the case of xanthous since both library and
executable have source-dirs: src, so all modules will be compiled
twice: Once for the library and then again for the executable
despite it depending on the library (actually 4 times in total
since we need to build a unprofiled and profiled object for each
module…).

To fix this we just move Main.hs into its own directory and change
the executable's source-dirs, so hpack doesn't get confused anymore.
Since all components now have their own source-dirs, unnecessary
redundant compilation should be down to 0. The diff of the cabal
file shows quite nicely how many module recompilation we've gotten
rid of.

Change-Id: I2df4fab9b0299b3a2b5d3005508c79b2d9796039
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3533
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
Reviewed-by: grfn <grfn@gws.fyi>
2021-09-11 16:00:12 +00:00
Griffin Smith
ad8d38c64c fix(xanthous): Fix display of square/cubic units
Previously this'd display `5 m m³`, because it'd show the underlying
value then add the unit suffix on at the end

Change-Id: Idd240ddfebc212460f9fb529eff72732a5dafe2a
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3241
Reviewed-by: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
2021-07-06 18:32:08 +00:00
Griffin Smith
7437a18188 fix(xanthous): Only use alphabetic chars for menu items
Previously, we were using `smallestNotIn` for selecting new characters
for menu items with duplicate chatacters - this uses the 'Bounded'
instance for the type, which for Char meant the first character we would
always select was \NUL - making it look like the menu item had no
character, and making it impossible to actually select the menu item.
This introduces an AlphaChar newtype, which is a wrapper around Char
whose Bounded and Enum instances only use alphabetic characters (a-ZA-Z)
and uses that for menu characters instead.

Change-Id: If34ed9e9ce84f2bcb1cb87432cc6273f40b69f72
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3229
Reviewed-by: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
2021-06-23 21:52:08 +00:00
Griffin Smith
76258fbfa1 feat(xanthous): Describe *where* the item is in the inventory
When describing items in the inventory, both in detail and when
producing menus from those items, describe not just the item itself but
also *where* in the inventory the item is (either in the backpack, or
wielded in either or both of the hands). This uses a new
InventoryPosition datatype, and a method to get a list of items in the
inventory associated with their inventory position. When *removing*
items from the inventory (to wield, drop, or eat them), we want to make
sure we remove from the right position, so this also introduces
a `removeItemAtPosition` method to make that happen correctly.

Finally, some of the tests for this stuff was getting really slow - I
narrowed this down to runaway arbitrary generation for message
Templates, so I've tweaked the Arbitrary instance for that type to
generate smaller values.

Change-Id: I24e9948adae24b0ca9bf13955602108ca9079dcc
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3228
Reviewed-by: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
2021-06-23 21:52:08 +00:00
Griffin Smith
f0c167d361 feat(xanthous): Add a command to describe an item in the inventory
Add a new DescribeInventory command, bound to I, to prompt for an item
in the inventory (anywhere in the inventory, including wielded) and
display a (new) panel describing it in detail. This description includes
the description, the long description, and the item's physical
properties (volume, density, and weight).

Change-Id: Idc1a05ab16b4514728d42aa6b520f93bea807c07
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3227
Reviewed-by: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
2021-06-23 21:52:08 +00:00
Griffin Smith
d8bd8e7eea feat(xanthous) Generate random volume+density for items
Generate random volumes and densities for items based on the ranges for
those two quantities in the raw when building instances of items.

Since this is the first time creating an item is impure, this also lifts
entity generation into a (random) monadic context

Change-Id: I2de4880e8144f7ff9e1304eb32806ed1d7affa18
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3226
Reviewed-by: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
2021-06-23 21:52:08 +00:00
Griffin Smith
8b97683f6e feat(xanthous): Track the volume and density of item types
Allow the itemType raw to have density and volume fields, both of which
represent *intervals* of both density and volume (because both can
hypothetically vary a bit). The idea here is that when we're making
an *instance* of one of these items, we pick a random value in the
range.

Lots of stuff in this commit is datatype and typeclass instances to
support things like intervals being fields on datatypes that get
serialized to saved games - including a manual definition of Ord for
Item since Ord isn't well-defined for intervals

Change-Id: Ia088f2f75cdce9d00560297e5c269e3310b85bc3
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3225
Reviewed-by: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
2021-06-23 21:52:08 +00:00