Browse Source

rewrite direction file content

Bastien Sevajol 9 years ago
parent
commit
81e6968da8
1 changed files with 65 additions and 62 deletions
  1. 65 62
      intelligine/synergy/event/move/direction.py

+ 65 - 62
intelligine/synergy/event/move/direction.py View File

@@ -18,36 +18,36 @@ directions_under_level = (1, 2, 3, 4, 5, 6, 7, 8, 9)
18 18
 directions_same_level = (10, 11, 12, 13, 15, 16, 17, 18)
19 19
 directions_upper_level = (19, 20, 21, 22, 23, 24, 25, 26, 27)
20 20
 directions_modifiers = {
21
-  #  (z, x, y)
22
-  1: (-1, -1, -1),
23
-  2: (-1, 0, -1),
24
-  3: (-1, 1, -1),
25
-  4: (-1, -1, 0),
26
-  5: (-1, 0, 0),
27
-  6: (-1, 1, 0),
28
-  7: (-1, -1, 1),
29
-  8: (-1, 0, 1),
30
-  9: (-1, 1, 1),
31
-  #  (z, x, y)
32
-  10: (0, -1, -1),
33
-  11: (0, 0, -1),
34
-  12: (0, 1, -1),
35
-  13: (0, -1, 0),
36
-  14: (0, 0, 0),
37
-  15: (0, 1, 0),
38
-  16: (0, -1, 1),
39
-  17: (0, 0, 1),
40
-  18: (0, 1, 1),
41
-  #  (z, x, y)
42
-  19: (1, -1, -1),
43
-  20: (1, 0, -1),
44
-  21: (1, 1, -1),
45
-  22: (1, -1, 0),
46
-  23: (1, 0, 0),
47
-  24: (1, 1, 0),
48
-  25: (1, -1, 1),
49
-  26: (1, 0, 1),
50
-  27: (1, 1, 1),
21
+    # (z, x, y)
22
+    1: (-1, -1, -1),
23
+    2: (-1, 0, -1),
24
+    3: (-1, 1, -1),
25
+    4: (-1, -1, 0),
26
+    5: (-1, 0, 0),
27
+    6: (-1, 1, 0),
28
+    7: (-1, -1, 1),
29
+    8: (-1, 0, 1),
30
+    9: (-1, 1, 1),
31
+    #  (z, x, y)
32
+    10: (0, -1, -1),
33
+    11: (0, 0, -1),
34
+    12: (0, 1, -1),
35
+    13: (0, -1, 0),
36
+    14: (0, 0, 0),
37
+    15: (0, 1, 0),
38
+    16: (0, -1, 1),
39
+    17: (0, 0, 1),
40
+    18: (0, 1, 1),
41
+    #  (z, x, y)
42
+    19: (1, -1, -1),
43
+    20: (1, 0, -1),
44
+    21: (1, 1, -1),
45
+    22: (1, -1, 0),
46
+    23: (1, 0, 0),
47
+    24: (1, 1, 0),
48
+    25: (1, -1, 1),
49
+    26: (1, 0, 1),
50
+    27: (1, 1, 1),
51 51
 }
52 52
 
53 53
 NORTH = 11
