File tree 6 files changed +37
-5
lines changed
6 files changed +37
-5
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,13 @@ current buffer (only if its empty) set `vim_be_good_floating` to 0.
24
24
25
25
` let g:vim_be_good_floating = 0 `
26
26
27
+ ### Games - relative
28
+ By default vim be good returns random offset for game difficult above noob, if
29
+ you with to set fixed offset set ` vim_be_good_delete_me_offset ` to desired
30
+ value.
31
+
32
+ ` let g:vim_be_good_delete_me_offset = 35 `
33
+
27
34
## Instructions are at top of games.
28
35
here too!
29
36
@@ -40,7 +47,7 @@ character's case to complete the round.
40
47
41
48
## Installation
42
49
43
- 1 . Use your favorite plugin manager to install! Only works on Nvim, the one true
50
+ 1 . Use your favorite plugin manager to install! Only works on Nvim, the one true
44
51
vim.
45
52
46
53
Linux
Original file line number Diff line number Diff line change 5
5
"main" : " src/index.ts" ,
6
6
"scripts" : {
7
7
"copy-rplugin-json" : " cp ./rplugin-package.json ./rplugin/node/vim-be-good/package.json" ,
8
- "build" : " tsc && npm run copy-rplugin-json" ,
8
+ "build" : " prettier ./src --check && tsc && npm run copy-rplugin-json" ,
9
9
"prebuild:watch" : " npm run copy-rplugin-json" ,
10
10
"build:watch" : " nodemon -e ts --exec \" npm run build && echo '\n Good to go 👍'\" " ,
11
11
"lint" : " prettier ./src --check" ,
Original file line number Diff line number Diff line change @@ -68,11 +68,11 @@ export function getRandomSentence(): string {
68
68
}
69
69
70
70
export class Game implements IGame {
71
- private difficulty : GameDifficulty ;
72
71
private timerId ?: ReturnType < typeof setTimeout > ;
73
72
private onExpired : ( ( ) => void ) [ ] ;
74
73
private timerExpired : boolean ;
75
74
public currentRound ! : Round ;
75
+ public difficulty ! : GameDifficulty ;
76
76
77
77
constructor (
78
78
public nvim : Neovim ,
Original file line number Diff line number Diff line change @@ -14,6 +14,30 @@ export class DeleteRound extends Round {
14
14
super ( ) ;
15
15
}
16
16
17
+ private async getColumnOffset ( game : IGame ) {
18
+ const isDefindedUserOffset = await game . nvim . eval (
19
+ 'exists("vim_be_good_delete_me_offset")' ,
20
+ ) ;
21
+ let offset ;
22
+ console . log (
23
+ "delete-round#getColumnOffset - isDefindedUserOffset " ,
24
+ isDefindedUserOffset ,
25
+ ) ;
26
+ if ( game . difficulty === "noob" ) {
27
+ offset = 3 ;
28
+ }
29
+
30
+ if ( isDefindedUserOffset ) {
31
+ offset = Number (
32
+ await game . nvim . getVar ( "vim_be_good_delete_me_offset" ) ,
33
+ ) ;
34
+ console . log ( "delete-round#getColumnOffset - userOffset " , offset ) ;
35
+ } else {
36
+ offset = Math . floor ( Math . random ( ) * ( 40 - 5 ) ) + 5 ;
37
+ }
38
+ return " " . repeat ( offset ) ;
39
+ }
40
+
17
41
public getInstructions ( ) : string [ ] {
18
42
return deleteRoundInstructions ;
19
43
}
@@ -23,7 +47,8 @@ export class DeleteRound extends Round {
23
47
const line = game . gameBuffer . midPointRandomPoint ( high ) ;
24
48
25
49
const lines = new Array ( game . state . lineLength ) . fill ( "" ) ;
26
- lines [ line ] = " DELETE ME" ;
50
+
51
+ lines [ line ] = ( await this . getColumnOffset ( game ) ) + "DELETE ME" ;
27
52
28
53
const middlePoint = game . gameBuffer . midPointRandomPoint ( ! high ) ;
29
54
console . log (
Original file line number Diff line number Diff line change @@ -102,4 +102,5 @@ export interface IGame {
102
102
nvim : Neovim ;
103
103
gameBuffer : IGameBuffer ;
104
104
state : GameState ;
105
+ difficulty : GameDifficulty ;
105
106
}
Original file line number Diff line number Diff line change @@ -266,7 +266,6 @@ export default function createPlugin(plugin: NvimPlugin): void {
266
266
const useCurrentBuffer =
267
267
Number ( await plugin . nvim . getVar ( "vim_be_good_floating" ) ) ===
268
268
0 ;
269
-
270
269
const isDefined = await plugin . nvim . eval (
271
270
'exists("vim_be_good_floating")' ,
272
271
) ;
You can’t perform that action at this time.
0 commit comments