Line data Source code
1 : package components
2 :
3 : import (
4 : "fmt"
5 :
6 : "github.com/kijimaD/ruins/internal/i18n"
7 :
8 : "github.com/kijimaD/ruins/internal/consts"
9 : "github.com/kijimaD/ruins/internal/rawschema"
10 : )
11 :
12 : // Pool は最大値と現在値を持つようなパラメータ
13 : type Pool[T consts.Numeric] struct {
14 : Max T // 最大値
15 : Current T // 現在値
16 : }
17 :
18 : // IntPool はPool[int]のエイリアス
19 : type IntPool = Pool[int]
20 :
21 : // FloatPool はPool[float64]のエイリアス
22 : type FloatPool = Pool[float64]
23 :
24 : // TurnBased はエンティティのアクションポイント管理コンポーネント
25 : // ターン制戦闘で、プレイヤー・敵共通で使用される
26 : type TurnBased struct {
27 : AP IntPool
28 : // Speed は毎ターンのAP回復量。能力値・状態異常・装備で変動する
29 : Speed int
30 : }
31 :
32 : // TargetType は選択対象
33 : type TargetType struct {
34 : TargetGroup rawschema.TargetGroup // 対象グループ(味方、敵など)
35 : TargetNum rawschema.TargetNum // 対象数(単体、複数、全体)
36 : }
37 :
38 : // RecipeInput はクラフトの元になる素材
39 : type RecipeInput struct {
40 : ID string // 素材アイテムの id
41 : Amount int // 必要量
42 : }
43 :
44 : // EquipBonus は装備品のオプショナルな性能。武器・防具で共通する
45 : type EquipBonus struct {
46 : Vitality int // 体力ボーナス
47 : Strength int // 筋力ボーナス
48 : Sensation int // 感覚ボーナス
49 : Dexterity int // 器用ボーナス
50 : Agility int // 敏捷ボーナス
51 :
52 : // 残り項目:
53 : // - 火属性などの属性耐性
54 : // - 頑丈+1、連射+2などのスキル
55 : }
56 :
57 : // EquipmentSlotNumber は装備スロット番号。0始まり
58 : type EquipmentSlotNumber int
59 :
60 : // 装備スロット番号定数
61 : const (
62 : SlotHead EquipmentSlotNumber = 0 // 頭部防具スロット
63 : SlotTorso EquipmentSlotNumber = 1 // 胴体防具スロット
64 : SlotArms EquipmentSlotNumber = 2 // 腕部防具スロット
65 : SlotHands EquipmentSlotNumber = 3 // 手部防具スロット
66 : SlotLegs EquipmentSlotNumber = 4 // 脚部防具スロット
67 : SlotFeet EquipmentSlotNumber = 5 // 足部防具スロット
68 : SlotJewelry EquipmentSlotNumber = 6 // 装飾品スロット
69 : SlotWeapon1 EquipmentSlotNumber = 7 // 武器スロット1
70 : SlotWeapon2 EquipmentSlotNumber = 8 // 武器スロット2
71 : SlotWeapon3 EquipmentSlotNumber = 9 // 武器スロット3
72 : SlotWeapon4 EquipmentSlotNumber = 10 // 武器スロット4
73 : SlotWeapon5 EquipmentSlotNumber = 11 // 武器スロット5
74 : )
75 :
76 : // Name は装備スロット番号の表示名を返す
77 : func (s EquipmentSlotNumber) Name() i18n.Msgid {
78 1 : switch s {
79 : case SlotHead:
80 1 : return EquipmentCategoryName(rawschema.EquipmentCategoryHEAD)
81 : case SlotTorso:
82 1 : return EquipmentCategoryName(rawschema.EquipmentCategoryTORSO)
83 : case SlotArms:
84 1 : return EquipmentCategoryName(rawschema.EquipmentCategoryARMS)
85 : case SlotHands:
86 1 : return EquipmentCategoryName(rawschema.EquipmentCategoryHANDS)
87 : case SlotLegs:
88 1 : return EquipmentCategoryName(rawschema.EquipmentCategoryLEGS)
89 : case SlotFeet:
90 1 : return EquipmentCategoryName(rawschema.EquipmentCategoryFEET)
91 : case SlotJewelry:
92 1 : return EquipmentCategoryName(rawschema.EquipmentCategoryJEWELRY)
93 : case SlotWeapon1:
94 1 : return "Weapon 1"
95 : case SlotWeapon2:
96 1 : return "Weapon 2"
97 : case SlotWeapon3:
98 1 : return "Weapon 3"
99 : case SlotWeapon4:
100 1 : return "Weapon 4"
101 : case SlotWeapon5:
102 1 : return "Weapon 5"
103 : default:
104 1 : panic(fmt.Sprintf("unknown EquipmentSlotNumber: %d", s))
105 : }
106 : }
107 :
108 : // ParseEquipmentSlot は raw の装備スロットから装備スロット番号を返す。未知の値は ok=false
109 : func ParseEquipmentSlot(slot rawschema.EquipSlot) (EquipmentSlotNumber, bool) {
110 1 : switch slot {
111 : case rawschema.EquipSlotWEAPON1:
112 1 : return SlotWeapon1, true
113 : case rawschema.EquipSlotWEAPON2:
114 1 : return SlotWeapon2, true
115 : case rawschema.EquipSlotWEAPON3:
116 1 : return SlotWeapon3, true
117 : case rawschema.EquipSlotWEAPON4:
118 1 : return SlotWeapon4, true
119 : case rawschema.EquipSlotWEAPON5:
120 1 : return SlotWeapon5, true
121 : case rawschema.EquipSlotHEAD:
122 1 : return SlotHead, true
123 : case rawschema.EquipSlotTORSO:
124 1 : return SlotTorso, true
125 : case rawschema.EquipSlotARMS:
126 1 : return SlotArms, true
127 : case rawschema.EquipSlotHANDS:
128 1 : return SlotHands, true
129 : case rawschema.EquipSlotLEGS:
130 1 : return SlotLegs, true
131 : case rawschema.EquipSlotFEET:
132 1 : return SlotFeet, true
133 : }
134 1 : return 0, false
135 : }
136 :
137 : // HealAmountKind は回復量の指定方法を表す判別子
138 : type HealAmountKind int
139 :
140 : const (
141 : // HealNumeral は絶対量指定
142 : HealNumeral HealAmountKind = iota
143 : // HealRatio は最大値に対する倍率指定
144 : HealRatio
145 : )
|