@@ -77,35 +77,35 @@ niv 1:   19 20 21
77 77
 """
78 78
 
79 79
 directions_slighty = {
80
-  1: (1, 2, 4, 13, 10, 11),
81
-  2: (1, 2, 3, 10, 11, 12),
82
-  3: (2, 3, 6, 11, 12, 15),
83
-  4: (1, 4, 7, 10, 13, 16),
84
-  5: (1, 2, 3, 4, 5, 6, 7, 8, 9),
85
-  6: (2, 3, 6, 12, 15, 18),
86
-  7: (4, 7, 8, 13, 16, 17),
87
-  8: (7, 8, 9, 16, 17, 18),
88
-  9: (6, 9, 8, 15, 18, 17),
89
-  #  (z, x, y)
90
-  10: (13, 10, 11),
91
-  11: (10, 11, 12),
92
-  12: (11, 12, 15),
93
-  13: (10, 13, 16),
94
-  14: (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27),
95
-  15: (12, 15, 18),
96
-  16: (13, 16, 17),
97
-  17: (16, 17, 18),
98
-  18: (15, 18, 17),
99
-  #  (z, x, y)
100
-  19: (22, 19, 20, 13, 10, 11),
101
-  20: (19, 20, 21, 10, 11, 12),
102
-  21: (20, 21, 24, 11, 12, 15),
103
-  22: (19, 22, 25, 10, 13, 16),
104
-  23: (19, 20, 21, 22, 23, 24, 25, 26, 27),
105
-  24: (21, 24, 27, 12, 15, 18),
106
-  25: (22, 25, 26, 13, 16, 17),
107
-  26: (25, 26, 27, 16, 17, 18),
108
-  27: (24, 27, 26, 15, 18, 17),
80
+    1: (1, 2, 4, 13, 10, 11),
81
+    2: (1, 2, 3, 10, 11, 12),
82
+    3: (2, 3, 6, 11, 12, 15),
83
+    4: (1, 4, 7, 10, 13, 16),
84
+    5: (1, 2, 3, 4, 5, 6, 7, 8, 9),
85
+    6: (2, 3, 6, 12, 15, 18),
86
+    7: (4, 7, 8, 13, 16, 17),
87
+    8: (7, 8, 9, 16, 17, 18),
88
+    9: (6, 9, 8, 15, 18, 17),
89
+    # (z, x, y)
90
+    10: (13, 10, 11),
91
+    11: (10, 11, 12),
92
+    12: (11, 12, 15),
93
+    13: (10, 13, 16),
94
+    14: (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27),
95
+    15: (12, 15, 18),
96
+    16: (13, 16, 17),
97
+    17: (16, 17, 18),
98
+    18: (15, 18, 17),
99
+    #  (z, x, y)
100
+    19: (22, 19, 20, 13, 10, 11),
101
+    20: (19, 20, 21, 10, 11, 12),
102
+    21: (20, 21, 24, 11, 12, 15),
103
+    22: (19, 22, 25, 10, 13, 16),
104
+    23: (19, 20, 21, 22, 23, 24, 25, 26, 27),
105
+    24: (21, 24, 27, 12, 15, 18),
106
+    25: (22, 25, 26, 13, 16, 17),
107
+    26: (25, 26, 27, 16, 17, 18),
108
+    27: (24, 27, 26, 15, 18, 17),
109 109
 }
110 110
 
111 111
 directions_degrees = {
@@ -120,13 +120,15 @@ directions_degrees = {
120 120
     (337.5, 0): 11
121 121
 }
122 122
 
123
+
123 124
 def get_direction_for_degrees(degrees):
124 125
     if degrees < 0:
125
-        degrees = 360 - degrees - degrees - degrees # TODO: math absolute !!!
126
+        degrees = 360 - degrees - degrees - degrees  # TODO: math absolute !!!
126 127
     for plage in directions_degrees:
127
-        if degrees >= plage[0] and degrees <= plage[1]:
128
+        if plage[0] <= degrees <= plage[1]:
128 129
             return directions_degrees[plage]
129
-    raise IndexError()  # TODO: personnalised exception
130
+    raise Exception("Unknow plage for degree \"" + degrees + '"')
131
+
130 132
 
131 133
 """
132 134
 niv 0:   10 11 12
@@ -149,6 +151,7 @@ directions_opposites = {
149 151
 def get_direction_opposite(direction):
150 152
     return directions_opposites[direction]
151 153
 
154
+
152 155
 def get_position_with_direction_decal(direction=CENTER, point=(0, 0, 0)):
153 156
     z, x, y = point
154 157
     directions_modifier = directions_modifiers[direction]