123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- #ifndef GALAXY_H
- #define GALAXY_H
- #include <array>
- #include <cstdint>
- #include <iostream>
- #include <ostream>
- #include <regex>
- #include <set>
- #include <stdexcept>
- #include <string>
- #include <vector>
- #include "buysell.h"
- #include "json.hpp"
- using json = nlohmann::json;
- typedef uint16_t sector_type;
- struct sector_warps {
- sector_type sector;
-
- std::set<sector_type> warps;
-
-
-
-
- sector_warps();
- sector_warps(sector_type, std::set<sector_type>);
- void add(sector_type sector);
-
- friend std::ostream& operator<<(std::ostream& os, const sector_warps& warps);
-
-
- };
- enum trade_types {
- NONE,
- BEST,
- OK,
- FAIR_E,
- FAIR_O,
- FAIR_F,
- };
- struct trade_type_result {
- trade_types type;
- buysell trades;
- };
- struct port_pair_type {
- int type;
- buysell trades;
- sector_type s1, s2;
- };
- struct port {
- sector_type sector;
- uint8_t type;
- uint16_t amount[3];
- uint8_t percent[3];
- bool unknown(void);
-
- friend std::ostream& operator<<(std::ostream& os, const port& p);
- };
- struct port parse_portcim(const std::string line);
- struct density {
- sector_type sector;
- uint16_t density;
- uint16_t warps;
- uint16_t navhaz;
- bool anomaly;
- bool known;
- friend bool operator==(const struct density lhs, const struct density rhs);
- };
- class density_scan {
- public:
- sector_type sector;
- std::array<density, 6> d;
- density_scan();
-
- void reset(sector_type sector);
- void add_scan(density d);
- density find(sector_type sector);
-
- int pos;
- };
- class planet {
- public:
- sector_type sector;
- int number;
- int level;
- std::string name;
- char c;
- };
- class Galaxy {
- public:
- Galaxy();
- ~Galaxy();
- void reset(void);
- json config;
- json meta;
- int burnt_percent;
- density_scan dscan;
-
-
- std::map<sector_type, port> ports;
- std::map<sector_type, sector_warps> warps;
- std::map<int, planet> planets;
- void add_warp(sector_warps);
- void add_port(sector_type sector, int port_class);
- void add_port(port);
- void save(void);
- void load(void);
- sector_type find_nearest_unexplored(sector_type sector);
- std::vector<port_pair_type> find_best_trades(void);
- std::vector<port_pair_type> find_trades(sector_type sector,
- bool highest = true);
- trade_type_result trade_type_info(sector_type port1, sector_type port2,
- int burnt_percent = 20);
- void sort_port_pair_type(std::vector<port_pair_type>& pptv);
- port_pair_type find_closest(int sector);
- port_pair_type find_closest_trade(int sector, int lowest_trade_type,
- int burnt_percent = 20);
- sector_type find_nearest_selling(int sector, int product, int selling=250);
- std::vector<sector_type> find_safe(void);
- char game;
- std::string username;
- };
- #endif
|