Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by feneq · Nov 25, 2013 at 08:13 PM · stringdatabasecardsregexinterpret

Creating a card game. Best ways to interpret the various cards?

I'm working on a card game. There are 100 cards to start with and all of them do different things. The cards are design to have a trigger, an action and a target. Right now all the card data is in a database, which the game will load in at start. What is the best way to interpret the various cards? Right now I've created a way to write expressions, like (trigger) ? TRIGGER_TYPE @ TARGET_TYPE, (action) ACTION_TYPE, (target) ? TARGET_TYPE : TARGET_MODIFIER. It's a simple syntax, though tedious to write expressions for each card, I have some ideas for simplification but I'm sitting here getting ready to research on how to read through a string with regex and interpret the cards but I can't help but wonder if there is a better way to approach this task.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by PaulGregory · Nov 26, 2013 at 02:20 PM

You have devised a tedious expression, which you don't yet know how to read. Yes, there is a better way.

You need to convert the human-readable abilities of each card into a series of properties that can be understood by your game. There is no need for you to stuff all the data into a text string and then extract it.

I assume your actual database has the trigger, action and target in separate columns in a table along with columns for the card name, text and art references etc. If not, it should. The game does not need to 'read' a card like a human would, it needs to be aware of its properties. You need to store the properties against the card reference. You then apply the properties to a game object when the card comes into play, along with additional properties such as which player controls it.

Each thing you have may actually be multiple properties - for your card's TARGET_TYPE you probably need an additional property that specifies the quantity of targets it would apply to, and use a spare number like 0 to mean all. And then another property to specify whether this relates to all players, all opponents, the opponent of your choice etc.

It will be worth your while reading a detailed description of a card game that has triggers, actions and targets - such as the official turn steps to Magic: The Gathering - so you can begin to imagine what data you will need and at what points, even for a less complicated game.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image feneq · Nov 27, 2013 at 10:46 AM 0
Share

Thanks for the response.

I would say this is overall a better way to approach this. It is less tedious, not by much but it helps. Also, it doesn't make sense to extract the data out of the expression string when you can just lay it out on a table. The expressions were pretty nice for readability though, now my table has about 13 extra fields and many of records won't use them. Still, I think you are right, this is a better solution.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

17 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Replace() with string and Regex not replacing numbers/integers 2 Answers

How to replace a word inside a string with different white space combos? 0 Answers

Quick SQLite question for Unity Game Database 1 Answer

Get the upper Chars out of a string 1 Answer

How do I connect to an Oracle Database? 6 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges