Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,33 @@ The player-facing command set is intentionally melee-focused.
| `h` `j` `k` `l` | move west / south / north / east |
| `.` | wait one turn |
| arrows | move (or move the cursor in look/throw mode) |
| `f` + `h/j/k/l` | bash an adjacent small obstacle |
| `x` + `h/j/k/l` | bash an adjacent small obstacle |
| `a` | use the Hands item / report the weapon ready |
| `b` | use the Head item |
| `c` `d` `e` `f` `g` | use Robe slots 1–5 |
| `r` / `t` | use the first / second known Rite |
| `A` `H` `C` `D` `R` | drop Hands, Head, Robe 1–3 |
| `g` | get the item from the ground |
| `e` | equipment overlay |
| `p` | pick up the item from the ground |
| `i` | inventory / equipment screen |
| `v` | view / look around |
| `~` | expand/collapse latest messages |
| `@` | character information |
| `O` | options |
| `o` | options |
| `?` | help / key bindings |
| `S` | save and quit |
| `s` | save and quit |
| `>` | use portal / stairs / elevator |
| `]` or `F7` | jump directly to the next map |
| `[` or `F8` | jump directly to the previous map |
| `Space` | close a modal screen without taking an action |
| `Q` | quit |
| `q` or `z` | quit |

Walking into a monster attacks it. Player and monster movement and attacks are
cardinal only (`hjkl`); there are no diagonal attacks. Bashing is intentional:
use `f` and a direction. A bash takes a turn, and some containers such as
use `x` and a direction. A bash takes a turn, and some containers such as
barrels or crates may drop supplies when smashed.

Screens generally close with `z`, `q`, `Space`, or `Esc`. The player is
On the inventory screen lowercase `a`–`g` use slots and uppercase `A`–`G` drop
them. Uppercase letters do nothing on the map. Screens generally close with
`i`, `z`, `q`, `Space`, or `Esc`. The player is
defenceless without a melee weapon; there is no unarmed attack. Flask throwing
is deferred for now.

