Line data Source code
1 : package gameaction
2 :
3 : import (
4 : gc "github.com/kijimaD/ruins/internal/components"
5 : "github.com/kijimaD/ruins/internal/gamelog"
6 : w "github.com/kijimaD/ruins/internal/world"
7 : "github.com/kijimaD/ruins/internal/world/query"
8 : "github.com/mlange-42/ark/ecs"
9 : )
10 :
11 : // illnessOnsetTimer は発症したての病気の初期進行度。発症する 25 以上にして浅く始め、早期発見を効かせる
12 : const illnessOnsetTimer = 30
13 :
14 : // ContractIllness は病気を1つ発症させる。病気は全身性なので胴に付ける。既に同じ病気があれば重ねない。
15 : // HealthStatus を持たない対象には何もしない。発症したら true を返し、身体機能の再計算を促す。
16 : // 発症したての浅い進行度で始まり、以降の進行は不調ごとの回復モードに従う
17 : func ContractIllness(world w.World, entity ecs.Entity, ct gc.ConditionType) bool {
18 1 : if !world.Components.HealthStatus.Has(entity) {
19 1 : return false
20 1 : }
21 1 : part := &world.Components.HealthStatus.Get(entity).Parts[gc.BodyPartTorso]
22 1 : if part.GetCondition(ct) != nil {
23 1 : return false
24 1 : }
25 1 : part.SetCondition(gc.HealthCondition{
26 1 : Type: ct,
27 1 : Timer: illnessOnsetTimer,
28 1 : Severity: gc.TimerToSeverity(illnessOnsetTimer),
29 1 : })
30 1 : if !world.Components.StatsChanged.Has(entity) {
31 0 : world.Components.StatsChanged.Add(entity, &gc.StatsChanged{})
32 0 : }
33 1 : if world.Components.Player.Has(entity) {
34 1 : name := query.ConditionName(world, ct)
35 1 : gamelog.New(query.GetGameLog(world)).
36 1 : Markup(query.T(world, "You contracted %s.", name)).
37 1 : Log()
38 1 : }
39 1 : return true
40 : }
|