« first day (270 days earlier)      last day (3285 days later) » 

12:00 AM
RELOAD!
 
looking good for you @rolfl ^^
@Duga that's it?
 
12:19 AM
@SimonAndréForsberg Slow day
 
1:14 AM
@Marc-Andre It looks like STS already has JS stuff coming with it
 
 
6 hours later…
6:46 AM
hey
 
 
2 hours later…
9:00 AM
@Simon, don't forget to fix Facebook Graph 2.0 in Minesweeper for Android!
 
 
2 hours later…
11:28 AM
@Duga working on it
 
 
1 hour later…
12:37 PM
any opinions?
private boolean validatePassword(String userName, String password) {
    File dir = new File("players");
    File[] directoryListing = dir.listFiles();
    if (directoryListing != null) {
        for (File child : directoryListing) {
            try (BufferedReader br = new BufferedReader(new FileReader(child))) {
                String firstLine = br.readLine();
                String secondLine = br.readLine();
                if (firstLine != null && firstLine.equals(userName)) {
                    if (secondLine != null && secondLine.equals(password)) {
 
12:57 PM
@bazola does the files contain anything other than usernames and passwords? What about hashing the passwords? Why not name the files to the same name as the username?
 
right now no, but i am thinking i will add the player data string on the third line. you are definitely right that I should just check the file name, as that is the same as the players username. I thought about using the encrypted value of the password instead of the decrypted version but I am still not totally sure of the best practice. I could implement something like bcrypt since this is on the server
 
using hash and salt is a good idea, really.
I am sure there's some library that works on LibGDX and GWT.
bah, Android is disturbing...
Error:Gradle: Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
	C:\Program Files (x86)\Android\android-sdk\build-tools\21.1.2\dx.bat --dex --force-jumbo --no-optimize --output C:\Users\Simon\Documents\workspace\minesweeper\TejpbitMFE\app\build\intermediates\dex\debug --input-list=C:\Users\Simon\Documents\workspace\minesweeper\TejpbitMFE\app\build\intermediates\tmp\dex\debug\inputList.txt
Error Code:
	2
Output:
	UNEXPECTED TOP-LEVEL EXCEPTION:
 
1:13 PM
@sᴉɔuɐɹɥԀ Nice! But I'm sure you can have some extention to provide more support (maybe)
 
@SimonAndréForsberg one thing I have read is that it is pointless to hash the password on the client side
 
@bazola both yes and no. Preferably, it should be encrypted/hashed when sent to the server.
 
right now i am using a cipher encrypter so that at least it is not plain text. ssl would be best but that is complicated because of the websocket thing
 
1:31 PM
@bazola Where did you read this ? I really think it's a good idea, the less time the password is in clear, the less time it is more vulnerable.
It protects against attack where you don't have access to the client machine but you can listen or orchestrate a MITM between the client and the server
 
2:04 PM
9
A: md5 hash for password string in GWT/GWT-Ext?

JP RichardsonPersonally, I would say you're doing it wrong. I wouldn't hash a password on the client side (which is what GWT is). If you hash your password, you will undoubtedly want to salt it, otherwise you will be susceptible to rainbow attacks. If you hash + salt it on the client side, your salt will be a...

 
2:15 PM
@Marc-Andre i think the basic reasoning that I have been reading is that if you hash on the client side, then a man in the middle could use that hashed object to authenticate itself with the server without actually knowing the password
 
@bazola what if you don't hash the password, won't you still be vulnerable to man-in-the-middle attacks?
2
A: md5 hash for password string in GWT/GWT-Ext?

DartheniusYou can use gwt-crypto to generate SHA-1 hashes on the client side using: String getSHA1for(String text) { SHA1Digest sd = new SHA1Digest(); byte[] bs = text.getBytes(); sd.update(bs, 0, bs.length); byte[] result = new byte[20]; sd.doFinal(result, 0); return byteArrayToHexString(resu...

 
@bazola If you can make a MITM attack, you have many more things to worry than using the hash password for authentification... if the password is in cleared, what is the diffence ? At least if it's hash he does not know the password and can't use it on other sites
 
@SimonAndréForsberg have you thought about the implications of the code being open for viewing as javascript after GWT compiles it? i'm not sure if the code in that answer would be vulnerable to that or not
@Marc-Andre i admit that i wanted to build a simple cipher mostly as a learning experience, but isn't it mostly as effective as anything else at preventing eavesdropping attacks?
 
@bazola the code produced by GWT is heavily obfuscated. Besides, all JS-code is viewable in the browser.
 
@SimonAndréForsberg thats what i mean, so if you have your encryption code in the browser, if the hacker really wants that password he can reverse engineer that to get it
 
2:26 PM
@bazola Overall, I don't think you need to worry too much about any attacks in this case. As long as you're not dealing with real money, or very sensitive user data, there is not much of a reason to attack you in first place.
 
yeah i agree its not really a concern here, as i will never have any payment information transferred with this system, but its still good to think about it
 
@bazola To get what? The method of encryption you use ? Who cares ? The password is not in the code, just as a content of a variable. He need to 1. do CSRF attack or 2. listen to the connection to intercept something somehow.
@SimonAndréForsberg Unless someone use the same password for another site...
 
@bazola still adds an additional layer of security compared to if the password is sent in clear text. Besides, hash-algorithms are one-way algorithms. Once you get the computed hash, it is computationally speaking impossible to get the real password back.
 
^^ that
Is the reason you don't care if he knows what you use for encryption.
 
@Marc-Andre We all know that there are so many users using the password "123", or "123456" anyway. Just pick a user and a site and start testing!
 
2:29 PM
Anyway I can tell that any serious site is using bcrypt to hash the password... there you go
@SimonAndréForsberg All I'm saying is it's not because you don't any important data that you won't be targeted... weak site are targeted everyday because it's easy and doesn't hurt to have a password db to create hash
 
^^ that is also true
 
Monking
 
all good points
i guess i fully understand now, since what you save on the server side is the hashed version of the password and not a decrypted version
but, i would then need to ensure that the encryption is the same on multiple platforms, because different hashing algorithms would produce different results with the same password as input?
 
@Marc-Andre I'll see if JSDT can add functionality, haven't tested it much in STS to actually run and debug JS, assuming it can at least do the basic client-side stuff without even firing up Tomcat
 
right now the goal is that the user can use any device to play the game
 
2:40 PM
@bazola in fact, the same hashing algorithm can actually produce different outputs, as many of them generate their own salts in the process.
Recommended reading btw:
11
Q: Password hashing method

BANNAI am having some issue to use PHP5 password_hash() function. My server is not supporting it, so I am using a function to hash. Is this one secure? public function Pass_Hash ($password) { $blowfish_salt = bin2hex(openssl_random_pseudo_bytes(22)); $hash = md5(crypt($password, "X1;G^C...

 
@bazola Sure but you need to inform you're user if the password mechanism is not secure, so that they can use a password that will not affect other accounts
 
@bazola you should of course use the same algorithm on all the platforms. Common algorithms are often implemented in many languages.
 
nice answer @SimonAndréForsberg
@SimonAndréForsberg if this is true, how can you possibly deal with cross platform?
pass the salt back and forth along with the hashed password?
 
@bazola you just make sure to use the algorithm correctly.
 
i see
 
2:50 PM
some algorithms (blowfish in PHP for example) store the generated salt inside the hashed result, so it is aware of its own salt, then you use that salt to make sure that the hashed password matches the non-hashed one.
 
Or you saved the salt on the db.
 
3:03 PM
i appreciate the help
 
I appreciate that you want to secure your apps for your users!
 
^^that :)
Just don't salt too much, it's bad for your health!
4
 
there is a whole lot of code in this gwt-crypto, seems like lots of different ciphers
 
3:35 PM
perhaps this should have been more commits:
> fixed compiler errors, increased version name+code, updated Facebook SDK, made gradle build
 
3:51 PM
why does java even let you compare strings with ==, they are just setting people up for failure
 
4:33 PM
okay, parts of my Minesweeper app works again, but parts of it seem totally broken.
Facebook name isn't retrieved in main menu, and local-player games doesn't work at all...
 
@SimonAndréForsberg BCrypt also does that afaik
@SimonAndréForsberg You're actually doing what @Duga told you?!
 
@bazola Why? Because == can compare Object. Why would you have a special case because beginner won't use the much better equals() or compare() ?
 
@skiwi as I said, "for example". there are likely many hash algorithms that do this
@skiwi yes, I actually am. trying to, at least.
 
5:06 PM
@Marc-Andre i guess that is a good enough reason ;)
 
I get your point, but it's just really because we think == means something more than what it really is.
 
@SimonAndréForsberg Is the Cardshifter version in the js branch compileable, as far as you know? I couldn't figure out how to compile it in Eclipse last night, just wanting to make sure it's user error and that it is supposed to compile
 
@sᴉɔuɐɹɥԀ I think it is, yes.
 
I think you had the same problem as every user who start doing Java 8 in eclipse. There is a bug somewhere that you need an extention to fix.
Or there is something else
 
@Marc-Andre the compiler could also just warn that you are comparing strings that way so that you don't make the mistake
 
5:12 PM
@Marc-Andre I'll do some research tonight, and if I get any specific Cardshifter-specific error I'll let you guys know
 
@bazola But it's not, there is some case where you want exactly that. That's the real problem.
@sᴉɔuɐɹɥԀ good
 
@bazola or programmers could just get in the habit of always using .equals for comparison of strings.
For me it is natural now to use .equals
 
^^that
 
5:35 PM
@SimonAndréForsberg well pretty much every time i forget, i am stuck debugging :)
 
6:12 PM
@SimonAndréForsberg I'm about to make these changes (change apply: from array to object) so the values can be referred without using indexes. See any problem with doing this?
 
@sᴉɔuɐɹɥԀ I see redundancy there
 
@sᴉɔuɐɹɥԀ for the health, use "health: 1" in the values section. creature type can also go to values section. no attack can also go to values (or elsewhere), name it whatever you'd like.
 
So... OK. Would anything need to go into an apply then? My thinking was that values would just be arbitrary data, while apply would be calls to functions
 
@sᴉɔuɐɹɥԀ between those two alternatives, I think using as array would be better. they don't need to be referred with indexes, the array could just be looped over. (the whole apply concept in JS would be a bit wicked though, as the methods would have to return something, which I don't yet know what...)
 
So would it make more sense to just use arbitrary data for everything, for the time being? e.g., noAttack: true
 
6:19 PM
@sᴉɔuɐɹɥԀ hmm... actually, that might not be a bad idea after all. Then we'd just need to define what is value and what is function. However, calling functions on the entities can be done anyway, without putting them in apply: [ ... ]
@sᴉɔuɐɹɥԀ I think that makes sense, yes. Then some different functions can loop over the data and apply the values somehow...
the real 'problem' is about the effects though. Stuff like "Heal 1 HP at end of turn", "50% chance to draw an extra card at the start of your turn", "Take 1 damage at the start of your turn"....
 
You could also take a look at my issue183-json-effects-card-loader branch, but I don't have time for it these days :/
 
That was kind of my idea of calling functions by name within JSON. Once we iron out the code logic for the simpler effects, like noAttack it would lay down kind of a template to use for more complex functions, I think
Like applyHealthEOT(1) (or -1 or whatever) or applyDrawCardEOTChance(0.50)
 
@sᴉɔuɐɹɥԀ I don't think "noAttack" and "heal 1 HP at end of turn" are that similar....
@sᴉɔuɐɹɥԀ okay, I understand your thinking there... but it's... complicated. And things like applyDrawCardEOTChance is waaaaaaaaaay too specific of a function for my taste. It really consists of these parts: 1. At end of turn, do something. 2. A chance to do something. 3. A player should draw a card. 4. The player is you. (3 and 4 can be merged into one)
 
Effects of card could work something similar as cards.onSomething(function). You would define what the function is and can have access and the onSomething registered an event somewhere that need to execute it at the rigth which could depends on the onSomething(). (I've not read everything so I may be off in the discussion)
 
6:39 PM
@SimonAndréForsberg Good point on the "too specific". There's always the option of writing a small function in the JSON card that would call the 3-4 specific functions in combination. Think that would be more flexible?
{
  name: "Some Card",
  values: {
    health: 1,
    attack: 1
  },
  onEndOfTurn: EOTDrawCardChance function() {
    var chanceOfAction = 0.50;
    var targetOfAction = "self";
    EOTAction(draw, chanceOfAction, targetOfAction);
  }
}
^^ Something along those lines perhaps
 
@Marc-Andre In the Java code, events work just fine. Are you talking about registering event listeners in JS code, or executing the actual events?
 
@SimonAndréForsberg Yeah pushing event from the JS to the Java, for the modding part.
 
@Marc-Andre okay, then I know what you are talking about.
@sᴉɔuɐɹɥԀ Better, I think. Not entirely syntatically correct and also a bit messy... (what if the action would have more parameters? you are only passing 3 parameters to the "EOTAction" call there). I can show an idea I got quite recently...
 
I'm all ears :)
Hm. I wonder if you can overload functions in JS...
 
{
  name: "Some Card",
  values: {
    health: 1,
    attack: 1
  },
  onEndOfTurn: {
      chance: {
          probability: 0.5,
          action: {
              draw: { target: "self" }
          }
      }
  }
}
@sᴉɔuɐɹɥԀ @bazola @skiwi @Marc-Andre What do you think about such a format for "effects"? ^^
 
6:55 PM
That actually seems quite clear to me. Not sure how it would work on the back-end but I like it!
 
from a back-end perspective, I think it should be possible to accomplish. I have a few ideas for how it could be implemented on the back-end, and probably quite extensible as well... will probably bump into some problems along the way, but those should be solvable.
 
@SimonAndréForsberg I think I need to think about it. There are some things I don't like.... It limits what a modder can do.
 
Would all those different object references be passed and interpreted by the Java game server, or via JS?
 
@Marc-Andre not necessarily. A modder could add some hooks that can define the "chance" stuff, and it could also be done to work with POJSF (Pure Old JavaScript Functions) as well.
 
I really need to read the Cardshifter Code... damn
 
7:00 PM
{
  name: "Some Card",
  values: {
    health: 1,
    attack: 1
  },
  onEndOfTurn: {
      chance: {
          probability: 0.5,
          action: function(eventObject) {
              // write code here
              eventObject.doWhateverYouWant();
          }
      }
  }
}
@Marc-Andre I'm not sure that would help much. It might just cause more confusion. :)
 
@SimonAndréForsberg How would I have acces to the board, others cards etc ?
in eventObject.doWhateverYouWant();
 
@Marc-Andre Perhaps look at this concept? Looks like the JS logic and Java core would be tightly interconnected throughout the game event
 
@Marc-Andre through the eventObject. It might be like eventObject.getGame()...
 
Well then you more advance in the concept of modding that I think you were. Nice. Still need to read the code... I need to understand more things, so that my input would mean something.
 
@SimonAndréForsberg it looks like it could work
 
7:10 PM
@SimonAndréForsberg quick question... Would it be smarter for card values to use the same nomenclature as in the PhrancisGame.PhrancisResources enum? e.g., ATTACK_AVAILABLE: false vs. noAttack: true
 
@SimonAndréForsberg when you say "write code here", is it the nashborn thing that will convert that JS code to Java that ends up executing?
 
@bazola Nashorn doesn't convert into Java. It is a JavaScript engine written in Java. It will essentially call JS code from Java. But yes, it is the Nashorn thing.
 
ah. so there is more infrastructure needed to actually make the ECS work with that, correct?
as in everything ECS will have to be javascript?
 
@sᴉɔuɐɹɥԀ In the current PhrancisGame, ATTACK_AVAILABLE is the number of times a creature can attack. It's an integer value, not a true/false thing. It could probably be implemented as attackAvailable: false, but at the moment I'm afraid it has to be noAttack: true (or a rename to attackAllowed, in which case it can be set to false of course. As long as it doesn't collide with attackAvailable)
@bazola Not really. Just like JS code is called from Java, Java code can also be called from JS. So the ECS core can continue to be Java.
 
OK, so would it make sense then to combine, like ATTACK_AVAILABLE: 0 === noAttack: true ?
 
7:16 PM
@SimonAndréForsberg It would need to understand loads of different keys though
 
@sᴉɔuɐɹɥԀ It would make sense, yes. But there are currently other things interfering which doesn't make it possible at the moment. At the beginning of each turn, ATTACK_AVAILABLE is set to 1 for all creatures that can attack.
 
I'm not sure if what we want is really feasible, you can't capture all possible things to do in a game, on the other hand you can provide helpers
 
@skiwi That's not a problem.
@skiwi You can't capture everything, no. But you can provide helpers, and you can allow modders to make helpers themselves. And as a fallback, there is support for POJSF.
 
@SimonAndréForsberg OK. I'll stick with noAttack for now, seems to make the most sense with what you explained just now
 
onEndOfTurn: function(game, event) {
    game.withProbability(0.5).opponent().characters().pickRandom(1).dealDamage(8);
}
What are the opinions on this format though?
function getCards() {
    return [
        {
            data: {
                name: "Ragnaros",
                attack: 8,
                hitpoints: 8,
                keywords: ["cant_attack"]
            },
            events: {
                BattlefieldComponent: {
                    onMainPhaseEnd: function (game, event) {
                        game.opponent().characters().pickRandom(1).dealDamage(8);
                    }
                }
            },
            setupEntity: function (entity) {
The functions there are helper functions defined in Java
 
7:21 PM
@skiwi Personally, I like the JSON way more. I think defining objects like in your code there and providing functions to them is a bigger hussle. (and as a side-note, game.withProbability(0.5).opponent() is a rather weird call chaining I think...)
 
Everyone OK with this JSON format for the time being, for the basic card data?
function loadCardLibrary() {
    var cardLibrary = {
        entities: [
            {
                name: "Spareparts",
                flavor: "Cobbled together from whatever was lying around at the time.",
                values: {
                    creature: "Mech",
                    noAttack: true,
                    sickness: 0,
                    manaCost: 0,
                    health: 1,
                    attack: 0,
                    scrap: 3,
                }
            },
 
@sᴉɔuɐɹɥԀ Fine by me. Just one two things: There's nothing indicating that the enchantment is an enchantment. If you want, you can remove the values wrapper and put all the values inside there, outside instead.
 
There's probably tons of ways we could reprsent this
 
^^ that, except for the typo
 
I guess the values wrapper doesn't really do much at all. How would you suggest to represent enchantments/effects? In a wrapper? Or just different naming?
 
7:32 PM
@sᴉɔuɐɹɥԀ something like enchantment: true / type: "Enchantment" or similar.
 
Ah ok
{
    name: "Spareparts",
    flavor: "Cobbled together from whatever was lying around at the time.",
    creature: "Mech",
    manaCost: 0,
    health: 1,
    attack: 0,
    scrap: 3,
    effects: {
        sickness: 0,
        noAttack: true,
    }
},
^^ Does this look better?
 
@sᴉɔuɐɹɥԀ Not sure if the effects is really necessary there... I guess it's your new version of apply, huh?
 
Well, I don't know any more lol
Perhaps an attempt to make it look more "organized" but may be overcomplicating
 
@sᴉɔuɐɹɥԀ Anything can be implemented, I have no strong preference one way or the other. It might make things more organized, but it should be clear somehow which things to write inside the effects wrapper and what things to write outside.
 
Is it even some problem we can solve here?
Every time someone thinks up a design it can be countered by talking about feature X which another design could support
 
7:40 PM
I agree. Once we decide on a format, I plan on writing some documentation in the file (kind of like I did for the .cards file) explaining all that. I see an "effect" as something that modifies the cards' behavior rather than just simple arbitrary values
 
@skiwi What problem?
 
@SimonAndréForsberg How we want to add effects to our data files
 
I think this is probably the closest we've ever got to something realistically flexible that would not be terribly high-maintenance once the main pieces are in place
 
[[Cardshifter/Cardshifter](null)] build #819 for commit [607dcbbb](null/commit/607dcbbb7d22d6fdd29fd0ffde0c9b9b3a7e10f0) on branch [js-json-test](null/tree/js-json-test) passed
 
I think it would be unrealistic that anyone could ever come up with a system that could cover every possible effect, so that's when a modder could use a POJSF
(or at worst, request one from us)
 
7:45 PM
@skiwi Well, we need to decide on and implement something.
7
 
^ Please pin that!
 
@SimonAndréForsberg We've been deciding on this for ages already
 
Dec 30 '14 at 16:26, by Duga
Ping: Favor focus over features.
 
I think the only perfect solution we can come up is an AI that can interpret text as effects
Which is way way way way way way over our heads ^^
So we'll need to settle with something sub-optimal
 
@skiwi the thought has occurred to me :) A simple version of it could be implemented with regex and/or some parsing techniques. But I think it would not be worth it (and definitely a pain to maintain and extend).
@skiwi but yet we haven't fully implemented something fully. Many things are semi-complete though.
 
7:52 PM
The only situation we want to avoid is the HearthStone situation where things are coded again for every card
But with some method extraction that shouldn't be that difficult
 
Would this kind of demarcation be useful/make sense?
            creature: true,
            creature.type: "Mech",
 
Maybe not the only situation we want to avoid, but definitely a situation we definitely want to avoid.
 
(or creatureType: "Mech")
 
@sᴉɔuɐɹɥԀ ugh!
@sᴉɔuɐɹɥԀ yes!
 
7:53 PM
@SimonAndréForsberg My brain is tired, you're correct
 
\[[**Cardshifter/Cardshifter**](https://github.com/Cardshifter/Cardshifter)\] [**Phrancis**](https://github.com/Phrancis) pushed commit [**a74c88b8**](https://github.com/Cardshifter/Cardshifter/commit/a74c88b83457ac6729162109f38645bac99266df) to [**js-json-test**](https://github.com/Cardshifter/Cardshifter/tree/js-json-test): Update and rename card-data.js to CardData.js

Further modified/improved JSON data structure
 
Overall, I think the defining-cards-with-JS-and-JSON-like-structure-approach (anyone has a better name for it?) is among the best overall in terms of cleanliness, simplicity for modders to learn/use, extensibility, maintainability, and all other -ility's.
 
@SimonAndréForsberg We'll coin a name for it once we get it to work ;)
 
Right. Focus over naming!
 
So, now that we got the JSON format somewhat settled on, do you think we should first focus on getting the rest of PhrancisGame.java into JS, or try to implement some effects?
 
@sᴉɔuɐɹɥԀ I think we could think a bit more about how some effects would be coded, to create more examples for the format. Maybe also think about how modders could from JS extend the available 'keywords' and the functionality. But getting the rest of PG.java to JS is also important, of course.
 
8:20 PM
Hm... Realistically, would it be a monumental task to implement just the JSON/JS effects part so it could work with the current Java setup?
 
@sᴉɔuɐɹɥԀ depends on your definition of 'monumental task' :)
 
So the game server would pull CardData.js and say... CardEffects.js and leave the rest of PhrancisGame as it is
 
I could maybe get it done with about 8-12 hours of coding. (cannot guarantee the accuracy of that estimate)
 
Well that's pretty significant, which is why I'm asking :)
 
> Closing as duplicate. See #183 and #190 for reference
 
8:33 PM
@skiwi How far did you get in building a JSON card loader?
 
@SimonAndréForsberg ^^
 
@sᴉɔuɐɹɥԀ You think both creature: true and creatureType: "Mech" is needed? Doesn't creatureType imply that it also is a creature?
 
Well, yes it does indeed. Would you rather those combined together?
I had it as just creature: "Mech" which may be perfectly sufficient
 
8:50 PM
@sᴉɔuɐɹɥԀ pick what you feel is the best. implementation-wise, it doesn't matter much.
 
> Small change to make
[Cardshifter/Cardshifter] build #822 for commit e5ec127c from pull request #192 to branch js passed
\[[**Cardshifter/Cardshifter**](https://github.com/Cardshifter/Cardshifter)\] [**Phrancis**](https://github.com/Phrancis) pushed commit [**95bd6e9e**](https://github.com/Cardshifter/Cardshifter/commit/95bd6e9e63f91473db0284467e3138e5e126eeb4) to [**js-json-test**](https://github.com/Cardshifter/Cardshifter/tree/js-json-test): Update CardData.js

Merged creatureType and creature into one attribute
> Made changes, please review and merge @Zomis if you are good with it
 
@SimonAndréForsberg that time estimate is to have functions in javascript working in the current java game? or to have a way to define a mod in javascript that is the same structure as PhrancisGame?
i really like this game music youtube.com/watch?v=ZYayzrSj-L0
 
9:06 PM
@Phrancis My vard loader works, if you're interested then you can hop on that branch and look at the commits
 
[Cardshifter/Cardshifter] build #824 for commit 95f61d23 from pull request #192 to branch js passed
[Cardshifter/Cardshifter] build #825 for commit 95f61d23 from pull request #192 to branch js passed
 
@skiwi Wow that's way over my head.
 
@bazola just an estimate for only the cards being defined in the JS-format that @sᴉɔuɐɹɥԀ is working on. Not for the whole mod.
 
I'm going to start trying to define the cards using the JS you already wrote in test.js and then come up with logic for the existing effects and after that try a few new things
I'm guessing ECSResourceMap and ECSAttributeMap is what I would want to pass data to right?
 
9:24 PM
Putting this where it belongs......
I hear you've all been struggling with how to define cards, and their actions and what not.
Have you guys considered creating a DSL with something like ANLTR?
 
> This will be step 1 of converting game logic to JavaScript, to be able to pass values and attributes using JSON data to ECSResourceMap / ECSAttributeMap
 
9:40 PM
@RubberDuck What would a DSL potentially look like/imply?
 
It would look however you want it, because you define it.
 
Hmm. So you just... make up your own language... And the code (e.g., Java, JS) just understands what to do with it...?
 
Kind of. Yes. First you define a grammar for your language, and then what actions happen when certain identifiers are found.
I wouldn't rule it out. It depends on how complex you need special effect actions to be.
If it's relatively simple, you might be able to provide a much better UX, but DSLs are definitely hard to understand.
 
\[[**Cardshifter/Cardshifter**](https://github.com/Cardshifter/Cardshifter)\] [**Phrancis**](https://github.com/Phrancis) pushed commit [**6fe101c4**](https://github.com/Cardshifter/Cardshifter/commit/6fe101c4482462d46807dc905d76146a248972aa) to [**js-card-data-loader**](https://github.com/Cardshifter/Cardshifter/tree/js-card-data-loader): Create CardDataLoader.js

Related to #193
 
9:56 PM
@RubberDuck Well, we already have keywords in the JSON file. The idea was to define what to do with those keywords using JavaScript... It's not so much that it has to be really complex, but more that it has to be modular (e.g., "chain" multiple keyword/value pairs together to create a distinct effect)
 
Yeah. That sounds like a good use case for a domain language to me. Not for the faint of heart though.
 
You used that for your calculator right? Do you have a link?
 
Yeah. My calculator is a bit messed up, but give me a sec.
 
[Cardshifter/Cardshifter] Phrancis pushed commit c0e5528c to js-card-data-loader: Update CardDataLoader.js
 
@RubberDuck with my recent calculator knowledge, I can see how that could be beneficial indeed. Definitely worth checking out.
 
10:06 PM
TTGH. I really feel like we took a bit step today :)
 
@RubberDuck This is the ANTLR definition, right? github.com/ckuhn203/Antlr4Calculator/blob/master/…
 
That's the grammar @SimonAndréForsberg. The tool uses it to generate a lexer, parser, listener, and walker.
Then you would still need to inherit from and override the default "empty" behavior of either a listener or visitor.
 
perhaps I should learn the difference between a lexer and a parser...
 
A listener walks the entire tree root to leaf. A visitor let's you walk the tree however you like.
A lexer breaks a text stream into tokens defined in your grammar.
A parser interprets those tokens into "rules" or "contexts".
 
10:19 PM
@RubberDuck Imagine the 'statement' "Deal 8 damage to a random opponent", could you give an example of how the DSL of that could look with ANTLR ? (not the grammar, but example code that uses the grammar)
 
@RubberDuck Aha, so a lexer is like taking the string "4 + 7 * abs(-5)" and converting it into the tokens [4, +, 7, *, abs(, -5, )] and the parser is like taking those tokens and doing the Shunting-Yard algorithm on it to convert into Reverse Polish Notation, or an Abstract Syntax Tree?
 
Yea! That!
At your code level, you would see something like.
card.SpecialEffect.Perform()
Where Perform is the action that walks the tree.
 
@RubberDuck that's Java code though, right?
 
Yes.
 
10:25 PM
I'm more thinking right now about how the actual DSL code could be made.
 
Would it be possible to make a grammar to make the actual text "Deal 8 damage to a random opponent" work? (I assume yes here, actually)
 
Yes. That's exactly what a DSL is.
 
How extensible would you say that it is?
 
Should be very.
So... what tokens do we have there...
Action number health modifier target
 
10:29 PM
something like that
 
It would be some work (possibly a lot, I'm not sure), but you could definitely define a plain text language like that.
Given it's a card game, the rules have to be very precise to begin with.
 
A friend of mine came up with a significantly more complex card today...
 
Which is good, that lends itself to it.
lol
I'm sure.
 
the problem is that we want extensible/flexible rules....
 
10:31 PM
This would be.
Because you can define an action as something that is that entire statement.
Or, a particular keyword, like "Deal"
 
Would the same DSL be able to interpret (using some of the same words) "Deal 1 card to your hand at the end of this turn" ?
 
Recursively define it kind of like this.
expression :
    expression MULTIPLY expression #Multiplication
	| expression DIVIDE expression #Division
	| expression ADD expression #Addition
	| expression SUBTRACT expression #Subtraction
	| NUMBER #Number
	;
@sᴉɔuɐɹɥԀ Action number target target whenModifier
 
"Deal 1 damage to opponent.

Exile this card. At the beginning of your turn, you may pay x mana (where x is the amount of damage this card deals). If you do, increase the damage of this card by one and then deal that much damage to opponent. If you don't, deal x damage to opponent (where x is the amount of damage this card deals)."
 
So, I'm thinking words like to and at are special keywords that indicate direction.
 
taste that ^^ @RubberDuck
 
10:34 PM
@SimonAndréForsberg Whoa.
 
Action
Action. whenModifier action conditionalAction...
It follows the rules, it's just defined in the terms of several individual actions.
 
Hmm. Very interesting.
 
So.. a rough stab that certainly wouldn't work.
 
Sounds like a PITA to make, but that could have huge benefits in the long term...
2
 
10:39 PM
action:
    action target
    | action target modifer
    | target action (modifier)?
Yeah. Absolutely. On both counts.
I'm not pushing ya, because it's hard, but it is certainly one way to do it.
 
Could you show/link how Mug used DSL for RD, by chance?
 
TTGTB, I think at some point I should look into ANTLR more. I would like to discover more about its advantages and disadvantages, I think ANTLR-approach is something more for "Distant Future" (love that milestone) than 1.0 though.
 
^ Agreed we should at least take it into consideration
Thanks for the ideas @ducky :)
 
You guys are very welcome.
You'd have to ask @Mat'sMug about how it's done in RD though. I understand the grammar, but I don't quite grasp the listeners he wrote.
 
 
1 hour later…
11:45 PM
200_success vs. rolfl: 42 diff. Year: -663. Quarter: -506. Month: -506. Week: -312. Day: -13.
Loki Astari vs. Simon André Forsberg: 4114 diff. Year: -1652. Quarter: -353. Month: -353. Week: -50. Day: -5.
 

« first day (270 days earlier)      last day (3285 days later) »