LCOV - code coverage report
Current view: top level - world/query - body_funcs.go Coverage Total Hit
Test: coverage.lcov Lines: 38.5 % 39 15
Test Date: 2026-11-19 00:25:22 Functions: - 0 0

            Line data    Source code
       1              : package query
       2              : 
       3              : import (
       4              :         gc "github.com/kijimaD/ruins/internal/components"
       5              :         "github.com/kijimaD/ruins/internal/rawschema"
       6              :         w "github.com/kijimaD/ruins/internal/world"
       7              :         "github.com/mlange-42/ark/ecs"
       8              : )
       9              : 
      10              : // EffectiveBodyFuncs は消費側が読む身体機能を返す。保存された不調と、疲労・空腹から組み立てた不調を
      11              : // 合わせて BodyFuncs へ畳む
      12              : func EffectiveBodyFuncs(world w.World, entity ecs.Entity) gc.BodyFuncs {
      13            1 :         needConds := DerivedConditions(world, entity)
      14            1 :         if world.Components.HealthStatus.Has(entity) {
      15            1 :                 return world.Components.HealthStatus.Get(entity).BodyFuncs(world.Resources.ConditionDefs, needConds...)
      16            1 :         }
      17              :         // HealthStatus 非所持は怪我を持たない
      18            1 :         return (&gc.HealthStatus{}).BodyFuncs(world.Resources.ConditionDefs, needConds...)
      19              : }
      20              : 
      21              : // DerivedConditions は疲労・空腹の量から過労・栄養失調の不調を読み取り時に組み立てる。
      22              : // 保存された疲労・空腹の不調は無く、量を変えた時点で次の読みに自動反映される。怪我と同じ不調として同じ経路を通る
      23              : func DerivedConditions(world w.World, entity ecs.Entity) []gc.HealthCondition {
      24            1 :         var conds []gc.HealthCondition
      25            1 :         if world.Components.Fatigue.Has(entity) {
      26            1 :                 if sev, ok := world.Components.Fatigue.Get(entity).FatigueSeverity(world.Resources.NeedDefs); ok {
      27            1 :                         conds = append(conds, gc.HealthCondition{Type: world.Resources.ConditionDefs.ByOnset(rawschema.Fatigue), Severity: sev})
      28            1 :                 }
      29              :         }
      30            1 :         if world.Components.Hunger.Has(entity) {
      31            1 :                 if sev, ok := world.Resources.NeedDefs.HungerSeverity(world.Components.Hunger.Get(entity).GetLevel(world.Resources.NeedDefs)); ok {
      32            1 :                         conds = append(conds, gc.HealthCondition{Type: world.Resources.ConditionDefs.ByOnset(rawschema.Hunger), Severity: sev})
      33            1 :                 }
      34              :         }
      35            1 :         return conds
      36              : }
      37              : 
      38              : // ConditionName は不調の訳した表示名を返す。定義が無ければ id をそのまま返す
      39              : func ConditionName(world w.World, ct gc.ConditionType) string {
      40            0 :         def, ok := world.Resources.ConditionDefs.Def(ct)
      41            0 :         if !ok {
      42            0 :                 return string(ct)
      43            0 :         }
      44            0 :         return T(world, def.Name)
      45              : }
      46              : 
      47              : // HungerName は空腹の段階の訳した表示名を返す
      48              : func HungerName(world w.World, level rawschema.HungerStageId) string {
      49            0 :         return T(world, world.Resources.NeedDefs.HungerName(level))
      50            0 : }
      51              : 
      52              : // FatigueName は疲労の段階の訳した表示名を返す
      53              : func FatigueName(world w.World, level rawschema.FatigueStageId) string {
      54            0 :         return T(world, world.Resources.NeedDefs.FatigueName(level))
      55            0 : }
      56              : 
      57              : // WeatherName は天候の訳した表示名を返す
      58              : func WeatherName(world w.World, k gc.WeatherKind) string {
      59            0 :         return T(world, world.Resources.WeatherDefs.Kinds[k].Name)
      60            0 : }
      61              : 
      62              : // TimeOfDayName は時間帯の訳した表示名を返す
      63              : func TimeOfDayName(world w.World, t gc.TimeOfDay) string {
      64            0 :         return T(world, world.Resources.CalendarDefs.TimesOfDay[t].Name)
      65            0 : }
      66              : 
      67              : // SeasonName は季節の訳した表示名を返す
      68              : func SeasonName(world w.World, s gc.Season) string {
      69            0 :         return T(world, world.Resources.CalendarDefs.Seasons[s].Name)
      70            0 : }
      71              : 
      72              : // ShelterName は囲われの度合いの訳した表示名を返す
      73              : func ShelterName(world w.World, shelter rawschema.Shelter) string {
      74            0 :         return T(world, world.Resources.TileEnvDefs.ShelterName(shelter))
      75            0 : }
      76              : 
      77              : // BodyPartName は部位の訳した表示名を返す
      78              : func BodyPartName(world w.World, part gc.BodyPart) string {
      79            0 :         return T(world, world.Resources.ConditionDefs.PartName(part))
      80            0 : }
      81              : 
      82              : // ConditionDescription は不調の訳した概要説明を返す。定義が無ければ空文字を返す
      83              : func ConditionDescription(world w.World, ct gc.ConditionType) string {
      84            0 :         def, ok := world.Resources.ConditionDefs.Def(ct)
      85            0 :         if !ok {
      86            0 :                 return ""
      87            0 :         }
      88            0 :         return T(world, def.Description)
      89              : }
        

Generated by: LCOV version 2.0-1