Permalink
Browse files

Various changes to gameplay and UI for 0.8.

  • Loading branch information...
Christopher Lane Hinson
Christopher Lane Hinson committed Sep 13, 2012
1 parent 9195ff6 commit 392d2409ceaaadefb0daecfbd4b012fe7bd7d92c
Showing with 556 additions and 673 deletions.
  1. +0 −66 Roguestar/Lib/AttributeGeneration.hs
  2. +16 −39 Roguestar/Lib/BeginGame.hs
  3. +19 −34 Roguestar/Lib/Behavior.hs
  4. +1 −1 Roguestar/Lib/Behavior/Travel.hs
  5. +5 −11 Roguestar/Lib/Building.hs
  6. +9 −2 Roguestar/Lib/BuildingData.hs
  7. +3 −4 Roguestar/Lib/Character.hs
  8. +4 −4 Roguestar/Lib/CharacterAdvancement.hs
  9. +19 −9 Roguestar/Lib/Creature.hs
  10. +0 −51 Roguestar/Lib/CreatureAttribute.hs
  11. +35 −79 Roguestar/Lib/CreatureData.hs
  12. +2 −1 Roguestar/Lib/DB.hs
  13. +0 −1 Roguestar/Lib/FactionData.hs
  14. +1 −1 Roguestar/Lib/GridRayCaster.hs
  15. +28 −13 Roguestar/Lib/Grids.hs
  16. +14 −6 Roguestar/Lib/Logging.hs
  17. +0 −79 Roguestar/Lib/Main.hs
  18. +7 −7 Roguestar/Lib/Perception.hs
  19. +9 −9 Roguestar/Lib/PlaneVisibility.hs
  20. +7 −3 Roguestar/Lib/PlayerState.hs
  21. +90 −10 Roguestar/Lib/Roguestar.hs
  22. +3 −87 Roguestar/Lib/Species.hs
  23. +3 −14 Roguestar/Lib/SpeciesData.hs
  24. +34 −65 Roguestar/Lib/TerrainData.hs
  25. +1 −1 Roguestar/Lib/Town.hs
  26. +10 −10 Roguestar/Lib/Turns.hs
  27. +76 −47 Roguestar/Server/Main.hs
  28. +0 −1 feedback/1b6f660f-70e0-4781-a10b-1033c2c23323
  29. +1 −0 feedback/37b314aa-7182-439e-915e-65ae52cdd943
  30. +5 −6 roguestar.cabal
  31. +2 −2 snaplets/heist/templates/contribute.tpl
  32. +26 −0 snaplets/heist/templates/help-actions.tpl
  33. +43 −0 snaplets/heist/templates/help-map.tpl
  34. +3 −2 snaplets/heist/templates/help.tpl
  35. +1 −0 snaplets/heist/templates/hidden/context.tpl
  36. +13 −0 snaplets/heist/templates/hidden/options.tpl
  37. +5 −1 snaplets/heist/templates/hidden/play/{game-over.tpl → failure.tpl}
  38. +4 −1 snaplets/heist/templates/hidden/play/normal.tpl
  39. +17 −0 snaplets/heist/templates/hidden/play/success.tpl
  40. +10 −0 snaplets/heist/templates/hidden/start.tpl
  41. +1 −1 snaplets/heist/templates/index.tpl
  42. +2 −2 static/encyclopedia/species/recreant.txt
  43. +27 −3 static/roguebasic.css
