@@ -85,11 +85,12 @@ multi MAIN('new-ui-type', Str:D $ui-type) is export {
85
85
. put , . IO . mkdir for « docs lib / MUGS/ App $ lib-dir
86
86
" $ lib-dir /Game" " $ lib-dir /Genre" »;
87
87
88
- $ tool . additional-step(' Adding MUGS-specific files' );
88
+ $ tool . additional-step(' Adding/updating MUGS-specific files' );
89
89
90
90
my $ MUGS-version = $ ? DISTRIBUTION . meta<version >;
91
91
my $ bin-file = ' bin/mugs-' ~ $ ui-type . lc . subst (/^ 'web' /, ' web-' );
92
92
my $ app-file = " lib/MUGS/App/{ $ ui-type } .rakumod" ;
93
+ my $ class-file = " lib/MUGS/UI/{ $ ui-type } .rakumod" ;
93
94
my $ test-file = " t/00-use.rakutest" ;
94
95
95
96
put $ bin-file ;
@@ -115,9 +116,10 @@ multi MAIN('new-ui-type', Str:D $ui-type) is export {
115
116
%PROCESS::SUB-MAIN-OPTS = :named-anywhere;
116
117
117
118
118
- #| \qq[$ui-type] App
119
+ #| \qq[$ui-type] app
119
120
class \qq[$app] is MUGS::App::LocalUI {
120
- # XXXX: Add attributes for app-wide state here
121
+ has MUGS::UI::Pop::Game $.current-game;
122
+ # XXXX: Add additional app-wide state attributes here
121
123
122
124
method ui-type() { '\qq[$ui-type]' }
123
125
@@ -142,9 +144,15 @@ multi MAIN('new-ui-type', Str:D $ui-type) is export {
142
144
await $.session.authenticate(:$username, :$password);
143
145
}
144
146
147
+ #| Create and initialize a new game UI for a given game type and client
148
+ method launch-game-ui(Str:D :$game-type, MUGS::Client::Game:D :$client, *%ui-opts) {
149
+ $!current-game = callsame;
150
+ }
151
+
145
152
#| Start actively playing current game UI
146
153
method play-current-game() {
147
- # XXXX: Enter \qq[$ui-type] main loop here
154
+ # XXXX: Enter \qq[$ui-type] main loop here, or (by default) hand to game UI
155
+ $!current-game.main-loop;
148
156
}
149
157
}
150
158
@@ -172,6 +180,23 @@ multi MAIN('new-ui-type', Str:D $ui-type) is export {
172
180
}
173
181
APP_MODULE
174
182
183
+ put $ class-file ;
184
+ my $ skip-first-line = $ class-file . IO . lines (:! chomp )[1 .. * ]. join ;
185
+ spurt ($ class-file , q :to /BASE_CLASS / ~ $ skip-first-line );
186
+ # ABSTRACT: \qq[$ui-type] UI for MUGS, including App and game UIs
187
+
188
+ unit module \qq[$class]:ver<0.0.1>;
189
+
190
+ use MUGS::UI;
191
+
192
+
193
+ # Base class for \qq[$ui-type] game UIs
194
+ class Game is MUGS::UI::Game {
195
+ method ui-type() { '\qq[$ui-type]' }
196
+ }
197
+
198
+ BASE_CLASS
199
+
175
200
put $ test-file ;
176
201
spurt ($ test-file , q :to /USE_TEST /);
177
202
use v6.d;
@@ -197,9 +222,9 @@ multi MAIN('new-ui-type', Str:D $ui-type) is export {
197
222
$ tool . run-or-exit($ _ , : force) for
198
223
« chmod + x $ bin-file »,
199
224
« mi6 build »,
200
- « git add $ bin-file $ app-file $ test-file META6. json »,
225
+ « git add $ bin-file $ app-file $ class-file $ test-file META6. json »,
201
226
« git rm t/ 01 -basic. rakutest », # Redundant with 00-use
202
- « git commit -m " Add MUGS-specific files" »,
227
+ « git commit -m " Add MUGS-specific files and tweaks " »,
203
228
« git status »,
204
229
;
205
230
0 commit comments