Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (536)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  trading card game security  (Read 2811 times)
0 Members and 1 Guest are viewing this topic.
Offline goowik

Senior Newbie


Medals: 1



« Posted 2012-07-17 13:23:35 »

Hi,

So I'm creating a trading card game (much like Magic: The Gathering, with different gameplay mechanics).

To test I usually create cards on the fly, but now it's time to create a database.
So I first thought of simply setting up a xml file which contains all cards and an object file of players with their decks and cards.

Problem though, it's not quite secure to save it locally.
So I was thinking of creating a server which keeps tracks of all cards and players.

The server would later be used to create rooms where players could battle each other.


But I'm not sure where to start.
So I have a few questions on this matter:
Is xml advised? Let's say I have around 250 cards. An example of xml would be:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
<?xml version="1.0" encoding="UTF-8"?>
<creatures>
<creature name="Skeleton">
  <description>This is a skeleton</description>
  <damage>3</damage>
  <health>2</health>
  <cost>2</cost>
  <type>ground</type>
  <effects>
   <effect name="Lightning">
    <target>opponent</target>
    <skipturn>false</skipturn>
    <damage>2</damage>
    <cost>2</cost>
   <effect>
  </effects>
</creature>
<creature name="Slime">
  <description>This is a slime</description>
  <damage>1</damage>
  <health>1</health>
  <cost>1</cost>
  <type>ground</type>
</creature>
<creature name="Pinguin">
  <description>This is a pinguin</description>
  <damage>0</damage>
  <health>3</health>
  <cost>1</cost>
  <type>flying</type>
  <effects>
   <effect name="Heal">
    <target>self</target>
    <skipturn>false</skipturn>
    <damage>-2</damage>
    <cost>1</cost>
   <effect>
   <effect name="Push">
    <target>target</target>
    <skipturn>true</skipturn>
    <damage>0</damage>
    <cost>1</cost>
   <effect>
  </effects>
</creature>
</creatures>


How would cards be imported in game (from the server)? Is it a one time retrieval (copy to new card object)?
Or what's your view on this?

How would you save up players and their info? For example cards? Would you keep track of only the id's of cards?

Maybe any more suggestions on what I should pay attention for?

Regards
Goowik
Offline _Al3x

Senior Member


Medals: 7


Indie Games FTW!


« Reply #1 - Posted 2012-07-17 13:34:21 »

If the game is online-only:
- Player connects to the server
- Server sends Player's account's cards (use anything you want, others may help you more on this)
- Player plays
- Player buys/wins a new card
- Server updates Player's card
- Server sends Player's account's cards
- Player sees his new cards

The player never sends "card list info" to the server. So no hack's allowed there.

If the game is offline-only:
- If the player wan't to cheat, he will cheat one way or another, make it fun care about other stuffs and get it done.

If the game is online-offline:
- Use a mix of both

Hope it helps Smiley

Offline goowik

Senior Newbie


Medals: 1



« Reply #2 - Posted 2012-07-19 13:09:35 »

Thanks, will check into it.

I'll probably make it online only. Now I just need to check out how server scripting works Smiley

Anything special I need to take into account?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Sickan

Senior Member


Medals: 8



« Reply #3 - Posted 2012-07-19 13:39:35 »

Thanks, will check into it.

I'll probably make it online only. Now I just need to check out how server scripting works Smiley

Anything special I need to take into account?
Make sure to notify me or make a showcase thread so that I can play it when it comes out.

Cheers Smiley
Offline goowik

Senior Newbie


Medals: 1



« Reply #4 - Posted 2012-07-19 14:08:24 »

Hehe I will Smiley

@_Al3x: Btw, if I use an online version only, should I check each second whether the user is connected to the server or not?
The only thing that comes through my mind is a separated thread that checks the connection. But isn't that abundant (not sure if using the right word here)?

Or what other solution is there?
Offline Sickan

Senior Member


Medals: 8



« Reply #5 - Posted 2012-07-19 14:17:37 »

Hehe I will Smiley

@_Al3x: Btw, if I use an online version only, should I check each second whether the user is connected to the server or not?
The only thing that comes through my mind is a separated thread that checks the connection. But isn't that abundant (not sure if using the right word here)?

Or what other solution is there?

Redundant might be the word you are after.

Cheers Smiley
Offline _Al3x

Senior Member


Medals: 7


Indie Games FTW!


« Reply #6 - Posted 2012-07-19 17:52:38 »

You don't need real-time checks like RTS or FPS, but we'll need others with more expertise on the subject to come and help you out.
Smiley

Offline jonjava
« Reply #7 - Posted 2012-07-19 21:21:28 »

There's old and easy to grasp way of creating a new Thread for every player or you can read about java.nio (java new IO) which came in java 1.4 and learn about the idea of "Channels". Java NIO makes extensive use of low level hardware/OS specific networking thingies and to really get an intuition on how it works you'd probably want to read about it.

Read this thread for more info and it also has an example on a simple server in java.nio as well as links to learn about java.nio: http://www.javaprogrammingforums.com/whats-wrong-my-code/8366-java-tcp-multiple-clients.html#post63245

@_Al3x: Btw, if I use an online version only, should I check each second whether the user is connected to the server or not?

Unless you absolutely must know the client is connected every 1 second... but then again a socket should automatically send a disconnection message when he disconnected.

So basically, no you don't. What you could do, is if the client has been idle (not sent you any messages) for about 3 minutes you could send a PINGPONG check to see if he's still there.

Offline goowik

Senior Newbie


Medals: 1



« Reply #8 - Posted 2012-07-31 09:32:41 »

Im terribly sorry for this late response. I totally forgot to enable notification when a reply has been sent.

So the idle part can be fixed by a simple turn timer (of about 30 seconds).
Problem however is I'm still new to netwroking and all example I seem to find are just text thats being sent.

So should I read out my xml files and send the content? One issue i can think of is that the total amount can exceed a few Mb's.
I suppose this should be done using some loading 'pattern' using different threads.

Sigh, the longer I think about this project the more difficult it gets.
Offline pjt33
« Reply #9 - Posted 2012-07-31 21:45:42 »

Sigh, the longer I think about this project the more difficult it gets.
If the rules even begin to approach the complexity of M:tG, the networking is the really easy bit.

BTW your XML snippet looks a bit denormalised. How many of an effect's parameters will vary between uses? Some effects might have variable target constraints; some might have variable costs; and some might have other parameters (e.g. damage, secondary cost, number of cards returned to hand), but you only really need to configure the variable parameters on a per-card basis.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline goowik

Senior Newbie


Medals: 1



« Reply #10 - Posted 2012-08-03 20:33:32 »

Well that was also an issue I came across.

But before continuing I shall start to figure out how the rules will be.
I will try and create a different set of rules, where positioning will be important and skills will be at a minimum.

For example heal, block, damage, multi target (no variable damage or whatsoever).
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Riven (15 views)
2014-07-29 18:09:19

Riven (10 views)
2014-07-29 18:08:52

Dwinin (10 views)
2014-07-29 10:59:34

E.R. Fleming (28 views)
2014-07-29 03:07:13

E.R. Fleming (10 views)
2014-07-29 03:06:25

pw (40 views)
2014-07-24 01:59:36

Riven (39 views)
2014-07-23 21:16:32

Riven (27 views)
2014-07-23 21:07:15

Riven (29 views)
2014-07-23 20:56:16

ctomni231 (59 views)
2014-07-18 06:55:21
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!