Skip to content

Commit

Permalink
[STCC-209] condition blocks were broken. Should be fixed now. (Catrob…
Browse files Browse the repository at this point in the history
  • Loading branch information
gregbauer authored and YoloSwagBoy committed Mar 20, 2020
1 parent 8bac01b commit 9b0fd52
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/scratchtocatrobat/converter/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1705,22 +1705,29 @@ def _convert_loop_blocks(self):
brick_arguments = self.arguments
if self.block_name == 'doRepeat':
times_value, nested_bricks = brick_arguments
if nested_bricks == None:
nested_bricks = []
catr_loop_start_brick = self.CatrobatClass(catrobat.create_formula_with_value(times_value))
catr_loop_start_brick.loopBricks = nested_bricks
for brick in nested_bricks:
catr_loop_start_brick.loopBricks.add(brick)
else:
assert self.block_name == 'doForever', self.block_name
[nested_bricks] = brick_arguments
if nested_bricks == None:
nested_bricks = []
catr_loop_start_brick = self.CatrobatClass()
catr_loop_start_brick.loopBricks = nested_bricks
for brick in nested_bricks:
catr_loop_start_brick.loopBricks.add(brick)
return [catr_loop_start_brick]

@_register_handler(_block_name_to_handler_map, "doUntil")
def _convert_do_until_block(self):
condition, nested_bricks = self.arguments
if nested_bricks == None:
nested_bricks = []
repeat_until_brick = self.CatrobatClass(catrobat.create_formula_with_value(condition))
repeat_until_brick.loopBricks = nested_bricks
for brick in nested_bricks:
repeat_until_brick.loopBricks.add(brick)
return repeat_until_brick

@_register_handler(_block_name_to_handler_map, "startScene")
Expand Down Expand Up @@ -1829,7 +1836,8 @@ def _convert_if_block(self):
if_bricks = self.arguments[1] or []
assert isinstance(if_bricks, list)

if_begin_brick.ifBranchBricks = if_bricks
for brick in if_bricks:
if_begin_brick.ifBranchBricks.add(brick)
return [if_begin_brick]# + if_bricks + [if_end_brick]

@_register_handler(_block_name_to_handler_map, "doIfElse")
Expand All @@ -1839,8 +1847,10 @@ def _convert_if_else_block(self):
if_bricks, [else_bricks] = self.arguments[1], self.arguments[2:] or [[]]
if_bricks = if_bricks if if_bricks != None else []
else_bricks = else_bricks if else_bricks != None else []
if_begin_brick.ifBranchBricks = if_bricks
if_begin_brick.elseBranchBricks = else_bricks
for brick in if_bricks:
if_begin_brick.ifBranchBricks.add(brick)
for brick in else_bricks:
if_begin_brick.elseBranchBricks.add(brick)
return if_begin_brick

@_register_handler(_block_name_to_handler_map, "lookLike:")
Expand Down

0 comments on commit 9b0fd52

Please # to comment.