@@ -1,66 +0,0 @@
--- | Generates random lists of specific data points "attributes" of any data type.
--- The attributes themselves aren't random, only their arrangement and frequency within the list.
---
-module Roguestar.Lib.AttributeGeneration
- where
-
-import Data.Ratio
-import Data.List
-import Control.Monad.Random
-import Data.Monoid
-import Control.Monad
-
--- | Description of the random data to be generated.
-data AttributeGenerator a =
- AttributeAlways {
- attribute_actual :: a,
- attribute_min_max :: (Integer,Integer) }
- | AttributeChoice {
- attribute_frequency :: Rational,
- attribute_yes :: [AttributeGenerator a],
- attribute_no :: [AttributeGenerator a] }
-
-instance Monoid (AttributeGenerator a) where
- mempty = AttributeChoice {
- attribute_frequency = 0,
- attribute_yes = [],
- attribute_no = [] }
- mappend a b = mconcat [a,b]
- mconcat as = AttributeChoice {
- attribute_frequency = 1,
- attribute_yes = as,
- attribute_no = [] }
-
--- | Generate exactly n copies of an attribute.
-attributeStatic :: Integer -> a -> AttributeGenerator a
-attributeStatic n a =attributeMinMax (n,n) a
-
--- | Generates between a random number of copies of an attribute between a lower and upper bound.
-attributeMinMax :: (Integer,Integer) -> a -> AttributeGenerator a
-attributeMinMax min_max a = AttributeAlways {
- attribute_actual = a,
- attribute_min_max = min_max }
-
--- | Generates the first class of attributes some fraction of the time, and the other list the remainder of the time.
--- For example 'attributeChoice (1%3) [attributeStatic 1 True] [attributeStatic 1 False]' would generate 'True' 33% of the time.
-attributeChoice :: Rational -> [AttributeGenerator a] -> [AttributeGenerator a] -> AttributeGenerator a
-attributeChoice freq yes no = AttributeChoice {
- attribute_frequency = freq,
- attribute_yes = yes,
- attribute_no = no }
-
--- | A set of mutually-exclusive choices, with Integer probability weights.
-attributeChoices :: [(Integer,[AttributeGenerator a])] -> AttributeGenerator a
-attributeChoices [] = mempty
-attributeChoices (x:xs) = attributeChoice (fst x % (sum $ map fst $ x:xs)) (snd x) [attributeChoices xs]
-
--- | Run the 'AttributeGenerator'.
-generateAttributes :: (MonadRandom m) => AttributeGenerator a -> m [a]
-generateAttributes (AttributeAlways { attribute_actual = a, attribute_min_max = min_max }) =
- do n <- getRandomR min_max
- return $ genericReplicate n a
-generateAttributes (AttributeChoice { attribute_frequency = l, attribute_yes = yes, attribute_no = no }) =
- do n <- getRandomR (1,denominator l)
- case () of
- () | n <= numerator l -> liftM concat $ mapM generateAttributes yes
- () | otherwise -> liftM concat $ mapM generateAttributes no
View
@@ -20,43 +20,24 @@ import Roguestar.Lib.Town
import Roguestar.Lib.PlanetData
import Roguestar.Lib.Planet
import qualified Data.ByteString.Char8 as B ()
+import Control.Monad.Random
-homeBiome :: Species -> Biome
-homeBiome Anachronid = ForestBiome
-homeBiome Ascendant = MountainBiome
-homeBiome Androsynth = IcyRockBiome
-homeBiome Caduceator = GrasslandBiome
-homeBiome Encephalon = SwampBiome
-homeBiome Goliath = DesertBiome
-homeBiome Hellion = SwampBiome
-homeBiome Kraken = OceanBiome
-homeBiome Myrmidon = DesertBiome
-homeBiome Perennial = GrasslandBiome
-homeBiome Recreant = TundraBiome
-homeBiome Reptilian = ForestBiome
-homeBiome DustVortex = DesertBiome
+homeBiome :: Species -> [Biome]
+homeBiome RedRecreant = [ForestBiome,TundraBiome,MountainBiome]
+homeBiome BlueRecreant = [ForestBiome,TundraBiome,MountainBiome]
startingEquipmentBySpecies :: Species -> [Tool]
-startingEquipmentBySpecies Anachronid = [sphere Radon]
-startingEquipmentBySpecies Ascendant = [sphere Neon]
-startingEquipmentBySpecies Androsynth = [sphere Silicon]
-startingEquipmentBySpecies Caduceator = [sphere Silver]
-startingEquipmentBySpecies Encephalon = [sphere Ammonia]
-startingEquipmentBySpecies Goliath = [sphere Iron]
-startingEquipmentBySpecies Hellion = [sphere Methane]
-startingEquipmentBySpecies Kraken = [sphere Substances.Water]
-startingEquipmentBySpecies Myrmidon = [sphere Krypton]
-startingEquipmentBySpecies Perennial = [sphere Wood]
-startingEquipmentBySpecies Recreant = [sphere Malignite]
-startingEquipmentBySpecies Reptilian = [sphere Oxygen]
-startingEquipmentBySpecies DustVortex = [sphere Aluminum, sphere Nitrogen]
+startingEquipmentBySpecies RedRecreant = []
+startingEquipmentBySpecies BlueRecreant = []
dbCreateStartingPlane :: Creature -> DB PlaneRef
dbCreateStartingPlane creature =
- do dbNewPlane "belhaven" (TerrainGenerationData {
- tg_smootheness = 3,
- tg_biome = homeBiome $ creature_species creature,
- tg_placements = [] }) TheUniverse
+ do seed <- getRandom
+ biome <- pickM $ homeBiome (creature_species creature)
+ dbNewPlane "belhaven" (TerrainGenerationData {
+ tg_smootheness = 2,
+ tg_biome = biome,
+ tg_placements = [recreantFactories seed] }) TheUniverse
-- |
-- Begins the game with the specified starting player creature.
@@ -71,15 +52,11 @@ beginGame =
landing_site <- pickRandomClearSite 200 30 2 (Position (0,0)) (not . (`elem` difficult_terrains)) plane_ref
creature_ref <- dbAddCreature creature (Standing plane_ref landing_site Here)
setPlayerCreature creature_ref
- _ <- createTown plane_ref [basic_stargate,monolith]
+ _ <- createTown plane_ref [basic_stargate]
let starting_equip = startingEquipmentBySpecies (creature_species creature)
forM_ starting_equip $ \tool -> dbAddTool tool (Inventory creature_ref)
- forM_ [0..10] $ \_ -> do tool_position <- pickRandomClearSite 200 1 2 landing_site (not . (`elem` difficult_terrains)) plane_ref
- tool_type <- weightedPickM [(8,phase_pistol),(5,phaser),(3,phase_rifle),(8,kinetic_fleuret),(3,kinetic_sabre),
- (5,Sphere $ toSubstance Nitrogen),(5,Sphere $ toSubstance Ionidium),(5,Sphere $ toSubstance Aluminum)]
- dbAddTool tool_type (Dropped plane_ref tool_position)
- (_,end_of_nonaligned_first_series) <- makePlanets (Subsequent plane_ref NonAlignedRegion) =<< generatePlanetInfo nonaligned_first_series_planets
- _ <- makePlanets (Subsequent end_of_nonaligned_first_series NonAlignedRegion) =<< generatePlanetInfo nonaligned_second_series_planets
- _ <- makePlanets (Subsequent end_of_nonaligned_first_series CyborgRegion) =<< generatePlanetInfo cyborg_planets
+ -- (_,end_of_nonaligned_first_series) <- makePlanets (Subsequent plane_ref NonAlignedRegion) =<< generatePlanetInfo nonaligned_first_series_planets
+ -- _ <- makePlanets (Subsequent end_of_nonaligned_first_series NonAlignedRegion) =<< generatePlanetInfo nonaligned_second_series_planets
+ -- _ <- makePlanets (Subsequent end_of_nonaligned_first_series CyborgRegion) =<< generatePlanetInfo cyborg_planets
setPlayerState $ PlayerCreatureTurn creature_ref
View
@@ -94,16 +94,16 @@ dbBehave_ (Step face) creature_ref =
dbBehave_ StepDown creature_ref =
do _ <- atomic executeClimb $ resolveClimb creature_ref ClimbDown
-- FIXME: should be conditional
- dbAdvanceTime creature_ref =<< fullActionTime creature_ref
+ dbAdvanceTime creature_ref =<< move2ActionTime creature_ref
dbBehave_ StepUp creature_ref =
do _ <- atomic executeClimb $ resolveClimb creature_ref ClimbUp
-- FIXME: should be conditional
- dbAdvanceTime creature_ref =<< fullActionTime creature_ref
+ dbAdvanceTime creature_ref =<< move2ActionTime creature_ref
dbBehave_ (Jump face) creature_ref =
do _ <- atomic executeTeleportJump $ resolveTeleportJump creature_ref face
- dbAdvanceTime creature_ref =<< fullActionTime creature_ref
+ dbAdvanceTime creature_ref =<< move2ActionTime creature_ref
dbBehave_ (TurnInPlace face) creature_ref =
do _ <- move creature_ref =<< turnCreature face creature_ref
@@ -146,7 +146,7 @@ dbBehave_ (Attack face) creature_ref =
do _ <- move creature_ref =<< turnCreature face creature_ref
melee_attack_model <- meleeAttackModel creature_ref
_ <- atomic executeAttack $ resolveAttack melee_attack_model face
- dbAdvanceTime creature_ref =<< move1ActionTime creature_ref
+ dbAdvanceTime creature_ref =<< quickActionTime creature_ref
return ()
dbBehave_ Wait creature_ref = dbAdvanceTime creature_ref =<< quickActionTime creature_ref
@@ -168,60 +168,45 @@ dbBehave_ Activate creature_ref =
dbBehave_ (Make make_prep) creature_ref =
do _ <- atomic executeMake $ resolveMake creature_ref make_prep
- dbAdvanceTime creature_ref =<< fullActionTime creature_ref
+ dbAdvanceTime creature_ref =<< quickActionTime creature_ref
return ()
dbBehave_ (ClearTerrain face) creature_ref =
do _ <- move creature_ref =<< turnCreature face creature_ref
ok <- modifyFacingTerrain clearTerrain face creature_ref
when (not ok) $ throwError $ DBErrorFlag Unable
- dbAdvanceTime creature_ref =<< fullActionTime creature_ref
+ dbAdvanceTime creature_ref =<< quickActionTime creature_ref
return ()
dbBehave_ (ActivateBuilding face) creature_ref =
do _ <- move creature_ref =<< turnCreature face creature_ref
ok <- activateFacingBuilding face creature_ref
when (not ok) $ throwError $ DBErrorFlag Unable
- dbAdvanceTime creature_ref =<< fullActionTime creature_ref
+ dbAdvanceTime creature_ref =<< quickActionTime creature_ref
{---------------------------------------------------------------------------------------------------
-- These are functions related to determing how long it takes for a creature to execute an action.
----------------------------------------------------------------------------------------------------}
--- | A value indicating the degree of difficulty a creature suffers on account of the inventory it is carrying.
-inventoryBurden :: (DBReadable db) => CreatureRef -> db Rational
-inventoryBurden creature_ref =
- do inventory_size <- liftM (genericLength . filterLocations (\(Child tool_ref :: Child Tool) -> True)) $ getContents creature_ref
- inventory_skill <- liftM roll_ideal $ rollCreatureAbilityScore InventorySkill 0 creature_ref
- return $ (inventory_size ^ 2) % inventory_skill
-
--- | Multiplier penalty if a creature is overweighted.
-overweightPenalty :: (DBReadable db) => CreatureRef -> db Rational
-overweightPenalty = liftM (max 1.0) . inventoryBurden
-
--- | Multiplier penalty if a creature is injured.
-healthPenalty :: (DBReadable db) => CreatureRef -> db Rational
-healthPenalty creature_ref =
- do current_health <- liftM creature_health $ getCreatureHealth creature_ref
- raw_speed <- liftM (rawScore Speed) $ dbGetCreature creature_ref
- return $ (max 1.0 $ recip $ max (1%raw_speed) current_health) -- maximum health penalty determined by speed
-
--- | Multiplier penalties for doing anything that requires physical movement, e.g. walking.
-physicalActionPenalties :: (DBReadable db) => CreatureRef -> db Rational
-physicalActionPenalties creature_ref = liftM2 (*) (overweightPenalty creature_ref) (healthPenalty creature_ref)
+getBaseSpeed :: (DBReadable db) => CreatureRef -> db Integer
+getBaseSpeed creature_ref =
+ do c <- dbGetCreature creature_ref
+ let raw_speed = rawScore Speed c
+ when (raw_speed <= 0) $ error $ "getBaseSpeed: Non-positive raw speed (" ++ show c ++ ")"
+ return raw_speed
-- | Time required to do a simple physical task.
quickActionTime :: (DBReadable db) => CreatureRef -> db Rational
-quickActionTime creature_ref = liftM2 (*) (physicalActionPenalties creature_ref) (liftM ((3%) . rawScore Speed) $ dbGetCreature creature_ref)
+quickActionTime creature_ref =
+ do raw_speed <- getBaseSpeed creature_ref
+ return $ 50 % (100 + raw_speed `div` 2)
-- | Time required to move one step.
move1ActionTime :: (DBReadable db) => CreatureRef -> db Rational
-move1ActionTime creature_ref = liftM2 (*) (physicalActionPenalties creature_ref) (liftM ((5%) . rawScore Speed) $ dbGetCreature creature_ref)
+move1ActionTime creature_ref =
+ do raw_speed <- getBaseSpeed creature_ref
+ return $ 100 % (100+raw_speed)
-- | Time required to move diagonally one step.
move2ActionTime :: (DBReadable db) => CreatureRef -> db Rational
move2ActionTime = liftM (*1.4142) . move1ActionTime
-
--- | Time required to complete a complex physical action.
-fullActionTime :: (DBReadable db) => CreatureRef -> db Rational
-fullActionTime = liftM (*2) . move1ActionTime
@@ -46,7 +46,7 @@ walkCreature face (x',y') creature_ref =
(standing_position standing)
case () of
() | not is_passable ->
- do logDB log_travel WARNING $ "Terrain not passable."
+ do logDB log_travel INFO $ "Terrain not passable."
return $ detail l
() | otherwise ->
return $ standing
View
@@ -24,6 +24,7 @@ import Control.Monad.Error
import Roguestar.Lib.PowerUpData
import Roguestar.Lib.CharacterAdvancement
import Roguestar.Lib.DetailedLocation
+import Roguestar.Lib.PlayerState
-- | The total occupied surface area of a building.
buildingSize :: (DBReadable db) => BuildingRef -> db Integer
@@ -60,18 +61,11 @@ activateBuilding (PowerUp pud) creature_ref building_ref =
do captureNode pud creature_ref building_ref
return True
activateBuilding (TwoWayStargate region) creature_ref building_ref =
- do (Parent plane_ref :: Parent Plane,Position (bx,by))
- <- liftM detail $ getPlanarLocation building_ref
- (Position (cx,cy)) <- liftM detail $ getPlanarLocation creature_ref
+ do (Parent plane_ref :: Parent Plane,building_position :: Position) <- liftM detail $ getPlanarLocation building_ref
+ (creature_position :: Position) <- liftM detail $ getPlanarLocation creature_ref
case () of
- () | cy - by == (-1) ->
- do subsequent_plane <- maybe (throwError $ DBErrorFlag NoStargateAddress) return
- =<< getSubsequent region plane_ref
- portalCreatureTo (Just $ TwoWayStargate region) 1 creature_ref subsequent_plane
- () | cy - by == 1 ->
- do previous_plane <- maybe (throwError $ DBErrorFlag NoStargateAddress) (return . asParent)
- =<< liftM fromLocation (whereIs plane_ref)
- portalCreatureTo (Just $ TwoWayStargate region) (-1) creature_ref previous_plane
+ () | distanceBetweenChessboard creature_position building_position == 1 ->
+ do setPlayerState $ GameOver PlayerIsVictorious
() | otherwise ->
do throwError $ DBErrorFlag BuildingApproachWrongAngle
return True
@@ -37,8 +37,15 @@ buildingOccupies :: BuildingShape -> [(Integer,Integer)]
-- Monolith/Node: X
buildingOccupies Monolith = [(0,0)]
buildingOccupies Anchor = [(0,0)]
--- Portal: XXX
-buildingOccupies Portal = [(0,0),(-1,0),(1,0)]
+-- Portal:
+--
+-- XXX
+-- X X
+-- X X X
+-- X X
+-- 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
@@ -4,15 +4,14 @@ module Roguestar.Lib.Character
where
import Roguestar.Lib.Alignment
-import Roguestar.Lib.CreatureAttribute
import Roguestar.Lib.CreatureData
import Roguestar.Lib.TerrainData
import Roguestar.Lib.PersistantData
applyCharacterClass :: CharacterClass -> Creature -> Creature
-applyCharacterClass character_class creature = applyToCreature (character_class & classInfo character_class) creature
+applyCharacterClass character_class creature = applyToCreature (CharacterClass character_class : classInfo character_class) creature
-classInfo :: CharacterClass -> CreatureAttribute
+classInfo :: CharacterClass -> [CreatureTrait]
-------------------------------------------------------------------------------
--
@@ -22,5 +21,5 @@ classInfo :: CharacterClass -> CreatureAttribute
--
-------------------------------------------------------------------------------
-classInfo StarChild = Mindfulness & Intellect & Perception
+classInfo StarChild = [Aggression,Perception]
@@ -27,7 +27,7 @@ data CharacterBumpResult =
--
bumpCharacter :: PowerUpData -> Creature -> CharacterBumpResult
bumpCharacter (ForceCharacter character_class) c =
- if character_class `elem` Map.keys (creature_levels c)
+ if CharacterClass character_class `elem` Map.keys (creature_traits c)
then bumpCharacter (AwardCharacter $ characterFitness new_character - characterFitness c) c
else CharacterForced {
character_new_character_class = character_class,
@@ -43,7 +43,7 @@ bumpCharacter (AwardCharacter n) c =
character_new = c { creature_points = bumped_score } }
where bumped_score = creature_points c + n
fitness_gain = characterFitness new_character - characterFitness c
- new_character = applyToCreature (Map.keys $ creature_levels c) c
+ new_character = applyToCreature (Map.keys $ creature_traits c) c
newCharacterClass :: CharacterBumpResult -> Maybe CharacterClass
newCharacterClass (CharacterForced character_class _) = Just character_class
@@ -60,11 +60,11 @@ newCharacterLevel _ = Nothing
-- measure of Character power.
--
characterLevel :: Creature -> Integer
-characterLevel = maximum . Map.elems . creature_levels
+characterLevel = maximum . Map.elems . creature_traits
-- |
-- Answers the estimated fitness (powerfulness) of the Character.
--
characterFitness :: Creature -> Integer
-characterFitness c = sum $ (Map.elems $ creature_aptitude c) ++ (Map.elems $ creature_ability c)
+characterFitness c = sum $ (Map.elems $ creature_traits c)
Oops, something went wrong.

0 comments on commit 392d240

Please sign in to comment.