Browse Source

#31

ai-migration
みてるぞ 3 weeks ago
parent
commit
50281f9120
2 changed files with 33 additions and 20 deletions
  1. +1
    -1
      nizika_ai
  2. +32
    -19
      test.py

+ 1
- 1
nizika_ai

@@ -1 +1 @@
Subproject commit 0dcc8656a16b3f0315bd66c8cc9226e8db6085de
Subproject commit 9e136a7cb3baf97b384a07c4af31205d745e7200

+ 32
- 19
test.py View File

@@ -51,9 +51,8 @@ def main (
y = CWindow.HEIGHT - 120,
balloon = balloon)
CurrentTime (game, SYSTEM_FONT)
broadcast = Broadcast (os.environ['BROADCAST_CODE'])
try:
Sound ('assets/bgm.mp3').play (loops = -1)
broadcast = Broadcast (os.environ['BROADCAST_CODE'])
except Exception:
pass
while True:
@@ -62,20 +61,23 @@ def main (
pygame.quit ()
sys.exit ()
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 ()


@@ -149,6 +151,7 @@ class Game:
sky (Sky): 天体情報
"""

bgm: Sound
clock: Clock
frame: int
last_answered_at: datetime
@@ -165,6 +168,9 @@ class Game:
self.clock = Clock ()
self.frame = 0
self.redrawers = []
self.bgm = Sound ('assets/bgm.mp3')
self.bgm.set_volume (.15)
self.bgm.play (loops = -1)
self._create_sky ()

def redraw (
@@ -257,6 +263,10 @@ class BgBase (GameObject):
surface (Surface): 背景 Surface
"""

bg: Surface
bg_evening: Surface
bg_grass: Surface
bg_night: Surface
surface: Surface

def __init__ (
@@ -264,8 +274,11 @@ class BgBase (GameObject):
game: 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 (
self,
@@ -370,7 +383,7 @@ class Deerjika (Creature):
super ().redraw ()
if (not self.balloon.enabled) and self.talking:
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):
self.read_out ()



Loading…
Cancel
Save