Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 88 lines (79 sloc) 3.407 kb
eb4b7b8 @clanehin Package move to Roguestar.Lib.
authored
1 module Roguestar.Lib.PlayerState
8e2c88a @clanehin Move common PlayerState functions into their own module.
authored
2 (PlayerState(..),
3 SnapshotEvent(..),
392d240 @clanehin Various changes to gameplay and UI for 0.8.
authored
4 HasSubject(..),
5 GameOverReason(..))
8e2c88a @clanehin Move common PlayerState functions into their own module.
authored
6 where
7
eb4b7b8 @clanehin Package move to Roguestar.Lib.
authored
8 import Roguestar.Lib.DBData
9 import Roguestar.Lib.CreatureData
10 import Roguestar.Lib.MakeData
11 import Roguestar.Lib.TravelData
9195ff6 @clanehin Getting to be a fairly acceptable web game.
authored
12 import Roguestar.Lib.PersistantData
8e2c88a @clanehin Move common PlayerState functions into their own module.
authored
13
60b5aa0 @clanehin Fixes issues with climbing up and down. Makefile changes.
authored
14 data PlayerState =
a563fc2 @clanehin Renders a map on the server.
authored
15 SpeciesSelectionState (Maybe Creature)
16 | PlayerCreatureTurn CreatureRef
8e2c88a @clanehin Move common PlayerState functions into their own module.
authored
17 | SnapshotEvent SnapshotEvent
392d240 @clanehin Various changes to gameplay and UI for 0.8.
authored
18 | GameOver GameOverReason
19 deriving (Read,Show)
20
21 data GameOverReason = PlayerIsDead | PlayerIsVictorious
60b5aa0 @clanehin Fixes issues with climbing up and down. Makefile changes.
authored
22 deriving (Read,Show)
8e2c88a @clanehin Move common PlayerState functions into their own module.
authored
23
60b5aa0 @clanehin Fixes issues with climbing up and down. Makefile changes.
authored
24 data SnapshotEvent =
8e2c88a @clanehin Move common PlayerState functions into their own module.
authored
25 AttackEvent {
26 attack_event_source_creature :: CreatureRef,
27 attack_event_source_weapon :: Maybe ToolRef,
28 attack_event_target_creature :: CreatureRef }
29 | MissEvent {
30 miss_event_creature :: CreatureRef,
60b5aa0 @clanehin Fixes issues with climbing up and down. Makefile changes.
authored
31 miss_event_weapon :: Maybe ToolRef }
8e2c88a @clanehin Move common PlayerState functions into their own module.
authored
32 | KilledEvent {
33 killed_event_creature :: CreatureRef }
34 | WeaponOverheatsEvent {
35 weapon_overheats_event_creature :: CreatureRef,
36 weapon_overheats_event_weapon :: ToolRef }
37 | WeaponExplodesEvent {
38 weapon_explodes_event_creature :: CreatureRef,
39 weapon_explodes_event_weapon :: ToolRef }
40 | DisarmEvent {
41 disarm_event_source_creature :: CreatureRef,
42 disarm_event_target_creature :: CreatureRef,
43 disarm_event_target_tool :: ToolRef }
44 | SunderEvent {
45 sunder_event_source_creature :: CreatureRef,
46 sunder_event_source_weapon :: ToolRef,
47 sunder_event_target_creature :: CreatureRef,
48 sunder_event_target_tool :: ToolRef }
e243bd9 @clanehin Notify planet names and teleport events.
authored
49 | TeleportEvent {
50 teleport_event_creature :: CreatureRef }
60b5aa0 @clanehin Fixes issues with climbing up and down. Makefile changes.
authored
51 | ClimbEvent {
52 climb_event_direction :: ClimbDirection,
53 climb_event_creature :: CreatureRef }
e894e37 @clanehin Proper handling of heal and expend item events.
authored
54 | HealEvent {
55 heal_event_creature :: CreatureRef }
56 | ExpendToolEvent {
57 expend_tool_event_tool :: ToolRef }
6c7cb3f @clanehin Make leveling-up work, after touching a planetary anchor or monolith.
authored
58 | BumpEvent {
59 bump_event_creature :: CreatureRef,
60 bump_event_new_level :: Maybe Integer,
61 bump_event_new_class :: Maybe CharacterClass }
8e2c88a @clanehin Move common PlayerState functions into their own module.
authored
62 deriving (Read,Show)
63
a563fc2 @clanehin Renders a map on the server.
authored
64 class HasSubject a where
65 subjectOf :: a -> Maybe CreatureRef
8e2c88a @clanehin Move common PlayerState functions into their own module.
authored
66
a563fc2 @clanehin Renders a map on the server.
authored
67 instance HasSubject PlayerState where
68 subjectOf (SpeciesSelectionState {}) = Nothing
69 subjectOf (PlayerCreatureTurn x) = Just x
70 subjectOf (SnapshotEvent x) = subjectOf x
392d240 @clanehin Various changes to gameplay and UI for 0.8.
authored
71 subjectOf (GameOver {}) = Nothing
8e2c88a @clanehin Move common PlayerState functions into their own module.
authored
72
a563fc2 @clanehin Renders a map on the server.
authored
73 instance HasSubject SnapshotEvent where
74 subjectOf event = case event of
75 AttackEvent { attack_event_source_creature = attacker_ref } -> Just attacker_ref
76 MissEvent { miss_event_creature = attacker_ref } -> Just attacker_ref
77 WeaponOverheatsEvent { weapon_overheats_event_creature = attacker_ref } -> Just attacker_ref
78 WeaponExplodesEvent { weapon_explodes_event_creature = attacker_ref } -> Just attacker_ref
79 KilledEvent killed_ref -> Just killed_ref
80 DisarmEvent { disarm_event_source_creature = attacker_ref } -> Just attacker_ref
81 SunderEvent { sunder_event_source_creature = attacker_ref } -> Just attacker_ref
82 TeleportEvent { teleport_event_creature = creature_ref } -> Just creature_ref
83 HealEvent { heal_event_creature = creature_ref } -> Just creature_ref
84 ClimbEvent { climb_event_creature = creature_ref } -> Just creature_ref
85 BumpEvent { bump_event_creature = creature_ref } -> Just creature_ref
86 ExpendToolEvent {} -> Nothing
8e2c88a @clanehin Move common PlayerState functions into their own module.
authored
87
Something went wrong with that request. Please try again.