LCOV - code coverage report
Current view: top level - messagedata - dialogues.go Coverage Total Hit
Test: coverage.lcov Lines: 100.0 % 10 10
Test Date: 2026-11-19 00:25:22 Functions: - 0 0

            Line data    Source code
       1              : package messagedata
       2              : 
       3              : import (
       4              :         "github.com/kijimaD/ruins/internal/i18n"
       5              :         "github.com/kijimaD/ruins/internal/raw"
       6              :         "github.com/kijimaD/ruins/internal/rawschema"
       7              :         w "github.com/kijimaD/ruins/internal/world"
       8              :         "github.com/kijimaD/ruins/internal/world/query"
       9              : )
      10              : 
      11              : // GetDialogue は raw の dialogues の行 key から会話データを組み立てる。1ページを1メッセージにして順につなぐ。
      12              : // ページの文は英語の msgid で、query.T で現在言語へ引いてからマークアップとして読む。行が無ければ既定の文を返す
      13              : func GetDialogue(world w.World, key string, speakerName string) *MessageData {
      14            1 :         for _, d := range raw.PtrSlice(world.Resources.RawMaster.Dialogues) {
      15            1 :                 if d.Id == key {
      16            1 :                         return dialoguePages(world, d, speakerName)
      17            1 :                 }
      18              :         }
      19            1 :         return NewDialogMessage("...", speakerName)
      20              : }
      21              : 
      22              : // dialoguePages は会話の行のページを1メッセージずつ組んでつなぐ
      23              : func dialoguePages(world w.World, d rawschema.Dialogue, speakerName string) *MessageData {
      24            1 :         pages := make([]*MessageData, 0, len(d.Pages))
      25            1 :         for _, p := range d.Pages {
      26            1 :                 pages = append(pages, NewDialogMessage("", speakerName).AddMarkup(query.T(world, i18n.Msgid(p))))
      27            1 :         }
      28            1 :         return ChainMessages(pages...)
      29              : }
        

Generated by: LCOV version 2.0-1