Hi community !
Here’s a tiddlywiki, that helps choose which board game the group would like to play. All player may not all be available, time may be a limit, etc. By selecting criteria, available game shows up. That’s the purpose.
The tiddlywiki can be interesting as :
-
It use the Boardgamegeek .com - API. The player collection is downloaded, and then corresponding game statistics are downloaded
-
It use the [XML plugin]. API return XML files. Games XML are converted to actual fields (to save space, and easier filter), collections are kept as xml.
-
Some example of filtered table through list
I feel there is quite some space for improvements! So if you have tips, these would be very welcome.
The following is both reflexion along the way, and issue I found
A) API
This is my first try with API, so I was struggling . Zotero’s example from tiddlywiki .com was very inspiring.
What I found is that the Boardgamegeek API is slow and some time asynchronous. For example when requesting a player connection, the first query doesn’t return the result but a message that say it will be ready. So user needs to re-send the request.
When requesting games, query needs to be send one by one.
Code is very similar to Zotero’s example, if you want example they are the “$:/_Macro_API_Game*” tiddlers
In tiddlywiki, I am not sure we have a wait function. So I am not sure how to tackle this.
So you have to click for each game in my implementation, which turns tedious.
B) XML plugin
The plugin is really good, and you can achieve a lot , but operators are limited. You need to be creative with filters for example this is what it looked like to filter on the different criteria:
Needs to define variable and a macro to apply the filter in the xpath widget (tiddler: $:/_Game list xml) (Note: I added spaces as else the code is not fully rendered)
\define queryn() /items/item[@type="boardgame"]/minplaytime[@value>=$(tmin)$]/../maxplaytime[@value<=$(tmax)$]/../maxplayers[@value>=$(Nb)$]/../minplayers[@value<=$(Nb)$]/../statistics/ratings/average[@value>=$(rat)$]/../averageweight[@value>=$(cmp)$]/../../../name[@type="primary"]
<$list filter="[field:type[text/xml]tag[Game]tag{Finder!!player1}] [field:type[text/xml]tag[Game]tag{Finder!!player2}] [field:type[text/xml]tag[Game]tag{Finder!!player3}] [field:type[text/xml]tag[Game]tag{Finder!!player4}]
[field:type[text/xml]tag[Game]tag{Finder!!player5}]
[field:type[text/xml]tag[Game]tag{Finder!!player6}] " >
<$list variable="Nb" filter={{Finder!!Nb}}>
<$list variable="tmin" filter={{Finder!!tempsmin}}>
<$list variable="tmax" filter={{Finder!!time}}>
<$list variable="cmp" filter={{Finder!!complexity}}>
<$list variable="rat" filter={{Finder!!rating}}>
<$xpath for-each=<<queryn>> >
I felt limited at one point, as getting the criteria and calculation seemed more complex.
So I converted all game XML into native tiddler format using tiddler “Mass Conver”. It saved quite some place as the XML stored many information that where not used
<$button>
<$list filter="[tag[Game]]">
<$xpath variable="id" value-of="items/item/@id">
<$xpath variable="thing" value-of="items/item/@type">
[...]
<$action-setfield $field="id" $value=<<id>> />
<$action-setfield $field="thing" $value=<<thing>> />
[...]
</$xpath></$xpath></$xpath></$xpath></$xpath></$xpath></$xpath></$xpath></$xpath>
</$list>
Transform </$button>
I should transform the data at import from the API, I may try this in a next session
C) Sorting on calculation results
One bit I don’t know how to do is the following one
Each game will have fields dedicated to vote from players, say when preparing for the game weekend
the vote are in the fields: antoine, dan, etc
I get the total with the following formula. (tiddler: $:/_Display_Default)
<$list filter="=[all[current]get[antoine]]=[all[current]get[dan]]=[all[current]get[francois]]=[all[current]get[jerome]]=[all[current]get[benoit]]+[sum[]]" />
is there a way to sort using this calculation ?
today the sort is in the filter looking the field to sort with.
[!sort:stric{Finder!!sort}]
Thanks for reading
I hope this was interesting.