|
@@ -51,9 +51,8 @@ def main ( |
|
|
y = CWindow.HEIGHT - 120, |
|
|
y = CWindow.HEIGHT - 120, |
|
|
balloon = balloon) |
|
|
balloon = balloon) |
|
|
CurrentTime (game, SYSTEM_FONT) |
|
|
CurrentTime (game, SYSTEM_FONT) |
|
|
broadcast = Broadcast (os.environ['BROADCAST_CODE']) |
|
|
|
|
|
try: |
|
|
try: |
|
|
Sound ('assets/bgm.mp3').play (loops = -1) |
|
|
|
|
|
|
|
|
broadcast = Broadcast (os.environ['BROADCAST_CODE']) |
|
|
except Exception: |
|
|
except Exception: |
|
|
pass |
|
|
pass |
|
|
while True: |
|
|
while True: |
|
@@ -62,20 +61,23 @@ def main ( |
|
|
pygame.quit () |
|
|
pygame.quit () |
|
|
sys.exit () |
|
|
sys.exit () |
|
|
if not balloon.enabled: |
|
|
if not balloon.enabled: |
|
|
DB.begin_transaction () |
|
|
|
|
|
answer_flags = (AnsweredFlag.where ('platform', Platform.YOUTUBE.value) |
|
|
|
|
|
.where ('answered', False) |
|
|
|
|
|
.get ()) |
|
|
|
|
|
if answer_flags: |
|
|
|
|
|
answer_flag = random.choice (answer_flags) |
|
|
|
|
|
answer = Answer.find (answer_flag.answer_id) |
|
|
|
|
|
if answer.answer_type == AnswerType.YOUTUBE_REPLY.value: |
|
|
|
|
|
query = Query.find (answer.query_id) |
|
|
|
|
|
deerjika.talk (query.content, answer.content) |
|
|
|
|
|
answer_flag.answered = True |
|
|
|
|
|
answer_flag.save () |
|
|
|
|
|
DB.commit () |
|
|
|
|
|
add_query (broadcast) |
|
|
|
|
|
|
|
|
try: |
|
|
|
|
|
DB.begin_transaction () |
|
|
|
|
|
answer_flags = (AnsweredFlag.where ('platform', Platform.YOUTUBE.value) |
|
|
|
|
|
.where ('answered', False) |
|
|
|
|
|
.get ()) |
|
|
|
|
|
if answer_flags: |
|
|
|
|
|
answer_flag = random.choice (answer_flags) |
|
|
|
|
|
answer = Answer.find (answer_flag.answer_id) |
|
|
|
|
|
if answer.answer_type == AnswerType.YOUTUBE_REPLY.value: |
|
|
|
|
|
query = Query.find (answer.query_id) |
|
|
|
|
|
deerjika.talk (query.content, answer.content) |
|
|
|
|
|
answer_flag.answered = True |
|
|
|
|
|
answer_flag.save () |
|
|
|
|
|
DB.commit () |
|
|
|
|
|
add_query (broadcast) |
|
|
|
|
|
except Exception: |
|
|
|
|
|
pass |
|
|
game.redraw () |
|
|
game.redraw () |
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -149,6 +151,7 @@ class Game: |
|
|
sky (Sky): 天体情報 |
|
|
sky (Sky): 天体情報 |
|
|
""" |
|
|
""" |
|
|
|
|
|
|
|
|
|
|
|
bgm: Sound |
|
|
clock: Clock |
|
|
clock: Clock |
|
|
frame: int |
|
|
frame: int |
|
|
last_answered_at: datetime |
|
|
last_answered_at: datetime |
|
@@ -165,6 +168,9 @@ class Game: |
|
|
self.clock = Clock () |
|
|
self.clock = Clock () |
|
|
self.frame = 0 |
|
|
self.frame = 0 |
|
|
self.redrawers = [] |
|
|
self.redrawers = [] |
|
|
|
|
|
self.bgm = Sound ('assets/bgm.mp3') |
|
|
|
|
|
self.bgm.set_volume (.15) |
|
|
|
|
|
self.bgm.play (loops = -1) |
|
|
self._create_sky () |
|
|
self._create_sky () |
|
|
|
|
|
|
|
|
def redraw ( |
|
|
def redraw ( |
|
@@ -257,6 +263,10 @@ class BgBase (GameObject): |
|
|
surface (Surface): 背景 Surface |
|
|
surface (Surface): 背景 Surface |
|
|
""" |
|
|
""" |
|
|
|
|
|
|
|
|
|
|
|
bg: Surface |
|
|
|
|
|
bg_evening: Surface |
|
|
|
|
|
bg_grass: Surface |
|
|
|
|
|
bg_night: Surface |
|
|
surface: Surface |
|
|
surface: Surface |
|
|
|
|
|
|
|
|
def __init__ ( |
|
|
def __init__ ( |
|
@@ -264,8 +274,11 @@ class BgBase (GameObject): |
|
|
game: Game, |
|
|
game: Game, |
|
|
): |
|
|
): |
|
|
super ().__init__ (game) |
|
|
super ().__init__ (game) |
|
|
self.surface = pygame.image.load ('assets/bg.jpg') |
|
|
|
|
|
self.surface = pygame.transform.scale (self.surface, (CWindow.WIDTH, CWindow.HEIGHT)) |
|
|
|
|
|
|
|
|
self.bg = pygame.image.load ('assets/bg.jpg') |
|
|
|
|
|
self.bg_evening = pygame.image.load ('assets/bg-evening.jpg') |
|
|
|
|
|
self.bg_grass = pygame.image.load ('assets/bg-grass.png') |
|
|
|
|
|
self.bg_night = pygame.image.load ('assets/bg-night.jpg') |
|
|
|
|
|
self.surface = pygame.transform.scale (self.bg, (CWindow.WIDTH, CWindow.HEIGHT)) |
|
|
|
|
|
|
|
|
def redraw ( |
|
|
def redraw ( |
|
|
self, |
|
|
self, |
|
@@ -370,7 +383,7 @@ class Deerjika (Creature): |
|
|
super ().redraw () |
|
|
super ().redraw () |
|
|
if (not self.balloon.enabled) and self.talking: |
|
|
if (not self.balloon.enabled) and self.talking: |
|
|
self.talking = False |
|
|
self.talking = False |
|
|
if (self.balloon.enabled and self.balloon.frame >= FPS * 3 |
|
|
|
|
|
|
|
|
if (self.balloon.enabled and self.balloon.frame >= FPS * 1.5 |
|
|
and not self.talking): |
|
|
and not self.talking): |
|
|
self.read_out () |
|
|
self.read_out () |
|
|
|
|
|
|
|
|