开发者

simulating a trading card game in actionscript

开发者 https://www.devze.com 2023-02-15 05:23 出处:网络
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 t

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 car开发者_如何学Gods.

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?


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号