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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 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
| import sys import time
CHEVRONS = 39
# 当前符号(默认原点) # 当前已编码 Chevron(全部未编码) # 当前旋转方向(顺时针) CurrentSymbol = 0 CurrentEngagedChevrons = [False, False, False, False, False, False] CurrentRotation = "CW" ChevronSevenLock = False
# Point of Origin (number 0) # 原点为地址的一部分 # 如果地址中不包含原点 # 拨号序列将不会结束 ABYDOS_ADDRESS = [26, 6, 14, 31, 11, 29, 0] CHULAK_ADDRESS = [8, 1, 22, 14, 36, 19, 0]
def rotatingSpinner(symbol, direction): global CurrentSymbol CurrentSymbol = symbol spinner_cw = ["-", "\\", "|", "/"] spinner_acw = ["-", "/", "|", "\\"]
if direction.lower() == "acw": spinner = spinner_acw else: spinner = spinner_cw
n_chars = len(spinner) start_time = time.time()
while time.time() - start_time < (int(symbol) * 0.3): char = spinner[int(time.time() * 10) % n_chars]
sys.stdout.write(f"\rRotating {char}") sys.stdout.flush()
time.sleep(0.3)
sys.stdout.write("\r \n") sys.stdout.flush()
# 交替旋转方向计算 def directionCalc(startNum, endNum, direction): N = 39 distance_cw = (endNum - startNum) % N
if direction == "CW": return distance_cw elif direction == "ACW": distance_acw = N - distance_cw return distance_acw if distance_cw != 0 else 0 else: raise ValueError("方向参数错误:CW/ACW")
# 计算旋转距离 def distanceCalc(address_list): if len(address_list) < 7: return []
N = 39 last_direction_code = None
distance_list = []
for i in range(len(address_list) - 1): startNum = address_list[i] endNum = address_list[i+1]
current_distance = 0 current_direction_code = ""
if i == 0: current_direction_code = "ACW" current_distance = directionCalc(startNum, endNum, current_direction_code) else: if last_direction_code == "CW": current_direction_code = "ACW" else: current_direction_code = "CW"
current_distance = directionCalc(startNum, endNum, current_direction_code)
distance_list.append(current_distance) last_direction_code = current_direction_code
return distance_list
# 顺时针旋转内环 def rotateClockwise(symbol): # distanceCalc() return symbol
# 逆时针旋转内环 def rotateAntiClockwise(symbol): # distanceCalc() return symbol
# 停止旋转 def endRotation(): print()
# 打开顶部 Chevron 准备对当前符号进行编码 def openChevron(): print()
# 关闭顶部打开的 Chevron 并对当前符号进行编码 # 如果符号已编码,返回状态码 -2 def closeChevron(): print()
# 将当前符号编码到顶部 Chevron # 如果 Chevron 未打开,返回状态码 -35 def encodeChevron(): print()
# 返回顶部 Chevron 下的符号 def getCurrentSymbol(): print()
# 返回内环位置 def getRotation(): print()
# 返回顶部 Chevron 打开状态 def isChevronOpen(): print()
def isCurrentSymbol(symbol): print()
# 返回已编码的 Chevron 数量 def getChevronsEngaged(): return 0
# 断开星际之门连接,如果未连接则重置星际之门 def disconnectStargate(): print()
def SGCdialing(address): global CurrentEngagedChevrons global ChevronSevenLock addressLength = len(address) start_index = getChevronsEngaged() + 1
for chevron_index in range(start_index, addressLength + 1): index = chevron_index - 1 symbol = address[index]
if chevron_index % 2 == 0: rotatingSpinner(26, "CW") else: rotatingSpinner(26, "ACW")
# endRotation()
time.sleep(1) # openChevron()
time.sleep(0.5)
if chevron_index < addressLength: encodeChevron() CurrentEngagedChevrons[index] = True print(CurrentEngagedChevrons) # Engaging print("Chevron", chevron_index, "已编码:", symbol) elif chevron_index == addressLength: ChevronSevenLock = True print("Chevron 7:", ChevronSevenLock)
time.sleep(0.5) closeChevron() time.sleep(1)
print("Starting Dial Progress") address = [26, 6, 14, 31, 11, 29, 0]
symbol_7 = ABYDOS_ADDRESS[6]
if symbol_7 != 0: print("Symbol 7 must be point of origin!") print(symbol_7) elif symbol_7 == 0: SGCdialing(ABYDOS_ADDRESS) print("Event cancelled successfully.")
|