Browse forums 
Ankama Trackers

[String ¿logical template?] How do I interpret these operators in translations?

By 0M1N0U5 - MEMBER - April 21, 2020, 22:22:10

Hello, I am working on a java text parser. I've seen other peer projects:

But I have seen that it does not support complex parsing of expressions. All shared projects are being published in the thread:

Currently, I have an automaton that consumes text input correctly and is capable of extracting constants, logical expressions, groups as well as using them recursively.

The text I am talking about is the one we find in the translations of, for example, "actions.json"

An example would be:

[el6] Heal: [# 1] {[+ 3]?% of HP:} {[+ 3]? {[1 = 3]? max: {[2 = 3]? current: {[3 = 3]? lost: {[4 = 3]? max: {[5 = 3]? current: {[6 = 3]? lost:}}}}}}:} {[+ 3]? {[4 <3]? of the caster: {[7 <3]? of the target:}}:} {[- 2]? {[0 = 2]? [ecnbi] [ecnbr]:}:} {[+ 2]? {[2 = 2]? [ecnbi]:}:} {[+ 2]? {[1 = 2]? [ecnbr]:}:}

As you can see, the string is based on logical expressions that depend on some input parameters, which from what I have analyzed and have also been able to observe in the project of the aforementioned partner, consumes a list or array of numbers. For example:

"params": [2.4, 0.2316]

I have found numerous operators and I have doubts in some of them because the time has come to implement the interpreter. I have suspicions about what each of them does but I put the list in case you can help me or if Ankama can help us.

The list of logical conditionals is as follows.

[+3] Example written above
[# 1] Health Point {[= 1] ?: s} ---> [= 1]
[# 1]% Harvesting Quantity {[~ 2]? in [# 2]:} ---> [~ 2]
[el0] Heal (Health Steal): [# 1] {[- 2]? {[0 = 2]? [ecnbi]:}:} ----> [0 = 2], [-2]
- [# 1] PA {[~ 2]? {[0> 2]? ([# 2]%):}:} ----> [0> 2]

In a list:


I know you are talking about parameters and comparing them to each other but I don't know exactly what the parameter [~2] means for example. Does it mean that it expects approximately 2 parameters? Dont have much sense. [0>2] means that parameter 0 is greater than parameter 2?

I also know that there is another management that I have to do like the substitution of constants (like [el0] and calculated properties (like [#1]). For this part I have it controlled but I still don't know what things like [ecnbi] mean or maybe [ecnbr]. For now I have the focus on how to interpret these logical conditions.

Hopefully someone can help me.

A greeting.

NOTE: Sorry if I have bad English. Any complaints to the google translator <3.

A greeting.

0 0
Reactions 8
Score : 674

~ is for matching the number of parameters. It's mainly used for things like having one localization string and effect for 1-3 random elements. It's expressed as a list of possible matches of which you need to find the correct one, then put the other parameters into the match.

# (as you've already concluded) is for any computed values from parameters

=, < and > are used as condition matching a number vs a parameter. I found this one to be more obtuse than the others, as it's intermixing using a raw numeric value as both a value to match against and a parameter on either side of the comparison operator.


0 0
Score : 98

I answered you in the thread to make it more enjoyable to read. Thank you!

0 0
Score : 98

First of all, thank you for your answer.

Yeah, you're right about everything you say. I've been doing some more research on the part of the >, <, = operators and I've come up with the following idea. What if when you're talking about a logical operator [>2] you're referring to the last parameter calculated?

For example:

    "definition": {
      "id": 1068,
      "effect": "Gain : Maîtrise Élémentaire dans un nombre variable d'éléments"
    "description": {
      "fr": "{[~3]?[#1] Maîtrise [#3]:[#1] Maîtrise sur [#2] élément{[>2]?s:} aléatoire{[>2]?s:}}",
      "en": "{[~3]?[#1] Mastery [#3]:[#1] Mastery of [#2] random{[=2]?:} element{[=2]?:s}}",
      "es": "{[~3]?[#1] Dominio[#3]:[#1] Dominio de [#2] elemento{[>2]?s:} aleatorio{[>2]?s:}}",
      "pt": "{[~3]?[#1] Domínio[#3]:[#1] Domínio sobre [#2] elemento{[>2]?s:} aleatório{[>2]?s:}}"
  }   }

For the parameters:

          "effect": {
            "definition": {
              "id": 201550,
              "actionId": 1068,
              "areaShape": 32767,
              "areaSize": [],
              "params": [

We can interpret [~3] as: Do you have at least 3 parameters? Taking into account that the parameters are distributed in such a way that in the first position goes the fixed amount and in the next one the progress per level of it, to calculate this would be

3 * 2 < params (size) -> 6 < 4 -> False

I will choose the Spanish option because it has a differentiator "s" later.

"es": "{[~3]?[#1] Dominio[#3]:[#1] Dominio de [#2] elemento{[>2]?s:} aleatorio{[>2]?s:}}",

By solving the first logical condition we would have

"es": "{[#1] Dominio de [#2] elemento{[>2]?s:} aleatorio{[>2]?s:}",

We would calculate the #1: param[0] + param[1] * itemlevel = param[0] + param[1] * 0 = param[0] = 75.0

I think here is the key, this value must be stacked to be able to solve the operators that don't have a digit at the beginning, like [>2].

We calculate #2 which results in 3.

We arrive at the condition [>2], as it doesn't have a number on the left, I have the hypothesis that we should look at the last stacked value, in this case 3.

3>2 -> True.

The same for the next logical operator, leaving the expression:

"75 Dominio de 3 elementos aleatorios."

Still, I am left wondering what [+2] means, for example, especially when I find it at the beginning of the text.

What do you think about the theory?

PS: It would be so simple if Ankama said how it works hahaha.

I'd like to know what the operators do. An example of this is [+3] or [-2] as a logical expression:

[el0] Damage: [#1]{[+3]?% of HP:}
[el0] Heal: [#1]{[-2]?{[0=2]? [ecnbi]:}:}

With this I think I would be able to complete the implementation.

0 0
Score : 3

[Reserving comment to edit later]

First impresion: What are you making is a lenguage interpreter. Soon you will make you own programming lenguage. Try to make it on C to make it even more faster.

1 -1
Score : 98


0 0
Score : 98

Yes, that's right. I already made using Flex a compiler for a subset of C (could we call it mini-c? hahaha).

For now I'm doing this one in java. I looked for libraries that would support me to make an interpreter but everything was more complicated than what I really wanted to do.I finally built my own state machine that produces signals when a transition is taken and these signals are interpreted to carry out actions in the stack (push and pop, you know).

I have everything programmed in the absence of the evaluation of logical expressions.

1) Parse the text
2) Generate a structure separating each component: text, calculated parameters, logical expressions, if(true) expression, if(false) expression.
3) Solve the generated structure automatically using the given parameters, performing the evaluation on the fly and discarding the useless paths.

As I mentioned above, I need to evaluate the logical expressions for this to work, so I am investigating what each operator means:

1: [+3]
1: [+3]
2: [1=3]
1: [+3]
2: [4<3]
1: [-2]
2: [0=2]
1: [+2]
2: [2=2]
1: [+2]
2: [1=2]

The numbers on the left only represent a classification that I carry internally, do not take them into account for now.

I have an idea about more or less what they are all about but I haven't been able to confirm if my suspicions about the + and - operators are correct. I'm going to finish implementing the rest of the operators and start doing hard tests (like parsing all the items returned by the API for a certain language for example)

By the way, I don't know who voted no on your commentary. I'd like that person to state the reason for their vote.

I'm sure together we'll go far.


So far it seems to be working. I have implemented what I discussed above and what another colleague also proposed:

Operators +, -, ~ to check the number of parameters.
<, >, = with two behaviours:

If it comes with a parameter on the left [2=3], I use it as a constant compared to the parameter on the right using the operator that is naturally between both.

Every time I solve a calculated parameter, it is stacked so I can use it later.

If it comes without a number on the left, then I read the value from the top of the stack and use it as a value and in the same way as mentioned above.

Now I'll move on to the testing phase but it will be tomorrow. Now I'm going to play that I've earned it hahaha.


Okay, it seems to be working. This is a sub-module of another larger project that I will publish when it is completed or reaches a stable point.

Thank you all for your help and if anyone needs anything, feel free to send a message.

Best regards and once again, thank you.

You can close the subject.

0 0
Score : 5381
Hi, people!
I've just posted some kind of guide to decode these "logical templates":

A big thanks to 0M1N0U5 for sharing what they discovered, since it helped me a lot to understand the codification behind it.
In the article there's also a link for the code I've used to parse the description (using javascript) and a test file for it.
Feel free to use on your own projects and/or to tweak it.
0 0
Score : 30


You have almost everything good except for the stacked value. It's simpler than that. If there is no value on the left, the constant is simply 1 (for >, <, =). Example:

"fr": "élément{[>2]?s:} aléatoire{[>2]?s:}"
"en": "random{[=2]?:} element{[=2]?:s}"
"es": "elemento{[>2]?s:} aleatorio{[>2]?s:}"

English version doesn't have any issue. The constant is just 1.
[#2] > 1 ?  True : 's'  | False : ''
[#2] = 1 ? True : '' | False : 's'

[2>3] = [#3] > 2
[>3] = [#3] > 1
[2<3] = [#3] < 2
[<3] = [#3] < 1
[+3] = [#3] >= 0
[-3] = [#3] < 0
[~3] = params.length >= 3 * 2

Ugly script just for logic :
ecnbi and ecnbr are not necessary for items but if you want it :
Don't forget to check the description of The Bloodthirsty (
"en": [$1ef] and steals [#1]%
; )

0 0
Respond to this thread