User:Relyk/SDA

From Guild Wars 2 Wiki
Jump to navigationJump to search

Overview[edit]

We store each possible item you can receive from a container in a subobject. The subobjects contains all the information we need for the rest of the table. For the row template, it'll create a similar subobject except we use some logic. We create an entry subobject that contains a Has total trials property and Gives total item properties, where the Gives total item contains the explicit name of the item and numeric total. It should look like:

{{template
| <item> = <number>
| <item> = <number>
| <item> = <number>
}}

And code the template to ask each subobject in the header if the Gives item property exists as a parameter and add it to the Gives total item property as a record.

{{#subobject:entry<x>
|?Has total trials={{{trials}}}
{{#arraymap: {{#ask:[[Has drop rate page:<page>]]|mainlabel=-|?Gives item|format=list}}|,|@@@| <!-- Query results in comma-separated list of items -->
               {{!}}{{#if: {{{@@@|}}}|Gives total item=@@@;{{{@@@}}}}}
             |\n}}
}}

Although I think setting multiple Record values in a subobject doesn't work yet (I wish it did). Once we have all our entries, we can use Sum format to calculate the total trials and total number of each item.

Example[edit]

{{User:Relyk/SDAH | showLabels = true
| Glob of Ectoplasm
| Orichalcum Imbued Inscription | icon2 = Knight's Orichalcum Imbued Inscription.png
| Large Bone                    | label3 = Not an Ecto
| Large Fang                    | icon4 = Knight's Orichalcum Imbued Inscription.png | label4 = Not an Ecto
| Large Scale
| Mithril Ore
}}
{{User:Relyk/SDAR | total = 10 | ~~~
| Glob of Ectoplasm             = 2
| Orichalcum Imbued Inscription = 4
}}
{{User:Relyk/SDAR | total = 20 | ~~~
| Large Bone                    = 8
| Large Fang                    = 8
| Large Scale                   = 12
| Mithril Ore                   = 5
}}
{{User:Relyk/SDAR| total = 30 | ~~~
| Glob of Ectoplasm             = 2
| Orichalcum Imbued Inscription = 4
| Large Bone                    = 8
| Large Fang                    = 8
| Large Scale                   = 12
| Mithril Ore                   = 5
}}
{{User:Relyk/SDAF}}

== Query test ==
=== Header subobject ===
{{#ask:[[Has drop rate page::Example]]|mainlabel=-|?Has column position|?Gives item|?Has game icon|?Has icon size|?Has label|sort=Has column position}}

== Entry subobjects ==
{{#ask:[[Has drop rate row page::Example]]|?Has total trials|?Gives total item}}

== Total amounts ==
{{#arraymap:{{#ask:[[Has drop rate page::Example]]|mainlabel=-|?Gives item =|format=list|link=none|sort=Has column position}}|,|@@@|* [[@@@]]: {{#var:@@@}}|\n}}
== Count ==
* Number of columns: {{#ask:[[Has drop rate page::Example]]|format=count}}
* Total number of trials: {{#ask:[[Has drop rate row page::Example]][[Has total trials::+]]|?Has total trials|format=sum|default=no}}