Skip to content

Commit c3c31a7

Browse files
committed
2026-04-28 sync
1 parent 0db1e64 commit c3c31a7

14 files changed

Lines changed: 154 additions & 8 deletions

_config.kira.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ docsTree:
101101
title: 15 添加单例,
102102
path: /docs/04-ritsulib/04-15-add-singleton/,
103103
},
104+
{
105+
title: 16 血条覆盖,
106+
path: /docs/04-ritsulib/04-16-health-bar-overlay/,
107+
},
104108
],
105109
},
106110
{

source/_posts/03-baselib/03-01-add-card.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ using MegaCrit.Sts2.Core.ValueProps;
2121

2222
namespace Test.Scripts.Cards;
2323

24-
// 加入哪个卡池
24+
// 注册卡牌。如果要写自定义池看添加人物的开头
2525
[Pool(typeof(ColorlessCardPool))]
2626
public class TestCard : CustomCardModel
2727
{

source/_posts/03-baselib/03-03-add-relic.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ categories:
88
和添加卡牌类似。先新建一个类。
99

1010
```csharp
11-
// 加入哪个遗物池,此处为通用
11+
// 注册遗物。如果要写自定义池看添加人物的开头
1212
[Pool(typeof(SharedRelicPool))]
1313
public class TestRelic : CustomRelicModel
1414
{

source/_posts/03-baselib/03-04-card-properties.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@ public class MyKeywords
7676
`:diff()`表示这个值一旦和基础值不同,就会变红色或绿色(例如升级时增加数值,预览变成绿色)。
7777

7878

79+
简单来说效果可以在`OnPlay`这么写,或者写一个自己的Cmd方便执行效果:
80+
```csharp
81+
// 使用DynamicVars["Leech"]获取数值,先让敌人失去生命(受到不可格挡不受能力影响的伤害)
82+
await CreatureCmd.Damage(choiceContext, [cardPlay.Target!], DynamicVars["Leech"].BaseValue, ValueProp.Unblockable | ValueProp.Unpowered, cardPlay.Card.Owner.Creature);
83+
// 再让玩家回复生命
84+
await CreatureCmd.Heal(cardPlay.Card.Owner.Creature, DynamicVars["Leech"].BaseValue);
85+
```
86+
7987
![alt text](../../images/image26.png)
8088

8189
## 添加卡牌提示文本

source/_posts/03-baselib/03-06-add-potion.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ using MegaCrit.Sts2.Core.Models.Cards;
2020

2121
namespace Test.Scripts;
2222

23+
// 注册药水。如果要写自定义池看添加人物的开头
2324
[Pool(typeof(TestPotionPool))]
2425
public class TestPotion : CustomPotionModel
2526
{

source/_posts/04-ritsulib.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ public class Entry
6969

7070
public static void Init()
7171
{
72+
// harmony可用,但是最好用ritsu的封装patch(TODO)
73+
// var harmony = new Harmony("com.example.testmod");
74+
// harmony.PatchAll();
7275
var assembly = Assembly.GetExecutingAssembly();
7376
RitsuLibFramework.EnsureGodotScriptsRegistered(assembly, Logger);
7477
// 自动注册内容

source/_posts/04-ritsulib/04-01-add-card.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ using STS2RitsuLib.Scaffolding.Content;
3333

3434
namespace Test.Scripts;
3535

36-
// 注册卡牌
36+
// 注册卡牌到指定池(这里是无色)。如果要写自定义池看添加人物的开头
3737
[RegisterCard(typeof(ColorlessCardPool))]
3838
// 注册成人物起始卡,后面是数量。不需要删除即可。
3939
// [RegisterCharacterStarterCard(typeof(TestCharacter), 5)]
@@ -53,6 +53,11 @@ public class TestCard : ModCardTemplate
5353
// 卡图资源
5454
public override CardAssetProfile AssetProfile => new(
5555
PortraitPath: $"res://Test/images/cards/{GetType().Name}.png"
56+
// 卡框等,有需求自己添加。需要自行判断卡牌类型(攻击、技能、能力等)设置,建议写在基类里。
57+
// 如果使用自定义卡池,需要改下material(TODO)
58+
// FramePath: "", // 卡牌背景
59+
// PortraitBorderPath: "", // 边框(状态牌感染使用的)
60+
// BannerTexturePath: "" // 横幅(不同类型)
5661
);
5762

5863
// 卡牌基础数值
@@ -128,7 +133,17 @@ namespace Test.Scripts;
128133
public abstract class TestCardModel : ModCardTemplate
129134
{
130135
public override CardAssetProfile AssetProfile => new(
131-
PortraitPath: $"res://Test/images/cards/{GetType().Name}.png"
136+
PortraitPath: $"res://RitsuTest/images/cards/{GetType().Name}.png",
137+
// 根据不同类型设置不同卡框
138+
FramePath: type switch
139+
{
140+
CardType.Attack => "res://RitsuTest/images/card_frame_attack.png",
141+
CardType.Skill => "res://RitsuTest/images/card_frame_skill.png",
142+
CardType.Power => "res://RitsuTest/images/card_frame_power.png",
143+
_ => ""
144+
}
145+
// PortraitBorderPath: "",
146+
// BannerTexturePath: ""
132147
);
133148

134149
public TestCardModel(int energyCost, CardType type, CardRarity rarity, TargetType targetType, bool shouldShowInCardLibrary)

source/_posts/04-ritsulib/04-03-add-relic.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,22 @@ categories:
1010
和添加卡牌类似。先新建一个类。
1111

1212
```csharp
13+
using Godot;
1314
using MegaCrit.Sts2.Core.Commands;
15+
using MegaCrit.Sts2.Core.Entities.Cards;
1416
using MegaCrit.Sts2.Core.Entities.Players;
1517
using MegaCrit.Sts2.Core.Entities.Relics;
1618
using MegaCrit.Sts2.Core.GameActions.Multiplayer;
1719
using MegaCrit.Sts2.Core.Localization.DynamicVars;
20+
using MegaCrit.Sts2.Core.Models.RelicPools;
1821
using MegaCrit.Sts2.Core.Saves.Runs;
1922
using STS2RitsuLib.Interop.AutoRegistration;
2023
using STS2RitsuLib.Scaffolding.Content;
2124

2225
namespace Test.Scripts;
2326

24-
[RegisterRelic(typeof(TestRelicPool))]
27+
// 注册遗物。如果要写自定义池看添加人物的开头
28+
[RegisterRelic(typeof(SharedRelicPool))]
2529
// [RegisterCharacterStarterRelic(typeof(TestCharacter))] // 注册起始遗物
2630
public class TestRelic : ModRelicTemplate
2731
{

source/_posts/04-ritsulib/04-04-card-properties.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,14 @@ public class MyKeywords
8181
`:diff()`表示这个值一旦和基础值不同,就会变红色或绿色(例如升级时增加数值,预览变成绿色)。
8282

8383

84+
简单来说效果可以在`OnPlay`这么写,或者写一个自己的Cmd方便执行效果:
85+
```csharp
86+
// 使用DynamicVars["Leech"]获取数值,先让敌人失去生命(受到不可格挡不受能力影响的伤害)
87+
await CreatureCmd.Damage(choiceContext, [cardPlay.Target!], DynamicVars["Leech"].BaseValue, ValueProp.Unblockable | ValueProp.Unpowered, cardPlay.Card.Owner.Creature);
88+
// 再让玩家回复生命
89+
await CreatureCmd.Heal(cardPlay.Card.Owner.Creature, DynamicVars["Leech"].BaseValue);
90+
```
91+
8492
![alt text](../../images/image26.png)
8593

8694

@@ -112,4 +120,30 @@ public class TestCard : ModCardTemplate
112120

113121
## 添加卡牌tag
114122

115-
`ritsulib`暂时不支持添加自定义的卡牌tag。也许暂时可以用keyword替代。
123+
tag是指`打击` `防御`这种。如果有打击tag会被打击木偶增伤。
124+
125+
```csharp
126+
[RegisterOwnedCardTag(nameof(Heavy))]
127+
// [RegisterOwnedCardTag(nameof(Heavy2))] // 添加更多就新加这个特性
128+
public class MyTags
129+
{
130+
public static readonly string Heavy = ModContentRegistry.GetQualifiedCardTagId(Entry.ModId, nameof(Heavy));
131+
132+
// public static readonly string Heavy2 = ModContentRegistry.GetQualifiedCardTagId(Entry.ModId, nameof(Heavy2));
133+
}
134+
```
135+
136+
然后在你的卡牌类里添加:
137+
138+
```csharp
139+
protected override IEnumerable<string> RegisteredCardTagIds => [MyTags.Heavy];
140+
```
141+
142+
需要使用时这么写。`Card`需要是个`CardModel`类型。
143+
144+
```csharp
145+
if (cardPlay.Card.HasModCardTag(MyTags.Heavy))
146+
{
147+
// Do something
148+
}
149+
```

source/_posts/04-ritsulib/04-06-add-potion.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ using STS2RitsuLib.Scaffolding.Content;
2121

2222
namespace Test.Scripts;
2323

24-
[RegisterPotion(typeof(TestPotionPool))]
24+
// 注册药水。如果要写自定义池看添加人物的开头
25+
[RegisterPotion(typeof(SharedPotionPool))]
2526
public class TestPotion : ModPotionTemplate
2627
{
2728
// 稀有度

0 commit comments

Comments
 (0)