Modularizing the code.
This commit is contained in:
parent
40ab1d0000
commit
7c8c897d60
@ -1,16 +1,8 @@
|
|||||||
accessing
|
accessing
|
||||||
fromDictionary: aDictionary
|
fromDictionary: aDictionary
|
||||||
| optionsTable |
|
|
||||||
name := aDictionary at: 'Name' ifAbsent: [ name := aDictionary at: 'Display name' ].
|
name := aDictionary
|
||||||
|
at: 'Name'
|
||||||
|
ifAbsent: [ name := aDictionary at: 'Display name' ].
|
||||||
intro := aDictionary at: 'Description'.
|
intro := aDictionary at: 'Description'.
|
||||||
optionsTable := aDictionary at: 'Table'.
|
self optionsFromDictionary: (aDictionary at: 'Table')
|
||||||
optionsTable doWithIndex: [:opt :i | | key value prevKey |
|
|
||||||
(i = 1)
|
|
||||||
ifTrue: [key := 1 to: (opt at: 'Chance') asInteger]
|
|
||||||
ifFalse: [
|
|
||||||
prevKey := ((optionsTable at: (i-1)) at: 'Chance').
|
|
||||||
key := (prevKey asInteger + 1) to: (opt at: 'Chance') asInteger.
|
|
||||||
].
|
|
||||||
value := (opt at: 'Description') capitalized.
|
|
||||||
self options at: key put: value .
|
|
||||||
].
|
|
@ -0,0 +1,12 @@
|
|||||||
|
accessing
|
||||||
|
optionsFromDictionary: aDictionary
|
||||||
|
|
||||||
|
aDictionary doWithIndex: [ :opt :i |
|
||||||
|
| key value prevKey |
|
||||||
|
i = 1
|
||||||
|
ifTrue: [ key := 1 to: (opt at: 'Chance') asInteger ]
|
||||||
|
ifFalse: [
|
||||||
|
prevKey := (aDictionary at: i - 1) at: 'Chance'.
|
||||||
|
key := prevKey asInteger + 1 to: (opt at: 'Chance') asInteger ].
|
||||||
|
value := (opt at: 'Description') capitalized.
|
||||||
|
self options at: key put: value ]
|
Loading…
Reference in New Issue
Block a user