Importing truths from JSON and exporting assets to WikiText.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2021-05-30 15:10:36 -05:00
parent f9c43d1db1
commit f1d39f2fc6
30 changed files with 165 additions and 0 deletions

View File

@ -0,0 +1,10 @@
converting
abilitiesAsWikiText
| output |
output := '' writeStream.
output
nextPutAll: '<ul style="list-style-type:none;">'; cr;
nextPutAll: (self abilitiesAsWikiTextFor: self currentAbilities);
nextPutAll: (self abilitiesAsWikiTextFor: self pendingAbilities);
nextPutAll: '</ul>'.
^ output contents

View File

@ -0,0 +1,12 @@
utilities
abilitiesAsWikiTextFor: abilitiesSubset
| aStream |
aStream := '' writeStream.
abilitiesSubset do: [:abi|
aStream
nextPutAll: ' <li> ⬢'; cr;
nextPutAll: ' ';
nextPutAll: abi; cr;
nextPutAll: ' </li>'; cr ].
^ aStream contents

View File

@ -0,0 +1,6 @@
converting
asTiddler
^ Tiddler new
title: self name;
tags: 'Starforged ' , self category;
text: self abilitiesAsWikiText

View File

@ -0,0 +1,3 @@
converting
currentAbilities
^ self abilities at: 'enabled'

View File

@ -0,0 +1,3 @@
converting
pendingAbilities
^ self abilities at: 'disabled'

View File

@ -0,0 +1,6 @@
printing
printOn: aStream
super printOn: aStream.
aStream
nextPutAll: ' ( ' , self name , ' | ';
nextPutAll: self category, ' )'

View File

View File

@ -0,0 +1,3 @@
accessing
character: optionsPhrase
character := optionsPhrase

View File

@ -0,0 +1,6 @@
accessing
fromDictionary: aDictionary
name := aDictionary at: 'Name'.
character := aDictionary at: 'Character'.
(aDictionary at: 'Truths') collect: [:truth | self options add: ((SfTruthOption new fromDictionary: truth))].
self refineOptionIntervals.

View File

@ -0,0 +1,3 @@
accessing
name: aString
name := aString

View File

@ -0,0 +1,3 @@
accessing
name
^ name

View File

@ -0,0 +1,3 @@
accessing
options: anOrderedCollection
options := anOrderedCollection

View File

@ -0,0 +1,3 @@
accessing
options
^ options ifNil: [ options := OrderedCollection new ]

View File

@ -0,0 +1,5 @@
accessing
printOn: aStream
super printOn: aStream.
aStream
nextPutAll: ' ( ', self name, ' ) '

View File

@ -0,0 +1,13 @@
accessing
refineOptionIntervals
| endings |
endings := self options collect: [:opt | opt chance ].
endings doWithIndex: [:end :i |
(i = 1)
ifTrue: [(self options at: i) chance: (1 to: end)]
ifFalse: [
(self options at: i) chance: (((endings at: (i-1)) + 1) to: (endings at: i))
]
].

View File

@ -0,0 +1,15 @@
{
"commentStamp" : "",
"super" : "Object",
"category" : "RoloLudo",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [
"options",
"name",
"character"
],
"name" : "SfTruth",
"type" : "normal"
}

View File

@ -0,0 +1,7 @@
accessing
emptyTruth
<gtExample>
| testSfTruth |
testSfTruth := SfTruth new.
self assert: testSfTruth isEmpty.
^ testSfTruth

View File

@ -0,0 +1,11 @@
{
"commentStamp" : "",
"super" : "Object",
"category" : "RoloLudo",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [ ],
"name" : "SfTruthExamples",
"type" : "normal"
}

View File

@ -0,0 +1,3 @@
accessing
brief: shortText
brief := shortText

View File

@ -0,0 +1,3 @@
accessing
brief
^ brief

View File

@ -0,0 +1,3 @@
accessing
chance: integerInterval
chance := integerInterval

View File

@ -0,0 +1,3 @@
accessing
chance
^ chance

View File

@ -0,0 +1,3 @@
accessing
details: longerText
details := longerText

View File

@ -0,0 +1,9 @@
accessing
fromDictionary: aDictionary
brief := aDictionary at: 'Description'.
details := aDictionary at: 'Details'.
questStarter := aDictionary at: 'Quest Starter'.
subtable := aDictionary at: 'Table' ifAbsent: [ subtable := nil ].
"Because of JSON original data this only puts the end of the chance interval.
This needs to be refined at 'container' object SfTruth."
chance := aDictionary at: 'Chance'

View File

@ -0,0 +1,6 @@
accessing
printOn: aStream
super printOn: aStream.
aStream
nextPutAll: ' ( ', self brief, ' )'

View File

@ -0,0 +1,3 @@
accessing
subtable: aDictionary
subtable := aDictionary

View File

@ -0,0 +1,3 @@
accessing
subtable
^ subtable ifNil: [ subtable := OrderedDictionary new]

View File

@ -0,0 +1,17 @@
{
"commentStamp" : "",
"super" : "Object",
"category" : "RoloLudo",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [
"brief",
"details",
"subtable",
"questStarter",
"chance"
],
"name" : "SfTruthOption",
"type" : "normal"
}