-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkit.go
More file actions
220 lines (183 loc) · 6.81 KB
/
Copy pathkit.go
File metadata and controls
220 lines (183 loc) · 6.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
// Package kit is the shellcade game developer kit: the authoring surface
// for wasm games targeting the shellcade ABI (see ABI.md; the wire package is
// the ABI's code form).
//
// A game implements Game + Handler and calls Main(game) from main(), plus the
// eight //go:export trampolines for the wasm build — run `shellcade-kit new` for a
// working scaffold, and see GUIDE.md for the full authoring guide.
//
// This package is a curated facade over internal/game; the implementation is
// internal so the public surface stays deliberate and versionable.
package kit
import "github.com/shellcade/kit/v2/internal/game"
// ABIVersion is the ABI major version this SDK targets.
const ABIVersion = game.ABIVersion
// ---- players & inputs ----------------------------------------------------------
type (
Player = game.Player
Character = game.Character
Kind = game.Kind
Input = game.Input
InputKind = game.InputKind
Key = game.Key
InputContext = game.InputContext
Action = game.Action
)
const (
KindGuest = game.KindGuest
KindMember = game.KindMember
InputRune = game.InputRune
InputKey = game.InputKey
KeyNone = game.KeyNone
KeyEnter = game.KeyEnter
KeyBackspace = game.KeyBackspace
KeyEsc = game.KeyEsc
KeyTab = game.KeyTab
KeyUp = game.KeyUp
KeyDown = game.KeyDown
KeyLeft = game.KeyLeft
KeyRight = game.KeyRight
KeyCtrlC = game.KeyCtrlC
CtxNav = game.CtxNav
CtxCommand = game.CtxCommand
CtxText = game.CtxText
ActNone = game.ActNone
ActUp = game.ActUp
ActDown = game.ActDown
ActLeft = game.ActLeft
ActRight = game.ActRight
ActConfirm = game.ActConfirm
ActBack = game.ActBack
)
// Resolve maps an Input to a semantic Action for the given context — the
// platform's canonical control vocabulary, reimplemented locally.
func Resolve(in Input, ctx InputContext) Action { return game.Resolve(in, ctx) }
// RuneControl declares a printable-rune extra control for GameMeta.Controls,
// e.g. RuneControl('r', "RESIGN").
func RuneControl(r rune, label string) ControlDecl { return game.RuneControl(r, label) }
// KeyControl declares a named-key extra control for GameMeta.Controls,
// e.g. KeyControl(KeyBackspace, "UNDO").
func KeyControl(k Key, label string) ControlDecl { return game.KeyControl(k, label) }
// ---- rooms & results -------------------------------------------------------------
type (
RoomConfig = game.RoomConfig
Mode = game.Mode
MergeRule = game.MergeRule
GameMeta = game.GameMeta
LeaderboardSpec = game.LeaderboardSpec
ConfigKeySpec = game.ConfigKeySpec
ControlDecl = game.ControlDecl
Lifecycle = game.Lifecycle
GameKind = game.GameKind
ConfigType = game.ConfigType
Direction = game.Direction
Aggregation = game.Aggregation
MetricFormat = game.MetricFormat
Status = game.Status
PlayerResult = game.PlayerResult
Result = game.Result
// ScoreKeeper standardises live/disconnect/periodic leaderboard posting.
ScoreKeeper = game.ScoreKeeper
Cadence = game.Cadence
)
// NewScoreKeeper constructs a ScoreKeeper with the given auto-post cadence.
func NewScoreKeeper(c Cadence) *ScoreKeeper { return game.NewScoreKeeper(c) }
const (
ModeQuick = game.ModeQuick
ModePrivate = game.ModePrivate
ModeSolo = game.ModeSolo
MergeKeepWinner = game.MergeKeepWinner
MergeKeepLoser = game.MergeKeepLoser
MergeSum = game.MergeSum
MergeMax = game.MergeMax
HigherBetter = game.HigherBetter
LowerBetter = game.LowerBetter
CtxFeatRosterEpoch = game.CtxFeatRosterEpoch
CtxFeatCharacter = game.CtxFeatCharacter
CtxFeatCredits = game.CtxFeatCredits
GameKindGame = game.GameKindGame
GameKindCasino = game.GameKindCasino
LifecycleResumable = game.LifecycleResumable
LifecycleEphemeral = game.LifecycleEphemeral
LifecycleResident = game.LifecycleResident
ConfigText = game.ConfigText
ConfigNumber = game.ConfigNumber
ConfigBool = game.ConfigBool
ConfigJSON = game.ConfigJSON
BestResult = game.BestResult
SumResults = game.SumResults
Integer = game.Integer
Decimal = game.Decimal
Duration = game.Duration
OnImprove = game.OnImprove
OnChange = game.OnChange
StatusFinished = game.StatusFinished
StatusDNF = game.StatusDNF
StatusFlagged = game.StatusFlagged
)
// ---- the canvas -------------------------------------------------------------------
type (
Frame = game.Frame
Cell = game.Cell
Style = game.Style
Color = game.Color
Attr = game.Attr
)
const (
Rows = game.Rows
Cols = game.Cols
AttrBold = game.AttrBold
AttrDim = game.AttrDim
AttrUnderline = game.AttrUnderline
AttrReverse = game.AttrReverse
)
// RGB constructs a truecolor value; Gray an even gray.
func RGB(r, g, b uint8) Color { return game.RGB(r, g, b) }
func Gray(v uint8) Color { return game.Gray(v) }
// Standard palette.
var (
White = game.White
Red = game.Red
Green = game.Green
Yellow = game.Yellow
Cyan = game.Cyan
DimGray = game.DimGray
)
// NewFrame returns a blank 24x80 frame. Frames are handled by POINTER
// throughout the SDK (see ABI.md §6).
func NewFrame() *Frame { return game.NewFrame() }
// CharacterCell returns the one ready-made cell of a member's character tile:
// the glyph styled with the resolved ink and background. The zero Character
// (the game's meta does not declare CtxFeatCharacter) yields a blank cell.
func CharacterCell(c Character) Cell { return game.CharacterCell(c) }
// ---- the authoring contract --------------------------------------------------------
type (
Game = game.Game
Handler = game.Handler
Base = game.Base
Room = game.Room
Services = game.Services
KVStore = game.KVStore
Account = game.Account
AccountStore = game.AccountStore
ConfigStore = game.ConfigStore
Credits = game.Credits
)
// Credits errors (casino-kind games): match with errors.Is. ErrEconomyDisabled
// means the host has the economy switched off — render an out-of-service
// state, never trap.
var (
ErrInsufficientCredits = game.ErrInsufficientCredits
ErrEconomyDisabled = game.ErrEconomyDisabled
ErrCreditsDenied = game.ErrCreditsDenied
ErrCreditsUnavailable = game.ErrCreditsUnavailable
)
// (Frame).Clear resets a frame for reuse — prefer one long-lived frame plus
// Clear() per render over NewFrame() per render (allocation-free steady state).
//
// Frame authoring methods (on *Frame, surfaced via the type alias above):
// Set/SetRune/Text/SetWide/Fill are unchanged single-code-point writers, and
// v2 adds (*Frame).SetGrapheme(row, col, cluster, style) and the width-2
// (*Frame).SetGraphemeWide(...) for clusters of up to three code points (VS16,
// skin-tone, keycap). Both refuse a >3- or 0-code-point cluster by drawing
// nothing (see GUIDE.md "Grapheme glyphs").