Connect another block onto the boottom of this block (not necessarily bottom of chain)
(self, new: Block)
| 528 | |
| 529 | # Adding/removing block |
| 530 | def attach_block(self, new: Block) -> Block: |
| 531 | """ |
| 532 | Connect another block onto the boottom of this block (not necessarily bottom of chain) |
| 533 | """ |
| 534 | if not self.can_next: |
| 535 | raise exceptions.BadBlockShape(f"{self.block_shape} cannot be stacked onto") |
| 536 | elif new.block_shape.is_hat or not new.block_shape.is_stack: |
| 537 | raise exceptions.BadBlockShape(f"{new.block_shape} is not stackable") |
| 538 | |
| 539 | new.parent = self |
| 540 | new.next = self.next |
| 541 | |
| 542 | self.next = new |
| 543 | |
| 544 | new.check_toplevel() |
| 545 | self.sprite.add_block(new) |
| 546 | |
| 547 | return new |
| 548 | |
| 549 | def duplicate_single_block(self) -> Block: |
| 550 | return self.attach_block(self.dcopy()) |
no test coverage detected