Skip to content

Instantly share code, notes, and snippets.

@darkfeline
Last active April 23, 2018 05:02
Show Gist options
  • Save darkfeline/8800d3b0f4cd570e9b32a07e7b5f8bd6 to your computer and use it in GitHub Desktop.
Save darkfeline/8800d3b0f4cd570e9b32a07e7b5f8bd6 to your computer and use it in GitHub Desktop.
RJ136743
import random
import sys
# SetCSVFile
# 初期音声(EARLY)1〜5
FILE = 'CSV/EARLY.csv'
# 初期音声(LATE)1〜6
FILE2 = 'CSV/LATE.csv'
# 無声音声
FILE4 = 'CSV/SOUNDLESS.csv'
# 初期XX音声(XX)
FILE5 = 'CSV/XX.csv'
# 最終ファイル名(FINISHED)
FILE7 = 'CSV/FINISHED.csv'
# XX音声選択
FILE8 = 'CSV/管理強化ボイス選択.csv'
def _read_csv(p):
lines = []
for l in open(p):
lines.append(l.replace('\\', '/').rstrip())
return lines
# SetArray
ARRAY = _read_csv(FILE)
ARRAY2 = _read_csv(FILE2)
ARRAY4 = _read_csv(FILE4)
ARRAY5 = _read_csv(FILE5)
ARRAY7 = _read_csv(FILE7)
ARRAY8 = _read_csv(FILE8)
def main():
while True:
print('''\
┌────────────────────────────┐
│    メニュー画面 │
├────────────────────────────┤
│ │
│ 1.ノーマルモード(管理強化ボイス選択) │
│ │
│ 2.ノーマルモード(管理強化ボイスランダム) │
│ │
│ 3.イージーモード(管理強化ボイス選択) │
│ │
│ 4.イージーモード(管理強化ボイスランダム) │
│ │
│ 5.ハードモード(管理強化ボイス選択) │
│ │
│ 6.ハードモード(管理強化ボイスランダム) │
│ │
│ 7.管理強化ボイス選択登録        │
│ │
│ 8.終了 │
│ │
└────────────────────────────┘
''')
choice = input('何番の処理を実行しますか?__:').upper()
if choice == '8':
sys.exit()
elif choice == 'HELL':
type8()
elif choice == '7':
type7()
elif choice == '6':
type6()
elif choice == '5':
type5()
elif choice == '4':
type4()
elif choice == '3':
type3()
elif choice == '2':
type2()
elif choice == '1':
type1()
def type1():
choice = input(' ノーマルモード(管理強化ボイス選択)を行いますか?__[Y/N] : ').upper()
if not choice == 'Y':
return
normal()
def type2():
choice = input(' ノーマルモード(管理強化ボイスランダム)を行いますか?__[Y/N] : ').upper()
if not choice == 'Y':
return
normal_random()
def type3():
choice = input(' イージーモード(管理強化ボイス選択)を行いますか?__[Y/N] : ').upper()
if not choice == 'Y':
return
easy()
def type4():
choice = input(' イージーモード(管理強化ボイスランダム)を行いますか?__[Y/N] : ').upper()
if not choice == 'Y':
return
easy_random()
def type5():
choice = input(' ハードモード(管理強化ボイス選択)を行いますか?__[Y/N] : ').upper()
if not choice == 'Y':
return
hard()
def type6():
choice = input(' ハードモード(管理強化ボイスランダム)を行いますか?__[Y/N] : ').upper()
if not choice == 'Y':
return
hard_random()
def type7():
choice = input(' 管理強化ボイス選択登録を行いますか?__[Y/N] : ').upper()
if not choice == 'Y':
return
customize()
def type8():
choice = input(' ハードモード(管理強化ボイスランダム)を行いますか?__[Y/N] : ').upper()
if not choice == 'Y':
return
hidden()
def normal():
# 環境変数
r = random.randrange(6)
_copy_choice(r)
sys.exit()
def normal_random():
# 環境変数
r = random.randrange(6)
_copy_random(r)
sys.exit()
def easy():
# 環境変数
r = random.randrange(6)
if r < 2:
r = random.randrange(2)
elif r < 4:
r = random.randrange(4) + 2
elif r < 6:
r = random.randrange(6)
_copy_choice(r)
sys.exit()
def easy_random():
# 環境変数
r = random.randrange(6)
if r < 2:
r = random.randrange(2)
elif r < 4:
r = random.randrange(4) + 2
elif r < 6:
r = random.randrange(6)
_copy_random(r)
sys.exit()
def hard():
# 環境変数
r = random.randrange(6)
if r < 2:
r = random.randrange(6)
elif r < 4:
r = random.randrange(4) + 2
elif r < 6:
r = random.randrange(2) + 4
_copy_choice(r)
sys.exit()
def hard_random():
# 環境変数
r = random.randrange(6)
if r < 2:
r = random.randrange(6)
elif r < 4:
r = random.randrange(4) + 2
elif r < 6:
r = random.randrange(2) + 4
_copy_random(r)
sys.exit()
def customize():
print('''\
管理強化ボイス選択の登録を行います。
1〜5の数値からお選びください。
数値を入力ごとに[Enter]キーを押してください。
数値は7回入力してください。
登録完了時は、[Ctrl]+[Z]を入力後、[Enter]キーを押してください。
''')
with open('CSV/管理強化ボイス選択.csv', 'w') as f:
for _ in range(7):
f.write(input())
def hidden():
while True:
print('''\
┌────────────────────────────┐
│    裏メニュー画面 │
├────────────────────────────┤
│ │
│ 1.へルモード             │
│ │
│ 2.通常メニュー              │
│ │
│ 3.終了 │
│ │
└────────────────────────────┘
''')
choice = input('何番の処理を実行しますか?__:').upper()
if choice == '3':
sys.exit()
elif choice == '2':
hidden_type2()
elif choice == '1':
hidden_type1()
def hidden_type1():
choice = input(' へルモードを稼動されますか?__[Y/N] : ').upper()
if not choice == 'Y':
return
choice = input(' 本当にへルモードを稼動してよろしいですか?__[Y/N] : ').upper()
if not choice == 'Y':
return
hell()
def hidden_type2():
choice = input(' 通常メニューに戻りますか?__[Y/N] : ').upper()
if not choice == 'Y':
return
main()
def hell():
# 環境変数
r = 6
_copy_random(r)
sys.exit()
def _copy_choice(r):
for c in range(7):
r2 = random.randrange(5)
c2 = ARRAY8[c]
if r > c:
# A
_copy([ARRAY5[c2], ARRAY[r2]], ARRAY7[c])
elif r == c:
# B
_copy([ARRAY5[c2], ARRAY2[r2]], ARRAY7[c])
else:
# C
_copy([ARRAY4[0]], ARRAY7[c])
_pad(ARRAY7[c], 523)
def _copy_random(r):
for c in range(7):
r2 = random.randrange(5)
r3 = random.randrange(5)
if r > c:
# A
_copy([ARRAY5[r3], ARRAY[r2]], ARRAY7[c])
elif r == c:
# B
_copy([ARRAY5[r3], ARRAY2[r2]], ARRAY7[c])
else:
# C
_copy([ARRAY4[0]], ARRAY7[c])
_pad(ARRAY7[c], 523)
def _copy(srclist, dst):
with open(dst, 'wb') as f:
for src in srclist:
with open(src, 'rb') as f2:
f.write(f2.read())
def _pad(p, n):
with open(p, 'ab') as f:
f.write(b'\x00' * n)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment