-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathswarkland.hpp
149 lines (128 loc) · 5.25 KB
/
swarkland.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#ifndef SWARKLAND_HPP
#define SWARKLAND_HPP
#include "hashtable.hpp"
#include "geometry.hpp"
#include "list.hpp"
#include "thing.hpp"
#include "item.hpp"
#include "action.hpp"
#include "random.hpp"
extern bool print_diagnostics;
extern int snapshot_interval;
extern bool headless_mode;
struct Game {
WandDescriptionId actual_wand_descriptions[WandId_COUNT];
PotionDescriptionId actual_potion_descriptions[PotionId_COUNT];
BookDescriptionId actual_book_descriptions[BookId_COUNT];
uint256 you_id = uint256::zero();
uint256 player_actor_id;
int64_t time_counter = 0;
// starts at 1
int dungeon_level = 0;
MapMatrix<TileType> actual_map_tiles;
MapMatrix<uint8_t> aesthetic_indexes;
bool test_mode;
// for test mode
uint256 random_arbitrary_large_number_count = uint256::zero();
uint256 random_initiative_count = uint256::zero();
// for normal mode
RandomState the_random_state;
int item_pool[TOTAL_ITEMS];
IdMap<Thing> actual_things;
IdMap<uint256> observer_to_active_identifiable_item;
};
extern bool cheatcode_full_visibility;
extern Thing cheatcode_spectator;
extern Game * game;
static inline Thing you() { return game->actual_things.get(game->you_id); }
static inline Thing player_actor() { return game->actual_things.get(game->player_actor_id); }
static inline uint256 random_id() {
if (game->test_mode) {
// just increment a counter
game->random_arbitrary_large_number_count.values[3]++;
return game->random_arbitrary_large_number_count;
}
return random_uint256();
}
void cheatcode_spectate(Coord location);
static inline bool is_actual_individual(Thing thing) {
return thing->still_exists && thing->thing_type == ThingType_INDIVIDUAL;
}
static inline FilteredIterator<IdMap<Thing>::Iterator, Thing> actual_individuals() {
return FilteredIterator<IdMap<Thing>::Iterator, Thing>(game->actual_things.value_iterator(), is_actual_individual);
}
static inline Thing get_top_level_container(Thing thing) {
while (thing->container_id != uint256::zero())
thing = game->actual_things.get(thing->container_id);
return thing;
}
static inline PerceivedThing get_top_level_container(const Thing & observer, PerceivedThing thing) {
while (thing->container_id != uint256::zero())
thing = observer->life()->knowledge.perceived_things.get(thing->container_id);
return thing;
}
static inline bool individual_uses_items(Thing thing) {
switch (thing->mental_species()->mind) {
case Mind_NONE:
case Mind_BEAST:
return false;
case Mind_SAVAGE:
case Mind_CIVILIZED:
return true;
}
unreachable();
}
static inline bool individual_is_clever(Thing thing) {
switch (thing->mental_species()->mind) {
case Mind_NONE:
case Mind_BEAST:
case Mind_SAVAGE:
return false;
case Mind_CIVILIZED:
return true;
}
unreachable();
}
static inline bool is_invisible(Thing observer, PerceivedThing thing) {
return has_status(get_top_level_container(observer, thing), StatusEffect::INVISIBILITY);
}
void swarkland_init();
bool validate_action(Thing actor, const Action & action);
bool can_move(Thing actor);
static inline int get_movement_cost(Thing actor) {
if (has_status(actor, StatusEffect::SPEED))
return speedy_movement_cost;
if (has_status(actor, StatusEffect::SLOWING))
return slow_movement_cost;
return actor->physical_species()->movement_cost;
}
void run_the_game();
int compare_perceived_things_by_type_and_z_order(const PerceivedThing & a, const PerceivedThing & b);
PerceivedThing find_perceived_individual_at(Thing observer, Coord location);
void find_perceived_things_at(Thing observer, Coord location, List<PerceivedThing> * output_sorted_list);
void find_perceived_items_at(Thing observer, Coord location, List<PerceivedThing> * output_sorted_list);
Thing find_individual_at(Coord location);
Thing get_equipped_weapon(Thing individual);
void find_items_in_inventory(uint256 container_id, List<Thing> * output_sorted_list);
void find_items_in_inventory(Thing observer, uint256 container_id, List<PerceivedThing> * output_sorted_list);
void find_items_on_floor(Coord location, List<Thing> * output_sorted_list);
void drop_item_to_the_floor(Thing item, Coord location);
void get_abilities(Thing individual, List<AbilityId> * output_sorted_abilities);
bool is_ability_ready(Thing actor, AbilityId ability_id);
void suck_up_item(Thing actor, Thing item);
bool attempt_move(Thing actor, Coord new_position);
bool attempt_dodge(Thing attacker, Thing actor);
void apply_impulse(Thing individual, Coord vector);
bool check_for_status_expired(Thing individual, int index);
void polymorph_individual(Thing individual, SpeciesId species_id, int duration);
void damage_individual(Thing target, int damage, Thing attacker, bool is_melee);
void poison_individual(Thing attacker, Thing target);
void slow_individual(Thing attacker, Thing target);
void heal_hp(Thing individual, int hp);
void use_mana(Thing actor, int mana);
void gain_mp(Thing individual, int mp);
void change_map(Coord location, TileType new_tile_type);
void fix_perceived_z_orders(Thing observer, uint256 container_id);
void fix_z_orders(uint256 container_id);
void fix_z_orders(Coord location);
#endif