diff --git a/public/main.js b/public/main.js index 9e93f342fcff837e471eb53c6a41f3bf8ee93131..354c26200d4889a362f846e696e8e8bfd44f8290 100644 --- a/public/main.js +++ b/public/main.js @@ -5159,21 +5159,54 @@ var $elm$core$Task$perform = F2( A2($elm$core$Task$map, toMessage, task))); }); var $elm$browser$Browser$document = _Browser_document; +var $author$project$OrderedCategories$Ability = {$: 'Ability'}; +var $author$project$OrderedCategories$Attribute = {$: 'Attribute'}; +var $author$project$Stats$Knowledge = {$: 'Knowledge'}; var $author$project$Stats$Mental = {$: 'Mental'}; var $author$project$Stats$Physical = {$: 'Physical'}; +var $author$project$Stats$Skill = {$: 'Skill'}; var $author$project$Stats$Social = {$: 'Social'}; -var $author$project$OrderedAttributeCategories$new = { - order: _List_fromArray( - [$author$project$Stats$Physical, $author$project$Stats$Social, $author$project$Stats$Mental]), - points: _List_fromArray( - [7, 5, 3]) +var $author$project$Stats$Talent = {$: 'Talent'}; +var $author$project$OrderedCategories$new = function (catType) { + if (catType.$ === 'Attribute') { + return { + order: _List_fromArray( + [$author$project$Stats$Physical, $author$project$Stats$Social, $author$project$Stats$Mental]), + points: _List_fromArray( + [7, 5, 3]) + }; + } else { + return { + order: _List_fromArray( + [$author$project$Stats$Talent, $author$project$Stats$Skill, $author$project$Stats$Knowledge]), + points: _List_fromArray( + [13, 9, 5]) + }; + } +}; +var $author$project$Creation$new = { + abilities: $author$project$OrderedCategories$new($author$project$OrderedCategories$Ability), + abilityDotLimit: 3, + attributes: $author$project$OrderedCategories$new($author$project$OrderedCategories$Attribute), + freebie: 15, + spheres: 6 +}; +var $author$project$Stats$Ability = function (a) { + return {$: 'Ability', a: a}; }; -var $author$project$Creation$new = {attributes: $author$project$OrderedAttributeCategories$new, freebie: 15, spheres: 6}; -var $author$project$Stats$Arete = {$: 'Arete'}; var $author$project$BoundedInt$new = F3( function (value, min, max) { return ((_Utils_cmp(value, min) < 0) || ((_Utils_cmp(value, max) > 0) || (_Utils_cmp(min, max) > 0))) ? {max: 0, min: 0, value: 0} : {max: max, min: min, value: value}; }); +var $author$project$Stats$newAbility = F2( + function (category, name) { + return { + dots: A3($author$project$BoundedInt$new, 0, 0, 5), + name: name, + statType: $author$project$Stats$Ability(category) + }; + }); +var $author$project$Stats$Arete = {$: 'Arete'}; var $author$project$Stats$newArete = { dots: A3($author$project$BoundedInt$new, 1, 1, 10), name: 'Arete', @@ -5218,7 +5251,40 @@ var $author$project$Stats$new = _List_fromArray( A2($author$project$Stats$newAttribute, $author$project$Stats$Social, 'Appearance'), A2($author$project$Stats$newAttribute, $author$project$Stats$Mental, 'Perception'), A2($author$project$Stats$newAttribute, $author$project$Stats$Mental, 'Intelligence'), - A2($author$project$Stats$newAttribute, $author$project$Stats$Mental, 'Wits') + A2($author$project$Stats$newAttribute, $author$project$Stats$Mental, 'Wits'), + A2($author$project$Stats$newAbility, $author$project$Stats$Talent, 'Alertness'), + A2($author$project$Stats$newAbility, $author$project$Stats$Talent, 'Art'), + A2($author$project$Stats$newAbility, $author$project$Stats$Talent, 'Athletics'), + A2($author$project$Stats$newAbility, $author$project$Stats$Talent, 'Awareness'), + A2($author$project$Stats$newAbility, $author$project$Stats$Talent, 'Brawl'), + A2($author$project$Stats$newAbility, $author$project$Stats$Talent, 'Empathy'), + A2($author$project$Stats$newAbility, $author$project$Stats$Talent, 'Expression'), + A2($author$project$Stats$newAbility, $author$project$Stats$Talent, 'Intimidation'), + A2($author$project$Stats$newAbility, $author$project$Stats$Talent, 'Leadership'), + A2($author$project$Stats$newAbility, $author$project$Stats$Talent, 'Streetwise'), + A2($author$project$Stats$newAbility, $author$project$Stats$Talent, 'Subterfuge'), + A2($author$project$Stats$newAbility, $author$project$Stats$Skill, 'Crafts'), + A2($author$project$Stats$newAbility, $author$project$Stats$Skill, 'Drive'), + A2($author$project$Stats$newAbility, $author$project$Stats$Skill, 'Etiquette'), + A2($author$project$Stats$newAbility, $author$project$Stats$Skill, 'Firearms'), + A2($author$project$Stats$newAbility, $author$project$Stats$Skill, 'Martial Arts'), + A2($author$project$Stats$newAbility, $author$project$Stats$Skill, 'Meditation'), + A2($author$project$Stats$newAbility, $author$project$Stats$Skill, 'Melee'), + A2($author$project$Stats$newAbility, $author$project$Stats$Skill, 'Research'), + A2($author$project$Stats$newAbility, $author$project$Stats$Skill, 'Stealth'), + A2($author$project$Stats$newAbility, $author$project$Stats$Skill, 'Survival'), + A2($author$project$Stats$newAbility, $author$project$Stats$Skill, 'Technology'), + A2($author$project$Stats$newAbility, $author$project$Stats$Knowledge, 'Academics'), + A2($author$project$Stats$newAbility, $author$project$Stats$Knowledge, 'Computer'), + A2($author$project$Stats$newAbility, $author$project$Stats$Knowledge, 'Cosmology'), + A2($author$project$Stats$newAbility, $author$project$Stats$Knowledge, 'Enigmas'), + A2($author$project$Stats$newAbility, $author$project$Stats$Knowledge, 'Esoterica'), + A2($author$project$Stats$newAbility, $author$project$Stats$Knowledge, 'Investigation'), + A2($author$project$Stats$newAbility, $author$project$Stats$Knowledge, 'Law'), + A2($author$project$Stats$newAbility, $author$project$Stats$Knowledge, 'Medicine'), + A2($author$project$Stats$newAbility, $author$project$Stats$Knowledge, 'Occult'), + A2($author$project$Stats$newAbility, $author$project$Stats$Knowledge, 'Politics'), + A2($author$project$Stats$newAbility, $author$project$Stats$Knowledge, 'Science') ]); var $author$project$Character$new = {creationPoints: $author$project$Creation$new, name: 'Default Name', stats: $author$project$Stats$new}; var $elm$core$Platform$Cmd$batch = _Platform_batch; @@ -5279,7 +5345,7 @@ var $elm$core$Maybe$withDefault = F2( return _default; } }); -var $author$project$OrderedAttributeCategories$categoryAtPosition = F2( +var $author$project$OrderedCategories$categoryAtPosition = F2( function (order, value) { return A2( $elm$core$Maybe$withDefault, @@ -5292,7 +5358,7 @@ var $author$project$OrderedAttributeCategories$categoryAtPosition = F2( }, A2($elm$core$List$indexedMap, $elm$core$Tuple$pair, order)))).b; }); -var $author$project$OrderedAttributeCategories$indexOf = F2( +var $author$project$OrderedCategories$indexOf = F2( function (order, category) { return A2( $elm$core$Maybe$withDefault, @@ -5306,10 +5372,10 @@ var $author$project$OrderedAttributeCategories$indexOf = F2( A2($elm$core$List$indexedMap, $elm$core$Tuple$pair, order)))).a; }); var $elm$core$List$sortBy = _List_sortBy; -var $author$project$OrderedAttributeCategories$changeOrder = F3( - function (oac, category, newIndex) { - var order = oac.order; - var currentIndex = A2($author$project$OrderedAttributeCategories$indexOf, order, category); +var $author$project$OrderedCategories$changeOrder = F3( + function (oCat, category, newIndex) { + var order = oCat.order; + var currentIndex = A2($author$project$OrderedCategories$indexOf, order, category); var unchangedIndex = 3 - (newIndex + currentIndex); var newOrder = _Utils_eq(currentIndex, newIndex) ? order : A2( $elm$core$List$map, @@ -5321,34 +5387,53 @@ var $author$project$OrderedAttributeCategories$changeOrder = F3( [ _Utils_Tuple2( unchangedIndex, - A2($author$project$OrderedAttributeCategories$categoryAtPosition, order, unchangedIndex)), + A2($author$project$OrderedCategories$categoryAtPosition, order, unchangedIndex)), _Utils_Tuple2( currentIndex, - A2($author$project$OrderedAttributeCategories$categoryAtPosition, order, newIndex)), + A2($author$project$OrderedCategories$categoryAtPosition, order, newIndex)), _Utils_Tuple2( newIndex, - A2($author$project$OrderedAttributeCategories$categoryAtPosition, order, currentIndex)) + A2($author$project$OrderedCategories$categoryAtPosition, order, currentIndex)) ]))); return _Utils_update( - oac, + oCat, {order: newOrder}); }); -var $author$project$Creation$changeOrder = F3( - function (cp, category, index) { - return _Utils_update( - cp, - { - attributes: A3($author$project$OrderedAttributeCategories$changeOrder, cp.attributes, category, index) - }); +var $author$project$Creation$changeOrder = F4( + function (cp, catType, category, index) { + if (catType.$ === 'Attribute') { + return _Utils_update( + cp, + { + attributes: A3($author$project$OrderedCategories$changeOrder, cp.attributes, category, index) + }); + } else { + return _Utils_update( + cp, + { + abilities: A3($author$project$OrderedCategories$changeOrder, cp.abilities, category, index) + }); + } }); -var $author$project$Character$changePriority = F3( - function (character, category, value) { +var $author$project$Character$changeOrder = F4( + function (character, catType, category, value) { return _Utils_update( character, { - creationPoints: A3($author$project$Creation$changeOrder, character.creationPoints, category, value) + creationPoints: A4($author$project$Creation$changeOrder, character.creationPoints, catType, category, value) }); }); +var $author$project$Stats$isAbility = function (stat) { + var _v0 = stat.statType; + if (_v0.$ === 'Ability') { + return true; + } else { + return false; + } +}; +var $author$project$Stats$abilitiesInList = function (stats) { + return A2($elm$core$List$filter, $author$project$Stats$isAbility, stats); +}; var $author$project$Stats$isArete = function (stat) { return _Utils_eq(stat.statType, $author$project$Stats$Arete); }; @@ -5434,6 +5519,8 @@ var $author$project$Character$changeStat = F2( return $author$project$Stats$spheresInList(character.stats); case 'Attribute': return $author$project$Stats$attributesInList(character.stats); + case 'Ability': + return $author$project$Stats$abilitiesInList(character.stats); default: return _List_Nil; } @@ -5445,6 +5532,8 @@ var $author$project$Character$changeStat = F2( return $author$project$Stats$areteInList(character.stats).dots.value; case 'Attribute': return stat.dots.max; + case 'Ability': + return character.creationPoints.abilityDotLimit; default: return 0; } @@ -5522,13 +5611,14 @@ var $author$project$Main$update = F2( }), $elm$core$Platform$Cmd$none); default: - var category = msg.a; - var value = msg.b; + var catType = msg.a; + var category = msg.b; + var value = msg.c; return _Utils_Tuple2( _Utils_update( model, { - character: A3($author$project$Character$changePriority, model.character, category, value) + character: A4($author$project$Character$changeOrder, model.character, catType, category, value) }), $elm$core$Platform$Cmd$none); } @@ -5547,6 +5637,97 @@ 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; +var $author$project$Main$ChangePriority = F3( + function (a, b, c) { + return {$: 'ChangePriority', a: a, b: b, c: c}; + }); +var $author$project$Stats$isAbilityOfCategory = F2( + function (category, stat) { + return _Utils_eq( + stat.statType, + $author$project$Stats$Ability(category)); + }); +var $author$project$Stats$abilitiesOfCategoryInList = F2( + function (category, stats) { + return A2( + $elm$core$List$filter, + $author$project$Stats$isAbilityOfCategory(category), + stats); + }); +var $elm$html$Html$button = _VirtualDom_node('button'); +var $author$project$OrderedCategories$categoryValue = F2( + function (oCat, category) { + var index = A2($author$project$OrderedCategories$indexOf, oCat.order, category); + return A2( + $elm$core$Maybe$withDefault, + _Utils_Tuple2(0, 0), + $elm$core$List$head( + A2( + $elm$core$List$filter, + function (x) { + return _Utils_eq(x.a, index); + }, + A2($elm$core$List$indexedMap, $elm$core$Tuple$pair, oCat.points)))).b; + }); +var $elm$core$List$sum = function (numbers) { + return A3($elm$core$List$foldl, $elm$core$Basics$add, 0, numbers); +}; +var $author$project$Stats$count = function (stats) { + return $elm$core$List$sum( + A2( + $elm$core$List$map, + function ($) { + return $.value; + }, + A2( + $elm$core$List$map, + function ($) { + return $.dots; + }, + stats))); +}; +var $elm$core$Basics$compare = _Utils_compare; +var $author$project$Main$creationInfo = function (points) { + var notificationColor = function () { + var _v0 = A2($elm$core$Basics$compare, points, 0); + switch (_v0.$) { + case 'GT': + return 'is-warning'; + case 'EQ': + return 'is-success'; + default: + return 'is-danger'; + } + }(); + return A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('notification ' + notificationColor) + ]), + _List_fromArray( + [ + $elm$html$Html$text( + $elm$core$String$fromInt(points) + ' remaining') + ])); +}; +var $elm$virtual_dom$VirtualDom$Normal = function (a) { + return {$: 'Normal', a: a}; +}; +var $elm$virtual_dom$VirtualDom$on = _VirtualDom_on; +var $elm$html$Html$Events$on = F2( + function (event, decoder) { + return A2( + $elm$virtual_dom$VirtualDom$on, + event, + $elm$virtual_dom$VirtualDom$Normal(decoder)); + }); +var $elm$html$Html$Events$onClick = function (msg) { + return A2( + $elm$html$Html$Events$on, + 'click', + $elm$json$Json$Decode$succeed(msg)); +}; var $elm$core$String$fromFloat = _String_fromNumber; var $elm$svg$Svg$Attributes$height = _VirtualDom_attribute('height'); var $elm$core$List$map3 = _List_map3; @@ -5612,23 +5793,6 @@ var $elm$core$Tuple$mapSecond = F2( x, func(y)); }); -var $elm$virtual_dom$VirtualDom$Normal = function (a) { - return {$: 'Normal', a: a}; -}; -var $elm$virtual_dom$VirtualDom$on = _VirtualDom_on; -var $elm$html$Html$Events$on = F2( - function (event, decoder) { - return A2( - $elm$virtual_dom$VirtualDom$on, - event, - $elm$virtual_dom$VirtualDom$Normal(decoder)); - }); -var $elm$html$Html$Events$onClick = function (msg) { - return A2( - $elm$html$Html$Events$on, - 'click', - $elm$json$Json$Decode$succeed(msg)); -}; var $elm$svg$Svg$Attributes$points = _VirtualDom_attribute('points'); var $elm$svg$Svg$polygon = $elm$svg$Svg$trustedNode('polygon'); var $elm$svg$Svg$Attributes$stroke = _VirtualDom_attribute('stroke'); @@ -5759,6 +5923,138 @@ var $author$project$Main$viewStat = function (stat) { ])) ])); }; +var $author$project$Main$viewAbilityCol = F4( + function (oCat, name, category, abilities) { + 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); + var points = basePoints - $author$project$Stats$count(categoryAbilities); + return A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('column is-one-fifth') + ]), + _Utils_ap( + _List_fromArray( + [ + A2( + $elm$html$Html$p, + _List_Nil, + _List_fromArray( + [ + $elm$html$Html$text(name) + ])), + $author$project$Main$creationInfo(points), + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('field has-addons is-fullwidth') + ]), + _List_fromArray( + [ + A2( + $elm$html$Html$p, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('control is-expanded') + ]), + _List_fromArray( + [ + A2( + $elm$html$Html$button, + _List_fromArray( + [ + $elm$html$Html$Attributes$class( + 'button is-small is-fullwidth' + ((!index) ? ' is-primary' : '')), + $elm$html$Html$Events$onClick( + A3($author$project$Main$ChangePriority, $author$project$OrderedCategories$Ability, category, 0)) + ]), + _List_fromArray( + [ + $elm$html$Html$text('I') + ])) + ])), + A2( + $elm$html$Html$p, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('control is-expanded') + ]), + _List_fromArray( + [ + A2( + $elm$html$Html$button, + _List_fromArray( + [ + $elm$html$Html$Attributes$class( + 'button is-small is-fullwidth' + ((index === 1) ? ' is-primary' : '')), + $elm$html$Html$Events$onClick( + A3($author$project$Main$ChangePriority, $author$project$OrderedCategories$Ability, category, 1)) + ]), + _List_fromArray( + [ + $elm$html$Html$text('II') + ])) + ])), + A2( + $elm$html$Html$p, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('control is-expanded') + ]), + _List_fromArray( + [ + A2( + $elm$html$Html$button, + _List_fromArray( + [ + $elm$html$Html$Attributes$class( + 'button is-small is-fullwidth' + ((index === 2) ? ' is-primary' : '')), + $elm$html$Html$Events$onClick( + A3($author$project$Main$ChangePriority, $author$project$OrderedCategories$Ability, category, 2)) + ]), + _List_fromArray( + [ + $elm$html$Html$text('III') + ])) + ])) + ])) + ]), + A2($elm$core$List$map, $author$project$Main$viewStat, categoryAbilities))); + }); +var $author$project$Main$viewAbilities = F2( + function (oCat, abilities) { + 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('Abilities') + ])), + A2( + $elm$html$Html$div, + _List_fromArray( + [ + $elm$html$Html$Attributes$class('columns is-centered is-mobile') + ]), + _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) + ])) + ])); + }); var $author$project$Main$viewArete = function (arete) { return A2( $elm$html$Html$div, @@ -5789,10 +6085,6 @@ var $author$project$Main$viewArete = function (arete) { ])) ])); }; -var $author$project$Main$ChangePriority = F2( - function (a, b) { - return {$: 'ChangePriority', a: a, b: b}; - }); var $author$project$Stats$isAttributeOfCategory = F2( function (category, stat) { return _Utils_eq( @@ -5806,68 +6098,11 @@ var $author$project$Stats$attributesOfCategoryInList = F2( $author$project$Stats$isAttributeOfCategory(category), stats); }); -var $elm$html$Html$button = _VirtualDom_node('button'); -var $author$project$OrderedAttributeCategories$categoryValue = F2( - function (oac, category) { - var index = A2($author$project$OrderedAttributeCategories$indexOf, oac.order, category); - return A2( - $elm$core$Maybe$withDefault, - _Utils_Tuple2(0, 0), - $elm$core$List$head( - A2( - $elm$core$List$filter, - function (x) { - return _Utils_eq(x.a, index); - }, - A2($elm$core$List$indexedMap, $elm$core$Tuple$pair, oac.points)))).b; - }); -var $elm$core$List$sum = function (numbers) { - return A3($elm$core$List$foldl, $elm$core$Basics$add, 0, numbers); -}; -var $author$project$Stats$count = function (stats) { - return $elm$core$List$sum( - A2( - $elm$core$List$map, - function ($) { - return $.value; - }, - A2( - $elm$core$List$map, - function ($) { - return $.dots; - }, - stats))); -}; -var $elm$core$Basics$compare = _Utils_compare; -var $author$project$Main$creationInfo = function (points) { - var notificationColor = function () { - var _v0 = A2($elm$core$Basics$compare, points, 0); - switch (_v0.$) { - case 'GT': - return 'is-warning'; - case 'EQ': - return 'is-success'; - default: - return 'is-danger'; - } - }(); - return A2( - $elm$html$Html$div, - _List_fromArray( - [ - $elm$html$Html$Attributes$class('notification ' + notificationColor) - ]), - _List_fromArray( - [ - $elm$html$Html$text( - $elm$core$String$fromInt(points) + ' remaining') - ])); -}; var $author$project$Main$viewAttributeCol = F4( - function (oac, name, category, attributes) { - var index = A2($author$project$OrderedAttributeCategories$indexOf, oac.order, category); + function (oCat, name, category, attributes) { + var index = A2($author$project$OrderedCategories$indexOf, oCat.order, category); var categoryAttributes = A2($author$project$Stats$attributesOfCategoryInList, category, attributes); - var basePoints = A2($author$project$OrderedAttributeCategories$categoryValue, oac, category); + var basePoints = A2($author$project$OrderedCategories$categoryValue, oCat, category); var points = (basePoints - $author$project$Stats$count(categoryAttributes)) + $elm$core$List$length(categoryAttributes); return A2( $elm$html$Html$div, @@ -5909,7 +6144,7 @@ var $author$project$Main$viewAttributeCol = F4( $elm$html$Html$Attributes$class( 'button is-small is-fullwidth' + ((!index) ? ' is-primary' : '')), $elm$html$Html$Events$onClick( - A2($author$project$Main$ChangePriority, category, 0)) + A3($author$project$Main$ChangePriority, $author$project$OrderedCategories$Attribute, category, 0)) ]), _List_fromArray( [ @@ -5931,7 +6166,7 @@ var $author$project$Main$viewAttributeCol = F4( $elm$html$Html$Attributes$class( 'button is-small is-fullwidth' + ((index === 1) ? ' is-primary' : '')), $elm$html$Html$Events$onClick( - A2($author$project$Main$ChangePriority, category, 1)) + A3($author$project$Main$ChangePriority, $author$project$OrderedCategories$Attribute, category, 1)) ]), _List_fromArray( [ @@ -5953,7 +6188,7 @@ var $author$project$Main$viewAttributeCol = F4( $elm$html$Html$Attributes$class( 'button is-small is-fullwidth' + ((index === 2) ? ' is-primary' : '')), $elm$html$Html$Events$onClick( - A2($author$project$Main$ChangePriority, category, 2)) + A3($author$project$Main$ChangePriority, $author$project$OrderedCategories$Attribute, category, 2)) ]), _List_fromArray( [ @@ -5965,7 +6200,7 @@ var $author$project$Main$viewAttributeCol = F4( A2($elm$core$List$map, $author$project$Main$viewStat, categoryAttributes))); }); var $author$project$Main$viewAttributes = F2( - function (oac, attributes) { + function (oCat, attributes) { return A2( $elm$html$Html$div, _List_fromArray( @@ -5989,9 +6224,9 @@ var $author$project$Main$viewAttributes = F2( ]), _List_fromArray( [ - A4($author$project$Main$viewAttributeCol, oac, 'Physical', $author$project$Stats$Physical, attributes), - A4($author$project$Main$viewAttributeCol, oac, 'Social', $author$project$Stats$Social, attributes), - A4($author$project$Main$viewAttributeCol, oac, 'Mental', $author$project$Stats$Mental, attributes) + 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) ])) ])); }); @@ -6329,6 +6564,7 @@ var $author$project$Main$view = function (model) { [ 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), A2( $author$project$Main$viewSpheres, model.character.creationPoints, diff --git a/src/Character.elm b/src/Character.elm index 96325d11be652851ee12395054f5ed804acf271c..20929506065912c02ff258bc9168c54bd5514bdd 100644 --- a/src/Character.elm +++ b/src/Character.elm @@ -1,8 +1,9 @@ module Character exposing (..) import Creation exposing (CreationPoints) -import Stats exposing (Stat, AttributeCategory) +import Stats exposing (Stat, Category) import BoundedInt exposing (BoundedInt) +import OrderedCategories as OCat exposing (CategoriesType) type alias Character = { name : String @@ -36,12 +37,14 @@ changeStat character stat = stats = case statType of Stats.Sphere -> Stats.spheresInList character.stats Stats.Attribute _ -> Stats.attributesInList character.stats + Stats.Ability _ -> Stats.abilitiesInList character.stats _ -> [] max : Int max = case statType of Stats.Sphere -> ( Stats.areteInList character.stats ).dots.value Stats.Attribute _ -> stat.dots.max + Stats.Ability _ -> character.creationPoints.abilityDotLimit _ -> 0 maybeOldDots : Maybe BoundedInt @@ -61,8 +64,8 @@ changeStat character stat = | stats = Stats.changeStatInList character.stats ( Stats.changeDotsTo stat ( oldDots.value + difference ) ) } -changePriority : Character -> AttributeCategory -> Int -> Character -changePriority character category value = +changeOrder : Character -> CategoriesType -> Category -> Int -> Character +changeOrder character catType category value = { character - | creationPoints = Creation.changeOrder character.creationPoints category value + | creationPoints = Creation.changeOrder character.creationPoints catType category value } \ No newline at end of file diff --git a/src/Creation.elm b/src/Creation.elm index 5e86cbbfed2d394444cbc4650b44f297567a0078..6fa81db9a4363779749a94a998dc926f4ef29fa7 100644 --- a/src/Creation.elm +++ b/src/Creation.elm @@ -1,19 +1,23 @@ module Creation exposing (..) -import OrderedAttributeCategories exposing (OAC) -import Stats exposing (AttributeCategory) +import OrderedCategories as OCat exposing (OCat, CategoriesType) +import Stats exposing (Category) type alias CreationPoints = { freebie : Int , spheres : Int - , attributes : OAC + , attributes : OCat + , abilities : OCat + , abilityDotLimit : Int } new : CreationPoints new = { freebie = 15 , spheres = 6 - , attributes = OrderedAttributeCategories.new + , attributes = OCat.new OCat.Attribute + , abilities = OCat.new OCat.Ability + , abilityDotLimit = 3 } cost : @@ -23,6 +27,14 @@ cost = { sphere = 7 } -changeOrder : CreationPoints -> AttributeCategory -> Int -> CreationPoints -changeOrder cp category index = - { cp | attributes = OrderedAttributeCategories.changeOrder cp.attributes category index } \ No newline at end of file +changeOrder : CreationPoints -> CategoriesType -> Category -> Int -> CreationPoints +changeOrder cp catType category index = + case catType of + OCat.Attribute -> + { cp + | attributes = OCat.changeOrder cp.attributes category index + } + OCat.Ability -> + { cp + | abilities = OCat.changeOrder cp.abilities category index + } \ No newline at end of file diff --git a/src/Main.elm b/src/Main.elm index 8485b668de232c2eb50bebc488ee5b7bf729f2ab..c355f1194b91f6bf517ff77a224a4178b7e73125 100644 --- a/src/Main.elm +++ b/src/Main.elm @@ -9,9 +9,9 @@ import Svg.Attributes import Character exposing (Character) import Stats exposing (Stat) import BoundedInt exposing (BoundedInt) -import Stats exposing (AttributeCategory) +import Stats exposing (Category) import Creation exposing (CreationPoints) -import OrderedAttributeCategories as OAC exposing (OAC) +import OrderedCategories as OCat exposing (OCat, CategoriesType) main : Program () Model Msg main = @@ -43,7 +43,7 @@ type Msg | ChangeModalValue String | SaveModalChange ModalType | ChangeStat Stat - | ChangePriority AttributeCategory Int + | ChangePriority CategoriesType Category Int type ModalType = Name @@ -81,9 +81,9 @@ update msg model = } , Cmd.none ) - ChangePriority category value -> + ChangePriority catType category value -> ( { model - | character = Character.changePriority model.character category value + | character = Character.changeOrder model.character catType category value } , Cmd.none ) @@ -95,6 +95,7 @@ view model = [ div [ class "container is-max-desktop" ] [ viewEditableText Name model.character.name , viewAttributes model.character.creationPoints.attributes model.character.stats + , viewAbilities model.character.creationPoints.abilities model.character.stats , viewSpheres model.character.creationPoints ( Stats.spheresInList model.character.stats ) , viewArete ( Stats.areteInList model.character.stats ) , viewModal model @@ -118,27 +119,27 @@ viewEditableText modalType content = ] ] -viewAttributes : OAC -> List Stat -> Html Msg -viewAttributes oac attributes = +viewAttributes : OCat -> List Stat -> Html Msg +viewAttributes oCat attributes = div [ class "has-text-centered" ] [ p [] [ text "Attributes" ] , div [ class "columns is-centered is-mobile" ] - [ viewAttributeCol oac "Physical" Stats.Physical attributes - , viewAttributeCol oac "Social" Stats.Social attributes - , viewAttributeCol oac "Mental" Stats.Mental attributes + [ viewAttributeCol oCat "Physical" Stats.Physical attributes + , viewAttributeCol oCat "Social" Stats.Social attributes + , viewAttributeCol oCat "Mental" Stats.Mental attributes ] ] -viewAttributeCol : OAC -> String -> AttributeCategory -> List Stat -> Html Msg -viewAttributeCol oac name category attributes = +viewAttributeCol : OCat -> String -> Category -> List Stat -> Html Msg +viewAttributeCol oCat name category attributes = let categoryAttributes : List Stat categoryAttributes = Stats.attributesOfCategoryInList category attributes index : Int - index = OAC.indexOf oac.order category + index = OCat.indexOf oCat.order category basePoints : Int - basePoints = OAC.categoryValue oac category + basePoints = OCat.categoryValue oCat category points : Int points = basePoints - ( Stats.count categoryAttributes ) + ( List.length categoryAttributes ) in @@ -149,19 +150,19 @@ viewAttributeCol oac name category attributes = [ p [ class "control is-expanded" ] [ button [ class ( "button is-small is-fullwidth" ++ if index == 0 then " is-primary" else "" ) - , onClick ( ChangePriority category 0 ) + , onClick ( ChangePriority OCat.Attribute category 0 ) ] [ text "I" ] ] , p [ class "control is-expanded" ] [ button [ class ( "button is-small is-fullwidth" ++ if index == 1 then " is-primary" else "" ) - , onClick ( ChangePriority category 1 ) + , onClick ( ChangePriority OCat.Attribute category 1 ) ] [ text "II" ] ] , p [ class "control is-expanded" ] [ button [ class ( "button is-small is-fullwidth" ++ if index == 2 then " is-primary" else "" ) - , onClick ( ChangePriority category 2 ) + , onClick ( ChangePriority OCat.Attribute category 2 ) ] [ text "III" ] ] ] @@ -171,6 +172,60 @@ viewAttributeCol oac name category attributes = ) ) +viewAbilities : OCat -> List Stat -> Html Msg +viewAbilities oCat abilities = + div [ class "has-text-centered" ] + [ p [] [ text "Abilities" ] + , div [ class "columns is-centered is-mobile" ] + [ viewAbilityCol oCat "Talents" Stats.Talent abilities + , viewAbilityCol oCat "Skills" Stats.Skill abilities + , viewAbilityCol oCat "Knowledges" Stats.Knowledge abilities + ] + ] + +viewAbilityCol : OCat -> String -> Category -> List Stat -> Html Msg +viewAbilityCol oCat name category abilities = + let + categoryAbilities : List Stat + categoryAbilities = Stats.abilitiesOfCategoryInList category abilities + + index : Int + index = OCat.indexOf oCat.order category + basePoints : Int + basePoints = OCat.categoryValue oCat category + points : Int + points = basePoints - ( Stats.count categoryAbilities ) + in + div [ class "column is-one-fifth" ] + ( [ p [] [ text name ] + , creationInfo points + , div [ class "field has-addons is-fullwidth" ] + [ p [ class "control is-expanded" ] + [ button + [ class ( "button is-small is-fullwidth" ++ if index == 0 then " is-primary" else "" ) + , onClick ( ChangePriority OCat.Ability category 0 ) + ] [ text "I" ] + ] + , p [ class "control is-expanded" ] + [ button + [ class ( "button is-small is-fullwidth" ++ if index == 1 then " is-primary" else "" ) + , onClick ( ChangePriority OCat.Ability category 1 ) + ] [ text "II" ] + ] + , p [ class "control is-expanded" ] + [ button + [ class ( "button is-small is-fullwidth" ++ if index == 2 then " is-primary" else "" ) + , onClick ( ChangePriority OCat.Ability category 2 ) + ] [ text "III" ] + ] + ] + ] + ++ + ( List.map viewStat categoryAbilities + ) + ) + + viewSpheres : CreationPoints -> List Stat -> Html Msg viewSpheres cp spheres = let diff --git a/src/OrderedAttributeCategories.elm b/src/OrderedCategories.elm similarity index 52% rename from src/OrderedAttributeCategories.elm rename to src/OrderedCategories.elm index d5a444cbb90a7972d6657a56f0bd01ce8c292b3a..7d5cb9989ec13acc54898817fe18bfb93692247a 100644 --- a/src/OrderedAttributeCategories.elm +++ b/src/OrderedCategories.elm @@ -1,28 +1,38 @@ -module OrderedAttributeCategories exposing (..) +module OrderedCategories exposing (..) -import Stats exposing (AttributeCategory) +import Stats exposing (Category) -type alias OrderedAttributeCategories = +type CategoriesType + = Attribute + | Ability + +type alias OrderedCategories = { points : List Int - , order : List AttributeCategory + , order : List Category } -type alias OAC = OrderedAttributeCategories +type alias OCat = OrderedCategories -new : OAC -new = - { points = [ 7, 5, 3 ] - , order = - [ Stats.Physical - , Stats.Social - , Stats.Mental - ] - } +new : CategoriesType -> OCat +new catType = + case catType of + Attribute -> + { points = [ 7, 5, 3 ] + , order = + [ Stats.Physical + , Stats.Social + , Stats.Mental + ] + } + Ability -> + { points = [ 13, 9, 5 ] + , order = + [ Stats.Talent + , Stats.Skill + , Stats.Knowledge + ] + } -type alias Priority = - { value : Int - , category : AttributeCategory - } -indexOf : List AttributeCategory -> AttributeCategory -> Int +indexOf : List Category -> Category -> Int indexOf order category = order |> List.indexedMap Tuple.pair @@ -31,7 +41,7 @@ indexOf order category = |> Maybe.withDefault ( -1, Stats.Physical ) |> Tuple.first -categoryAtPosition : List AttributeCategory -> Int -> AttributeCategory +categoryAtPosition : List Category -> Int -> Category categoryAtPosition order value = order |> List.indexedMap Tuple.pair @@ -40,11 +50,11 @@ categoryAtPosition order value = |> Maybe.withDefault ( -1, Stats.Physical ) |> Tuple.second -changeOrder : OAC -> AttributeCategory -> Int -> OAC -changeOrder oac category newIndex = +changeOrder : OCat -> Category -> Int -> OCat +changeOrder oCat category newIndex = let - order : List AttributeCategory - order = oac.order + order : List Category + order = oCat.order currentIndex : Int currentIndex = indexOf order category @@ -52,7 +62,7 @@ changeOrder oac category newIndex = unchangedIndex : Int unchangedIndex = 3 - ( newIndex + currentIndex ) - newOrder : List AttributeCategory + newOrder : List Category newOrder = if currentIndex == newIndex then order @@ -64,15 +74,15 @@ changeOrder oac category newIndex = |> List.sortBy Tuple.first |> List.map Tuple.second in - { oac | order = newOrder } + { oCat | order = newOrder } -categoryValue : OAC -> AttributeCategory -> Int -categoryValue oac category = +categoryValue : OCat -> Category -> Int +categoryValue oCat category = let index : Int - index = indexOf oac.order category + index = indexOf oCat.order category in - oac.points + oCat.points |> List.indexedMap Tuple.pair |> List.filter ( \x -> Tuple.first x == index ) |> List.head diff --git a/src/Stats.elm b/src/Stats.elm index 6ed451257eb8c5afbfe9d1c8dc9f4622ac9eeebf..f527e6eb0d84a35fe9db1c819893d39bbb993a7c 100644 --- a/src/Stats.elm +++ b/src/Stats.elm @@ -11,12 +11,18 @@ type alias Stat = type StatType = Sphere | Arete - | Attribute AttributeCategory + | Attribute Category + | Ability Category -type AttributeCategory +type Category + -- Attributes = Physical | Social | Mental + -- Abilities + | Talent + | Skill + | Knowledge new : List Stat new = @@ -39,6 +45,39 @@ new = , newAttribute Mental "Perception" , newAttribute Mental "Intelligence" , newAttribute Mental "Wits" + , newAbility Talent "Alertness" + , newAbility Talent "Art" + , newAbility Talent "Athletics" + , newAbility Talent "Awareness" + , newAbility Talent "Brawl" + , newAbility Talent "Empathy" + , newAbility Talent "Expression" + , newAbility Talent "Intimidation" + , newAbility Talent "Leadership" + , newAbility Talent "Streetwise" + , newAbility Talent "Subterfuge" + , newAbility Skill "Crafts" + , newAbility Skill "Drive" + , newAbility Skill "Etiquette" + , newAbility Skill "Firearms" + , newAbility Skill "Martial Arts" + , newAbility Skill "Meditation" + , newAbility Skill "Melee" + , newAbility Skill "Research" + , newAbility Skill "Stealth" + , newAbility Skill "Survival" + , newAbility Skill "Technology" + , newAbility Knowledge "Academics" + , newAbility Knowledge "Computer" + , newAbility Knowledge "Cosmology" + , newAbility Knowledge "Enigmas" + , newAbility Knowledge "Esoterica" + , newAbility Knowledge "Investigation" + , newAbility Knowledge "Law" + , newAbility Knowledge "Medicine" + , newAbility Knowledge "Occult" + , newAbility Knowledge "Politics" + , newAbility Knowledge "Science" ] newSphere : String -> Stat @@ -55,13 +94,20 @@ newArete = , statType = Arete } -newAttribute : AttributeCategory -> String -> Stat +newAttribute : Category -> String -> Stat newAttribute category name = { name = name , dots = BoundedInt.new 1 1 5 , statType = Attribute category } +newAbility : Category -> String -> Stat +newAbility category name = + { name = name + , dots = BoundedInt.new 0 0 5 + , statType = Ability category + } + spheresInList : List Stat -> List Stat spheresInList stats = List.filter isSphere stats @@ -93,14 +139,32 @@ isAttribute stat = Attribute _ -> True _ -> False -attributesOfCategoryInList : AttributeCategory -> List Stat -> List Stat +attributesOfCategoryInList : Category -> List Stat -> List Stat attributesOfCategoryInList category stats = List.filter ( isAttributeOfCategory category ) stats -isAttributeOfCategory : AttributeCategory -> Stat -> Bool +isAttributeOfCategory : Category -> Stat -> Bool isAttributeOfCategory category stat = stat.statType == Attribute category +abilitiesInList : List Stat -> List Stat +abilitiesInList stats = + List.filter isAbility stats + +isAbility : Stat -> Bool +isAbility stat = + case stat.statType of + Ability _ -> True + _ -> False + +abilitiesOfCategoryInList : Category -> List Stat -> List Stat +abilitiesOfCategoryInList category stats = + List.filter ( isAbilityOfCategory category ) stats + +isAbilityOfCategory : Category -> Stat -> Bool +isAbilityOfCategory category stat = + stat.statType == Ability category + dotsOfStatInList : List Stat -> String -> Maybe BoundedInt dotsOfStatInList stats name = let