*Author

PuppyChow

  • Guest
Re: How to decipher the card codes? https://elementscommunity.org/forum/index.php?topic=5672.msg61968#msg61968
« Reply #12 on: May 01, 2010, 10:33:39 pm »
Added a plea for help :D.

Offline yaladilae

  • Sr. Member
  • ****
  • Posts: 951
  • Reputation Power: 12
  • yaladilae is taking their first peeks out of the Antlion's burrow.yaladilae is taking their first peeks out of the Antlion's burrow.
  • † RIP Butterfly Angel †
  • Awards: Undefeated 100-0 Competition Winner
Re: How to decipher the card codes? https://elementscommunity.org/forum/index.php?topic=5672.msg61971#msg61971
« Reply #13 on: May 01, 2010, 10:41:18 pm »
Added a plea for help :D.
If you need help for the suggestion / discussion, I am in (but bare in mind I am only much better at building FG deck then pvp deck)

If you need help for the java language, I could help you some.... 6 years ago (and not very advanced).... =(
Now my job dont even have any resemblence to these kind of thing

Frz

  • Guest
Re: How to decipher the card codes? https://elementscommunity.org/forum/index.php?topic=5672.msg62007#msg62007
« Reply #14 on: May 02, 2010, 01:10:44 am »
You really shouldn't put all the cards in the code itself. Externalize it in a database (h2 db?), an xml file (take a look at xstream), a json file or any other external storage file, that way non programmers can add card definitions/change costs, etc.

Also: cascading ifs is kind of a bad idea, build a hashmap, that allows much faster access:

map.get("code");

Id's also convert the card codes to their numeric equivalent if that is possible they don't actually appear to be base 32 as plaplan stated (stone pillars are code 58o but their numeric value is 400 (see http://elementsthegame.wikia.com/index.php?title=Template:Card_Name_From_Id&action=edit ))

PuppyChow

  • Guest
Re: How to decipher the card codes? https://elementscommunity.org/forum/index.php?topic=5672.msg62047#msg62047
« Reply #15 on: May 02, 2010, 03:55:03 am »
You really shouldn't put all the cards in the code itself. Externalize it in a database (h2 db?), an xml file (take a look at xstream), a json file or any other external storage file, that way non programmers can add card definitions/change costs, etc.

Also: cascading ifs is kind of a bad idea, build a hashmap, that allows much faster access:

map.get("code");

Id's also convert the card codes to their numeric equivalent if that is possible they don't actually appear to be base 32 as plaplan stated (stone pillars are code 58o but their numeric value is 400 (see http://elementsthegame.wikia.com/index.php?title=Template:Card_Name_From_Id&action=edit ))
I could, but I've already pretty much built the program around doing it this way, so a hashmap won't really fit. And I'm rather an amateur programmer; I'm working my way up to using IO streams and such, but I'm not there yet. I'm good at making equations and using arrays so the actual responding part isn't hard, but I'm inept at using some (most) of the more technical classes.

Frz

  • Guest
Re: How to decipher the card codes? https://elementscommunity.org/forum/index.php?topic=5672.msg62169#msg62169
« Reply #16 on: May 02, 2010, 12:07:30 pm »
You can convert if cascaed like you described above to a hashmap really quickly probably even with a regex. There is really no reason not to do it

PuppyChow

  • Guest
Re: How to decipher the card codes? https://elementscommunity.org/forum/index.php?topic=5672.msg62265#msg62265
« Reply #17 on: May 02, 2010, 04:52:38 pm »
Yes, I could make a hashmap connecting cards to codes like ("Hjk","Quantumpillar"), but that isn't what I'm trying to really do.

Basically, it takes a deck code. Made up code:
"hjk lik gh6 i8s v6f"
Then I loop through all the sets of three codes, and make a new card in a card[] corresponding to the code.
Now I could use a hashmap to get what card it's supposed to be, but how would that help?

Here's what it basically is right now:

Loop through each group of 3 letters
If 3 letters equal xxx, then the card[c] is a new Card(stuff corresponding to that card)
else if its...

With a hashmap:
Set up hashmap with two strings, code and card corresponding to code. (This in itself will take tons of time).
Loop through each group of 3 letters
Get the corresponding card to each code
THEN write tons of if statements of "if card=="quantumpillar" then card[c] is a new Card(stuff corresponding to that card)

So basically with a hashmap all I'm doing is adding in a whole lot more than necessary. It's like going from a -> b -> c when you could just go from a -> c. The problem is that as far as I know hashmaps can only accept strings and numbers; any class you make up yourself (which is what I did with the class Card) can't be taken as an argument.

If I could make a hashmap with a string and a instance of the class Card, it would work better (hashmap.put("code", new Card(stuff));) but I can't do that as far as I know.

Offline Xinef

  • Hero Member
  • *****
  • Posts: 1358
  • Country: pl
  • Reputation Power: 15
  • Xinef is a Blue Crawler starting to think about his first run.Xinef is a Blue Crawler starting to think about his first run.Xinef is a Blue Crawler starting to think about his first run.
  • Fluttershy's samurai
  • Awards: Slice of Elements 10th Birthday Cake
Re: How to decipher the card codes? https://elementscommunity.org/forum/index.php?topic=5672.msg63416#msg63416
« Reply #18 on: May 04, 2010, 05:48:01 pm »
I just found this thread (It surprises me, I didn't notice it earlier)...

So... I'll help!
I've some experience with XStream library, some simple Java applets and things like that.

The thing is that I'm using this to also help out my java programming skills, so I kinda want to do the whole thing myself :).
But if you don't want help with coding, I'll help with the if else thingy. I'm working on the quantum index calculator (http://elementscommunity.org/forum/index.php/topic,5676.0.html) and I'd need something similar anyway.

The way I would do it though would be quite different.
First, I'd write a separate Java application that creates an array of all cards (So this is the place where I'd need to call a constructor once for each card). Then this application would write it as an XML file.
Now, the Java Applet can read the XML file to recreate the array (a really short, simple code) and use it to fill a hashtable. Once again a short simple code. Now we can quickly find each card by it's code.

Why would I do it like that? Because now the applet itself contains no unnecessary code, we can add new cards without recompiling the applet simply by adding new entries in the XML file, and if anything needs to change (eg. some new field is added to the cards class), we can quickly recreate the XML file with the added field.

As for hashmaps, try something like this:

Code: [Select]
import java.util.HashMap;

public class test {

public static void main(String[] args) {

HashMap<String, Card> hashmap = new HashMap<String, Card>(500);

hashmap.put("xxx", new Card("Hello Elements!"));

System.out.println(hashtable.get("xxx"));
}

}

class Card {

private String name;

public Card(String name) {
this.name = name;
}

@Override
public String toString() {
return name;
}
}
But anyway, I'll try to make the if else thingy for :time cards, because I'm eager to see what your applet really can do :P



EDIT:
A little expanded example:
Code: [Select]
import java.util.HashMap;

public class test {

public static void main(String[] args) {

HashMap<String, Card> hashtable = new HashMap<String, Card>(500);

Card[] cards = new Card[3];

cards[0] = new Card("Scarab", "xxx");
cards[1] = new Card("Deja vu", "xxy");
cards[2] = new Card("4n00b15", "xxz");

for(Card card : cards) {
hashtable.put(card.getHash(), card);
}

System.out.println(hashtable.get("xxy"));
}

}

class Card {

private String name;
private String hash;

public Card() {
}

public Card(String name, String hash) {
this.name = name;
this.hash = hash;
}

@Override
public String toString() {
return name;
}

public String getHash() {
return hash;
}
}
May the force of the D4HK side be with U ^_^
:time samurai

Offline Xinef

  • Hero Member
  • *****
  • Posts: 1358
  • Country: pl
  • Reputation Power: 15
  • Xinef is a Blue Crawler starting to think about his first run.Xinef is a Blue Crawler starting to think about his first run.Xinef is a Blue Crawler starting to think about his first run.
  • Fluttershy's samurai
  • Awards: Slice of Elements 10th Birthday Cake
Re: How to decipher the card codes? https://elementscommunity.org/forum/index.php?topic=5672.msg65616#msg65616
« Reply #19 on: May 08, 2010, 11:29:43 pm »
Time cards ready:
Code: [Select]
else if (card.equals("5rg")) cards[c] = new Card("timefactory", "permanent", 0, "none", 0, 0, "generate", 0, "time", "none");
else if (card.equals("5rh")) cards[c] = new Card("dejavu", "creature", 1, "time", 1, 1, "dejavu", 1, "time", "none", true);
else if (card.equals("5ri")) cards[c] = new Card("fateegg", "creature", 3, "time", 0, 1, "fate", 1, "time", "none", true);
else if (card.equals("5rj")) cards[c] = new Card("procrastination", "shield", 6, "time", 0, 0, "none", 0, "none", "procrastination", false);
else if (card.equals("5rk")) cards[c] = new Card("reversetime", "spell", 2, "time", 0, 0, "rewind", 0, "none", "none", false);
else if (card.equals("5rl")) cards[c] = new Card("goldenhourglass", "permanent", 4, "time", 0, 0, "hasten", 2, "time", "none");
else if (card.equals("5rm")) cards[c] = new Card("devoniandragon", "creature", 10, "time", 10, 5, "none", 0, "none", "none", true);
else if (card.equals("5rn")) cards[c] = new Card("anubis", "creature", 8, "time", 5, 8, "immortality", 2, "aether", "none");
else if (card.equals("5ro")) cards[c] = new Card("eternity", "weapon", 6, "time", 4, 8, "rewind", 3, "time", "none");
else if (card.equals("5rp")) cards[c] = new Card("sundial", "permanent", 1, "time", 0, 0, "hasten", 1, "light", "stasis", false);
else if (card.equals("5rq")) cards[c] = new Card("scarab", "creature", 2, "time", 2, 0, "devour", 1, "gravity", "swarm");
else if (card.equals("5rr")) cards[c] = new Card("precognition", "spell", 2, "time", 0, 0, "precognition", 0, "none", "none");
else if (card.equals("5rs")) cards[c] = new Card("pharaoh", "creature", 9, "time", 3, 8, "scarab", 2, "time", "none");
else if (card.equals("5s4")) cards[c] = new Card("goldennymph", "creature", 9, "time", 6, 8, "precognition", 2, "time", "none");

else if (card.equals("7q0")) cards[c] = new Card("timetower", "permanent", -1, "time", 0, 0, "generate", 0, "time", "none");
else if (card.equals("7q1")) cards[c] = new Card("elitedejavu", "creature", 1, "time", 2, 2, "dejavu", 1, "time", "none", true);
else if (card.equals("7q2")) cards[c] = new Card("fateegg", "creature", 3, "time", 0, 1, "fateelite", 1, "time", "none", true);
else if (card.equals("7q3")) cards[c] = new Card("turtleshield", "shield", 4, "time", 0, 0, "none", 0, "none", "procrastination", false);
else if (card.equals("7q4")) cards[c] = new Card("rewind", "spell", 1, "time", 0, 0, "rewind", 0, "none", "none", false);
else if (card.equals("7q5")) cards[c] = new Card("electrumhourglass", "permanent", 4, "time", 0, 0, "hasten", 1, "time", "none");
else if (card.equals("7q6")) cards[c] = new Card("siluriandragon", "creature", 12, "time", 13, 4, "none", 0, "none", "none", true);
else if (card.equals("7q7")) cards[c] = new Card("eliteanubis", "creature", 8, "time", 5, 8, "immortality", 1, "aether", "none");
else if (card.equals("7q8")) cards[c] = new Card("eternity", "weapon", 5, "time", 4, 8, "rewind", 3, "time", "none");
else if (card.equals("7q9")) cards[c] = new Card("sundial", "permanent", 0, "none", 0, 0, "hasten", 2, "light", "stasis", false);
else if (card.equals("7qa")) cards[c] = new Card("elitescarab", "creature", 2, "time", 3, 0, "devour", 1, "gravity", "swarm");
else if (card.equals("7qb")) cards[c] = new Card("precognition", "spell", 1, "time", 0, 0, "precognition", 0, "none", "none");
else if (card.equals("7qc")) cards[c] = new Card("pharaoh", "creature", 9, "time", 3, 8, "scarabelite", 2, "time", "none");
else if (card.equals("7qk")) cards[c] = new Card("goldennymph", "creature", 9, "time", 7, 9, "precognition", 2, "time", "none");
Questions I have so far:
Has the cost of golden nymph gone down to 8 in recent update or not? Because it seems in trainer all nymphs are still at 9, but in real game my auburn nymph has a cost of 8, so I wonder if golden nymphs cost also got decreased? (I don't have one to check myself)

What should I give as scarabs hp? Right now I gave 0, and the passive ability "swarm".
How should I name anubises and pharaohs abilities? (so far "immortality", "scarab" and "scarabelite")
How should I name sundials passive ability? (so far it has "hasten" as active and "stasis" as passive)
How should I mark the fact that tower gives +1 the turn it is played? Should it have a cost of -1 time?
Upgrading a fate egg changes only it's ability, so how should I name it? (right now it's "fate" and "fateelite")
Is procrastinations "procrastination" ability considered active or passive? (I guess passive).

I'll do the "other" cards next, and then I'll leave other elements to other people, unless I have some more free time (very improbable).

PS.: I'd do the elements and card type as enums, rather than strings (unless you call the constructor with a string as a parameter, then convert it into an enum internally, and throw an exception if string does not fit any element/permanent type).
May the force of the D4HK side be with U ^_^
:time samurai

PuppyChow

  • Guest
Re: How to decipher the card codes? https://elementscommunity.org/forum/index.php?topic=5672.msg65692#msg65692
« Reply #20 on: May 09, 2010, 02:15:15 am »
Quote
Questions I have so far:
Has the cost of golden nymph gone down to 8 in recent update or not? Because it seems in trainer all nymphs are still at 9, but in real game my auburn nymph has a cost of 8, so I wonder if golden nymphs cost also got decreased? (I don't have one to check myself)

What should I give as scarabs hp? Right now I gave 0, and the passive ability "swarm".
How should I name anubises and pharaohs abilities? (so far "immortality", "scarab" and "scarabelite")
How should I name sundials passive ability? (so far it has "hasten" as active and "stasis" as passive)
How should I mark the fact that tower gives +1 the turn it is played? Should it have a cost of -1 time?
Upgrading a fate egg changes only it's ability, so how should I name it? (right now it's "fate" and "fateelite")
Is procrastinations "procrastination" ability considered active or passive? (I guess passive).

I'll do the "other" cards next, and then I'll leave other elements to other people, unless I have some more free time (very improbable).

PS.: I'd do the elements and card type as enums, rather than strings (unless you call the constructor with a string as a parameter, then convert it into an enum internally, and throw an exception if string does not fit any element/permanent type).
Scarabs hp? Yes, 0 sounds good.
The abilities are scarab, scarabelite, and immortalize. Not immortality (it was listed under aether :)) .
Stasis as passive is good. I forgot about that one.
For towers, make the ability "generate+1".
Fateelite is fine.
Shield abilities are passive.

Thanks, and great job :) . As to using enums, I do exactly what you just said: convert both to enums internally. I originally was going to make the abilities an enum too, but it ended up being too many possibilities and I got errors.

Also, about the hashmap, I didn't know that it could accept things other than strings and integers. Thinking about it, a hashmap would possibly be a better alternative but it's lots more work to change it back that I don't feel like doing.

 

anything
blarg: