diff --git a/public/main.js b/public/main.js index a695e48c73056addaf39903829c6d8e217cb4348..3e272611a35ebacc8b2bdcb6a445d28183644e90 100644 --- a/public/main.js +++ b/public/main.js @@ -6978,15 +6978,40 @@ var $author$project$Main$update = F2( model, $elm$browser$Browser$Navigation$load(href)); } - default: + case 'UrlChanged': var url = msg.a; return _Utils_Tuple2( _Utils_update( model, {url: url}), $elm$core$Platform$Cmd$none); + default: + return _Utils_Tuple2( + _Utils_update( + model, + {character: $author$project$Character$new}), + $elm$core$Platform$Cmd$none); } }); +var $elm$html$Html$div = _VirtualDom_node('div'); +var $author$project$Main$CreateCharacter = {$: 'CreateCharacter'}; +var $author$project$Main$ViewCharacter = {$: 'ViewCharacter'}; +var $author$project$Main$getMode = function (url) { + var _v0 = url.fragment; + if (_v0.$ === 'Just') { + var fragment = _v0.a; + switch (fragment) { + case 'view': + return $author$project$Main$ViewCharacter; + case 'create': + return $author$project$Main$CreateCharacter; + default: + return $author$project$Main$CreateCharacter; + } + } else { + return $author$project$Main$CreateCharacter; + } +}; var $author$project$Main$Name = {$: 'Name'}; var $elm$json$Json$Encode$string = _Json_wrap; var $elm$html$Html$Attributes$stringProperty = F2( @@ -6997,7 +7022,6 @@ var $elm$html$Html$Attributes$stringProperty = F2( $elm$json$Json$Encode$string(string)); }); var $elm$html$Html$Attributes$class = $elm$html$Html$Attributes$stringProperty('className'); -var $elm$html$Html$div = _VirtualDom_node('div'); var $elm$html$Html$p = _VirtualDom_node('p'); var $elm$virtual_dom$VirtualDom$text = _VirtualDom_text; var $elm$html$Html$text = $elm$virtual_dom$VirtualDom$text; @@ -7169,8 +7193,8 @@ var $author$project$Main$valueOrReset = F2( function (dots, value) { return _Utils_eq(dots.value, value) ? dots.min : value; }); -var $author$project$Main$viewDot = F6( - function (stat, size, strokeWidth, isFilled, id, position) { +var $author$project$Main$viewDot = F7( + function (allowChange, stat, size, strokeWidth, isFilled, id, position) { return A2( $elm$svg$Svg$polygon, _List_fromArray( @@ -7212,51 +7236,51 @@ var $author$project$Main$viewDot = F6( $elm$core$String$fromFloat(strokeWidth)), $elm$html$Html$Events$onClick( $author$project$Main$ChangeStat( - _Utils_update( + allowChange ? _Utils_update( stat, { dots: A2( $author$project$BoundedInt$changeTo, stat.dots, A2($author$project$Main$valueOrReset, stat.dots, id + 1)) - }))) + }) : stat)) ]), _List_Nil); }); var $elm$svg$Svg$Attributes$width = _VirtualDom_attribute('width'); -var $author$project$Main$viewDots = function (stat) { - var rangeList = A2($elm$core$List$range, 0, stat.dots.max - 1); - var isFilledList = A2( - $elm$core$List$map, - $elm$core$Basics$gt(stat.dots.value), - rangeList); - var dotSize = 12 * 2; - var dotOutline = 0.05 * dotSize; - var svgOutlineMargin = $elm$core$Basics$sqrt( - 2 * A2($elm$core$Basics$pow, dotOutline, 2)) / 2; - var dotGap = dotSize / 2; - var marginalIncrease = (dotSize + dotGap) / 2; - return A2( - $elm$svg$Svg$svg, - _List_fromArray( - [ - $elm$svg$Svg$Attributes$width( - $elm$core$String$fromFloat((dotSize + (marginalIncrease * (stat.dots.max - 1))) + (2 * svgOutlineMargin))), - $elm$svg$Svg$Attributes$height( - $elm$core$String$fromFloat((dotSize + marginalIncrease) + (2 * svgOutlineMargin))) - ]), - A4( - $elm$core$List$map3, - A3($author$project$Main$viewDot, stat, dotSize, dotOutline), - isFilledList, - rangeList, - A2( - $elm$core$List$map, - A3($author$project$Main$toDotPosition, dotSize, dotGap, svgOutlineMargin), - rangeList))); -}; -var $author$project$Main$viewStatInGrid = F3( - function (cols, totalCount, indexedStat) { +var $author$project$Main$viewDots = F3( + function (allowChange, dotSize, stat) { + var rangeList = A2($elm$core$List$range, 0, stat.dots.max - 1); + var isFilledList = A2( + $elm$core$List$map, + $elm$core$Basics$gt(stat.dots.value), + rangeList); + var dotOutline = 0.05 * dotSize; + var svgOutlineMargin = $elm$core$Basics$sqrt( + 2 * A2($elm$core$Basics$pow, dotOutline, 2)) / 2; + var dotGap = dotSize / 2; + var marginalIncrease = (dotSize + dotGap) / 2; + return A2( + $elm$svg$Svg$svg, + _List_fromArray( + [ + $elm$svg$Svg$Attributes$width( + $elm$core$String$fromFloat((dotSize + (marginalIncrease * (stat.dots.max - 1))) + (2 * svgOutlineMargin))), + $elm$svg$Svg$Attributes$height( + $elm$core$String$fromFloat((dotSize + marginalIncrease) + (2 * svgOutlineMargin))) + ]), + A4( + $elm$core$List$map3, + A4($author$project$Main$viewDot, allowChange, stat, dotSize, dotOutline), + isFilledList, + rangeList, + A2( + $elm$core$List$map, + A3($author$project$Main$toDotPosition, dotSize, dotGap, svgOutlineMargin), + rangeList))); + }); +var $author$project$Main$viewStatInGrid = F4( + function (dotSize, cols, totalCount, indexedStat) { var stat = indexedStat.b; var offset = totalCount % cols; var index = indexedStat.a; @@ -7296,13 +7320,13 @@ var $author$project$Main$viewStatInGrid = F3( ]), _List_fromArray( [ - $author$project$Main$viewDots(stat) + A3($author$project$Main$viewDots, true, dotSize, stat) ])) ])) ])); }); -var $author$project$Main$viewAbilityCol = F4( - function (oCat, name, category, abilities) { +var $author$project$Main$viewAbilityCol = F5( + function (oCat, name, category, abilities, dotSize) { var index = A2($author$project$OrderedCategories$indexOf, oCat.order, category); var categoryAbilities = A2($author$project$Stats$abilitiesOfCategoryInList, category, abilities); var basePoints = A2($author$project$OrderedCategories$categoryValue, oCat, category); @@ -7414,16 +7438,17 @@ var $author$project$Main$viewAbilityCol = F4( ]), A2( $elm$core$List$map, - A2( + A3( $author$project$Main$viewStatInGrid, + dotSize, 3, $elm$core$List$length(categoryAbilities)), A2($elm$core$List$indexedMap, $elm$core$Tuple$pair, categoryAbilities))) ])) ])); }); -var $author$project$Main$viewAbilities = F2( - function (oCat, abilities) { +var $author$project$Main$viewAbilities = F3( + function (oCat, abilities, dotSize) { return A2( $elm$html$Html$div, _List_fromArray( @@ -7447,9 +7472,9 @@ var $author$project$Main$viewAbilities = F2( ]), _List_fromArray( [ - A4($author$project$Main$viewAbilityCol, oCat, 'Talents', $author$project$Stats$Talent, abilities), - A4($author$project$Main$viewAbilityCol, oCat, 'Skills', $author$project$Stats$Skill, abilities), - A4($author$project$Main$viewAbilityCol, oCat, 'Knowledges', $author$project$Stats$Knowledge, abilities) + A5($author$project$Main$viewAbilityCol, oCat, 'Talents', $author$project$Stats$Talent, abilities, dotSize), + A5($author$project$Main$viewAbilityCol, oCat, 'Skills', $author$project$Stats$Skill, abilities, dotSize), + A5($author$project$Main$viewAbilityCol, oCat, 'Knowledges', $author$project$Stats$Knowledge, abilities, dotSize) ])) ])); }); @@ -7466,39 +7491,40 @@ var $author$project$Stats$attributesOfCategoryInList = F2( $author$project$Stats$isAttributeOfCategory(category), stats); }); -var $author$project$Main$viewStat = function (stat) { - return A2( - $elm$html$Html$div, - _List_fromArray( - [ - $elm$html$Html$Attributes$class('notification') - ]), - _List_fromArray( - [ - A2( - $elm$html$Html$p, - _List_fromArray( - [ - $elm$html$Html$Attributes$class('block') - ]), - _List_fromArray( - [ - $elm$html$Html$text(stat.name) - ])), - A2( - $elm$html$Html$p, - _List_fromArray( - [ - $elm$html$Html$Attributes$class('block') - ]), - _List_fromArray( - [ - $author$project$Main$viewDots(stat) - ])) - ])); -}; -var $author$project$Main$viewAttributeCol = F4( - function (oCat, name, category, attributes) { +var $author$project$Main$viewStat = F2( + function (dotSize, stat) { + return A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('notification') + ]), + _List_fromArray( + [ + A2( + $elm$html$Html$p, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('block') + ]), + _List_fromArray( + [ + $elm$html$Html$text(stat.name) + ])), + A2( + $elm$html$Html$p, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('block') + ]), + _List_fromArray( + [ + A3($author$project$Main$viewDots, true, dotSize, stat) + ])) + ])); + }); +var $author$project$Main$viewAttributeCol = F5( + function (oCat, name, category, attributes, dotSize) { var index = A2($author$project$OrderedCategories$indexOf, oCat.order, category); var categoryAttributes = A2($author$project$Stats$attributesOfCategoryInList, category, attributes); var basePoints = A2($author$project$OrderedCategories$categoryValue, oCat, category); @@ -7596,10 +7622,13 @@ var $author$project$Main$viewAttributeCol = F4( ])) ])) ]), - A2($elm$core$List$map, $author$project$Main$viewStat, categoryAttributes))); + A2( + $elm$core$List$map, + $author$project$Main$viewStat(dotSize), + categoryAttributes))); }); -var $author$project$Main$viewAttributes = F2( - function (oCat, attributes) { +var $author$project$Main$viewAttributes = F3( + function (oCat, attributes, dotSize) { return A2( $elm$html$Html$div, _List_fromArray( @@ -7623,9 +7652,9 @@ var $author$project$Main$viewAttributes = F2( ]), _List_fromArray( [ - A4($author$project$Main$viewAttributeCol, oCat, 'Physical', $author$project$Stats$Physical, attributes), - A4($author$project$Main$viewAttributeCol, oCat, 'Social', $author$project$Stats$Social, attributes), - A4($author$project$Main$viewAttributeCol, oCat, 'Mental', $author$project$Stats$Mental, attributes) + A5($author$project$Main$viewAttributeCol, oCat, 'Physical', $author$project$Stats$Physical, attributes, dotSize), + A5($author$project$Main$viewAttributeCol, oCat, 'Social', $author$project$Stats$Social, attributes, dotSize), + A5($author$project$Main$viewAttributeCol, oCat, 'Mental', $author$project$Stats$Mental, attributes, dotSize) ])) ])); }); @@ -7689,34 +7718,39 @@ var $author$project$Main$switchDropdownActive = F2( $elm$core$Maybe$Just(dropdownAction)) ? $elm$core$Maybe$Nothing : $elm$core$Maybe$Just(dropdownAction); }); var $elm$html$Html$a = _VirtualDom_node('a'); +var $author$project$Main$getFragment = function (url) { + return '#' + A2($elm$core$Maybe$withDefault, '', url.fragment); +}; var $elm$html$Html$Attributes$href = function (url) { return A2( $elm$html$Html$Attributes$stringProperty, 'href', _VirtualDom_noJavaScriptUri(url)); }; -var $author$project$Main$viewStatDropdown = function (stat) { - return A2( - $elm$html$Html$a, - _List_fromArray( - [ - $elm$html$Html$Attributes$class('dropdown-item'), - $elm$html$Html$Events$onClick( - $author$project$Main$ChangeStat( - _Utils_update( - stat, - { - dots: A2($author$project$BoundedInt$changeTo, stat.dots, 1) - }))), - $elm$html$Html$Attributes$href('#') - ]), - _List_fromArray( - [ - $elm$html$Html$text(stat.name) - ])); -}; -var $author$project$Main$viewOtherBackgrounds = F2( - function (activeDropdown, backgrounds) { +var $author$project$Main$viewStatDropdown = F2( + function (url, stat) { + return A2( + $elm$html$Html$a, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('dropdown-item'), + $elm$html$Html$Events$onClick( + $author$project$Main$ChangeStat( + _Utils_update( + stat, + { + dots: A2($author$project$BoundedInt$changeTo, stat.dots, 1) + }))), + $elm$html$Html$Attributes$href( + $author$project$Main$getFragment(url)) + ]), + _List_fromArray( + [ + $elm$html$Html$text(stat.name) + ])); + }); +var $author$project$Main$viewOtherBackgrounds = F3( + function (url, activeDropdown, backgrounds) { return A2( $elm$html$Html$div, _List_fromArray( @@ -7791,52 +7825,56 @@ var $author$project$Main$viewOtherBackgrounds = F2( [ $elm$html$Html$Attributes$class('dropdown-content has-text-left') ]), - A2($elm$core$List$map, $author$project$Main$viewStatDropdown, backgrounds)) + A2( + $elm$core$List$map, + $author$project$Main$viewStatDropdown(url), + backgrounds)) ])) ])); }); -var $author$project$Main$viewStatHorizontal = function (stat) { - return A2( - $elm$html$Html$div, - _List_fromArray( - [ - $elm$html$Html$Attributes$class('notification is-narrow') - ]), - _List_fromArray( - [ - A2( - $elm$html$Html$div, - _List_fromArray( - [ - $elm$html$Html$Attributes$class('columns is-centered is-vcentered is-mobile') - ]), - _List_fromArray( - [ - A2( - $elm$html$Html$div, - _List_fromArray( - [ - $elm$html$Html$Attributes$class('column has-text-right') - ]), - _List_fromArray( - [ - $elm$html$Html$text(stat.name) - ])), - A2( - $elm$html$Html$div, - _List_fromArray( - [ - $elm$html$Html$Attributes$class('column has-text-left') - ]), - _List_fromArray( - [ - $author$project$Main$viewDots(stat) - ])) - ])) - ])); -}; -var $author$project$Main$viewBackgrounds = F3( - function (activeDropdown, cp, backgrounds) { +var $author$project$Main$viewStatHorizontal = F2( + function (dotSize, stat) { + return A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('notification is-narrow') + ]), + _List_fromArray( + [ + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('columns is-centered is-vcentered is-mobile') + ]), + _List_fromArray( + [ + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('column has-text-right') + ]), + _List_fromArray( + [ + $elm$html$Html$text(stat.name) + ])), + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('column has-text-left') + ]), + _List_fromArray( + [ + A3($author$project$Main$viewDots, true, dotSize, stat) + ])) + ])) + ])); + }); +var $author$project$Main$viewBackgrounds = F5( + function (url, activeDropdown, cp, backgrounds, dotSize) { var separatedBackgrounds = $author$project$Stats$splitZero(backgrounds); var basePoints = cp.backgrounds; var points = basePoints - $author$project$Stats$count(backgrounds); @@ -7873,9 +7911,12 @@ var $author$project$Main$viewBackgrounds = F3( _List_fromArray( [ $author$project$Main$creationInfo(points), - A2($author$project$Main$viewOtherBackgrounds, activeDropdown, separatedBackgrounds.b) + A3($author$project$Main$viewOtherBackgrounds, url, activeDropdown, separatedBackgrounds.b) ]), - A2($elm$core$List$map, $author$project$Main$viewStatHorizontal, separatedBackgrounds.a))) + A2( + $elm$core$List$map, + $author$project$Main$viewStatHorizontal(dotSize), + separatedBackgrounds.a))) ])) ])); }); @@ -8104,81 +8145,335 @@ var $author$project$Main$viewModal = function (model) { ])); } }; -var $author$project$Main$ariaExpanded = function (value) { - return A2($elm$html$Html$Attributes$attribute, 'aria-expanded', value); -}; -var $author$project$Main$ariaLabel = function (value) { - return A2($elm$html$Html$Attributes$attribute, 'aria-label', value); +var $elm$core$Basics$neq = _Utils_notEqual; +var $author$project$Stats$hasSetAffinity = function (spheres) { + var affinityCount = $elm$core$List$length( + A2( + $elm$core$List$filter, + function (x) { + return _Utils_eq( + x.statType, + $author$project$Stats$Sphere(true)); + }, + spheres)); + return !(!affinityCount); }; -var $elm$html$Html$nav = _VirtualDom_node('nav'); -var $author$project$Main$ImportCharacter = function (a) { - return {$: 'ImportCharacter', a: a}; +var $author$project$Main$affinityWarning = function (spheres) { + var hasSetAffinity = $author$project$Stats$hasSetAffinity(spheres); + return hasSetAffinity ? A2($elm$html$Html$div, _List_Nil, _List_Nil) : A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('notification is-danger') + ]), + _List_fromArray( + [ + $elm$html$Html$text('Affinity Sphere not set') + ])); }; -var $author$project$Main$viewImport = A2( - $elm$html$Html$div, - _List_fromArray( - [ - $elm$html$Html$Attributes$class('navbar-item has-dropdown is-hoverable') - ]), - _List_fromArray( - [ - A2( - $elm$html$Html$a, - _List_fromArray( - [ - $elm$html$Html$Attributes$class('navbar-link'), - $elm$html$Html$Attributes$href('#') - ]), - _List_fromArray( - [ - $elm$html$Html$text('Import Character') - ])), +var $author$project$Stats$everyThirdStat = F2( + function (stats, offset) { + return A2( + $elm$core$List$map, + $elm$core$Tuple$second, A2( + $elm$core$List$filter, + function (x) { + return _Utils_eq((x.a / 3) | 0, offset); + }, + A2($elm$core$List$indexedMap, $elm$core$Tuple$pair, stats))); + }); +var $author$project$Main$SetAffinity = function (a) { + return {$: 'SetAffinity', a: a}; +}; +var $author$project$Main$viewSphere = F2( + function (dotSize, stat) { + return A2( $elm$html$Html$div, _List_fromArray( [ - $elm$html$Html$Attributes$class('navbar-dropdown') + $elm$html$Html$Attributes$class('notification') ]), _List_fromArray( [ A2( - $elm$html$Html$a, + $elm$html$Html$p, _List_fromArray( [ - $elm$html$Html$Attributes$class('navbar-item'), + $elm$html$Html$Attributes$class('delete is-not-delete icon corner'), $elm$html$Html$Events$onClick( - $author$project$Main$ImportCharacter('./characters/empty.json')), - $elm$html$Html$Attributes$href('#') + $author$project$Main$SetAffinity( + _Utils_update( + stat, + { + statType: $author$project$Stats$Sphere(true) + }))) ]), _List_fromArray( [ - $elm$html$Html$text('Empty') + function () { + var _v0 = stat.statType; + if (_v0.$ === 'Sphere') { + var affinity = _v0.a; + return affinity ? A2( + $elm$html$Html$i, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('fas fa-star') + ]), + _List_Nil) : A2( + $elm$html$Html$i, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('far fa-star') + ]), + _List_Nil); + } else { + return A2($elm$html$Html$i, _List_Nil, _List_Nil); + } + }() ])), A2( - $elm$html$Html$a, + $elm$html$Html$p, _List_fromArray( [ - $elm$html$Html$Attributes$class('navbar-item'), - $elm$html$Html$Events$onClick( - $author$project$Main$ImportCharacter('./characters/john_doe.json')), - $elm$html$Html$Attributes$href('#') + $elm$html$Html$Attributes$class('block') ]), _List_fromArray( [ - $elm$html$Html$text('John Doe') + $elm$html$Html$text(stat.name) ])), A2( - $elm$html$Html$a, + $elm$html$Html$p, _List_fromArray( [ - $elm$html$Html$Attributes$class('navbar-item'), - $elm$html$Html$Events$onClick( - $author$project$Main$ImportCharacter('./characters/jane_doe.json')), - $elm$html$Html$Attributes$href('#') + $elm$html$Html$Attributes$class('block') ]), _List_fromArray( [ - $elm$html$Html$text('Jane Doe') + A3($author$project$Main$viewDots, true, dotSize, stat) + ])) + ])); + }); +var $author$project$Main$viewSpheres = F3( + function (cp, spheres, dotSize) { + var basePoints = cp.spheres; + var points = basePoints - $author$project$Stats$count(spheres); + return A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('has-text-centered') + ]), + _List_fromArray( + [ + A2( + $elm$html$Html$p, + _List_Nil, + _List_fromArray( + [ + $elm$html$Html$text('Spheres') + ])), + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('columns is-centered is-mobile') + ]), + _List_fromArray( + [ + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('column is-three-fifths') + ]), + _List_fromArray( + [ + $author$project$Main$creationInfo(points), + $author$project$Main$affinityWarning(spheres) + ])) + ])), + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('columns is-centered is-mobile') + ]), + _List_fromArray( + [ + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('column is-one-fifth') + ]), + A2( + $elm$core$List$map, + $author$project$Main$viewSphere(dotSize), + A2($author$project$Stats$everyThirdStat, spheres, 0))), + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('column is-one-fifth') + ]), + A2( + $elm$core$List$map, + $author$project$Main$viewSphere(dotSize), + A2($author$project$Stats$everyThirdStat, spheres, 1))), + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('column is-one-fifth') + ]), + A2( + $elm$core$List$map, + $author$project$Main$viewSphere(dotSize), + A2($author$project$Stats$everyThirdStat, spheres, 2))) + ])) + ])); + }); +var $author$project$Main$viewCreate = function (model) { + var dotSize = 24; + return A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('container') + ]), + _List_fromArray( + [ + A2($author$project$Main$viewEditableText, $author$project$Main$Name, model.character.name), + A3($author$project$Main$viewAttributes, model.character.creationPoints.attributes, model.character.stats, dotSize), + A3($author$project$Main$viewAbilities, model.character.creationPoints.abilities, model.character.stats, dotSize), + A5( + $author$project$Main$viewBackgrounds, + model.url, + model.activeDropdown, + model.character.creationPoints, + $author$project$Stats$backgroundsInList(model.character.stats), + dotSize), + A3( + $author$project$Main$viewSpheres, + model.character.creationPoints, + $author$project$Stats$spheresInList(model.character.stats), + dotSize), + $author$project$Main$viewModal(model) + ])); +}; +var $author$project$Main$ResetCharacter = {$: 'ResetCharacter'}; +var $author$project$Main$ariaExpanded = function (value) { + return A2($elm$html$Html$Attributes$attribute, 'aria-expanded', value); +}; +var $author$project$Main$ariaLabel = function (value) { + return A2($elm$html$Html$Attributes$attribute, 'aria-label', value); +}; +var $elm$html$Html$nav = _VirtualDom_node('nav'); +var $author$project$Main$ImportCharacter = function (a) { + return {$: 'ImportCharacter', a: a}; +}; +var $author$project$Main$viewImport = function (url) { + return A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('navbar-item has-dropdown is-hoverable') + ]), + _List_fromArray( + [ + A2( + $elm$html$Html$a, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('navbar-link'), + $elm$html$Html$Attributes$href( + $author$project$Main$getFragment(url)) + ]), + _List_fromArray( + [ + $elm$html$Html$text('Import Character') + ])), + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('navbar-dropdown') + ]), + _List_fromArray( + [ + A2( + $elm$html$Html$a, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('navbar-item'), + $elm$html$Html$Events$onClick( + $author$project$Main$ImportCharacter('./characters/empty.json')), + $elm$html$Html$Attributes$href( + $author$project$Main$getFragment(url)) + ]), + _List_fromArray( + [ + $elm$html$Html$text('Empty') + ])), + A2( + $elm$html$Html$a, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('navbar-item'), + $elm$html$Html$Events$onClick( + $author$project$Main$ImportCharacter('./characters/john_doe.json')), + $elm$html$Html$Attributes$href( + $author$project$Main$getFragment(url)) + ]), + _List_fromArray( + [ + $elm$html$Html$text('John Doe') + ])), + A2( + $elm$html$Html$a, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('navbar-item'), + $elm$html$Html$Events$onClick( + $author$project$Main$ImportCharacter('./characters/jane_doe.json')), + $elm$html$Html$Attributes$href( + $author$project$Main$getFragment(url)) + ]), + _List_fromArray( + [ + $elm$html$Html$text('Jane Doe') + ])) + ])) + ])); +}; +var $author$project$Main$viewNavbarFinish = A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('navbar-end') + ]), + _List_fromArray( + [ + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('navbar-item') + ]), + _List_fromArray( + [ + A2( + $elm$html$Html$a, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('button is-primary'), + $elm$html$Html$Attributes$href('#view') + ]), + _List_fromArray( + [ + $elm$html$Html$text('Finish Character') ])) ])) ])); @@ -8219,7 +8514,8 @@ var $author$project$Main$viewNavbar = function (model) { $elm$html$Html$Attributes$class('navbar-burger'), $author$project$Main$ariaLabel('menu'), $author$project$Main$ariaExpanded('false'), - $elm$html$Html$Attributes$href('#') + $elm$html$Html$Attributes$href( + $author$project$Main$getFragment(model.url)) ]), _List_fromArray( [ @@ -8275,179 +8571,514 @@ var $author$project$Main$viewNavbar = function (model) { _List_fromArray( [ $elm$html$Html$Attributes$class('navbar-item'), - $elm$html$Html$Attributes$href('#') + $elm$html$Html$Attributes$href('#create'), + $elm$html$Html$Events$onClick($author$project$Main$ResetCharacter) ]), _List_fromArray( [ $elm$html$Html$text('New Character') ])), - $author$project$Main$viewImport + $author$project$Main$viewImport(model.url) ])), - A2( - $elm$html$Html$div, - _List_fromArray( - [ - $elm$html$Html$Attributes$class('navbar-end') - ]), - _List_fromArray( - [ - A2( - $elm$html$Html$div, - _List_fromArray( - [ - $elm$html$Html$Attributes$class('navbar-item') - ]), - _List_fromArray( - [ - A2( - $elm$html$Html$a, - _List_fromArray( - [ - $elm$html$Html$Attributes$class('button is-primary'), - $elm$html$Html$Attributes$href('#') - ]), - _List_fromArray( - [ - $elm$html$Html$text('Finish Character') - ])) - ])) - ])) + function () { + var _v0 = $author$project$Main$getMode(model.url); + if (_v0.$ === 'CreateCharacter') { + return $author$project$Main$viewNavbarFinish; + } else { + return A2($elm$html$Html$div, _List_Nil, _List_Nil); + } + }() ])) ])); }; -var $elm$core$Basics$neq = _Utils_notEqual; -var $author$project$Stats$hasSetAffinity = function (spheres) { - var affinityCount = $elm$core$List$length( - A2( - $elm$core$List$filter, - function (x) { - return _Utils_eq( - x.statType, - $author$project$Stats$Sphere(true)); - }, - spheres)); - return !(!affinityCount); -}; -var $author$project$Main$affinityWarning = function (spheres) { - var hasSetAffinity = $author$project$Stats$hasSetAffinity(spheres); - return hasSetAffinity ? A2($elm$html$Html$div, _List_Nil, _List_Nil) : A2( - $elm$html$Html$div, - _List_fromArray( - [ - $elm$html$Html$Attributes$class('notification is-danger') - ]), - _List_fromArray( - [ - $elm$html$Html$text('Affinity Sphere not set') - ])); +var $elm$html$Html$Attributes$colspan = function (n) { + return A2( + _VirtualDom_attribute, + 'colspan', + $elm$core$String$fromInt(n)); }; -var $author$project$Stats$everyThirdStat = F2( - function (stats, offset) { +var $elm$virtual_dom$VirtualDom$style = _VirtualDom_style; +var $elm$html$Html$Attributes$style = $elm$virtual_dom$VirtualDom$style; +var $elm$html$Html$table = _VirtualDom_node('table'); +var $elm$html$Html$tbody = _VirtualDom_node('tbody'); +var $elm$html$Html$th = _VirtualDom_node('th'); +var $elm$html$Html$thead = _VirtualDom_node('thead'); +var $elm$html$Html$tr = _VirtualDom_node('tr'); +var $elm$html$Html$td = _VirtualDom_node('td'); +var $author$project$Main$vView3ColTableStat = F4( + function (dotSize, a, b, c) { return A2( - $elm$core$List$map, - $elm$core$Tuple$second, - A2( - $elm$core$List$filter, - function (x) { - return _Utils_eq((x.a / 3) | 0, offset); - }, - A2($elm$core$List$indexedMap, $elm$core$Tuple$pair, stats))); - }); -var $author$project$Main$SetAffinity = function (a) { - return {$: 'SetAffinity', a: a}; -}; -var $author$project$Main$viewSphere = function (stat) { - return A2( - $elm$html$Html$div, - _List_fromArray( - [ - $elm$html$Html$Attributes$class('notification') - ]), - _List_fromArray( - [ - A2( - $elm$html$Html$p, - _List_fromArray( - [ - $elm$html$Html$Attributes$class('delete is-not-delete icon corner'), - $elm$html$Html$Events$onClick( - $author$project$Main$SetAffinity( - _Utils_update( - stat, - { - statType: $author$project$Stats$Sphere(true) - }))) - ]), - _List_fromArray( - [ - function () { - var _v0 = stat.statType; - if (_v0.$ === 'Sphere') { - var affinity = _v0.a; - return affinity ? A2( - $elm$html$Html$i, - _List_fromArray( - [ - $elm$html$Html$Attributes$class('fas fa-star') - ]), - _List_Nil) : A2( - $elm$html$Html$i, - _List_fromArray( - [ - $elm$html$Html$Attributes$class('far fa-star') - ]), - _List_Nil); - } else { - return A2($elm$html$Html$i, _List_Nil, _List_Nil); - } - }() - ])), + $elm$html$Html$tr, + _List_Nil, + _List_fromArray( + [ + A2( + $elm$html$Html$td, + _List_Nil, + _List_fromArray( + [ + $elm$html$Html$text(a.name) + ])), + A2( + $elm$html$Html$td, + _List_Nil, + _List_fromArray( + [ + A3($author$project$Main$viewDots, false, dotSize, a) + ])), + A2( + $elm$html$Html$td, + _List_Nil, + _List_fromArray( + [ + $elm$html$Html$text(b.name) + ])), + A2( + $elm$html$Html$td, + _List_Nil, + _List_fromArray( + [ + A3($author$project$Main$viewDots, false, dotSize, b) + ])), + A2( + $elm$html$Html$td, + _List_Nil, + _List_fromArray( + [ + $elm$html$Html$text(c.name) + ])), + A2( + $elm$html$Html$td, + _List_Nil, + _List_fromArray( + [ + A3($author$project$Main$viewDots, false, dotSize, c) + ])) + ])); + }); +var $author$project$Main$vViewAbilities = F2( + function (abilities, dotSize) { + return A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('notification') + ]), + _List_fromArray( + [ + A2( + $elm$html$Html$table, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('table is-fullwidth') + ]), + _List_fromArray( + [ + A2( + $elm$html$Html$thead, + _List_Nil, + _List_fromArray( + [ + A2( + $elm$html$Html$tr, + _List_Nil, + _List_fromArray( + [ + A2( + $elm$html$Html$th, + _List_fromArray( + [ + $elm$html$Html$Attributes$colspan(2), + A2($elm$html$Html$Attributes$style, 'width', '33%') + ]), + _List_fromArray( + [ + $elm$html$Html$text('Talents') + ])), + A2( + $elm$html$Html$th, + _List_fromArray( + [ + $elm$html$Html$Attributes$colspan(2), + A2($elm$html$Html$Attributes$style, 'width', '33%') + ]), + _List_fromArray( + [ + $elm$html$Html$text('Skills') + ])), + A2( + $elm$html$Html$th, + _List_fromArray( + [ + $elm$html$Html$Attributes$colspan(2), + A2($elm$html$Html$Attributes$style, 'width', '33%') + ]), + _List_fromArray( + [ + $elm$html$Html$text('Knowledges') + ])) + ])) + ])), + A2( + $elm$html$Html$tbody, + _List_Nil, + A4( + $elm$core$List$map3, + $author$project$Main$vView3ColTableStat(dotSize), + A2($author$project$Stats$abilitiesOfCategoryInList, $author$project$Stats$Talent, abilities), + A2($author$project$Stats$abilitiesOfCategoryInList, $author$project$Stats$Skill, abilities), + A2($author$project$Stats$abilitiesOfCategoryInList, $author$project$Stats$Knowledge, abilities))) + ])) + ])); + }); +var $author$project$Main$vViewAttributes = F2( + function (attributes, dotSize) { + return A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('notification') + ]), + _List_fromArray( + [ + A2( + $elm$html$Html$table, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('table is-fullwidth') + ]), + _List_fromArray( + [ + A2( + $elm$html$Html$thead, + _List_Nil, + _List_fromArray( + [ + A2( + $elm$html$Html$tr, + _List_Nil, + _List_fromArray( + [ + A2( + $elm$html$Html$th, + _List_fromArray( + [ + $elm$html$Html$Attributes$colspan(2), + A2($elm$html$Html$Attributes$style, 'width', '33%') + ]), + _List_fromArray( + [ + $elm$html$Html$text('Physical') + ])), + A2( + $elm$html$Html$th, + _List_fromArray( + [ + $elm$html$Html$Attributes$colspan(2), + A2($elm$html$Html$Attributes$style, 'width', '33%') + ]), + _List_fromArray( + [ + $elm$html$Html$text('Social') + ])), + A2( + $elm$html$Html$th, + _List_fromArray( + [ + $elm$html$Html$Attributes$colspan(2), + A2($elm$html$Html$Attributes$style, 'width', '33%') + ]), + _List_fromArray( + [ + $elm$html$Html$text('Mental') + ])) + ])) + ])), + A2( + $elm$html$Html$tbody, + _List_Nil, + A4( + $elm$core$List$map3, + $author$project$Main$vView3ColTableStat(dotSize), + A2($author$project$Stats$attributesOfCategoryInList, $author$project$Stats$Physical, attributes), + A2($author$project$Stats$attributesOfCategoryInList, $author$project$Stats$Social, attributes), + A2($author$project$Stats$attributesOfCategoryInList, $author$project$Stats$Mental, attributes))) + ])) + ])); + }); +var $author$project$Main$vViewNDE = F2( + function (category, value) { + return A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('notification has-text-centered') + ]), + _List_fromArray( + [ + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('level-item') + ]), + _List_fromArray( + [ + $elm$html$Html$text(category) + ])), + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('level-item') + ]), + _List_fromArray( + [ + $elm$html$Html$text(value) + ])) + ])); + }); +var $elm$html$Html$textarea = _VirtualDom_node('textarea'); +var $author$project$Main$vViewNotes = function (notes) { + return A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('notification') + ]), + _List_fromArray( + [ A2( - $elm$html$Html$p, + $elm$html$Html$div, + _List_Nil, _List_fromArray( [ - $elm$html$Html$Attributes$class('block') - ]), + $elm$html$Html$text('Notes') + ])), + A2( + $elm$html$Html$div, + _List_Nil, _List_fromArray( [ - $elm$html$Html$text(stat.name) - ])), + A2( + $elm$html$Html$textarea, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('textarea'), + $elm$html$Html$Attributes$placeholder('Character Notes') + ]), + _List_fromArray( + [ + $elm$html$Html$text(notes) + ])) + ])) + ])); +}; +var $author$project$Main$vViewQuintParadox = function (dotSize) { + return A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('notification') + ]), + _List_fromArray( + [ A2( - $elm$html$Html$p, + $elm$html$Html$nav, _List_fromArray( [ - $elm$html$Html$Attributes$class('block') + $elm$html$Html$Attributes$class('level') ]), _List_fromArray( [ - $author$project$Main$viewDots(stat) + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('level-left') + ]), + _List_fromArray( + [ + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('level-item') + ]), + _List_fromArray( + [ + $elm$html$Html$text('Quintessence') + ])) + ])), + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('level-center is-centered') + ]), + _List_fromArray( + [ + A3( + $author$project$Main$viewDots, + false, + dotSize, + { + dots: A3($author$project$BoundedInt$new, 0, 0, 20), + name: '', + statType: $author$project$Stats$Arete + }) + ])), + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('level-right') + ]), + _List_fromArray( + [ + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('level-item') + ]), + _List_fromArray( + [ + $elm$html$Html$text('Paradox') + ])) + ])) ])) ])); }; -var $author$project$Main$viewSpheres = F2( - function (cp, spheres) { - var basePoints = cp.spheres; - var points = basePoints - $author$project$Stats$count(spheres); +var $author$project$Main$vViewStatHorizontal = F2( + function (stat, dotSize) { + return A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('notification') + ]), + _List_fromArray( + [ + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('columns is-vcentered has-text-left') + ]), + _List_fromArray( + [ + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('column') + ]), + _List_fromArray( + [ + $elm$html$Html$text(stat.name) + ])), + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('column') + ]), + _List_fromArray( + [ + A3($author$project$Main$viewDots, false, dotSize, stat) + ])) + ])) + ])); + }); +var $author$project$Main$vViewStat = F2( + function (dotSize, stat) { + return A2( + $elm$html$Html$tr, + _List_Nil, + _List_fromArray( + [ + A2( + $elm$html$Html$td, + _List_Nil, + _List_fromArray( + [ + $elm$html$Html$text(stat.name) + ])), + A2( + $elm$html$Html$td, + _List_Nil, + _List_fromArray( + [ + A3($author$project$Main$viewDots, false, dotSize, stat) + ])) + ])); + }); +var $author$project$Main$vViewStatList = F3( + function (stats, statTypeName, dotSize) { return A2( $elm$html$Html$div, _List_fromArray( [ - $elm$html$Html$Attributes$class('has-text-centered') + $elm$html$Html$Attributes$class('notification') ]), _List_fromArray( [ A2( - $elm$html$Html$p, - _List_Nil, + $elm$html$Html$table, _List_fromArray( [ - $elm$html$Html$text('Spheres') - ])), + $elm$html$Html$Attributes$class('table is-fullwidth') + ]), + _List_fromArray( + [ + A2( + $elm$html$Html$thead, + _List_Nil, + _List_fromArray( + [ + A2( + $elm$html$Html$tr, + _List_Nil, + _List_fromArray( + [ + A2( + $elm$html$Html$th, + _List_fromArray( + [ + $elm$html$Html$Attributes$colspan(2) + ]), + _List_fromArray( + [ + $elm$html$Html$text(statTypeName) + ])) + ])) + ])), + A2( + $elm$html$Html$tbody, + _List_Nil, + A2( + $elm$core$List$map, + $author$project$Main$vViewStat(dotSize), + stats)) + ])) + ])); + }); +var $author$project$Main$vViewBody = F2( + function (character, dotSize) { + return A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('columns') + ]), + _List_fromArray( + [ A2( $elm$html$Html$div, _List_fromArray( [ - $elm$html$Html$Attributes$class('columns is-centered is-mobile') + $elm$html$Html$Attributes$class('column is-half') ]), _List_fromArray( [ @@ -8455,55 +9086,522 @@ var $author$project$Main$viewSpheres = F2( $elm$html$Html$div, _List_fromArray( [ - $elm$html$Html$Attributes$class('column is-three-fifths') + $elm$html$Html$Attributes$class('columns') ]), _List_fromArray( [ - $author$project$Main$creationInfo(points), - $author$project$Main$affinityWarning(spheres) - ])) + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('column is-half') + ]), + _List_fromArray( + [ + A2( + $author$project$Main$vViewStatHorizontal, + $author$project$Stats$areteInList(character.stats), + dotSize) + ])), + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('column is-half') + ]), + _List_fromArray( + [ + A2( + $author$project$Main$vViewStatHorizontal, + { + dots: A3($author$project$BoundedInt$new, 5, 0, 10), + name: 'Willpower', + statType: $author$project$Stats$Arete + }, + dotSize) + ])) + ])), + $author$project$Main$vViewQuintParadox(dotSize), + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('columns') + ]), + _List_fromArray( + [ + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('column is-half') + ]), + _List_fromArray( + [ + A3( + $author$project$Main$vViewStatList, + $author$project$Stats$splitZero( + $author$project$Stats$backgroundsInList(character.stats)).a, + 'Backgrounds', + dotSize) + ])), + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('column is-half') + ]), + _List_fromArray( + [ + A3($author$project$Main$vViewStatList, _List_Nil, 'Merits', dotSize), + A3($author$project$Main$vViewStatList, _List_Nil, 'Flaws', dotSize) + ])) + ])), + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('columns') + ]), + _List_fromArray( + [ + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('column is-one-third') + ]), + _List_fromArray( + [ + A2($author$project$Main$vViewNDE, 'Nature', 'NaN') + ])), + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('column is-one-third') + ]), + _List_fromArray( + [ + A2($author$project$Main$vViewNDE, 'Demeanor', 'NaN') + ])), + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('column is-one-third') + ]), + _List_fromArray( + [ + A2($author$project$Main$vViewNDE, 'Essence', 'NaN') + ])) + ])), + $author$project$Main$vViewNotes('') ])), A2( $elm$html$Html$div, _List_fromArray( [ - $elm$html$Html$Attributes$class('columns is-centered is-mobile') + $elm$html$Html$Attributes$class('column is-half') ]), _List_fromArray( [ A2( - $elm$html$Html$div, + $author$project$Main$vViewAttributes, + $author$project$Stats$attributesInList(character.stats), + dotSize), + A2( + $author$project$Main$vViewAbilities, + $author$project$Stats$abilitiesInList(character.stats), + dotSize) + ])) + ])); + }); +var $elm$core$String$toUpper = _String_toUpper; +var $author$project$Main$first4Letters = function (string) { + return $elm$core$String$toUpper( + A3($elm$core$String$slice, 0, 4, string)); +}; +var $author$project$Main$vViewStatAsCol = F2( + function (dotSize, stat) { + return A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('column') + ]), + _List_fromArray( + [ + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('notification') + ]), + _List_fromArray( + [ + A2( + $elm$html$Html$p, _List_fromArray( [ - $elm$html$Html$Attributes$class('column is-one-fifth') + $elm$html$Html$Attributes$class('block') ]), + _List_fromArray( + [ + $elm$html$Html$text( + $author$project$Main$first4Letters(stat.name)) + ])), A2( - $elm$core$List$map, - $author$project$Main$viewSphere, - A2($author$project$Stats$everyThirdStat, spheres, 0))), - A2( - $elm$html$Html$div, + $elm$html$Html$p, _List_fromArray( [ - $elm$html$Html$Attributes$class('column is-one-fifth') + $elm$html$Html$Attributes$class('block') ]), - A2( - $elm$core$List$map, - $author$project$Main$viewSphere, - A2($author$project$Stats$everyThirdStat, spheres, 1))), + _List_fromArray( + [ + A3($author$project$Main$viewDots, false, dotSize, stat) + ])) + ])) + ])); + }); +var $author$project$Main$vViewSpheres = F2( + function (spheres, dotSize) { + return A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('columns has-text-centered') + ]), + A2( + $elm$core$List$map, + $author$project$Main$vViewStatAsCol(dotSize), + spheres)); + }); +var $author$project$Main$vViewHeader = F2( + function (character, dotSize) { + return A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('block ') + ]), + _List_fromArray( + [ + A2( + $elm$html$Html$nav, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('columns is-multiline') + ]), + _List_fromArray( + [ A2( $elm$html$Html$div, _List_fromArray( [ - $elm$html$Html$Attributes$class('column is-one-fifth') + $elm$html$Html$Attributes$class('column') ]), - A2( - $elm$core$List$map, - $author$project$Main$viewSphere, - A2($author$project$Stats$everyThirdStat, spheres, 2))) + _List_fromArray( + [ + A2( + $elm$html$Html$div, + _List_Nil, + _List_fromArray( + [ + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('level') + ]), + _List_fromArray( + [ + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('level-left') + ]), + _List_fromArray( + [ + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('level-item') + ]), + _List_fromArray( + [ + A2( + $elm$html$Html$div, + _List_Nil, + _List_fromArray( + [ + A2( + $elm$html$Html$p, + _List_Nil, + _List_fromArray( + [ + $elm$html$Html$text(character.name) + ])), + A2( + $elm$html$Html$p, + _List_Nil, + _List_fromArray( + [ + $elm$html$Html$text('Default Chronicle') + ])), + A2( + $elm$html$Html$p, + _List_Nil, + _List_fromArray( + [ + $elm$html$Html$text('Default Player') + ])) + ])) + ])) + ])), + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('level-right') + ]), + _List_fromArray( + [ + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('level-item') + ]), + _List_fromArray( + [ + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('columns is-multiline is-right') + ]), + _List_fromArray( + [ + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('column is-narrow') + ]), + _List_fromArray( + [ + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('buttons has-addons') + ]), + _List_fromArray( + [ + A2( + $elm$html$Html$button, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('button is-static') + ]), + _List_fromArray( + [ + $elm$html$Html$text('Downtime') + ])), + A2( + $elm$html$Html$button, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('button') + ]), + _List_fromArray( + [ + $elm$html$Html$text('0') + ])) + ])) + ])), + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('column is-narrow') + ]), + _List_fromArray( + [ + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('buttons has-addons') + ]), + _List_fromArray( + [ + A2( + $elm$html$Html$button, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('button is-static') + ]), + _List_fromArray( + [ + $elm$html$Html$text('Tass') + ])), + A2( + $elm$html$Html$button, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('button') + ]), + _List_fromArray( + [ + $elm$html$Html$text('0') + ])) + ])) + ])), + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('column is-narrow') + ]), + _List_fromArray( + [ + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('buttons has-addons') + ]), + _List_fromArray( + [ + A2( + $elm$html$Html$button, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('button is-static') + ]), + _List_fromArray( + [ + $elm$html$Html$text('Health') + ])), + A2( + $elm$html$Html$button, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('button') + ]), + _List_fromArray( + [ + $elm$html$Html$text('0') + ])) + ])) + ])), + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('column is-narrow') + ]), + _List_fromArray( + [ + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('buttons has-addons') + ]), + _List_fromArray( + [ + A2( + $elm$html$Html$button, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('button is-static') + ]), + _List_fromArray( + [ + $elm$html$Html$text('Experience') + ])), + A2( + $elm$html$Html$button, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('button') + ]), + _List_fromArray( + [ + $elm$html$Html$text('0') + ])) + ])) + ])), + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('column is-narrow') + ]), + _List_fromArray( + [ + A2( + $elm$html$Html$button, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('button') + ]), + _List_fromArray( + [ + $elm$html$Html$text('Lvl Up') + ])) + ])), + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('column is-narrow') + ]), + _List_fromArray( + [ + A2( + $elm$html$Html$button, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('button') + ]), + _List_fromArray( + [ + $elm$html$Html$text('Edit') + ])) + ])) + ])) + ])) + ])) + ])), + A2( + $author$project$Main$vViewSpheres, + $author$project$Stats$spheresInList(character.stats), + dotSize) + ])) + ])) ])) ])); }); +var $author$project$Main$viewView = function (model) { + var dotSize = 16; + return A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('container') + ]), + _List_fromArray( + [ + A2($author$project$Main$vViewHeader, model.character, dotSize), + A2($author$project$Main$vViewBody, model.character, dotSize) + ])); +}; var $author$project$Main$view = function (model) { return { body: _List_fromArray( @@ -8514,28 +9612,14 @@ var $author$project$Main$view = function (model) { _List_fromArray( [ $author$project$Main$viewNavbar(model), - A2( - $elm$html$Html$div, - _List_fromArray( - [ - $elm$html$Html$Attributes$class('container') - ]), - _List_fromArray( - [ - A2($author$project$Main$viewEditableText, $author$project$Main$Name, model.character.name), - A2($author$project$Main$viewAttributes, model.character.creationPoints.attributes, model.character.stats), - A2($author$project$Main$viewAbilities, model.character.creationPoints.abilities, model.character.stats), - A3( - $author$project$Main$viewBackgrounds, - model.activeDropdown, - model.character.creationPoints, - $author$project$Stats$backgroundsInList(model.character.stats)), - A2( - $author$project$Main$viewSpheres, - model.character.creationPoints, - $author$project$Stats$spheresInList(model.character.stats)), - $author$project$Main$viewModal(model) - ])) + function () { + var _v0 = $author$project$Main$getMode(model.url); + if (_v0.$ === 'ViewCharacter') { + return $author$project$Main$viewView(model); + } else { + return $author$project$Main$viewCreate(model); + } + }() ])) ]), title: 'Character Sheet' diff --git a/src/Main.elm b/src/Main.elm index c16669c1583586e855921095d7045a019d12fbb3..fb3044818ed0e381e42523c485314eaf813336b1 100644 --- a/src/Main.elm +++ b/src/Main.elm @@ -16,6 +16,8 @@ import Http import Json.Decode import Url import Browser.Navigation as Nav +import Url.Parser exposing (Parser, (</>)) +import Url.Parser.Query main : Program () Model Msg main = @@ -52,6 +54,10 @@ type alias Model = type ActiveDropdown = Backgrounds +type Mode + = CreateCharacter + | ViewCharacter + type Msg = OpenModal ModalType | CloseModal @@ -65,6 +71,7 @@ type Msg | JsonContent ( Result Http.Error Character ) | LinkClicked Browser.UrlRequest | UrlChanged Url.Url + | ResetCharacter type ModalType = Name @@ -151,9 +158,32 @@ update msg model = , Nav.load href ) UrlChanged url -> - ( { model | url = url } - , Cmd.none -- this is where changing the url should have some effect on the model + ( { model + | url = url + } + , Cmd.none ) + ResetCharacter -> + ( { model + | character = Character.new + } + , Cmd.none + ) + +getMode : Url.Url -> Mode +getMode url = + case url.fragment of + Just fragment -> + case fragment of + "view" -> ViewCharacter + "create" -> CreateCharacter + _ -> CreateCharacter + Nothing -> + CreateCharacter + +getFragment : Url.Url -> String +getFragment url = + ( "#" ++ ( Maybe.withDefault "" url.fragment ) ) view : Model -> Browser.Document Msg view model = @@ -161,15 +191,9 @@ view model = , body = [ div [] [ viewNavbar model - , div - [ class "container" ] - [ viewEditableText Name model.character.name - , viewAttributes model.character.creationPoints.attributes model.character.stats - , viewAbilities model.character.creationPoints.abilities model.character.stats - , viewBackgrounds model.activeDropdown model.character.creationPoints ( Stats.backgroundsInList model.character.stats ) - , viewSpheres model.character.creationPoints ( Stats.spheresInList model.character.stats ) - , viewModal model - ] + , case getMode model.url of + ViewCharacter -> viewView model + CreateCharacter -> viewCreate model ] ] } @@ -188,7 +212,7 @@ viewNavbar model = , class "navbar-burger" , ariaLabel "menu" , ariaExpanded "false" - , href "#" + , href ( getFragment model.url ) ] [ span [ ariaHidden "true" ] [] , span [ ariaHidden "true" ] [] @@ -203,49 +227,71 @@ viewNavbar model = [ div [ class "navbar-start" ] [ a [ class "navbar-item" - , href "#" + , href "#create" + , onClick ResetCharacter ] [ text "New Character" ] - , viewImport - ] - , div [ class "navbar-end" ] - [ div [ class "navbar-item" ] - [ a - [ class "button is-primary" - , href "#" - ] - [ text "Finish Character" ] - ] + , viewImport model.url ] + , case getMode model.url of + CreateCharacter -> viewNavbarFinish + ViewCharacter -> div [] [] ] ] -viewImport : Html Msg -viewImport = +viewNavbarFinish : Html Msg +viewNavbarFinish = + div [ class "navbar-end" ] + [ div [ class "navbar-item" ] + [ a + [ class "button is-primary" + , href "#view" + ] + [ text "Finish Character" ] + ] + ] + +viewImport : Url.Url -> Html Msg +viewImport url = div [ class "navbar-item has-dropdown is-hoverable" ] [ a [ class "navbar-link" - , href "#" + , href ( getFragment url ) ] [ text "Import Character" ] , div [ class "navbar-dropdown" ] [ a [ class "navbar-item" , onClick ( ImportCharacter "./characters/empty.json" ) - , href "#" + , href ( getFragment url ) ] [ text "Empty" ] , a [ class "navbar-item" , onClick ( ImportCharacter "./characters/john_doe.json" ) - , href "#" + , href ( getFragment url ) ] [ text "John Doe" ] , a [ class "navbar-item" , onClick ( ImportCharacter "./characters/jane_doe.json" ) - , href "#" + , href ( getFragment url ) ] [ text "Jane Doe" ] ] ] +viewCreate : Model -> Html Msg +viewCreate model = + let + dotSize = 24 + in + div + [ class "container" ] + [ viewEditableText Name model.character.name + , viewAttributes model.character.creationPoints.attributes model.character.stats dotSize + , viewAbilities model.character.creationPoints.abilities model.character.stats dotSize + , viewBackgrounds model.url model.activeDropdown model.character.creationPoints ( Stats.backgroundsInList model.character.stats ) dotSize + , viewSpheres model.character.creationPoints ( Stats.spheresInList model.character.stats ) dotSize + , viewModal model + ] + viewEditableText : ModalType -> String -> Html Msg viewEditableText modalType content = div [] @@ -262,19 +308,19 @@ viewEditableText modalType content = ] ] -viewAttributes : OCat -> List Stat -> Html Msg -viewAttributes oCat attributes = +viewAttributes : OCat -> List Stat -> Float -> Html Msg +viewAttributes oCat attributes dotSize = div [ class "has-text-centered" ] [ p [] [ text "Attributes" ] , div [ class "columns is-centered is-mobile" ] - [ viewAttributeCol oCat "Physical" Stats.Physical attributes - , viewAttributeCol oCat "Social" Stats.Social attributes - , viewAttributeCol oCat "Mental" Stats.Mental attributes + [ viewAttributeCol oCat "Physical" Stats.Physical attributes dotSize + , viewAttributeCol oCat "Social" Stats.Social attributes dotSize + , viewAttributeCol oCat "Mental" Stats.Mental attributes dotSize ] ] -viewAttributeCol : OCat -> String -> Category -> List Stat -> Html Msg -viewAttributeCol oCat name category attributes = +viewAttributeCol : OCat -> String -> Category -> List Stat -> Float -> Html Msg +viewAttributeCol oCat name category attributes dotSize = let categoryAttributes : List Stat categoryAttributes = Stats.attributesOfCategoryInList category attributes @@ -311,23 +357,23 @@ viewAttributeCol oCat name category attributes = ] ] ++ - ( List.map viewStat categoryAttributes + ( List.map ( viewStat dotSize ) categoryAttributes ) ) -viewAbilities : OCat -> List Stat -> Html Msg -viewAbilities oCat abilities = +viewAbilities : OCat -> List Stat -> Float -> Html Msg +viewAbilities oCat abilities dotSize = div [ class "has-text-centered" ] [ p [] [ text "Abilities" ] , div [ class "columns is-centered is-desktop" ] - [ viewAbilityCol oCat "Talents" Stats.Talent abilities - , viewAbilityCol oCat "Skills" Stats.Skill abilities - , viewAbilityCol oCat "Knowledges" Stats.Knowledge abilities + [ viewAbilityCol oCat "Talents" Stats.Talent abilities dotSize + , viewAbilityCol oCat "Skills" Stats.Skill abilities dotSize + , viewAbilityCol oCat "Knowledges" Stats.Knowledge abilities dotSize ] ] -viewAbilityCol : OCat -> String -> Category -> List Stat -> Html Msg -viewAbilityCol oCat name category abilities = +viewAbilityCol : OCat -> String -> Category -> List Stat -> Float -> Html Msg +viewAbilityCol oCat name category abilities dotSize = let categoryAbilities : List Stat categoryAbilities = Stats.abilitiesOfCategoryInList category abilities @@ -364,14 +410,14 @@ viewAbilityCol oCat name category abilities = ] , div [ class "fixed-grid has-6-cols" ] [ div [ class "grid" ] - ( List.map ( viewStatInGrid 3 ( List.length categoryAbilities ) ) ( List.indexedMap Tuple.pair categoryAbilities ) + ( List.map ( viewStatInGrid dotSize 3 ( List.length categoryAbilities ) ) ( List.indexedMap Tuple.pair categoryAbilities ) ) ] ] ) -viewStatInGrid : Int -> Int -> ( Int, Stat ) -> Html Msg -viewStatInGrid cols totalCount indexedStat = +viewStatInGrid : Float -> Int -> Int -> ( Int, Stat ) -> Html Msg +viewStatInGrid dotSize cols totalCount indexedStat = let index : Int index = Tuple.first indexedStat @@ -392,12 +438,12 @@ viewStatInGrid cols totalCount indexedStat = div [ class ( "cell is-col-span-2" ++ offsetString ) ] [ div [ class "notification" ] [ p [ class "block" ] [ text stat.name ] - , p [ class "block" ] [ viewDots stat ] + , p [ class "block" ] [ viewDots True dotSize stat ] ] ] -viewBackgrounds : Maybe ActiveDropdown -> CreationPoints -> List Stat -> Html Msg -viewBackgrounds activeDropdown cp backgrounds = +viewBackgrounds : Url.Url -> Maybe ActiveDropdown -> CreationPoints -> List Stat -> Float -> Html Msg +viewBackgrounds url activeDropdown cp backgrounds dotSize = let basePoints : Int basePoints = cp.backgrounds @@ -412,17 +458,17 @@ viewBackgrounds activeDropdown cp backgrounds = , div [ class "columns is-centered is-mobile" ] [ div [ class "column is-two-fifths" ] ( [ creationInfo points - , viewOtherBackgrounds activeDropdown ( Tuple.second separatedBackgrounds ) + , viewOtherBackgrounds url activeDropdown ( Tuple.second separatedBackgrounds ) ] ++ - ( List.map viewStatHorizontal ( Tuple.first separatedBackgrounds ) ) + ( List.map ( viewStatHorizontal dotSize ) ( Tuple.first separatedBackgrounds ) ) ) ] ] ) -viewOtherBackgrounds : Maybe ActiveDropdown -> List Stat -> Html Msg -viewOtherBackgrounds activeDropdown backgrounds = +viewOtherBackgrounds : Url.Url -> Maybe ActiveDropdown -> List Stat -> Html Msg +viewOtherBackgrounds url activeDropdown backgrounds = div [ class ( "block dropdown is-fullwidth" ++ if activeDropdown == Just Backgrounds then " is-active" else "" ) ] [ div [ class "dropdown-trigger" ] [ div @@ -446,30 +492,30 @@ viewOtherBackgrounds activeDropdown backgrounds = , ariaRole "menu" ] [ div [ class "dropdown-content has-text-left" ] - ( List.map viewStatDropdown backgrounds ) + ( List.map ( viewStatDropdown url ) backgrounds ) ] ] -viewStatHorizontal : Stat -> Html Msg -viewStatHorizontal stat = +viewStatHorizontal : Float -> Stat -> Html Msg +viewStatHorizontal dotSize stat = div [ class "notification is-narrow" ] [ div [ class "columns is-centered is-vcentered is-mobile" ] [ div [ class "column has-text-right" ] [ text stat.name ] - , div [ class "column has-text-left" ] [ viewDots stat ] + , div [ class "column has-text-left" ] [ viewDots True dotSize stat ] ] ] -viewStatDropdown : Stat -> Html Msg -viewStatDropdown stat = +viewStatDropdown : Url.Url -> Stat -> Html Msg +viewStatDropdown url stat = a [ class "dropdown-item" , onClick ( ChangeStat { stat | dots = BoundedInt.changeTo stat.dots 1 } ) - , href "#" + , href ( getFragment url ) ] [ text stat.name ] -viewSpheres : CreationPoints -> List Stat -> Html Msg -viewSpheres cp spheres = +viewSpheres : CreationPoints -> List Stat -> Float -> Html Msg +viewSpheres cp spheres dotSize = let basePoints : Int basePoints = cp.spheres @@ -486,19 +532,19 @@ viewSpheres cp spheres = ] , div [ class "columns is-centered is-mobile" ] [ div [ class "column is-one-fifth" ] - ( List.map viewSphere ( Stats.everyThirdStat spheres 0 ) + ( List.map ( viewSphere dotSize ) ( Stats.everyThirdStat spheres 0 ) ) , div [ class "column is-one-fifth" ] - ( List.map viewSphere ( Stats.everyThirdStat spheres 1 ) + ( List.map ( viewSphere dotSize ) ( Stats.everyThirdStat spheres 1 ) ) , div [ class "column is-one-fifth" ] - ( List.map viewSphere ( Stats.everyThirdStat spheres 2 ) + ( List.map ( viewSphere dotSize ) ( Stats.everyThirdStat spheres 2 ) ) ] ] -viewSphere : Stat -> Html Msg -viewSphere stat = +viewSphere : Float -> Stat -> Html Msg +viewSphere dotSize stat = div [ class "notification" ] [ p [ class "delete is-not-delete icon corner" @@ -512,7 +558,7 @@ viewSphere stat = _ -> i [] [] ] , p [ class "block" ] [ text stat.name ] - , p [ class "block" ] [ viewDots stat ] + , p [ class "block" ] [ viewDots True dotSize stat ] ] affinityWarning : List Stat -> Html Msg @@ -539,17 +585,16 @@ creationInfo points = [ text ( ( String.fromInt points ) ++ " remaining" ) ] -viewStat : Stat -> Html Msg -viewStat stat = +viewStat : Float -> Stat -> Html Msg +viewStat dotSize stat = div [ class "notification" ] [ p [ class "block" ] [ text stat.name ] - , p [ class "block" ] [ viewDots stat ] + , p [ class "block" ] [ viewDots True dotSize stat ] ] -viewDots : Stat -> Html Msg -viewDots stat = +viewDots : Bool -> Float -> Stat -> Html Msg +viewDots allowChange dotSize stat = let - dotSize = 12*2 dotGap = dotSize / 2 dotOutline = 0.05 * dotSize marginalIncrease = ( dotSize + dotGap ) / 2 @@ -565,7 +610,7 @@ viewDots stat = ] ( rangeList |> List.map ( toDotPosition dotSize dotGap svgOutlineMargin ) - |> List.map3 ( viewDot stat dotSize dotOutline ) isFilledList rangeList + |> List.map3 ( viewDot allowChange stat dotSize dotOutline ) isFilledList rangeList ) toDotPosition : Float -> Float -> Float -> Int -> ( Float, Float ) @@ -577,8 +622,8 @@ toDotPosition size gap offset id = , toFloat ( remainderBy 2 ( id + 1 ) ) * marginalIncrease + offset ) -viewDot : Stat -> Float -> Float -> Bool -> Int -> ( Float, Float ) -> Html Msg -viewDot stat size strokeWidth isFilled id position = +viewDot : Bool -> Stat -> Float -> Float -> Bool -> Int -> ( Float, Float ) -> Html Msg +viewDot allowChange stat size strokeWidth isFilled id position = Svg.polygon [ Svg.Attributes.points ( [ ( 0.5, 0.0 ) @@ -597,7 +642,13 @@ viewDot stat size strokeWidth isFilled id position = , Svg.Attributes.fillOpacity ( boolAsIntString isFilled ) , Svg.Attributes.stroke "var(--bulma-body-color)" , Svg.Attributes.strokeWidth ( String.fromFloat strokeWidth ) - , onClick ( ChangeStat { stat | dots = BoundedInt.changeTo stat.dots ( valueOrReset stat.dots ( id + 1 ) ) } ) + , onClick + ( ChangeStat + ( if allowChange + then { stat | dots = BoundedInt.changeTo stat.dots ( valueOrReset stat.dots ( id + 1 ) ) } + else stat + ) + ) ] [] tupleToString : ( Float, Float ) -> String @@ -676,6 +727,255 @@ modalValue modalType character = case modalType of Name -> character.name +viewView : Model -> Html Msg +viewView model = + let + dotSize = 16 + in + div [ class "container" ] + [ vViewHeader model.character dotSize + , vViewBody model.character dotSize + ] + +vViewHeader : Character -> Float -> Html Msg +vViewHeader character dotSize = + div [ class "block "] + [ nav [ class "columns is-multiline" ] + [ div [ class "column" ] + [ div [] + [ div [ class "level" ] + [ div [ class "level-left" ] + [ div [ class "level-item" ] + [ div [] + [ p [] [ text character.name ] + , p [] [ text "Default Chronicle" ] + , p [] [ text "Default Player" ] + ] + ] + ] + , div [ class "level-right" ] + [ div [ class "level-item" ] + [ div [ class "columns is-multiline is-right" ] + [ div [ class "column is-narrow" ] + [ div [ class "buttons has-addons" ] + [ button [ class "button is-static" ] [ text "Downtime" ] + , button [ class "button" ] [ text "0" ] + ] + ] + , div [ class "column is-narrow" ] + [ div [ class "buttons has-addons" ] + [ button [ class "button is-static" ] [ text "Tass" ] + , button [ class "button" ] [ text "0" ] + ] + ] + , div [ class "column is-narrow" ] + [ div [ class "buttons has-addons" ] + [ button [ class "button is-static" ] [ text "Health" ] + , button [ class "button" ] [ text "0" ] + ] + ] + , div [ class "column is-narrow" ] + [ div [ class "buttons has-addons" ] + [ button [ class "button is-static" ] [ text "Experience" ] + , button [ class "button" ] [ text "0" ] + ] + ] + , div [ class "column is-narrow" ] + [ button [ class "button" ] [ text "Lvl Up" ] + ] + , div [ class "column is-narrow" ] + [ button [ class "button" ] [ text "Edit" ] + ] + ] + ] + ] + ] + , vViewSpheres ( Stats.spheresInList character.stats ) dotSize + ] + ] + ] + ] + +vViewSpheres : List Stat -> Float -> Html Msg +vViewSpheres spheres dotSize = + div [ class "columns has-text-centered"] + ( List.map ( vViewStatAsCol dotSize ) spheres + ) + +vViewStatAsCol : Float -> Stat -> Html Msg +vViewStatAsCol dotSize stat = + div [ class "column" ] + [ div [ class "notification" ] + [ p [ class "block" ] [ text ( first4Letters stat.name ) ] + , p [ class "block" ] [ viewDots False dotSize stat ] + ] + ] + +first4Letters : String -> String +first4Letters string = + String.slice 0 4 string + |> String.toUpper + +vViewBody : Character -> Float -> Html Msg +vViewBody character dotSize = + div [ class "columns" ] + [ div [ class "column is-half" ] + [ div [ class "columns" ] + [ div [ class "column is-half" ] + [ vViewStatHorizontal ( Stats.areteInList character.stats ) dotSize + ] + , div [ class "column is-half" ] + [ vViewStatHorizontal { name = "Willpower", dots = BoundedInt.new 5 0 10, statType = Stats.Arete } dotSize + ] + ] + , vViewQuintParadox dotSize + , div [ class "columns" ] + [ div [ class "column is-half" ] + [ vViewStatList ( Tuple.first <| Stats.splitZero <| Stats.backgroundsInList character.stats ) "Backgrounds" dotSize + ] + , div [ class "column is-half" ] + [ vViewStatList [] "Merits" dotSize + , vViewStatList [] "Flaws" dotSize + ] + ] + , div [ class "columns" ] + [ div [ class "column is-one-third" ] + [ vViewNDE "Nature" "NaN" + ] + , div [ class "column is-one-third" ] + [ vViewNDE "Demeanor" "NaN" + ] + , div [ class "column is-one-third" ] + [ vViewNDE "Essence" "NaN" + ] + ] + , vViewNotes "" + ] + , div [ class "column is-half" ] + [ vViewAttributes ( Stats.attributesInList character.stats ) dotSize + , vViewAbilities ( Stats.abilitiesInList character.stats ) dotSize + ] + ] + +vViewStatHorizontal : Stat -> Float -> Html Msg +vViewStatHorizontal stat dotSize = + div [ class "notification" ] + [ div [ class "columns is-vcentered has-text-left"] + [ div [ class "column" ] [ text stat.name ] + , div [ class "column" ] [ viewDots False dotSize stat ] + ] + ] + +vViewQuintParadox : Float -> Html Msg +vViewQuintParadox dotSize = + div [ class "notification" ] + [ nav [ class "level" ] + [ div [ class "level-left" ] + [ div [ class "level-item" ] [ text "Quintessence" ] + ] + , div [ class "level-center is-centered" ] + [ viewDots False dotSize { name = "", dots = BoundedInt.new 0 0 20, statType = Stats.Arete } + ] + , div [ class "level-right" ] + [ div [ class "level-item" ] [ text "Paradox" ] + ] + ] + ] + +vViewNDE : String -> String -> Html Msg +vViewNDE category value = + div [ class "notification has-text-centered" ] + [ div [ class "level-item" ] [ text category ] + , div [ class "level-item" ] [ text value ] + ] + +vViewNotes : String -> Html Msg +vViewNotes notes = + div [ class "notification" ] + [ div [] [ text "Notes" ] + , div [] + [ textarea + [ class "textarea" + , placeholder "Character Notes" + ] + [ text notes ] + ] + ] + +vViewStatList : List Stat -> String -> Float -> Html Msg +vViewStatList stats statTypeName dotSize = + div [ class "notification" ] + [ table [ class "table is-fullwidth" ] + [ thead [] + [ tr [] + [ th [ colspan 2 ] [ text statTypeName ] + ] + ] + , tbody [] + ( List.map ( vViewStat dotSize ) stats ) + ] + ] + +vViewStat : Float -> Stat -> Html Msg +vViewStat dotSize stat = + tr [] + [ td [] [ text stat.name ] + , td [] [ viewDots False dotSize stat ] + ] + +vViewAttributes : List Stat -> Float -> Html Msg +vViewAttributes attributes dotSize = + div [ class "notification" ] + [ table [ class "table is-fullwidth" ] + [ thead [] + [ tr [] + [ th [ colspan 2, style "width" "33%" ] [ text "Physical" ] + , th [ colspan 2, style "width" "33%" ] [ text "Social" ] + , th [ colspan 2, style "width" "33%" ] [ text "Mental" ] + ] + ] + , tbody [] + ( List.map3 ( vView3ColTableStat dotSize ) + ( Stats.attributesOfCategoryInList Stats.Physical attributes ) + ( Stats.attributesOfCategoryInList Stats.Social attributes ) + ( Stats.attributesOfCategoryInList Stats.Mental attributes ) + ) + ] + ] + +vView3ColTableStat : Float -> Stat -> Stat -> Stat -> Html Msg +vView3ColTableStat dotSize a b c = + tr [] + [ td [] [ text a.name ] + , td [] [ viewDots False dotSize a ] + , td [] [ text b.name ] + , td [] [ viewDots False dotSize b ] + , td [] [ text c.name ] + , td [] [ viewDots False dotSize c ] + ] + +vViewAbilities : List Stat -> Float -> Html Msg +vViewAbilities abilities dotSize = + div [ class "notification" ] + [ table [ class "table is-fullwidth" ] + [ thead [] + [ tr [] + [ th [ colspan 2, style "width" "33%" ] [ text "Talents" ] + , th [ colspan 2, style "width" "33%" ] [ text "Skills" ] + , th [ colspan 2, style "width" "33%" ] [ text "Knowledges" ] + ] + ] + , tbody [] + ( List.map3 ( vView3ColTableStat dotSize ) + ( Stats.abilitiesOfCategoryInList Stats.Talent abilities ) + ( Stats.abilitiesOfCategoryInList Stats.Skill abilities ) + ( Stats.abilitiesOfCategoryInList Stats.Knowledge abilities ) + ) + ] + ] + +-- subscriptions + subscriptions : Model -> Sub Msg subscriptions _ = Sub.none