Difference between revisions of "Extending the editor"
(One intermediate revision by the same user not shown) | |||
Line 18: | Line 18: | ||
* Move card effect: It moves the target card to another game zone. | * Move card effect: It moves the target card to another game zone. | ||
− | It is possible to create your own custom effects in a very convenient way and the editor will pick them up automatically without you having to write any additional code to do so | + | It is possible to create your own custom effects in a very convenient way and the editor will pick them up automatically and make them available in the effects dropwdown without you having to write any additional code to do so. |
https://www.ccgkit.com/images/effects_dropdown.png | https://www.ccgkit.com/images/effects_dropdown.png | ||
Line 47: | Line 47: | ||
player.stats[statId].AddModifier(modifier); | player.stats[statId].AddModifier(modifier); | ||
} | } | ||
− | } | + | }</nowiki> |
− | </nowiki> | + | |
And the ''decrease card effect'' as a reference on card effects: | And the ''decrease card effect'' as a reference on card effects: | ||
Line 69: | Line 68: | ||
card.stats[statId].AddModifier(modifier); | card.stats[statId].AddModifier(modifier); | ||
} | } | ||
− | } | + | }</nowiki> |
− | </nowiki> | + | |
As you can see, there are several useful base classes for effects: | As you can see, there are several useful base classes for effects: | ||
Line 105: | Line 103: | ||
{ | { | ||
// ... | // ... | ||
− | } | + | }</nowiki> |
− | </nowiki> | + | |
And the following signature for card effects: | And the following signature for card effects: | ||
Line 114: | Line 111: | ||
{ | { | ||
// ... | // ... | ||
− | } | + | }</nowiki> |
− | </nowiki> | + | |
|} | |} |
Latest revision as of 03:51, 4 August 2017
Creating new card effectsThe kit includes a collection of default card effects:
It is possible to create your own custom effects in a very convenient way and the editor will pick them up automatically and make them available in the effects dropwdown without you having to write any additional code to do so.
If you want to create a new effect, you will first need to decide if it is a player effect (i.e., it targets a player or group of players) or a card effect (i.e., it targets a card or group of cards). Let's take the increase player stat effect as a reference on player effects: [PlayerTarget] public class IncreasePlayerStatEffect : PlayerEffect { [PlayerStatField("Player stat")] [Order(1)] public int statId; [ValueField("Value")] [Order(2)] public Value value; [IntField("Duration")] [Order(3)] public int duration; public override void Resolve(GameState state, PlayerInfo player) { var modifier = new Modifier(value.GetValue(state, player), duration); player.stats[statId].AddModifier(modifier); } } And the decrease card effect as a reference on card effects: [CardTarget] public class DecreaseCardStatEffect : CardStatEffect { [ValueField("Value")] [Order(4)] public Value value; [IntField("Duration")] [Order(5)] public int duration; public override void Resolve(GameState state, RuntimeCard card) { var modifier = new Modifier(-value.GetValue(state, card.ownerPlayer), duration); card.stats[statId].AddModifier(modifier); } } As you can see, there are several useful base classes for effects:
And several useful attributes for effect fields:
These attributes allow you to dynamically access the general settings you have defined for your game (like stats or zones) without writing any additional code. This is how the previous player effect looks like in the editor:
And this is how the previous card effect looks like in the editor:
The actual logic of the effects happens in the Resolve method, with the following signature for player effects: public override void Resolve(GameState state, PlayerInfo player) { // ... } And the following signature for card effects: public override void Resolve(GameState state, RuntimeCard card) { // ... } |