Area
Classes¶
Area
¶
Source code in AoE2ScenarioParser/objects/support/area.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 |
|
Attributes¶
Attribute | Type | ||
---|---|---|---|
|
str
|
||
|
int
|
||
|
int
|
||
|
int
|
||
|
int
|
||
|
int
|
||
|
int
|
||
|
bool
|
||
|
int
|
||
|
int
|
||
|
UUID
|
||
|
|||
Source code in
|
167 168 |
|
corner2
property
writable
¶
Source code in AoE2ScenarioParser/objects/support/area.py
175 176 |
|
map_size
property
writable
¶
Source code in AoE2ScenarioParser/objects/support/area.py
183 184 |
|
x1
property
writable
¶
int
Source code in AoE2ScenarioParser/objects/support/area.py
135 136 |
|
x2
property
writable
¶
int
Source code in AoE2ScenarioParser/objects/support/area.py
151 152 |
|
y1
property
writable
¶
int
Source code in AoE2ScenarioParser/objects/support/area.py
143 144 |
|
y2
property
writable
¶
int
Source code in AoE2ScenarioParser/objects/support/area.py
159 160 |
|
Functions¶
def __init__(...)
¶
Object to easily select an area on the map. Uses method chaining for ease of use.
Please note: Setting a uuid
will always overwrite the map_size
attribute, even if it's not None
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
map_size |
int
|
The size of the map this area object will handle |
None
|
uuid |
UUID
|
The UUID of the scenario this area belongs to |
None
|
x1 |
int
|
The X location of the left corner |
None
|
y1 |
int
|
The Y location of the left corner |
None
|
x2 |
int
|
The X location of the right corner |
None
|
y2 |
int
|
The Y location of the right corner |
None
|
corner1 |
Tile
|
The location of the left corner |
None
|
corner2 |
Tile
|
The location of the right corner |
None
|
Source code in AoE2ScenarioParser/objects/support/area.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
|
def __repr__(...)
¶
Source code in AoE2ScenarioParser/objects/support/area.py
845 846 |
|
def along_axis(...)
¶
Sets the axis. Can be either "x" or "y".
Source code in AoE2ScenarioParser/objects/support/area.py
456 457 458 459 |
|
def associate_scenario(...)
¶
Associate area with scenario. Saves scenario UUID in this area object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scenario |
AoE2Scenario
|
The scenario to associate with |
required |
Source code in AoE2ScenarioParser/objects/support/area.py
210 211 212 213 214 215 216 217 |
|
def attr(...)
¶
Sets the attribute to the given value. AreaAttr or str can be used as key
Source code in AoE2ScenarioParser/objects/support/area.py
461 462 463 464 465 466 467 468 469 470 471 472 |
|
def attrs(...)
¶
Sets multiple attributes to the corresponding values.
Returns:
Type | Description |
---|---|
Area
|
This area object |
Source code in AoE2ScenarioParser/objects/support/area.py
474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 |
|
def center(...)
¶
Moves the selection center to a given position. When the given center forces the selection of the edge of the map the off-map tiles will not be returned. When moving the selection back into the map the tiles will be returned again.
If you want to limit moving the center without changing the selection box size, use: center_bounded
Source code in AoE2ScenarioParser/objects/support/area.py
541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 |
|
def center_bounded(...)
¶
Moves the selection center to a given position on the map. This function makes sure it cannot go over the edge of the map. The selection will be forced against the edge of the map and the selection will not be decreased in size.
Source code in AoE2ScenarioParser/objects/support/area.py
557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 |
|
def copy(...)
¶
Copy this instance of an Area. Useful for when you want to do multiple extractions (to_...) from the same source with small tweaks.
Examples:
1 2 3 4 5 6 |
|
Returns:
Type | Description |
---|---|
Area
|
A copy of this Area object |
Source code in AoE2ScenarioParser/objects/support/area.py
696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 |
|
def expand(...)
¶
Expands the selection from all sides
Source code in AoE2ScenarioParser/objects/support/area.py
633 634 635 636 637 638 639 |
|
def expand_x1(...)
¶
Expands the selection from the first corner on the X axis by n
Source code in AoE2ScenarioParser/objects/support/area.py
641 642 643 644 |
|
def expand_x2(...)
¶
Expands the selection from the second corner on the X axis by n
Source code in AoE2ScenarioParser/objects/support/area.py
651 652 653 654 |
|
def expand_y1(...)
¶
Expands the selection from the first corner on the Y axis by n
Source code in AoE2ScenarioParser/objects/support/area.py
646 647 648 649 |
|
def expand_y2(...)
¶
Expands the selection from the second corner on the Y axis by n
Source code in AoE2ScenarioParser/objects/support/area.py
656 657 658 659 |
|
def from_tiles(...)
classmethod
¶
Parameters:
Name | Type | Description | Default |
---|---|---|---|
corner1 |
Tile
|
- | required |
corner2 |
Tile
|
- |
None
|
Source code in AoE2ScenarioParser/objects/support/area.py
128 129 130 |
|
def from_uuid(...)
classmethod
¶
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uuid |
UUID
|
- | required |
Source code in AoE2ScenarioParser/objects/support/area.py
124 125 126 |
|
def get_center(...)
¶
Get center of current selection
Source code in AoE2ScenarioParser/objects/support/area.py
329 330 331 |
|
def get_center_int(...)
¶
Get center of current selection, coords can only be integers. If even length, the value is ceiled
Source code in AoE2ScenarioParser/objects/support/area.py
333 334 335 |
|
def get_dimensions(...)
¶
Returns the lengths of the x & y side of the selection (in that order).
Source code in AoE2ScenarioParser/objects/support/area.py
353 354 355 |
|
def get_height(...)
¶
Returns the length of the y side of the selection.
Source code in AoE2ScenarioParser/objects/support/area.py
349 350 351 |
|
def get_range_x(...)
¶
Returns a range object for the x coordinates.
Source code in AoE2ScenarioParser/objects/support/area.py
337 338 339 |
|
def get_range_y(...)
¶
Returns a range object for the y coordinates.
Source code in AoE2ScenarioParser/objects/support/area.py
341 342 343 |
|
def get_raw_selection(...)
¶
Get the four values of the selection (even if they are outside the map) as: ((x1, y1), (x2, y2))
Source code in AoE2ScenarioParser/objects/support/area.py
325 326 327 |
|
def get_selection(...)
¶
Get the four values of the selection as: ((x1, y1), (x2, y2))
Source code in AoE2ScenarioParser/objects/support/area.py
321 322 323 |
|
def get_width(...)
¶
Returns the length of the x side of the selection.
Source code in AoE2ScenarioParser/objects/support/area.py
345 346 347 |
|
def height(...)
¶
Sets the height (y axis) of the selection. Shrinks/Expands both sides equally. If the expansion hits the edge of the map, it'll expand on the other side.
Source code in AoE2ScenarioParser/objects/support/area.py
519 520 521 522 523 524 525 526 527 528 |
|
def invert(...)
¶
Inverts the inverted boolean. Causes the to_coords
to return the inverted selection. (Especially useful for
the grid state. Not as useful for the edge which would be the same as shrinking the selection. When used with
the fill state an empty set is returned.
Please note: This inverts the INTERNAL selection. Tiles OUTSIDE of the selection will NOT be returned.
Source code in AoE2ScenarioParser/objects/support/area.py
445 446 447 448 449 450 451 452 453 454 |
|
def is_within_selection(...)
¶
If a given (x,y) location is within the selection.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
int
|
The X coordinate |
-1
|
y |
int
|
The Y coordinate |
-1
|
tile |
Tile
|
A Tile object, replacing the x & y coordinates |
None
|
Returns:
Type | Description |
---|---|
bool
|
|
Source code in AoE2ScenarioParser/objects/support/area.py
663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 |
|
def select(...)
¶
Sets the selection to the given coordinates
Source code in AoE2ScenarioParser/objects/support/area.py
586 587 588 589 590 591 592 |
|
def select_centered(...)
¶
Sets the selection to the given coordinates
Source code in AoE2ScenarioParser/objects/support/area.py
594 595 596 597 598 599 600 601 602 603 |
|
def select_entire_map(...)
¶
Sets the selection to the entire map
Source code in AoE2ScenarioParser/objects/support/area.py
581 582 583 584 |
|
def shrink(...)
¶
Shrinks the selection from all sides
Source code in AoE2ScenarioParser/objects/support/area.py
605 606 607 608 609 610 611 |
|
def shrink_x1(...)
¶
Shrinks the selection from the first corner on the X axis by n
Source code in AoE2ScenarioParser/objects/support/area.py
613 614 615 616 |
|
def shrink_x2(...)
¶
Shrinks the selection from the second corner on the X axis by n
Source code in AoE2ScenarioParser/objects/support/area.py
623 624 625 626 |
|
def shrink_y1(...)
¶
Shrinks the selection from the first corner on the Y axis by n
Source code in AoE2ScenarioParser/objects/support/area.py
618 619 620 621 |
|
def shrink_y2(...)
¶
Shrinks the selection from the second corner on the Y axis by n
Source code in AoE2ScenarioParser/objects/support/area.py
628 629 630 631 |
|
def size(...)
¶
Sets the selection to a size around the center. If center is (4,4) with a size of 3 the selection will become
((3,3), (5,5))
Source code in AoE2ScenarioParser/objects/support/area.py
506 507 508 509 510 511 512 513 514 515 516 517 |
|
def to_chunks(...)
¶
Converts the selection to a list of OrderedSets with Tile NamedTuples with (x, y) coordinates. The separation between chunks is based on if they're connected to each other. So the tiles must share an edge (i.e. they should be non-diagonal).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
as_terrain |
bool
|
If the returning coordinates should be Tile objects or Terrain Tiles. If |
False
|
Returns:
Type | Description |
---|---|
List[OrderedSet[Tile | 'TerrainTile']]
|
A list of OrderedSets of Tiles ((x, y) named tuple) of the selection. |
Source code in AoE2ScenarioParser/objects/support/area.py
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 |
|
def to_coords(...)
¶
Converts the selection to an OrderedSet of (x, y) coordinates
Parameters:
Name | Type | Description | Default |
---|---|---|---|
as_terrain |
bool
|
If the returning coordinates should be Tile objects or Terrain Tiles. If |
False
|
Returns:
Type | Description |
---|---|
OrderedSet[Tile | 'TerrainTile']
|
An OrderedSet of Tiles ((x, y) named tuple) of the selection. |
Examples:
The selection: ((3,3), (5,5))
would result in an OrderedSet with a length of 9::
1 2 3 4 5 |
|
Source code in AoE2ScenarioParser/objects/support/area.py
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 |
|
def to_dict(...)
¶
Converts the 2 corners of the selection to area keys for use in effects etc. This can be used by adding double stars (**) before this function.
Usage
The selection: ((3,3), (5,5))
would result in a dict that looks like:
{'area_x1': 3, 'area_y1': 3, 'area_x2': 5, 'area_y2': 5}
Then do: **area.to_dict()
in a function that accepts area tiles
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prefix |
str
|
The prefix of the string before 'x1' (e.g. prefix="coord_" will result in: "coord_x1" as key) |
'area_'
|
Returns:
Type | Description |
---|---|
Dict[str, int]
|
A dict with area_x1, area_y1, area_x2, area_y2 as keys and their respective values. |
Source code in AoE2ScenarioParser/objects/support/area.py
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 |
|
def use_full(...)
¶
Sets the area object to use the entire selection
Source code in AoE2ScenarioParser/objects/support/area.py
359 360 361 362 |
|
def use_only_corners(...)
¶
Sets the area object to only use the corners pattern within the selection.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
corner_size |
int
|
The size along both the x and y axis of the corner areas |
None
|
corner_size_x |
int
|
The size along the x axis of the corner areas |
None
|
corner_size_y |
int
|
The size along the y axis of the corner areas |
None
|
Returns:
Type | Description |
---|---|
Area
|
This area object |
Source code in AoE2ScenarioParser/objects/support/area.py
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 |
|
def use_only_edge(...)
¶
Sets the area object to only use the edge of the selection
Parameters:
Name | Type | Description | Default |
---|---|---|---|
line_width |
int
|
The width of the x & y edge line |
None
|
line_width_x |
int
|
The width of the x edge line |
None
|
line_width_y |
int
|
The width of the y edge line |
None
|
Returns:
Type | Description |
---|---|
Area
|
This area object |
Source code in AoE2ScenarioParser/objects/support/area.py
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 |
|
def use_pattern_grid(...)
¶
Sets the area object to use a grid pattern within the selection.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
block_size |
int
|
The size of the gaps between lines |
None
|
gap_size |
int
|
The width of the grid lines |
None
|
block_size_x |
int
|
The size of the x gaps between lines |
None
|
block_size_y |
int
|
The size of the y gaps between lines |
None
|
gap_size_x |
int
|
The width of the x grid lines |
None
|
gap_size_y |
int
|
The width of the y grid lines |
None
|
Returns:
Type | Description |
---|---|
Area
|
This area object |
Source code in AoE2ScenarioParser/objects/support/area.py
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 |
|
def use_pattern_lines(...)
¶
Sets the area object to use a lines pattern within the selection.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
axis |
str
|
The axis the lines should follow. Can either be "x" or "y" |
None
|
gap_size |
int
|
The size of the gaps between lines |
None
|
line_width |
int
|
The width of the x & y lines |
None
|
Returns:
Type | Description |
---|---|
Area
|
This area object |
Source code in AoE2ScenarioParser/objects/support/area.py
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 |
|
def width(...)
¶
Sets the width (x axis) of the selection. Shrinks/Expands both sides equally. If the expansion hits the edge of the map, it'll expand on the other side.
Source code in AoE2ScenarioParser/objects/support/area.py
530 531 532 533 534 535 536 537 538 539 |
|
AreaAttr
¶
Bases: Enum
Enum to show the supported attributes that can be edited using Area.attr(k, v)
Source code in AoE2ScenarioParser/objects/support/area.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
|
Attributes¶
Attribute | Type |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AreaState
¶
Bases: Enum
Enum to show the state of the Area object
Source code in AoE2ScenarioParser/objects/support/area.py
22 23 24 25 26 27 28 29 30 31 32 33 |
|
Attributes¶
Attribute | Type |
---|---|
|
|
|
|
|
|
|
|
|
Functions¶
def unchunkables(...)
staticmethod
¶
Returns the states that cannot be split into chunks
Source code in AoE2ScenarioParser/objects/support/area.py
30 31 32 33 |
|