| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
#pragma warning(disable: 4786) |
|---|
| 7 |
#pragma once |
|---|
| 8 |
|
|---|
| 9 |
#include <windows.h> |
|---|
| 10 |
|
|---|
| 11 |
#include "GraphIcon.h" |
|---|
| 12 |
#include "mysql.h" |
|---|
| 13 |
|
|---|
| 14 |
#include <vector> |
|---|
| 15 |
#include <list> |
|---|
| 16 |
#include <string> |
|---|
| 17 |
#include <map> |
|---|
| 18 |
|
|---|
| 19 |
using std::vector; |
|---|
| 20 |
using std::string; |
|---|
| 21 |
using std::list; |
|---|
| 22 |
using std::map; |
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
enum GOType {GO_NPC = 0x0, GO_LOCATION, GO_ITEM, GO_LAST}; |
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
class GameObject |
|---|
| 32 |
{ |
|---|
| 33 |
public: |
|---|
| 34 |
GOType type; |
|---|
| 35 |
}; |
|---|
| 36 |
|
|---|
| 37 |
class NPC : public GameObject { |
|---|
| 38 |
public: |
|---|
| 39 |
string name; |
|---|
| 40 |
|
|---|
| 41 |
int xcoord, ycoord; |
|---|
| 42 |
|
|---|
| 43 |
NPC() {type = GO_NPC;} |
|---|
| 44 |
|
|---|
| 45 |
map<string, int> attributes; |
|---|
| 46 |
map<std::pair<string, int>, int> relationships; |
|---|
| 47 |
}; |
|---|
| 48 |
|
|---|
| 49 |
|
|---|
| 50 |
enum LocType {LOC_TOWN = 0x0, LOC_FARM, LOC_MARKET, LOC_BAR, LOC_GENERIC, LOC_LAST}; |
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 |
class Location : public GameObject |
|---|
| 54 |
{ |
|---|
| 55 |
public: |
|---|
| 56 |
string name; |
|---|
| 57 |
|
|---|
| 58 |
LocType loc_type; |
|---|
| 59 |
|
|---|
| 60 |
Location() {type = GO_LOCATION;} |
|---|
| 61 |
|
|---|
| 62 |
|
|---|
| 63 |
int ur_x, ur_y, ll_x, ll_y; |
|---|
| 64 |
}; |
|---|
| 65 |
|
|---|
| 66 |
class Item : public GameObject |
|---|
| 67 |
{ |
|---|
| 68 |
public: |
|---|
| 69 |
Item() {type = GO_ITEM;} |
|---|
| 70 |
|
|---|
| 71 |
|
|---|
| 72 |
}; |
|---|
| 73 |
|
|---|
| 74 |
|
|---|
| 75 |
|
|---|
| 76 |
|
|---|
| 77 |
|
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 |
enum OpCode {OP_CHANGEATTRIBUTE=0x0, OP_MOVENPC, OP_CHANGERELATIONSHIP, OP_NOOP, OP_LAST}; |
|---|
| 81 |
|
|---|
| 82 |
const int NUM_COND = 10; |
|---|
| 83 |
|
|---|
| 84 |
|
|---|
| 85 |
|
|---|
| 86 |
|
|---|
| 87 |
class Condition |
|---|
| 88 |
{ |
|---|
| 89 |
public: |
|---|
| 90 |
Condition() { |
|---|
| 91 |
satisfied = 0; |
|---|
| 92 |
conditions = new string*[NUM_COND]; |
|---|
| 93 |
for (int i = 0; i < NUM_COND; i++) |
|---|
| 94 |
conditions[i] = new string[NUM_COND]; |
|---|
| 95 |
} |
|---|
| 96 |
|
|---|
| 97 |
int satisfied; |
|---|
| 98 |
|
|---|
| 99 |
|
|---|
| 100 |
vector<vector<GameObject *> > vars; |
|---|
| 101 |
|
|---|
| 102 |
string ** conditions; |
|---|
| 103 |
}; |
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 |
|
|---|
| 107 |
|
|---|
| 108 |
class Operator |
|---|
| 109 |
{ |
|---|
| 110 |
public: |
|---|
| 111 |
Operator() {code = OP_NOOP;} |
|---|
| 112 |
|
|---|
| 113 |
|
|---|
| 114 |
OpCode code; |
|---|
| 115 |
|
|---|
| 116 |
|
|---|
| 117 |
Condition PreConds; |
|---|
| 118 |
|
|---|
| 119 |
Condition PostConds; |
|---|
| 120 |
}; |
|---|
| 121 |
|
|---|
| 122 |
|
|---|
| 123 |
class World |
|---|
| 124 |
{ |
|---|
| 125 |
public: |
|---|
| 126 |
int map_height, map_width; |
|---|
| 127 |
|
|---|
| 128 |
vector<Location> Locations; |
|---|
| 129 |
|
|---|
| 130 |
|
|---|
| 131 |
vector<NPC> NPCs; |
|---|
| 132 |
vector<Item> Items; |
|---|
| 133 |
}; |
|---|
| 134 |
|
|---|
| 135 |
|
|---|
| 136 |
|
|---|
| 137 |
|
|---|
| 138 |
|
|---|
| 139 |
|
|---|
| 140 |
|
|---|
| 141 |
enum NodeType {NODE_STORY = 0x0, NODE_KEYFRAME, NODE_LAST}; |
|---|
| 142 |
|
|---|
| 143 |
|
|---|
| 144 |
class AuthorNode { |
|---|
| 145 |
public: |
|---|
| 146 |
NodeType type; |
|---|
| 147 |
string name; |
|---|
| 148 |
|
|---|
| 149 |
GraphIcon *icon; |
|---|
| 150 |
|
|---|
| 151 |
virtual int save(int story_id, int parent_id) = 0; |
|---|
| 152 |
virtual void del_node() = 0; |
|---|
| 153 |
}; |
|---|
| 154 |
|
|---|
| 155 |
|
|---|
| 156 |
|
|---|
| 157 |
|
|---|
| 158 |
|
|---|
| 159 |
class KeyFrameNode : public AuthorNode |
|---|
| 160 |
{ |
|---|
| 161 |
public: |
|---|
| 162 |
KeyFrameNode() {type = NODE_KEYFRAME; name = "NONE"; parent = NULL; icon = new GraphIcon(this); attempted = 0;} |
|---|
| 163 |
|
|---|
| 164 |
|
|---|
| 165 |
KeyFrameNode* parent; |
|---|
| 166 |
|
|---|
| 167 |
vector<KeyFrameNode*> preconds; |
|---|
| 168 |
|
|---|
| 169 |
Condition conditions; |
|---|
| 170 |
|
|---|
| 171 |
|
|---|
| 172 |
int attempted; |
|---|
| 173 |
|
|---|
| 174 |
|
|---|
| 175 |
virtual int save(int story_id, int parent_id); |
|---|
| 176 |
|
|---|
| 177 |
virtual void del_node(); |
|---|
| 178 |
}; |
|---|
| 179 |
|
|---|
| 180 |
|
|---|
| 181 |
|
|---|
| 182 |
|
|---|
| 183 |
class StoryNode : public AuthorNode |
|---|
| 184 |
{ |
|---|
| 185 |
public: |
|---|
| 186 |
StoryNode() {type = NODE_STORY; name = "NONE"; frame = NULL; visited = false; icon = new GraphIcon(this); parent = NULL;} |
|---|
| 187 |
|
|---|
| 188 |
StoryNode* parent; |
|---|
| 189 |
KeyFrameNode* frame; |
|---|
| 190 |
bool visited; |
|---|
| 191 |
|
|---|
| 192 |
vector<StoryNode*> next; |
|---|
| 193 |
|
|---|
| 194 |
|
|---|
| 195 |
virtual int save(int story_id, int parent_id); |
|---|
| 196 |
|
|---|
| 197 |
virtual void del_node(); |
|---|
| 198 |
}; |
|---|
| 199 |
|
|---|
| 200 |
|
|---|
| 201 |
|
|---|
| 202 |
|
|---|
| 203 |
class PlanNode |
|---|
| 204 |
{ |
|---|
| 205 |
public: |
|---|
| 206 |
PlanNode(const Operator& op, int depth = -1) : Op(op) |
|---|
| 207 |
{this->depth = depth; icon = new GraphIcon();} |
|---|
| 208 |
|
|---|
| 209 |
inline bool isLeaf() {return branches.empty();} |
|---|
| 210 |
|
|---|
| 211 |
|
|---|
| 212 |
vector<PlanNode*> branches; |
|---|
| 213 |
|
|---|
| 214 |
vector<PlanNode*> prevs; |
|---|
| 215 |
|
|---|
| 216 |
Operator Op; |
|---|
| 217 |
|
|---|
| 218 |
GraphIcon *icon; |
|---|
| 219 |
|
|---|
| 220 |
|
|---|
| 221 |
int num; |
|---|
| 222 |
|
|---|
| 223 |
int depth; |
|---|
| 224 |
}; |
|---|
| 225 |
|
|---|
| 226 |
|
|---|
| 227 |
|
|---|
| 228 |
|
|---|
| 229 |
|
|---|
| 230 |
|
|---|
| 231 |
int CheckValidOps(string str, int x, int y); |
|---|
| 232 |
int IsInt(string s); |
|---|
| 233 |
std::pair<int,int> GetMapSize(); |
|---|
| 234 |
vector<Location> MapGenerator(); |
|---|
| 235 |
list<Operator>* GetGregOperators(World* W); |
|---|
| 236 |
void DoOps(World* W, Operator* O); |
|---|
| 237 |
void initRegressionPanes(); |
|---|
| 238 |
vector<list<Operator> > GetMeOperators(Condition C, int index); |
|---|
| 239 |
vector<vector<GameObject *> > GetList(string** conds, World* W); |
|---|
| 240 |
vector<vector<GameObject *> > BindList(vector<vector<GameObject*> > Obs, World* W, string** conds, int level); |
|---|
| 241 |
Condition CheckWorldState(World* W, Condition C); |
|---|
| 242 |
int recievedata(); |
|---|
| 243 |
|
|---|
| 244 |
|
|---|
| 245 |
|
|---|
| 246 |
|
|---|
| 247 |
|
|---|
| 248 |
extern StoryNode* story_root; |
|---|
| 249 |
extern World* real_world; |
|---|
| 250 |
extern MYSQL* conn; |
|---|
| 251 |
extern list<Operator> Ops; |
|---|
| 252 |
|
|---|
| 253 |
extern PlanNode* forward_root; |
|---|
| 254 |
extern PlanNode* regression_root; |
|---|
| 255 |
extern PlanNode* current_plan_root; |
|---|
| 256 |
extern list<vector<PlanNode*> > pending_execution; |
|---|
| 257 |
|
|---|
| 258 |
|
|---|