Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Rename "Monster" to "MonsterData."

  • Loading branch information...
commit 261308157c885d3073a23b8d6f44b3ee50c4e502 1 parent 24ef726
@clanehin authored
View
2  Makefile
@@ -12,7 +12,7 @@ configure-profiling:
--enable-library-profiling --enable-executable-profiling
build:
- cabal-dev build -j
+ cabal-dev build
clean:
cabal-dev clean
View
12 Roguestar/Lib/Behavior/CharacterAdvancement.hs
@@ -16,18 +16,18 @@ import Roguestar.Lib.Data.PersistantData
data CharacterBumpResult =
CharacterAwarded { character_points_awarded :: Integer,
- character_new :: Monster }
+ character_new :: MonsterData }
| CharacterAdvanced { character_new_level :: Integer,
- character_new :: Monster }
+ character_new :: MonsterData }
| CharacterForced { character_new_character_class :: CharacterClass,
- character_new :: Monster }
+ character_new :: MonsterData }
-- |
-- Increases the character score by the set amount.
-- If the score is high enough that the character can advance to the next level,
-- this function will apply that advancement.
--
-bumpCharacter :: PowerUpData -> Monster -> CharacterBumpResult
+bumpCharacter :: PowerUpData -> MonsterData -> CharacterBumpResult
bumpCharacter (ForceCharacter character_class) c =
if CharacterClass character_class `elem` Map.keys (creature_traits c)
then bumpCharacter (AwardCharacter $ characterFitness new_character - characterFitness c) c
@@ -61,12 +61,12 @@ newCharacterLevel _ = Nothing
-- A rather arbitrary (non-representative of game balance)
-- measure of Character power.
--
-characterLevel :: Monster -> Integer
+characterLevel :: MonsterData -> Integer
characterLevel = maximum . Map.elems . creature_traits
-- |
-- Answers the estimated fitness (powerfulness) of the Character.
--
-characterFitness :: Monster -> Integer
+characterFitness :: MonsterData -> Integer
characterFitness c = sum $ (Map.elems $ creature_traits c)
View
4 Roguestar/Lib/Behavior/Turns.hs
@@ -10,7 +10,7 @@ import Control.Monad.Trans
import Roguestar.Lib.DB
import Roguestar.Lib.Data.FactionData
import Roguestar.Lib.Data.SpeciesData
-import Roguestar.Lib.Data.MonsterData (Monster)
+import Roguestar.Lib.Data.MonsterData (MonsterData)
import Roguestar.Lib.Core.Plane
import Control.Monad
import Control.Monad.Reader
@@ -77,7 +77,7 @@ monster_spawns = [(RecreantFactory,RedRecreant)]
dbPerform1PlanarAITurn :: PlaneRef -> DB ()
dbPerform1PlanarAITurn plane_ref =
do logDB gameplay_log INFO $ "dbPerform1PlanarAITurn; Beginning planar AI turn (for the plane itself):"
- (creature_locations :: [DetailedLocation (Child Monster)]) <- liftM mapLocations $ asks $ getContents plane_ref
+ (creature_locations :: [DetailedLocation (Child MonsterData)]) <- liftM mapLocations $ asks $ getContents plane_ref
player_locations <- filterRO (liftM (== Player) . getMonsterFaction . asChild . detail) creature_locations
num_npcs <- liftM length $ filterRO (liftM (/= Player) . getMonsterFaction . asChild . detail) creature_locations
when (num_npcs < length player_locations * 3) $
View
4 Roguestar/Lib/Core/Monster.hs
@@ -35,7 +35,7 @@ import qualified Data.Set as Set
-- |
-- Generates a new Monster from the specified species.
--
-generateMonster :: Faction -> Species -> DB Monster
+generateMonster :: Faction -> Species -> DB MonsterData
generateMonster faction species =
do r <- getRandomR (1,1000000)
return $ applyToMonster (species_specials $ speciesInfo species) $
@@ -56,7 +56,7 @@ generateInitialPlayerMonster species =
-- |
-- Generates a new Monster from the specified Species and adds it to the database.
--
-newMonster :: (LocationConstructor l, ReferenceTypeOf l ~ Monster) => Faction -> Species -> l -> DB MonsterRef
+newMonster :: (LocationConstructor l, ReferenceTypeOf l ~ MonsterData) => Faction -> Species -> l -> DB MonsterRef
newMonster faction species loc =
do creature <- generateMonster faction species
dbAddMonster creature loc
View
6 Roguestar/Lib/Core/Plane.hs
@@ -24,7 +24,7 @@ import Roguestar.Lib.Data.TerrainData
import Roguestar.Lib.Data.PlaneData
import Roguestar.Lib.Data.PlanetData
import Roguestar.Lib.Data.ToolData (Tool)
-import Roguestar.Lib.Data.MonsterData (Monster)
+import Roguestar.Lib.Data.MonsterData (MonsterData)
import Control.Monad
import Control.Monad.Random as Random
import Control.Monad.Reader
@@ -65,7 +65,7 @@ planeDepth this_plane =
class AlwaysHasIndirectPlanarLocation a
instance AlwaysHasIndirectPlanarLocation Tool
-instance AlwaysHasIndirectPlanarLocation Monster
+instance AlwaysHasIndirectPlanarLocation MonsterData
instance AlwaysHasIndirectPlanarLocation Building
-- |
@@ -211,7 +211,7 @@ whatIsOccupying plane_ref position =
-- Lava is considered passable, but trees are not.
isTerrainPassable :: (DBReadable db) => PlaneRef -> MonsterRef -> Position -> db Bool
isTerrainPassable plane_ref creature_ref position =
- do let f :: Maybe (Either (Child Building) (Child Monster)) -> Bool
+ do let f :: Maybe (Either (Child Building) (Child MonsterData)) -> Bool
f = maybe False $ either (const True) (\(Child c) -> c /= creature_ref)
(critters :: [PlanarLocation]) <- liftM (filter $ f . fromLocation . toLocation) $ whatIsOccupying plane_ref position
terrain <- terrainAt plane_ref position
View
2  Roguestar/Lib/Core/Tests.hs
@@ -15,7 +15,7 @@ import Test.HUnit
testcases :: Test
testcases = TestLabel "Roguestar.Lib.Core.Tests" $ TestList [testAncestors]
-spock :: Monster
+spock :: MonsterData
spock = empty_monster
setupCreatureWithTool :: DB (ToolRef,MonsterRef,PlaneRef)
View
10 Roguestar/Lib/DB.hs
@@ -92,7 +92,7 @@ data DBContext s = DBContext {
data DB_BaseType = DB_BaseType { db_player_state :: PlayerState,
db_next_object_ref :: Integer,
- db_creatures :: Map MonsterRef Monster,
+ db_creatures :: Map MonsterRef MonsterData,
db_player_creature :: Maybe MonsterRef,
db_planes :: Map PlaneRef Plane,
db_tools :: Map ToolRef Tool,
@@ -282,7 +282,7 @@ dbAddObjectComposable constructReferenceAction updateObjectAction constructLocat
-- |
-- Adds a new Monster to the database.
--
-dbAddMonster :: (LocationConstructor l, ReferenceTypeOf l ~ Monster) => Monster -> l -> DB MonsterRef
+dbAddMonster :: (LocationConstructor l, ReferenceTypeOf l ~ MonsterData) => MonsterData -> l -> DB MonsterRef
dbAddMonster = dbAddObjectComposable MonsterRef dbPutMonster (\r l -> constructLocation r l Nothing)
-- |
@@ -334,7 +334,7 @@ dbPutObjectComposable get_map_fn put_map_fn key thing =
-- |
-- Puts a Monster under an arbitrary MonsterRef.
--
-dbPutMonster :: MonsterRef -> Monster -> DB ()
+dbPutMonster :: MonsterRef -> MonsterData -> DB ()
dbPutMonster = dbPutObjectComposable db_creatures (\x db_base_type ->
db_base_type { db_creatures = x })
@@ -369,7 +369,7 @@ getObjectComposable type_info get_fn ref =
-- |
-- Gets a Monster from a MonsterRef
--
-getMonster :: MonsterRef -> DB_BaseType -> Monster
+getMonster :: MonsterRef -> DB_BaseType -> MonsterData
getMonster = getObjectComposable "MonsterRef" db_creatures
-- |
@@ -406,7 +406,7 @@ dbModPlane = dbModObjectComposable (asks . getPlane) dbPutPlane
-- |
-- Modifies a Monster based on a PlaneRef.
--
-dbModMonster :: (Monster -> Monster) -> MonsterRef -> DB ()
+dbModMonster :: (MonsterData -> MonsterData) -> MonsterRef -> DB ()
dbModMonster = dbModObjectComposable (asks . getMonster) dbPutMonster
-- |
View
2  Roguestar/Lib/Data/CharacterData.hs
@@ -5,7 +5,7 @@ module Roguestar.Lib.Data.CharacterData
import Roguestar.Lib.Data.MonsterData
import Roguestar.Lib.Data.PersistantData
-applyCharacterClass :: CharacterClass -> Monster -> Monster
+applyCharacterClass :: CharacterClass -> MonsterData -> MonsterData
applyCharacterClass character_class creature = applyToMonster (CharacterClass character_class : classInfo character_class) creature
classInfo :: CharacterClass -> [MonsterTrait]
View
2  Roguestar/Lib/Data/LocationData.hs
@@ -177,7 +177,7 @@ class LocationConstructor l where
constructLocation :: Reference (ReferenceTypeOf l) -> l -> Maybe Location -> Location
instance LocationConstructor Standing where
- type ReferenceTypeOf Standing = Monster
+ type ReferenceTypeOf Standing = MonsterData
constructLocation a l _ = IsStanding a l
instance LocationConstructor Dropped where
View
18 Roguestar/Lib/Data/MonsterData.hs
@@ -1,6 +1,6 @@
--Data
module Roguestar.Lib.Data.MonsterData
- (Monster(..),
+ (MonsterData(..),
MonsterTrait(..),
MonsterSpecial(..),
MonsterInteractionMode(..),
@@ -24,7 +24,7 @@ import Data.List as List
import Roguestar.Lib.Data.SpeciesData
import Roguestar.Lib.Data.TerrainData
-data Monster = Monster { creature_traits :: Map.Map MonsterTrait Integer,
+data MonsterData = MonsterData { creature_traits :: Map.Map MonsterTrait Integer,
creature_specials :: Set.Set MonsterSpecial,
creature_species :: Species,
creature_random_id :: Integer, -- random number attached to the creature, not unique
@@ -35,8 +35,8 @@ data Monster = Monster { creature_traits :: Map.Map MonsterTrait Integer,
-- | Monster having no attributes and undefined 'creature_species', 'creature_random_id', and 'creature_faction'
--
-empty_monster :: Monster
-empty_monster = Monster {
+empty_monster :: MonsterData
+empty_monster = MonsterData {
creature_traits = Map.empty,
creature_specials = Set.empty,
creature_species = error "empty_creature: undefined creature_species",
@@ -48,11 +48,11 @@ empty_monster = Monster {
-- | Endomorphisms over a 'Monster'. These are types that contribute some feature to a 'Monster',
-- so that 'Monster's can be defined concisely by those properties.
class MonsterEndo a where
- applyToMonster :: a -> Monster -> Monster
+ applyToMonster :: a -> MonsterData -> MonsterData
-- | Primitive numeric properties of a Monster.
class MonsterScore s where
- rawScore :: s -> Monster -> Integer
+ rawScore :: s -> MonsterData -> Integer
instance (MonsterEndo a,Integral i) => MonsterEndo (a,i) where
applyToMonster (_,i) | i <= 0 = id
@@ -127,11 +127,11 @@ instance MonsterScore CharacterClass where
-- | Calculator to determine how many ranks a creature has in an ability.
-- Number of aptitude points plus n times number of ability points
-figureAbility :: [MonsterTrait] -> Monster -> Integer
+figureAbility :: [MonsterTrait] -> MonsterData -> Integer
figureAbility [] _ = 1
figureAbility traits c = 1 + sum (map (flip rawScore c) traits) `div` List.genericLength traits
-creatureAbilityScore :: MonsterAbility -> Monster -> Integer
+creatureAbilityScore :: MonsterAbility -> MonsterData -> Integer
creatureAbilityScore ToughnessTrait = figureAbility [Caution,Fortitude]
creatureAbilityScore (AttackSkill _) = figureAbility [Aggression,Dexterity]
creatureAbilityScore (DefenseSkill _) = figureAbility [Caution,Dexterity]
@@ -145,7 +145,7 @@ creatureAbilityScore InventorySkill = figureAbility [Fortitude]
-- |
-- Answers the health/injury/maximum health of this creature.
-creatureHealth :: Monster -> MonsterHealth
+creatureHealth :: MonsterData -> MonsterHealth
creatureHealth c = case () of
() | creature_max_health result <= 0 -> error "creatureHealth: creature_max_health <= 0"
() | otherwise -> result
View
2  Roguestar/Lib/Data/PlayerState.hs
@@ -12,7 +12,7 @@ import Roguestar.Lib.Data.PersistantData
import Data.Maybe
data PlayerState =
- SpeciesSelectionState (Maybe Monster)
+ SpeciesSelectionState (Maybe MonsterData)
| PlayerMonsterTurn MonsterRef
| SnapshotEvent SnapshotEvent
| GameOver GameOverReason
View
4 Roguestar/Lib/Data/ReferenceTypes.hs
@@ -43,7 +43,7 @@ import Roguestar.Lib.Position
--
data TheUniverse = TheUniverse deriving (Read,Show,Eq,Ord)
-type MonsterRef = Reference Monster
+type MonsterRef = Reference MonsterData
type ToolRef = Reference Tool
type PlaneRef = Reference Plane
type BuildingRef = Reference Building
@@ -92,7 +92,7 @@ instance ReferenceType Tool where
coerceReference (ToolRef ref) = Just $ ToolRef ref
coerceReference _ = Nothing
-instance ReferenceType Monster where
+instance ReferenceType MonsterData where
coerceReference (MonsterRef ref) = Just $ MonsterRef ref
coerceReference _ = Nothing
View
2  Roguestar/Lib/Graph/Graph.hs
@@ -13,7 +13,7 @@ import Roguestar.Lib.Position
data Monster = Monster {
monster_to_reference :: References.MonsterRef,
- monster_to_data :: MonsterData.Monster,
+ monster_to_data :: MonsterData.MonsterData,
monster_to_square :: Square }
data Square = Square {
View
1  Roguestar/Lib/Graph/Tests.hs
@@ -17,6 +17,7 @@ testcases = TestLabel "Roguestar.Lib.Model.Tests" $ TestList [
equestria :: Plane
equestria = Plane {
plane_to_reference = References.PlaneRef 0,
+ plane_to_data = error "undefined equestria",
plane_to_monsters = Set.fromList [twilight, picard, zathras],
plane_to_buildings = Set.fromList [] }
View
2  Roguestar/Lib/Roguestar.hs
@@ -12,7 +12,7 @@ module Roguestar.Lib.Roguestar
getPlayerState,
getSnapshotPlayerState,
rerollStartingSpecies,
- Monster(..),
+ MonsterData(..),
Terrain(..),
Position(..),
Facing(..),
View
22 Roguestar/Lib/Utility/DetailedLocation.hs
@@ -29,9 +29,9 @@ import Roguestar.Lib.Data.FacingData
type PlaneLocation = DetailedLocation (Child Plane)
type BuildingLocation = DetailedLocation (Child Building)
-type MonsterLocation = DetailedLocation (Child Monster)
+type MonsterLocation = DetailedLocation (Child MonsterData)
type ToolLocation = DetailedLocation (Child Tool)
-type CarriedLocation = DetailedLocation (Parent Monster)
+type CarriedLocation = DetailedLocation (Parent MonsterData)
type PlanarLocation = DetailedLocation Planar
data DetailedLocation a = DetailedLocation { dl_location :: Location }
@@ -98,14 +98,14 @@ type instance LocationAssignmentTable Planar Position
type instance LocationAssignmentTable Planar (Parent Plane, MultiPosition) = Supported
type instance LocationAssignmentTable Planar (Parent Plane, Position) = Supported
type instance LocationAssignmentTable (Child a) (Child a) = Supported
-type instance LocationAssignmentTable (Child Monster) Standing = Supported
-type instance LocationAssignmentTable (Child Monster) (Parent Plane) = Supported
-type instance LocationAssignmentTable (Child Monster) Position = Supported
-type instance LocationAssignmentTable (Child Monster) MultiPosition = Supported
-type instance LocationAssignmentTable (Child Monster) Planar = Supported
-type instance LocationAssignmentTable (Child Monster) Facing = Supported
-type instance LocationAssignmentTable (Child Monster) (Facing,Position) = Supported
-type instance LocationAssignmentTable (Child Monster) (Position,Facing) = Supported
+type instance LocationAssignmentTable (Child MonsterData) Standing = Supported
+type instance LocationAssignmentTable (Child MonsterData) (Parent Plane) = Supported
+type instance LocationAssignmentTable (Child MonsterData) Position = Supported
+type instance LocationAssignmentTable (Child MonsterData) MultiPosition = Supported
+type instance LocationAssignmentTable (Child MonsterData) Planar = Supported
+type instance LocationAssignmentTable (Child MonsterData) Facing = Supported
+type instance LocationAssignmentTable (Child MonsterData) (Facing,Position) = Supported
+type instance LocationAssignmentTable (Child MonsterData) (Position,Facing) = Supported
type instance LocationAssignmentTable (Child Building) (Parent Plane) = Supported
type instance LocationAssignmentTable (Child Building) Position = Supported
type instance LocationAssignmentTable (Child Building) MultiPosition = Supported
@@ -113,7 +113,7 @@ type instance LocationAssignmentTable (Child Building) BuildingShape
type instance LocationAssignmentTable Beneath (Child Plane) = Supported
type instance LocationAssignmentTable Subsequent (Child Plane) = Supported
type instance LocationAssignmentTable Standing Planar = Supported
-type instance LocationAssignmentTable Standing (Child Monster) = Supported
+type instance LocationAssignmentTable Standing (Child MonsterData) = Supported
type instance LocationAssignmentTable Standing (Parent Plane) = Supported
type instance LocationAssignmentTable Standing Position = Supported
type instance LocationAssignmentTable Standing MultiPosition = Supported
View
2  Roguestar/Lib/World/BeginGame.hs
@@ -32,7 +32,7 @@ startingEquipmentBySpecies BlueRecreant = []
startingEquipmentBySpecies Anachronid = []
startingEquipmentBySpecies TabularMonstrosity = []
-dbCreateStartingPlane :: Monster -> DB PlaneRef
+dbCreateStartingPlane :: MonsterData -> DB PlaneRef
dbCreateStartingPlane creature =
do seed <- getRandom
dbNewPlane "belhaven" (TerrainGenerationData {
Please sign in to comment.
Something went wrong with that request. Please try again.