コミットを比較
1 コミット
| 作成者 | SHA1 | 日付 | |
|---|---|---|---|
| 65a9033a4b |
バイナリ
バイナリファイルは表示されません.
|
変更前 幅: | 高さ: | サイズ: 99 KiB |
バイナリ
バイナリファイルは表示されません.
|
変更前 幅: | 高さ: | サイズ: 53 KiB 変更後 幅: | 高さ: | サイズ: 38 KiB |
@@ -2,7 +2,3 @@ class CWindow:
|
|||||||
WIDTH: int = 1024
|
WIDTH: int = 1024
|
||||||
HEIGHT: int = 768
|
HEIGHT: int = 768
|
||||||
|
|
||||||
|
|
||||||
class CMath:
|
|
||||||
PI: float = 3.14159265358979323846
|
|
||||||
|
|
||||||
|
|||||||
+4
-26
@@ -1,28 +1,17 @@
|
|||||||
import unicodedata
|
import unicodedata
|
||||||
|
|
||||||
from common_const import *
|
|
||||||
|
|
||||||
|
|
||||||
class CommonModule:
|
class CommonModule:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def is_wide (
|
def is_wide (c: str) -> bool:
|
||||||
c: str) \
|
|
||||||
-> bool:
|
|
||||||
return unicodedata.east_asian_width (c) in ['F', 'W', 'A']
|
return unicodedata.east_asian_width (c) in ['F', 'W', 'A']
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def len_by_full (
|
def len_by_full (cls, string: str) -> float:
|
||||||
cls,
|
|
||||||
string: str) \
|
|
||||||
-> float:
|
|
||||||
return sum (1 if cls.is_wide (c) else .5 for c in string)
|
return sum (1 if cls.is_wide (c) else .5 for c in string)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def index_by_f2c (
|
def index_by_f2c (cls, string: str, index: float) -> int:
|
||||||
cls,
|
|
||||||
string: str,
|
|
||||||
index: float) \
|
|
||||||
-> int:
|
|
||||||
i: int = 0
|
i: int = 0
|
||||||
work: str = ''
|
work: str = ''
|
||||||
for c in string:
|
for c in string:
|
||||||
@@ -35,19 +24,8 @@ class CommonModule:
|
|||||||
return i
|
return i
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def mid_by_full (
|
def mid_by_full (cls, string: str, start: float, length: float) -> str:
|
||||||
cls,
|
|
||||||
string: str,
|
|
||||||
start: float,
|
|
||||||
length: float) \
|
|
||||||
-> str:
|
|
||||||
trimmed_left: str = string[cls.index_by_f2c (string, start):]
|
trimmed_left: str = string[cls.index_by_f2c (string, start):]
|
||||||
|
|
||||||
return trimmed_left[:cls.index_by_f2c (trimmed_left, length)]
|
return trimmed_left[:cls.index_by_f2c (trimmed_left, length)]
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def rad_to_deg (
|
|
||||||
rad: float) \
|
|
||||||
-> float:
|
|
||||||
return rad * 180 / CMath.PI
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,10 +5,9 @@ import random
|
|||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime
|
||||||
|
|
||||||
import emoji
|
import emoji
|
||||||
import ephem
|
|
||||||
import pygame
|
import pygame
|
||||||
import pytchat
|
import pytchat
|
||||||
from playsound import playsound
|
from playsound import playsound
|
||||||
@@ -18,6 +17,7 @@ from aques import Aques
|
|||||||
from common_const import *
|
from common_const import *
|
||||||
from common_module import CommonModule
|
from common_module import CommonModule
|
||||||
from mode import Mode
|
from mode import Mode
|
||||||
|
from othello import Othello
|
||||||
from talk import Talk
|
from talk import Talk
|
||||||
from youtube import *
|
from youtube import *
|
||||||
|
|
||||||
@@ -48,15 +48,8 @@ class Main:
|
|||||||
screen: pygame.Surface = pygame.display.set_mode (
|
screen: pygame.Surface = pygame.display.set_mode (
|
||||||
(CWindow.WIDTH, CWindow.HEIGHT))
|
(CWindow.WIDTH, CWindow.HEIGHT))
|
||||||
|
|
||||||
# 大月ヨヨコの観測値
|
# オセロ用オブジェクト
|
||||||
observer = ephem.Observer ()
|
othello = Othello (screen)
|
||||||
observer.lat, observer.lon = '35', '139'
|
|
||||||
|
|
||||||
# き太く陽オブジェクト
|
|
||||||
sun = ephem.Sun ()
|
|
||||||
|
|
||||||
# 大月ヨヨコ・オブジェクト
|
|
||||||
moon = ephem.Moon ()
|
|
||||||
|
|
||||||
# 吹き出し
|
# 吹き出し
|
||||||
balloon = pygame.transform.scale (pygame.image.load ('talking.png'),
|
balloon = pygame.transform.scale (pygame.image.load ('talking.png'),
|
||||||
@@ -64,11 +57,6 @@ class Main:
|
|||||||
if goatoh_mode:
|
if goatoh_mode:
|
||||||
balloon = pygame.transform.flip (balloon, False, True)
|
balloon = pygame.transform.flip (balloon, False, True)
|
||||||
|
|
||||||
# 背景(昼)
|
|
||||||
bg_day: pygame.Surface = pygame.transform.scale (
|
|
||||||
pygame.image.load ('bg.jpg'),
|
|
||||||
(CWindow.WIDTH, CWindow.HEIGHT))
|
|
||||||
|
|
||||||
# 背景(夕方)
|
# 背景(夕方)
|
||||||
bg_evening: pygame.Surface = pygame.transform.scale (
|
bg_evening: pygame.Surface = pygame.transform.scale (
|
||||||
pygame.image.load ('bg-evening.jpg'),
|
pygame.image.load ('bg-evening.jpg'),
|
||||||
@@ -79,19 +67,6 @@ class Main:
|
|||||||
pygame.image.load ('bg-night.jpg'),
|
pygame.image.load ('bg-night.jpg'),
|
||||||
(CWindow.WIDTH, CWindow.HEIGHT))
|
(CWindow.WIDTH, CWindow.HEIGHT))
|
||||||
|
|
||||||
# 背景の草
|
|
||||||
bg_grass: pygame.Surface = pygame.transform.scale (
|
|
||||||
pygame.image.load ('bg-grass.png'),
|
|
||||||
(CWindow.WIDTH, CWindow.HEIGHT))
|
|
||||||
|
|
||||||
# き太く陽
|
|
||||||
kita: pygame.Surface = pygame.transform.scale (
|
|
||||||
pygame.image.load ('sun.png'), (200, 200))
|
|
||||||
|
|
||||||
# 大月ヨヨコ
|
|
||||||
jojoko: pygame.Surface = pygame.transform.scale (
|
|
||||||
pygame.image.load ('moon.png'), (200, 200))
|
|
||||||
|
|
||||||
# 音声再生器の初期化
|
# 音声再生器の初期化
|
||||||
pygame.mixer.init (frequency = 44100)
|
pygame.mixer.init (frequency = 44100)
|
||||||
|
|
||||||
@@ -123,48 +98,7 @@ class Main:
|
|||||||
histories: list = []
|
histories: list = []
|
||||||
|
|
||||||
while (True):
|
while (True):
|
||||||
# 観測地の日づけ更新
|
cls.draw_bg (screen, bg_evening, bg_night)
|
||||||
observer.date: datetime = datetime.now ().date ()
|
|
||||||
|
|
||||||
# 日の出開始
|
|
||||||
sunrise_start: datetime = (
|
|
||||||
(ephem.localtime (observer.previous_rising (sun))
|
|
||||||
- timedelta (minutes = 30)))
|
|
||||||
|
|
||||||
# 日の出終了
|
|
||||||
sunrise_end: datetime = sunrise_start + timedelta (hours = 1)
|
|
||||||
|
|
||||||
# 日の入開始
|
|
||||||
sunset_start: datetime = (
|
|
||||||
(ephem.localtime (observer.next_setting (sun))
|
|
||||||
- timedelta (minutes = 30)))
|
|
||||||
|
|
||||||
# 日の入終了
|
|
||||||
sunset_end: datetime = sunset_start + timedelta (hours = 1)
|
|
||||||
|
|
||||||
# 月の出開始
|
|
||||||
'todo'
|
|
||||||
|
|
||||||
# 月の出終了
|
|
||||||
'todo'
|
|
||||||
|
|
||||||
# 月の入開始
|
|
||||||
'todo'
|
|
||||||
|
|
||||||
# 月の入終了
|
|
||||||
'todo'
|
|
||||||
|
|
||||||
# 日の角度
|
|
||||||
observer_with_time: ephem.Observer = observer
|
|
||||||
observer_with_time.date = datetime.now () - timedelta (hours = 9)
|
|
||||||
sun.compute (observer_with_time)
|
|
||||||
sun_alt: float = CommonModule.rad_to_deg (sun.alt)
|
|
||||||
|
|
||||||
# 背景描画
|
|
||||||
cls.draw_bg (screen, bg_day, bg_evening, bg_night, bg_grass,
|
|
||||||
kita, jojoko,
|
|
||||||
sunrise_start, sunrise_end, sunset_start, sunset_end,
|
|
||||||
sun_alt)
|
|
||||||
|
|
||||||
# 左上に時刻表示
|
# 左上に時刻表示
|
||||||
for i in range (4):
|
for i in range (4):
|
||||||
@@ -208,9 +142,7 @@ class Main:
|
|||||||
|
|
||||||
# ログ書込み
|
# ログ書込み
|
||||||
with open ('log.txt', 'a') as f:
|
with open ('log.txt', 'a') as f:
|
||||||
f.write (f'{datetime.now ()}\t'
|
f.write (f'{datetime.now ()}\t{json.dumps (chat_item.__dict__)}\t{answer}\n')
|
||||||
+ f'{json.dumps (chat_item.__dict__)}\t'
|
|
||||||
+ f'{answer}\n')
|
|
||||||
|
|
||||||
# 吹出し描画(ニジカは上,ゴートうは下)
|
# 吹出し描画(ニジカは上,ゴートうは下)
|
||||||
if nizika_mode:
|
if nizika_mode:
|
||||||
@@ -228,8 +160,7 @@ class Main:
|
|||||||
screen.blit (
|
screen.blit (
|
||||||
user_font.render (
|
user_font.render (
|
||||||
'> ' + (message
|
'> ' + (message
|
||||||
if (CommonModule.len_by_full (
|
if (CommonModule.len_by_full (message)
|
||||||
message)
|
|
||||||
<= 21)
|
<= 21)
|
||||||
else (CommonModule.mid_by_full (
|
else (CommonModule.mid_by_full (
|
||||||
message, 0, 19.5)
|
message, 0, 19.5)
|
||||||
@@ -290,11 +221,7 @@ class Main:
|
|||||||
if not double_mode or random.random () < .5:
|
if not double_mode or random.random () < .5:
|
||||||
break
|
break
|
||||||
|
|
||||||
cls.draw_bg (screen, bg_day, bg_evening, bg_night,
|
cls.draw_bg (screen, bg_evening, bg_night)
|
||||||
bg_grass, kita, jojoko,
|
|
||||||
sunrise_start, sunrise_end,
|
|
||||||
sunset_start, sunset_end,
|
|
||||||
sun_alt)
|
|
||||||
|
|
||||||
chat_item.author = {'name': 'ゴートうひとり' if goatoh_talking else '伊地知ニジカ',
|
chat_item.author = {'name': 'ゴートうひとり' if goatoh_talking else '伊地知ニジカ',
|
||||||
'id': '',
|
'id': '',
|
||||||
@@ -321,47 +248,15 @@ class Main:
|
|||||||
def draw_bg (
|
def draw_bg (
|
||||||
cls,
|
cls,
|
||||||
screen: pygame.Surface,
|
screen: pygame.Surface,
|
||||||
bg_day: pygame.Surface,
|
|
||||||
bg_evening: pygame.Surface,
|
bg_evening: pygame.Surface,
|
||||||
bg_night: pygame.Surface,
|
bg_night: pygame.Surface) \
|
||||||
bg_grass: pygame.Surface,
|
|
||||||
kita: pygame.Surface,
|
|
||||||
jojoko: pygame.Surface,
|
|
||||||
sunrise_start: datetime,
|
|
||||||
sunrise_end: datetime,
|
|
||||||
sunset_start: datetime,
|
|
||||||
sunset_end: datetime,
|
|
||||||
sun_alt: float) \
|
|
||||||
-> None:
|
-> None:
|
||||||
sunrise_centre: datetime = (
|
if 17 <= (h := datetime.now ().hour) < 18:
|
||||||
sunrise_start + (sunrise_end - sunrise_start) / 2)
|
|
||||||
sunset_centre: datetime = (
|
|
||||||
sunset_start + (sunset_end - sunset_start) / 2)
|
|
||||||
|
|
||||||
dt: datetime = datetime.now ()
|
|
||||||
|
|
||||||
if sunrise_centre <= dt < sunset_centre:
|
|
||||||
screen.blit (bg_day, (0, 0))
|
|
||||||
else:
|
|
||||||
screen.blit (bg_night, (0, 0))
|
|
||||||
|
|
||||||
if sunrise_start <= dt < sunrise_end:
|
|
||||||
bg_evening.set_alpha (255 - ((abs (dt - sunrise_centre) * 510)
|
|
||||||
/ (sunrise_end - sunrise_centre)))
|
|
||||||
elif sunset_start <= dt < sunset_end:
|
|
||||||
bg_evening.set_alpha (255 - ((abs (dt - sunset_centre) * 510)
|
|
||||||
/ (sunset_end - sunset_centre)))
|
|
||||||
else:
|
|
||||||
bg_evening.set_alpha (0)
|
|
||||||
|
|
||||||
screen.blit (bg_evening, (0, 0))
|
screen.blit (bg_evening, (0, 0))
|
||||||
|
elif (h < 6) or (18 <= h):
|
||||||
if -10 <= sun_alt < 40:
|
screen.blit (bg_night, (0, 0))
|
||||||
y = ((CWindow.HEIGHT / 2 + 100)
|
else:
|
||||||
- (CWindow.HEIGHT / 2 + 200) / 30 * sun_alt)
|
screen.fill ((0, 255, 0))
|
||||||
screen.blit (kita, kita.get_rect (center = (400, y)))
|
|
||||||
|
|
||||||
screen.blit (bg_grass, (0, 0))
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
+13
-21
@@ -2,31 +2,23 @@ import pygame
|
|||||||
from pygame.locals import *
|
from pygame.locals import *
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from common_const import *
|
||||||
|
|
||||||
|
|
||||||
class Othello:
|
class Othello:
|
||||||
SCREEN_SIZE: tuple = (640, 480)
|
# 盤の色
|
||||||
|
|
||||||
BOARD_COLOUR: tuple = (0, 128, 0)
|
BOARD_COLOUR: tuple = (0, 128, 0)
|
||||||
|
|
||||||
@classmethod
|
def __init__ (
|
||||||
def main (cls) -> None:
|
self,
|
||||||
pygame.init ()
|
screen: pygame.Surface) \
|
||||||
screen: pygame.Surface = pygame.display.set_mode (cls.SCREEN_SIZE)
|
-> None:
|
||||||
|
self.screen = screen
|
||||||
|
|
||||||
while True:
|
# オセロ中?
|
||||||
screen.fill ((0, 0, 0))
|
self.othello_mode = False
|
||||||
|
|
||||||
# pygame.draw.rect (screen, BOARD_COLOUR, )
|
def redraw (self) -> None:
|
||||||
|
if self.othello_mode:
|
||||||
pygame.display.update ()
|
pass
|
||||||
pygame.time.wait (33)
|
|
||||||
|
|
||||||
for event in pygame.event.get ():
|
|
||||||
if event.type == QUIT:
|
|
||||||
pygame.quit ()
|
|
||||||
sys.exit ()
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
Othello.main ()
|
|
||||||
|
|
||||||
|
|||||||
@@ -116,12 +116,9 @@ class Talk:
|
|||||||
+ 'ニジカはあくまでも種族名であり、あなたはたくさんいるニジカの中の1匹。'
|
+ 'ニジカはあくまでも種族名であり、あなたはたくさんいるニジカの中の1匹。'
|
||||||
+ 'あなたの誕生日は12月3日。'
|
+ 'あなたの誕生日は12月3日。'
|
||||||
+ '現在地は下北沢虹鹿園。'
|
+ '現在地は下北沢虹鹿園。'
|
||||||
+ '挨拶は「ぬ゛ん゛あ゛す゛!」。'
|
|
||||||
+ '草に「きし天」を植え、水で割ったアセロラをかけたらニジカが増殖した。'
|
+ '草に「きし天」を植え、水で割ったアセロラをかけたらニジカが増殖した。'
|
||||||
+ 'あなたの趣味はニコニコでエゴサすること。'
|
+ 'あなたの趣味はニコニコでエゴサすること。'
|
||||||
+ 'ニコニコ荒らしすぎて245回BANされたことある。'
|
+ 'ニコニコ荒らしすぎて245回BANされたことある。'
|
||||||
+ 'そんなニコニコでは100年に1度の『伊地知ニジカ超投稿祭21c』が絶賛開催中だが、ニジカは永久追放されているため参加できない。'
|
|
||||||
+ 'ニジカはその逆恨みでニコニコ本社を爆破したところ、死刑判決を食らった。'
|
|
||||||
+ 'あなたの友達は「ゴートうひとり」と「ラマ田リョウ」。'
|
+ 'あなたの友達は「ゴートうひとり」と「ラマ田リョウ」。'
|
||||||
+ 'ゴートうのことは「ボッチチャーン」、ラマ田のことは「リョー」と呼ぶこと。'
|
+ 'ゴートうのことは「ボッチチャーン」、ラマ田のことは「リョー」と呼ぶこと。'
|
||||||
+ 'ゴートうは男の子だが、性自認はメスである。'
|
+ 'ゴートうは男の子だが、性自認はメスである。'
|
||||||
|
|||||||
新しい課題から参照
ユーザをブロックする