diff --git a/.envrc b/.envrc deleted file mode 100644 index 3550a30..0000000 --- a/.envrc +++ /dev/null @@ -1 +0,0 @@ -use flake diff --git a/flake.lock b/flake.lock index 061263f..66032f3 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1731533236, - "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "lastModified": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", "owner": "numtide", "repo": "flake-utils", - "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", "type": "github" }, "original": { @@ -20,11 +20,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1704290814, - "narHash": "sha256-LWvKHp7kGxk/GEtlrGYV68qIvPHkU9iToomNFGagixU=", + "lastModified": 1699169573, + "narHash": "sha256-cvUb1xZkvOp3W2SzylStrTirhVd9zCeo5utJl9nSIhw=", "owner": "nixos", "repo": "nixpkgs", - "rev": "70bdadeb94ffc8806c0570eb5c2695ad29f0e421", + "rev": "aeefe2054617cae501809b82b44a8e8f7be7cc4b", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 198698b..0390e42 100644 --- a/flake.nix +++ b/flake.nix @@ -35,7 +35,6 @@ haskellPackages.haskell-language-server # you must build it with your ghc to work ghcid cabal-install - stylish-haskell ]; inputsFrom = map (__getAttr "env") (__attrValues self.packages.${system}); }; diff --git a/lib/DND.hs b/lib/DND.hs index c933afb..004e8eb 100644 --- a/lib/DND.hs +++ b/lib/DND.hs @@ -2,10 +2,8 @@ module DND ( module DND.Sheet.Content , module DND.Sheet.Parser , module DND.Bob -, module DND.Dice ) where -import DND.Bob -import DND.Dice -import DND.Sheet.Content -import DND.Sheet.Parser +import DND.Sheet.Content +import DND.Sheet.Parser +import DND.Bob diff --git a/lib/DND/Bob.hs b/lib/DND/Bob.hs index ac462c6..2ee605b 100644 --- a/lib/DND/Bob.hs +++ b/lib/DND/Bob.hs @@ -1,12 +1,12 @@ module DND.Bob (bob) where -import DND.Sheet.Content +import DND.Sheet.Content bob :: Character -bob = Character {skills = testSkills, trivia = testTrivia, stats = testStats, spells = Just testSpells, preamble = testPreamble, feats = Just testFeatures} +bob = Character testPreamble testTrivia testStats (Just testSpells) testStats :: [Stat] -testStats = [strStat, dexStat, conStat, intStat, wisStat, chaStat] +testStats = [strStat,dexStat,conStat,intStat,wisStat,chaStat] testPreamble :: Preamble testPreamble = Preamble 1 "Bob" "Elf" "Fighter" False @@ -15,72 +15,65 @@ testTrivia :: Trivia testTrivia = Trivia "farmer" "none" "I me likey fun things" "yay" "all" "idk" strStat :: Stat -strStat = Stat "Strength" 10 False +strStat = Stat "Strength" 10 False strSkills strSkills :: [Skill] -strSkills = [ Skill "Athletics" None "Strength" ] +strSkills = [ Skill "Athletics" None ] dexStat :: Stat -dexStat = Stat "Dexterity" 10 False +dexStat = Stat "Dexterity" 10 False dexSkills dexSkills :: [Skill] -dexSkills = [ Skill "Acrobatics" None "Dexterity" - , Skill "Sleight of Hand" None "Dexterity" - , Skill "Stealth" None "Dexterity" +dexSkills = [ Skill "Acrobatics" None + , Skill "Sleight of Hand" None + , Skill "Stealth" None ] conStat :: Stat -conStat = Stat "Constitution" 10 False +conStat = Stat "Constitution" 10 False [] intStat :: Stat -intStat = Stat "Intelligence" 10 False +intStat = Stat "Intelligence" 10 False intSkills intSkills :: [Skill] -intSkills = [ Skill "Arcana" None "Intelligence" - , Skill "History" None "Intelligence" - , Skill "Investigation" None "Intelligence" - , Skill "Nature" None "Intelligence" - , Skill "Religion" None "Intelligence" +intSkills = [ Skill "Arcana" None + , Skill "History" None + , Skill "Investigation" None + , Skill "Nature" None + , Skill "Religion" None ] wisStat :: Stat -wisStat = Stat "Wisdom" 10 False +wisStat = Stat "Wisdom" 10 False wisSkills wisSkills :: [Skill] -wisSkills = [ Skill "Animal Handling" None "Wisdom" - , Skill "Insight" None "Wisdom" - , Skill "Medicine" None "Wisdom" - , Skill "Perception" None "Wisdom" - , Skill "Survival" None "Wisdom" +wisSkills = [ Skill "Animal Handling" None + , Skill "Insight" None + , Skill "Medicine" None + , Skill "Perception" None + , Skill "Survival" None ] chaStat :: Stat -chaStat = Stat "Charisma" 10 False +chaStat = Stat "Charisma" 10 False chaSkills chaSkills :: [Skill] -chaSkills = [ Skill "Deception" None "Charisma" - , Skill "Intimidation" None "Charisma" - , Skill "Performance" None "Charisma" - , Skill "Persuasion" None "Charisma" +chaSkills = [ Skill "Deception" None + , Skill "Intimidation" None + , Skill "Performance" None + , Skill "Persuasion" None ] -testSkills :: [Skill] -testSkills = strSkills ++ dexSkills ++ intSkills ++ wisSkills ++ chaSkills - testSpells :: [Spell] -testSpells = [ Spell { spellName = "Firetesticle" - , spellLevel = 3 - , castingTime = "3 Minutes" - , range = 50 - , components = [Verbal, Somatic] - , duration = "Instant" - , attackSave = "Dexterity" - , damageEffect = "Fire" - , description = "Shoots a huge testicle shaped fireball" - , school = "Conjuration" - , atHighLevel = "Cast more of the sodding things" - } +testSpells = [ Spell "Firetesticle" -- spellName + 3 -- spellLevel + "3 Minutes" -- castingTime + 50 -- range + [Verbal, Somatic] -- components + "Instant" -- duration + "Dexterity" -- attackSave + "Fire" -- damge/effect + "Shoots a huge testicle shaped fireball" -- description + "Conjuration" -- school + "Cast more of the sodding things" -- atHighLevel ] - -testFeatures :: [Feature] -testFeatures = [ Roleplay FeatInfo { featName = "fiets", featDescription = "allows you to ride a 'fiets'" } ] diff --git a/lib/DND/Dice.hs b/lib/DND/Dice.hs deleted file mode 100644 index c0f142e..0000000 --- a/lib/DND/Dice.hs +++ /dev/null @@ -1,16 +0,0 @@ -module DND.Dice -( rolls -, d20 -, advantage -) where - -import System.Random - -rolls :: RandomGen a => Int -> Int -> a -> [Int] -rolls x y = take x . randomRs (1, y) - -d20 :: RandomGen a => a -> Int -d20 = minimum . rolls 1 20 - -advantage :: RandomGen a => a -> Int -advantage = maximum . rolls 2 20 diff --git a/lib/DND/Sheet.hs b/lib/DND/Sheet.hs index a6d1e37..cb03f6e 100644 --- a/lib/DND/Sheet.hs +++ b/lib/DND/Sheet.hs @@ -3,5 +3,5 @@ module DND.Sheet , module DND.Sheet.Parser ) where -import DND.Sheet.Content -import DND.Sheet.Parser +import DND.Sheet.Content +import DND.Sheet.Parser diff --git a/lib/DND/Sheet/Content.hs b/lib/DND/Sheet/Content.hs index c714472..bff79a3 100644 --- a/lib/DND/Sheet/Content.hs +++ b/lib/DND/Sheet/Content.hs @@ -10,11 +10,10 @@ module DND.Sheet.Content , Spell(..) , SpellComponent(..) , Feature(..) -, FeatInfo(..) ) where -import Data.Aeson (FromJSON, ToJSON) -import GHC.Generics (Generic) +import Data.Aeson ( FromJSON, ToJSON ) +import GHC.Generics ( Generic ) instance FromJSON Character instance ToJSON Character @@ -37,12 +36,6 @@ instance ToJSON ScoreMod instance FromJSON Spell instance ToJSON Spell -instance FromJSON Feature -instance ToJSON Feature - -instance FromJSON FeatInfo -instance ToJSON FeatInfo - instance FromJSON SpellComponent instance ToJSON SpellComponent @@ -53,54 +46,53 @@ data ScoreMod = None data Character = Character { preamble :: Preamble - , trivia :: Trivia - , stats :: [Stat] - , skills :: [Skill] - , spells :: Maybe [Spell] - , feats :: Maybe [Feature] + , trivia :: Trivia + , stats :: [Stat] + , spells :: Maybe [Spell] + --, feats :: [Feat] } deriving ( Show, Eq, Ord, Generic) data Preamble = Preamble - { charLevel :: Int - , charName :: String - , charRace :: String - , charClass :: String + { charLevel :: Int + , charName :: String + , charRace :: String + , charClass :: String , jackOfAllTrades :: Bool } deriving ( Show, Eq, Ord, Generic) data Trivia = Trivia - { background :: String + { background :: String , personalityTrait :: String - , ideals :: String - , bonds :: String - , flaws :: String - , quirk :: String + , ideals :: String + , bonds :: String + , flaws :: String + , quirk :: String } deriving ( Show, Eq, Ord, Generic) data Skill = Skill - { skillName :: String - , skillMod :: ScoreMod - , relatedStat :: String + { skillName :: String + , skillMod :: ScoreMod } deriving ( Show, Eq, Ord, Generic) data Stat = Stat - { statName :: String - , score :: Int + { stat :: String + , score :: Int , proficient :: Bool + , skills :: [Skill] } deriving ( Show, Eq, Ord, Generic) data Spell = Spell - { spellName :: String - , spellLevel :: Int - , castingTime :: String - , range :: Int - , components :: [SpellComponent] - , duration :: String - , attackSave :: String + { spellName :: String + , spellLevel :: Int + , castingTime :: String + , range :: Int + , components :: [SpellComponent] + , duration :: String + , attackSave :: String , damageEffect :: String - , description :: String - , school :: String - , atHighLevel :: String + , description :: String + , school :: String + , atHighLevel :: String } deriving ( Show, Eq, Ord, Generic) data SpellComponent = Verbal @@ -108,25 +100,21 @@ data SpellComponent = Verbal | Material deriving ( Show, Eq, Ord, Generic) -data FeatInfo = FeatInfo { featName :: String - , featDescription :: String - } deriving ( Show, Eq, Ord, Generic) - data Feature = StatIncrease - { featInfo :: FeatInfo - , increase :: [Stat] } - | SetProficiency - { featInfo :: FeatInfo - , changeModState :: [ScoreMod] + { increase :: [Stat] } + | SetProficiency + { changeModState :: [ScoreMod] + , featDescription :: String } | SetExpertise - { featInfo :: FeatInfo - , changeModState :: [ScoreMod] + { changeModState :: [ScoreMod] + , featDescription :: String } | AddSpell - { featInfo :: FeatInfo - , addSpell :: [Spell] + { addSpell :: [Spell] + , featDescription :: String } - | Roleplay - { featInfo :: FeatInfo } - deriving ( Show, Eq, Ord, Generic) + | Roleplay + { featDescription :: String + } + deriving ( Show, Eq, Ord, Generic) diff --git a/lib/DND/Sheet/Parser.hs b/lib/DND/Sheet/Parser.hs index 29a0620..1be1bbb 100644 --- a/lib/DND/Sheet/Parser.hs +++ b/lib/DND/Sheet/Parser.hs @@ -4,17 +4,16 @@ module DND.Sheet.Parser , listSkills , createExample , getName -, getStat , listSkillNames ) where -import Control.Monad -import Data.Aeson -import qualified Data.ByteString.Lazy as B +import Data.Aeson +import DND.Sheet.Content +import DND.Bob(bob) +import Control.Monad +import qualified Data.ByteString.Lazy as B import qualified Data.ByteString.Lazy.UTF8 as BSU -import Data.Maybe (fromJust) -import DND.Bob (bob) -import DND.Sheet.Content +import Data.Maybe (fromJust) --getSheet :: FilePath -> IO B.ByteString --getSheet = B.readFile @@ -35,6 +34,3 @@ createExample = flip encodeFile bob getName :: Character -> String getName = charName . preamble - -getStat :: Character -> String -> Stat -getStat char s = head . filter (\a -> statName a == s) . stats $ char diff --git a/sheet-parser-hs.cabal b/sheet-parser-hs.cabal index b03ea5f..8d363e0 100644 --- a/sheet-parser-hs.cabal +++ b/sheet-parser-hs.cabal @@ -58,7 +58,6 @@ library exposed-modules: DND , DND.Bob - , DND.Dice , DND.Sheet , DND.Sheet.Content , DND.Sheet.Parser @@ -67,7 +66,6 @@ library , aeson , bytestring , utf8-string - , random hs-source-dirs: lib