Skip to content

Commit 521028d

Browse files
authored
Update caseblock.ts (partial update)
Has SOME of the updates carried over from caseblock2.ts (more to come) and ALSO updates the annotations/block-meta-data to fix block-view issues when using the varying case-blocks.
1 parent 21c72de commit 521028d

File tree

1 file changed

+50
-10
lines changed

1 file changed

+50
-10
lines changed

caseblock.ts

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
11
//import { SwitchContext } from "./classes/switchcontext";
22
//import { SwitchManager } from "./classes/switchmanager";
33

4-
4+
/**
5+
* Logic: Switch-Case
6+
*
7+
* color: "#d9d3c4"
8+
* color2: "#ceb588"
9+
* Icons:
10+
* lightning-bolt: "\uf0e7"
11+
* fa-scroll: "\uf70e"
12+
* fa-book: "\uf02d"
13+
* fa-file-alt: "\uf15c"
14+
*/
15+
//% block="Logic: Switch-Case"
16+
//% color="#d9d3c4" weight=300 icon="\uf70e"
17+
//% groups=["Core","Advanced","Debug","Test"]
518
namespace switchcase {
619

720

@@ -44,18 +57,39 @@ namespace switchcase {
4457
* SwitchManager { }
4558
*
4659
*/
47-
60+
61+
//% block="PowerUp"
62+
//% blockId=switchcase_powerup
63+
export enum PowerUps {
64+
None = 0x0,
65+
Fireball = 0x1 << 0,
66+
Shell = 0x1 << 1,
67+
Poisonous = 0x1 << 2,
68+
}
69+
70+
//% block="PowerDown"
71+
//% blockId=switchcase_powerdown
72+
export enum PowerDowns {
73+
None = 0x0,
74+
Stunned = 0x1 << 0,
75+
Weak = 0x1 << 1,
76+
Poisoned = 0x1 << 2,
77+
}
4878

4979

5080
/**
5181
* Case Block Container
5282
*/
53-
//% block="case $match do $handler"
83+
//% block="switch:$name | case $match do $handler"
5484
//% blockId=switchcase_case_block
55-
//% group="Control"
85+
//% group="Core"
5686
//% weight=90
87+
//% inlineInput=false
88+
//% expandInput=true
5789
//% draggableParameters
58-
//% draggableStatement=true
90+
//% draggableStatement=enabled
91+
//% match.shadow="dropdown"
92+
//% match.defl="PowerUps.None"
5993
export function caseBlock(name: string, match: any, handler: () => void): void {
6094
//Placeholder for CodeGen
6195
//currentSwitchCase.addCase(match, handler)
@@ -78,11 +112,15 @@ namespace switchcase {
78112
* Case Block Value
79113
* Outside of debugging, testing, or rare niche scenarios: this may not be useful
80114
*/
81-
//% block="[Advanced/Test/Debug] switch $name matches case $match?"
115+
//% block="[Advanced/Test/Debug] | switch $name | does case match $match?"
82116
//% blockId=switchcase_case_block_value
83-
//% group="Control"
117+
//% alias=switchcase_case_block
118+
//% group="Advanced"
84119
//% weight=80
85120
//% draggableParameters
121+
//% expandInput=true
122+
//% match.shadow="dropdown"
123+
//% match.defl="PowerUps.None
86124
export function caseBlockValue(name: string, match: any): boolean {
87125
//return match === switchValue || match == switchValue;
88126
let cxt = switchcase.createSwitch(name);
@@ -96,11 +134,13 @@ namespace switchcase {
96134
/**
97135
* Default-Case Block Container
98136
*/
99-
//% block="default case"
137+
//% block="switch $name | default case handles $handle"
100138
//% blockId=switchcase_default_case_block
101-
//% group="Control"
139+
//% group="Core"
102140
//% weight=70
103-
//% draggableStatement=true
141+
//% draggableParameters
142+
//% draggableStatement=enabled
143+
//% expandInput=true
104144
export function defaultCaseBlock(name: string, handler: () => void): void {
105145

106146
let cxt = switchcase.createSwitch(name);

0 commit comments

Comments
 (0)