在 Actionscript 中模拟集换式卡牌游戏
更具体地说,我正在尝试模拟 Pokemon TCG,如果有帮助的话。
目前,我已经掌握了游戏的基本元素,例如抽牌和洗牌。但是,我不知道如何实现某些卡特有的功能。
为了简化事情,我有一个牌组类和一个卡牌类。卡类包含卡的名称和类型等变量,它通过从数据库中提取它们来获取它们的值。但是,如果我试图创建一个基础集喷火龙,我将如何存储和调用他的 poke-power(可读:能力),因为它的效果超出了游戏的正常规则,并且需要自己的代码。
将能力的代码存储到数据库中并在需要时调用它是否有效(或者甚至可能)?如果没有,解决这种情况的最佳替代方案是什么?
More specifically, I'm trying to simulate the Pokemon TCG, if that helps.
Currently, I have a handle on the basic elements of the game, like drawing cards and shuffling. However, I am lost on how to implement the functionalities unique to certain cards.
To simplify things, I have a deck class and a card class. The card class includes variables like a card's name and type, and it gets their values by extracting them from a database. But say, if I'm trying to create a Base Set Charizard, how would I store and call his poke-power (read:ability), as it has effects beyond the normal rules of the game and needs its own code.
Would it be efficient (or is it even possible) to store the code for the ability into a database and call it when needed? If not, what are the best alternatives to attack this situation?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为您不会将代码存储在数据库中,甚至不会存储在卡上。我认为您需要将执行能力的代码以及定义每张卡的能力分开。
您可能需要抽象出每个效果,并且能力/戳力将是具有不同值的不同“效果”的集合。这可能会变得相当复杂,而且不是一个简单的任务。有些能力具有相同的效果,因此将这些能力抽象出来可以确保你不会重复自己。
I don't think you would store the code in a database, or even against the card. I think you need to separate out the code that does the abilities, and the defining of the ability for each card.
You probably need to abstract out each effect, and an ability/poke-power will be a collection of different "effect" with different values. This could get pretty complicated, and is not a simple task. There will be abilities that share the same effects, so abstracting these out will make sure you don't repeat yourself.
您不会将 AS3 代码存储在数据库中,但将卡片的属性存储在数据库中将是一个好主意。然后,在创建卡片时,有一个工厂类来读取这些属性并使用数据实例化对象。
You wouldn't store AS3 code in a database, but storing properties of the cards in a database would be a good idea. Then when creating the cards have a factory class that reads these properties and instantiates objects using the data.