Adding scripting functionality to .NET applications

前端 未结 9 1512
不思量自难忘°
不思量自难忘° 2020-11-29 21:55

I have a little game written in C#. It uses a database as back-end. It\'s a trading card game, and I wanted to implement the function of the cards as a script.

What

9条回答
  •  误落风尘
    2020-11-29 22:28

    Yes, I thought about that, but I soon figured out that another Domain-Specific-Language (DSL) would be a bit too much.

    Essentially, they need to interact with my gamestate in possibly unpredictable ways. For example, a card could have a rule "When this cards enter play, all your undead minions gain +3 attack against flying enemies, except when the enemy is blessed". As trading card games are turn based, the GameState Manager will fire OnStageX events and let the cards modify other cards or the GameState in whatever way the card needs.

    If I try to create a DSL, I have to implement a rather large feature set and possibly constantly update it, which shifts the maintenance work to another part without actually removing it.

    That's why I wanted to stay with a "real" .NET language to essentially be able to just fire the event and let the card manipulate the gamestate in whatever way (within the limits of the code access security).

提交回复
热议问题