Code cleanup, rearranging modules.

parent 3c5955a5
-- Data
module Roguestar.Lib.Alignment
(Alignment,
MoralAlignment(..),
EthicalAlignment(..),
alignments,
alignmentMoralPotency,
alignmentEthicalPotency,
alignmentPotency)
where
data MoralAlignment = Lawful | Neutral | Chaotic | Evil deriving (Eq,Read,Show,Ord)
data EthicalAlignment = Strategic | Tactical | Diplomatic | Indifferent deriving (Eq,Read,Show,Ord)
type Alignment = (MoralAlignment,EthicalAlignment)
alignments :: [Alignment]
alignments =
do moral <- [Lawful,Neutral,Chaotic,Evil]
ethical <- [Strategic,Tactical,Diplomatic,Indifferent]
return (moral,ethical)
alignmentMoralPotency :: MoralAlignment -> Integer
alignmentMoralPotency Lawful = 6
alignmentMoralPotency Chaotic = 3
alignmentMoralPotency Neutral = 1
alignmentMoralPotency Evil = 10
alignmentEthicalPotency :: EthicalAlignment -> Integer
alignmentEthicalPotency Strategic = 7
alignmentEthicalPotency Tactical = 2
alignmentEthicalPotency Diplomatic = 4
alignmentEthicalPotency Indifferent = 10
alignmentPotency :: Alignment -> Integer
alignmentPotency (moral,ethical) = alignmentMoralPotency moral * alignmentEthicalPotency ethical
......@@ -18,7 +18,7 @@ import Data.Ratio
import Roguestar.Lib.Tool
import Control.Monad.Error
import Roguestar.Lib.Behavior.Combat
import Roguestar.Lib.Activate
import Roguestar.Lib.Behavior.Activate
import Roguestar.Lib.Behavior.Travel
import Roguestar.Lib.TravelData
import Roguestar.Lib.Creature
......@@ -29,7 +29,7 @@ import Data.List
import Roguestar.Lib.TerrainData
import Roguestar.Lib.Behavior.Make
import Roguestar.Lib.Behavior.Construction
import Roguestar.Lib.Building
import Roguestar.Lib.Core.Building
import Roguestar.Lib.Reference
import Roguestar.Lib.DetailedLocation
import Roguestar.Lib.PlaneData
......
-- Mechanics
module Roguestar.Lib.Activate
module Roguestar.Lib.Behavior.Activate
(ActivationOutcome,
resolveActivation,
executeActivation)
......
The Behavior module contains rules for resolving various types of character behaviors, such as moving, attacking, or crafting an item. Most behavior rules use a resolve-execute pattern. In the resolve phase, we construct a probability table describing the possible outcomes. In the execute phase, we randomly select a possibility from the table and cause it to happen.
Some older code generates the outcome directly, without generating the probability table. I would hope to upgrade the code to the newer style.
......@@ -13,6 +13,8 @@ import Roguestar.Lib.CreatureData
import Roguestar.Lib.PowerUpData
import Roguestar.Lib.PersistantData
-- TODO: rename "bump" to more clear language, like "advance" or "advanceCharacterLevel".
data CharacterBumpResult =
CharacterAwarded { character_points_awarded :: Integer,
character_new :: Creature }
......
{-# LANGUAGE ScopedTypeVariables #-}
--Core
module Roguestar.Lib.Building
module Roguestar.Lib.Core.Building
(buildingSize,
buildingShape,
buildingBehavior,
......@@ -10,7 +10,7 @@ module Roguestar.Lib.Building
import Prelude hiding (getContents)
import Roguestar.Lib.DB
import Roguestar.Lib.BuildingData
import Roguestar.Lib.Data.BuildingData
import Data.List
import Roguestar.Lib.Facing
import Data.Maybe
......
......@@ -35,7 +35,7 @@ import Roguestar.Lib.Data.PlayerState
import Roguestar.Lib.FactionData
import Roguestar.Lib.DetailedLocation
import qualified Data.ByteString.Char8 as B
import Roguestar.Lib.BuildingData
import Roguestar.Lib.Data.BuildingData
import Roguestar.Lib.Logging
import Control.Monad.Maybe
import Control.Monad.Trans
......
The Core module contains descriptions and rules for the basic game elements: monsters, planes, buildings, and tools. This module doesn't really contain any game mechanics, just ways to manipulate the elements.
The concept of a "plane" may require some explanation. A plane is a single layer of terrain, on which monsters, buildings, and tools may be placed. A single planet might consist of one surface plane with multiple below-ground dungeon planes.
......@@ -59,7 +59,7 @@ import Roguestar.Lib.DBData
import Roguestar.Lib.Reference
import Roguestar.Lib.CreatureData
import Roguestar.Lib.PlaneData
import Roguestar.Lib.BuildingData
import Roguestar.Lib.Data.BuildingData
import Roguestar.Lib.RNG
import Data.Map as Map
import Data.List as List
......
......@@ -35,7 +35,7 @@ import Roguestar.Lib.DBPrivate
import Roguestar.Lib.ToolData
import Roguestar.Lib.CreatureData
import Roguestar.Lib.PlaneData
import Roguestar.Lib.BuildingData
import Roguestar.Lib.Data.BuildingData
import Control.Monad
import Roguestar.Lib.Position
import Roguestar.Lib.Reference
......
......@@ -24,7 +24,7 @@ import Roguestar.Lib.Facing
import Roguestar.Lib.CreatureData
import Roguestar.Lib.ToolData
import Roguestar.Lib.PlaneData
import Roguestar.Lib.BuildingData
import Roguestar.Lib.Data.BuildingData
import Roguestar.Lib.PlanetData
import Roguestar.Lib.Position
......
-- Data
module Roguestar.Lib.BuildingData
module Roguestar.Lib.Data.BuildingData
(Building(..),
BuildingBehavior(..),
BuildingShape(..),
......@@ -47,9 +47,6 @@ buildingOccupies Anchor = [(0,0)]
-- XXX
--
buildingOccupies Portal = [(0,0),(3,0),(3,1),(3,-1),(-3,0),(-3,1),(-3,-1),(0,3),(-1,3),(1,3),(0,-3),(-1,-3),(1,-3)]
-- Cybergate: XXX
-- XX XX
-- XX XX
-- X X
buildingOccupies CyberGate = [(-3,-3),(-3,-2),(-2,-2),(-2,-1),(-1,-1),(-1,0),(0,0),(1,-1),(1,0),(2,-2),(2,-1),(3,-3),(3,-2)]
......@@ -19,7 +19,7 @@ module Roguestar.Lib.DetailedLocation
import Roguestar.Lib.DBData
import Roguestar.Lib.PlaneData
import Roguestar.Lib.BuildingData
import Roguestar.Lib.Data.BuildingData
import Roguestar.Lib.ToolData
import Roguestar.Lib.CreatureData
import Roguestar.Lib.Position
......
......@@ -43,8 +43,8 @@ import Control.Applicative
import Roguestar.Lib.Facing
import Roguestar.Lib.Position as Position
import Roguestar.Lib.TerrainData
import Roguestar.Lib.BuildingData
import Roguestar.Lib.Building
import Roguestar.Lib.Data.BuildingData
import Roguestar.Lib.Core.Building
import Roguestar.Lib.Core.Plane
import Roguestar.Lib.DetailedLocation
import Roguestar.Lib.SpeciesData
......
......@@ -20,7 +20,7 @@ import Roguestar.Lib.GridRayCaster
import Roguestar.Lib.VisibilityData
import Roguestar.Lib.Facing
import Data.Ratio
import Roguestar.Lib.Building
import Roguestar.Lib.Core.Building
import Roguestar.Lib.Position as Position
import Control.Applicative
import Roguestar.Lib.Reference
......
......@@ -18,7 +18,7 @@ import Roguestar.Lib.Town
import Data.List
import Data.ByteString.Char8 as B
import Roguestar.Lib.FactionData
import Roguestar.Lib.BuildingData
import Roguestar.Lib.Data.BuildingData
makePlanet :: (LocationConstructor l, ReferenceTypeOf l ~ Plane) => l -> PlanetInfo -> DB PlaneRef
makePlanet plane_location planet_info =
......
......@@ -11,7 +11,7 @@ module Roguestar.Lib.PlanetData
import Roguestar.Lib.PersistantData
import Roguestar.Lib.TerrainData
import Roguestar.Lib.BuildingData
import Roguestar.Lib.Data.BuildingData
import qualified Roguestar.Lib.Random as Random
import Data.Ratio
import qualified Data.ByteString.Char8 as B
......
......@@ -9,7 +9,7 @@ module Roguestar.Lib.Reference
import Roguestar.Lib.DBPrivate
import Roguestar.Lib.PlaneData
import Roguestar.Lib.BuildingData
import Roguestar.Lib.Data.BuildingData
import Roguestar.Lib.ToolData
import Roguestar.Lib.CreatureData
......
......@@ -41,7 +41,7 @@ import Roguestar.Lib.Data.PlayerState
import Roguestar.Lib.SpeciesData
import Roguestar.Lib.Creature
import Roguestar.Lib.CreatureData
import Roguestar.Lib.BeginGame as BeginGame
import Roguestar.Lib.World.BeginGame as BeginGame
import Roguestar.Lib.Perception
import Roguestar.Lib.TerrainData
import Roguestar.Lib.Facing
......
......@@ -3,7 +3,7 @@ module Roguestar.Lib.Town
(createTown)
where
import Roguestar.Lib.BuildingData
import Roguestar.Lib.Data.BuildingData
import Roguestar.Lib.DB
import Roguestar.Lib.Utility.SiteCriteria
import Data.List as List
......
{-# LANGUAGE OverloadedStrings #-}
module Roguestar.Lib.BeginGame
module Roguestar.Lib.World.BeginGame
(beginGame)
where
-- World
import Roguestar.Lib.Core.Plane
import Roguestar.Lib.CreatureData
import Roguestar.Lib.BuildingData
import Roguestar.Lib.Data.BuildingData
import Roguestar.Lib.DB
import Roguestar.Lib.Facing
import Roguestar.Lib.TerrainData
......
......@@ -59,13 +59,12 @@ library
other-modules: Roguestar.Lib.TravelData,
Roguestar.Lib.VisibilityData,
Roguestar.Lib.FactionData,
Roguestar.Lib.Behavior,
Roguestar.Lib.Alignment,
Roguestar.Lib.PlaneData,
Roguestar.Lib.Grids,
Roguestar.Lib.Perception,
Roguestar.Lib.PlaneVisibility,
Roguestar.Lib.Turns,
Roguestar.Lib.Core.Building,
Roguestar.Lib.Core.Plane,
Roguestar.Lib.Utility.SiteCriteria,
Roguestar.Lib.CreatureData,
......@@ -86,18 +85,17 @@ library
Roguestar.Lib.Tests,
Roguestar.Lib.DBData,
Roguestar.Lib.GridRayCaster,
Roguestar.Lib.BeginGame,
Roguestar.Lib.World.BeginGame,
Roguestar.Lib.SpeciesData,
Roguestar.Lib.TimeCoordinate,
Roguestar.Lib.DB,
Roguestar.Lib.Building,
Roguestar.Lib.BuildingData,
Roguestar.Lib.Town,
Roguestar.Lib.Random,
Roguestar.Lib.MakeData,
Roguestar.Lib.Behavior,
Roguestar.Lib.Behavior.Activate,
Roguestar.Lib.Behavior.Construction,
Roguestar.Lib.Behavior.Make,
Roguestar.Lib.Activate,
Roguestar.Lib.Contact,
Roguestar.Lib.Planet,
Roguestar.Lib.PlanetData,
......@@ -105,6 +103,7 @@ library
Roguestar.Lib.CharacterAdvancement,
Roguestar.Lib.PersistantData,
Roguestar.Lib.PowerUpData,
Roguestar.Lib.Data.BuildingData,
Roguestar.Lib.Data.PlayerState,
Roguestar.Lib.HTML.Mustache
ghc-prof-options: -prof -auto-all
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment