From 67be1173673ebd598b182ac44c0ee5236c0e6023 Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Sun, 5 Dec 2021 13:58:22 -0500 Subject: [PATCH] Oracles importation improved. --- .../SfOracle.class/instance/asTiddler.st | 2 +- .../instance/optionColumnNames.st | 4 ++++ .../instance/optionsFromDictionary..st | 2 +- .../instance/optionsWikiTextRow..st | 20 +++++++++++++++++++ .../instance/optionsWikiTextTable.st | 3 ++- 5 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 RoloLudo.package/SfOracle.class/instance/optionColumnNames.st create mode 100644 RoloLudo.package/SfOracle.class/instance/optionsWikiTextRow..st diff --git a/RoloLudo.package/SfOracle.class/instance/asTiddler.st b/RoloLudo.package/SfOracle.class/instance/asTiddler.st index 2bf22eb..52bf7ed 100644 --- a/RoloLudo.package/SfOracle.class/instance/asTiddler.st +++ b/RoloLudo.package/SfOracle.class/instance/asTiddler.st @@ -4,4 +4,4 @@ asTiddler title: self name; tags: 'Starforged'; text: self introText, String cr, String cr, self optionsWikiTextTable; - created: DateAndTime now asString. \ No newline at end of file + created: Tiddler nowLocal. \ No newline at end of file diff --git a/RoloLudo.package/SfOracle.class/instance/optionColumnNames.st b/RoloLudo.package/SfOracle.class/instance/optionColumnNames.st new file mode 100644 index 0000000..14dc03b --- /dev/null +++ b/RoloLudo.package/SfOracle.class/instance/optionColumnNames.st @@ -0,0 +1,4 @@ +accessing +optionColumnNames + self options ifEmpty: [ ^ nil ]. + ^ self options associations first value keys reversed \ No newline at end of file diff --git a/RoloLudo.package/SfOracle.class/instance/optionsFromDictionary..st b/RoloLudo.package/SfOracle.class/instance/optionsFromDictionary..st index d048d70..1a502d4 100644 --- a/RoloLudo.package/SfOracle.class/instance/optionsFromDictionary..st +++ b/RoloLudo.package/SfOracle.class/instance/optionsFromDictionary..st @@ -8,5 +8,5 @@ optionsFromDictionary: aDictionary ifFalse: [ prevKey := (aDictionary at: i - 1) at: 'Chance'. key := prevKey asInteger + 1 to: (opt at: 'Chance') asInteger ]. - value := (opt at: 'Description') capitalized. + value := (opt copy removeKey: 'Chance'; yourself). self options at: key put: value ] \ No newline at end of file diff --git a/RoloLudo.package/SfOracle.class/instance/optionsWikiTextRow..st b/RoloLudo.package/SfOracle.class/instance/optionsWikiTextRow..st new file mode 100644 index 0000000..55fed40 --- /dev/null +++ b/RoloLudo.package/SfOracle.class/instance/optionsWikiTextRow..st @@ -0,0 +1,20 @@ +accessing +optionsWikiTextRow: value + | output | + value class = String ifTrue: [ ^ value , '|' ]. + output := '' writeStream. + output + nextPutAll: (value at: 'Description'), ' |'. + value keys size > 1 ifTrue: [ | remaining cell | + remaining := value copy removeKey: 'Description'; yourself. + cell := remaining values. + cell class = Array ifTrue: [ + cell first doWithIndex: [:each :i | + output nextPutAll: '[[', each asString,']] '. + (i % 2 = 1) ifTrue: [output nextPutAll: '; ' ] + ] + ]. + output nextPutAll: '|'. + ]. + ^ output contents + \ No newline at end of file diff --git a/RoloLudo.package/SfOracle.class/instance/optionsWikiTextTable.st b/RoloLudo.package/SfOracle.class/instance/optionsWikiTextTable.st index 7b2deaf..773cda6 100644 --- a/RoloLudo.package/SfOracle.class/instance/optionsWikiTextTable.st +++ b/RoloLudo.package/SfOracle.class/instance/optionsWikiTextTable.st @@ -2,10 +2,11 @@ accessing optionsWikiTextTable | output | output := '' writeStream. + output nextPutAll: String crlf. self options keysAndValuesDo: [:k :v | | keyString | keyString := ((k size = 1) ifTrue: [ k first asString ] ifFalse: [ k first asString, ' - ', k last asString ]). output nextPutAll: '| ',keyString , ' |'; - nextPutAll: v, ' |'; cr + nextPutAll: (self optionsWikiTextRow: v); cr ]. ^ output contents \ No newline at end of file