|
1 | | -def move_to_pos(x, y): |
| 1 | +def move_to_pos(x, y) -> None: |
2 | 2 | current_x = get_pos_x() |
3 | 3 | current_y = get_pos_y() |
4 | 4 |
|
@@ -26,62 +26,55 @@ def move_to_pos(x, y): |
26 | 26 | move_to_pos(0, 0) |
27 | 27 |
|
28 | 28 |
|
29 | | -def odd(a): |
30 | | - if a % 2 == 0: |
31 | | - return False |
32 | | - else: |
33 | | - return True |
| 29 | +def odd(a) -> bool: |
| 30 | + return a % 2 != 0 |
34 | 31 |
|
35 | 32 |
|
36 | | -def even(a): |
37 | | - if a % 2 == 0: |
38 | | - return True |
39 | | - else: |
40 | | - return False |
| 33 | +def even(a) -> bool: |
| 34 | + return a % 2 == 0 |
41 | 35 |
|
42 | 36 |
|
43 | | -def tplace(): |
44 | | - if odd(get_pos_x()) == False and odd(get_pos_y()) == False: |
| 37 | +def tplace() -> bool | None: |
| 38 | + if odd(get_pos_x()) is False and odd(get_pos_y()) is False: |
45 | 39 | return True |
46 | | - elif odd(get_pos_x()) == True and odd(get_pos_y()) == True: |
| 40 | + if odd(get_pos_x()) is True and odd(get_pos_y()) is True: |
47 | 41 | return True |
| 42 | + return None |
48 | 43 |
|
49 | 44 |
|
50 | 45 | while True: |
51 | | - for i in range(get_world_size()): |
| 46 | + for _i in range(get_world_size()): |
52 | 47 | if get_pos_y() == 0: |
53 | 48 | plant(Entities.grass) |
54 | 49 | if can_harvest(): |
55 | 50 | harvest() |
56 | 51 |
|
57 | | - else: |
58 | | - if tplace() == True: |
59 | | - if get_ground_type() == Grounds.Soil: |
60 | | - pass |
61 | | - else: |
62 | | - till() |
| 52 | + elif tplace() is True: |
| 53 | + if get_ground_type() == Grounds.Soil: |
| 54 | + pass |
| 55 | + else: |
| 56 | + till() |
63 | 57 |
|
64 | | - plant(Entities.Tree) |
| 58 | + plant(Entities.Tree) |
65 | 59 |
|
66 | | - if get_water() < 0.5: |
67 | | - use_item(Items.Water_Tank) |
| 60 | + if get_water() < 0.5: |
| 61 | + use_item(Items.Water_Tank) |
68 | 62 |
|
69 | | - else: |
70 | | - if ( |
71 | | - get_ground_type() == Grounds.soil |
72 | | - and get_entity_type() == Entities.Carrots |
73 | | - and can_harvest() == True |
74 | | - ): |
75 | | - harvest() |
76 | | - trade(Items.Carrot_Seed) |
77 | | - plant(Entities.Carrots) |
78 | | - elif get_ground_type() != Grounds.Soil: |
79 | | - till() |
80 | | - trade(Items.Carrot_Seed) |
81 | | - plant(Entities.Carrots) |
82 | | - elif get_ground_type() == Grounds.Soil and get_entity_type() != Entities.Carrots: |
83 | | - trade(Items.Carrot_Seed) |
84 | | - plant(Entities.Carrots) |
| 63 | + elif ( |
| 64 | + get_ground_type() == Grounds.soil |
| 65 | + and get_entity_type() == Entities.Carrots |
| 66 | + and can_harvest() is True |
| 67 | + ): |
| 68 | + harvest() |
| 69 | + trade(Items.Carrot_Seed) |
| 70 | + plant(Entities.Carrots) |
| 71 | + elif get_ground_type() != Grounds.Soil: |
| 72 | + till() |
| 73 | + trade(Items.Carrot_Seed) |
| 74 | + plant(Entities.Carrots) |
| 75 | + elif get_ground_type() == Grounds.Soil and get_entity_type() != Entities.Carrots: |
| 76 | + trade(Items.Carrot_Seed) |
| 77 | + plant(Entities.Carrots) |
85 | 78 | move(East) |
86 | 79 | if can_harvest(): |
87 | 80 | harvest() |
|
0 commit comments