Expand Down Expand Up @@ -111,7 +114,7 @@ grants a second Rite is not implemented yet.
* blood, corpses and limbs
* Hands, Head and a permanently worn Robe with three starting slots
* one-line HUD with HP/AP, the ready weapon and Rite charges; one-line message bar
* `~` expands the latest eight messages; `e` opens a non-scrolling equipment overlay
* `~` expands the latest eight messages; `i` opens the non-scrolling inventory/equipment overlay
* one item maximum per ground tile; dropping onto an occupied tile is refused
* experience is stored for now; player levels and skill points are removed
* auto-opening doors, portals, bashing, acid/fire/smoke, rain
Expand Down
46 changes: 43 additions & 3 deletions internal/game/controls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ func TestActiveBindingsUseNewKeys(t *testing.T) {
for _, b := range ActiveKeyBindings {
found[rune(b.Key)] = true
}
for _, key := range []rune{'h', 'j', 'k', 'l', '.', 'e', 'v', '~', 'g', 'r', 'R'} {
for _, key := range []rune{'h', 'j', 'k', 'l', '.', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'i', 'p', 'r', 'v', '~'} {
if !found[key] {
t.Fatalf("active key bindings missing %q", key)
}
}
for _, key := range []rune{'1', '2', '3', '4', '5', '6', '7', '8', '9'} {
for _, key := range []rune{'1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G'} {
if found[key] {
t.Fatalf("active key bindings still contain numpad key %q", key)
t.Fatalf("active key bindings still contain removed key %q", key)
}
}
}
Expand Down Expand Up @@ -208,3 +208,43 @@ func TestBarrelBashDropsLoot(t *testing.T) {
t.Fatalf("missing bash loot message: %v", msgs)
}
}

func TestSlotKeysAndUppercaseDrops(t *testing.T) {
want := map[rune]int{
'a': SlotHands,
'b': SlotHead,
'c': SlotRobe1,
'd': SlotRobe2,
'e': SlotRobe3,
'f': SlotRobe4,
'g': SlotRobe5,
}
for key, slot := range want {
got, ok := slotForKey(key)
if !ok || got != slot {
t.Fatalf("slotForKey(%q) = %d,%v, want %d,true", key, got, ok, slot)
}
}

g := NewGame(7308)
g.SetupNewGame(0, "tester")
g.Items = nil
g.Critters = nil
g.State = StatePlaying
weapon := &Item{Proto: itemProtoByName("sickle"), X: -1, Y: -1}
g.Player.Slots.Hands = weapon
u := &UI{g: g}
u.handlePlaying(tcell.NewEventKey(tcell.KeyRune, 'A', tcell.ModNone))
if g.Player.Slots.Hands != weapon {
t.Fatal("uppercase A dropped an item on the map")
}

g.State = StateInventory
u.handleInventory(tcell.NewEventKey(tcell.KeyRune, 'A', tcell.ModNone))
if g.Player.Slots.Hands != nil {
t.Fatal("uppercase A did not drop the Hands item in inventory")
}
if g.ItemAt(g.Player.X, g.Player.Y) == nil {
t.Fatal("dropped Hands item is not on the ground")
}
}
2 changes: 1 addition & 1 deletion internal/game/player_experience_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func TestInventoryGetPicksUpItem(t *testing.T) {
it := &Item{Proto: 48, X: g.Player.X, Y: g.Player.Y, Charges: 5}
g.Items = append(g.Items, it)
u := &UI{g: g}
u.handleInventory(tcell.NewEventKey(tcell.KeyRune, 'g', tcell.ModNone))
u.handleInventory(tcell.NewEventKey(tcell.KeyRune, 'p', tcell.ModNone))
if g.ItemAt(g.Player.X, g.Player.Y) != nil {
t.Fatal("item was not removed from the ground")
}
Expand Down
25 changes: 13 additions & 12 deletions internal/game/scope.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,28 +114,29 @@ var ActiveKeyBindings = []KeyBind{
{Key: 'k', Name: "move to north", Desc: "move player north"},
{Key: 'l', Name: "move to east", Desc: "move player east"},
{Key: '.', Name: "wait", Desc: "wait one turn"},
{Key: 'f', Name: "bash", Desc: "choose a direction and bash an adjacent small obstacle"},
{Key: 'x', Name: "bash", Desc: "choose a direction and bash an adjacent small obstacle"},
{Key: 'a', Name: "hands action", Desc: "use the Hands item (tool) or report the weapon ready"},
{Key: 'b', Name: "head action", Desc: "wear or inspect the Head item"},
{Key: 'c', Name: "robe slot 1", Desc: "use or consume robe slot 1"},
{Key: 'd', Name: "robe slot 2", Desc: "use or consume robe slot 2"},
{Key: 'e', Name: "robe slot 3", Desc: "use or consume robe slot 3"},
{Key: 'f', Name: "robe slot 4", Desc: "use or consume robe slot 4"},
{Key: 'g', Name: "robe slot 5", Desc: "use or consume robe slot 5"},
{Key: 'r', Name: "use rite", Desc: "use the first known rite"},
{Key: 't', Name: "use second rite", Desc: "use the second known rite"},
{Key: 'A', Name: "drop hands", Desc: "drop the Hands item"},
{Key: 'H', Name: "drop head", Desc: "drop the Head item"},
{Key: 'C', Name: "drop robe 1", Desc: "drop robe slot 1"},
{Key: 'D', Name: "drop robe 2", Desc: "drop robe slot 2"},
{Key: 'R', Name: "drop robe 3", Desc: "drop robe slot 3"},
{Key: 'g', Name: "get item", Desc: "pick up items from the current tile"},
{Key: 'e', Name: "equipment", Desc: "display the equipment overlay"},
{Key: 'p', Name: "pick up item", Desc: "pick up items from the current tile"},
{Key: 'i', Name: "inventory", Desc: "display equipment; uppercase A-G drop slots"},
{Key: 'v', Name: "view / look", Desc: "look around and examine the surroundings"},
{Key: '~', Name: "message log", Desc: "expand or collapse the latest eight messages"},
{Key: '@', Name: "player screen", Desc: "display character information"},
{Key: 'O', Name: "options", Desc: "display the options screen"},
{Key: 'o', Name: "options", Desc: "display the options screen"},
{Key: '?', Name: "help", Desc: "display this key binding screen"},
{Key: ' ', Name: "close overlay", Desc: "close a modal screen without taking an action"},
{Key: 'S', Name: "save and quit", Desc: "save the game and quit"},
{Key: 's', Name: "save and quit", Desc: "save the game and quit"},
{Key: '>', Name: "use portal", Desc: "use a portal, stairs or elevator"},
{Key: ']', Name: "next map", Desc: "jump directly to the next map"},
{Key: '[', Name: "previous map", Desc: "jump directly to the previous map"},
{Key: 'Q', Name: "quit", Desc: "quit the game"},
{Key: 'q', Name: "quit", Desc: "quit the game"},
}

// ActiveHints is the melee-focused hint list. The recovered hints that refer
Expand All @@ -148,5 +149,5 @@ var ActiveHints = []string{
Hints[7], // acid ignores armor
"you are defenceless without a weapon; keep a melee weapon equipped.",
"grenades and molotovs can only be thrown at tiles within your sight range.",
"bash small obstacles with f and a direction; barrels and crates may hide supplies.",
"bash small obstacles with x and a direction; barrels and crates may hide supplies.",
}
79 changes: 45 additions & 34 deletions internal/game/screens.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,41 @@ func slotKey(slot int) string {
case SlotHands:
return "a"
case SlotHead:
return "h"
return "b"
case SlotRobe1:
return "c"
case SlotRobe2:
return "d"
case SlotRobe3:
return "r"
return "e"
case SlotRobe4:
return "4"
return "f"
case SlotRobe5:
return "5"
return "g"
}
return "-"
}

func slotForKey(key rune) (int, bool) {
switch key {
case 'a':
return SlotHands, true
case 'b':
return SlotHead, true
case 'c':
return SlotRobe1, true
case 'd':
return SlotRobe2, true
case 'e':
return SlotRobe3, true
case 'f':
return SlotRobe4, true
case 'g':
return SlotRobe5, true
}
return 0, false
}

func itemSummary(it *Item) string {
if it == nil {
return "empty"
Expand Down Expand Up @@ -127,18 +147,18 @@ func (u *UI) drawInventory() {
y++
}

u.putStr(16, 10, "a use hands h head", 8, 0)
u.putStr(16, 11, "c/d/r use robe slot 1-3", 8, 0)
u.putStr(16, 12, "A/H/C/D/R drop slot", 8, 0)
u.putStr(16, 13, "j/k select enter use e/z/space close", 8, 0)
u.putStr(16, 10, "a hands b head c-g robe slots", 8, 0)
u.putStr(16, 11, "A-G drop the corresponding slot", 8, 0)
u.putStr(16, 12, "j/k select enter use p pick up", 8, 0)
u.putStr(16, 13, "i/z/q/space close", 8, 0)
u.putStr(16, 14, g.RiteSummary(), 11, 0)

ground := g.ItemAt(g.Player.X, g.Player.Y)
u.putStr(1, 17, "[ g ] item here: "+itemSummary(ground), 10, 0)
u.putStr(1, 17, "[ p ] item here: "+itemSummary(ground), 10, 0)

u.fill(0, 22, screenW, 2, ' ', 8, 0)
u.putStr(1, 22, "Robe slots hold vials, shards and small items; the robe cannot be removed.", 8, 0)
u.putStr(1, 23, "g get e/z/space close", 8, 0)
u.putStr(1, 23, "lowercase use uppercase drop p pick up i close", 8, 0)
}

func slotStats(it *Item) string {
Expand Down Expand Up @@ -226,30 +246,21 @@ func (u *UI) handleInventory(e *tcell.EventKey) {
u.slotSel = (u.slotSel + 1) % len(slots)
case 'k':
u.slotSel = (u.slotSel + len(slots) - 1) % len(slots)
case 'a':
g.UseSlot(SlotHands)
case 'h':
g.UseSlot(SlotHead)
case 'c':
g.UseSlot(SlotRobe1)
case 'd':
g.UseSlot(SlotRobe2)
case 'r':
g.UseSlot(SlotRobe3)
case 'A':
g.DropSlot(SlotHands)
case 'H':
g.DropSlot(SlotHead)
case 'C':
g.DropSlot(SlotRobe1)
case 'D':
g.DropSlot(SlotRobe2)
case 'R':
g.DropSlot(SlotRobe3)
case 'g':
g.PickUp()
case 'z', 'q', 'e', ' ':
case 'i', 'z', 'q', ' ':
g.State = StatePlaying
case 'p':
g.PickUp()
default:
key := e.Rune()
if slot, ok := slotForKey(key); ok {
g.UseSlot(slot)
return
}
if key >= 'A' && key <= 'G' {
if slot, ok := slotForKey(key - 'A' + 'a'); ok {
g.DropSlot(slot)
}
}
}
}

Expand Down Expand Up @@ -296,7 +307,7 @@ func (u *UI) drawPlayerScreen() {
}
u.fill(0, 22, screenW, 3, ' ', 8, 0)
u.putStr(1, 23, "z/space quit screen", 8, 0)
u.putStr(1, 24, "e equipment", 8, 0)
u.putStr(1, 24, "i inventory", 8, 0)
}

func skillLevelName(v int) string {
Expand Down
32 changes: 10 additions & 22 deletions internal/game/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -982,59 +982,47 @@ func (u *UI) handlePlaying(e *tcell.EventKey) {
return
}
r := e.Rune()
if slot, ok := slotForKey(r); ok {
g.UseSlot(slot)
return
}
switch r {
case '.':
g.WaitTurn()
case 'a':
g.UseSlot(SlotHands)
case 'r':
g.UseRite(0)
case 't':
g.UseRite(1)
case 'A':
g.DropSlot(SlotHands)
case 'H':
g.DropSlot(SlotHead)
case 'C':
g.DropSlot(SlotRobe1)
case 'D':
g.DropSlot(SlotRobe2)
case 'R':
g.DropSlot(SlotRobe3)
case 'g':
case 'p':
g.PickUp()
case 'f':
case 'x':
u.bashPending = true
g.Msg("bash in which direction? (esc cancels)", 8)
case '?':
g.State = StateHelp
case 'e':
case 'i':
g.State = StateInventory
u.slotSel = 0
case 'v':
g.State = StateLook
g.LookX, g.LookY = g.Player.X, g.Player.Y
case '~':
u.msgExpanded = true
case 'O':
case 'o':
g.State = StateOptions
u.optSel = 0
u.optScroll = 0
case '@':
g.State = StatePlayerScreen
case 'S':
case 's':
g.SaveAndQuit()
case '>':
g.UsePortal()
case ']':
g.ChangeLevelRelative(1)
case '[':
g.ChangeLevelRelative(-1)
case 'Q':
g.State = StateQuitConfirm
case 'z':
g.State = StateQuitConfirm
case 'Z':
case 'q', 'z':
g.State = StateQuitConfirm
}
if e.Key() == tcell.KeyEscape {
Expand Down
Loading