123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 |
- #include <iostream>
- #include <string>
- #include <vector>
- #include <array>
- #include <cstdint>
- #include <regex>
- #include <stdexcept>
- #include <ostream>
- enum PRODUCT { FUEL = 0, ORG = 1, EQUIP = 2 };
- struct buysell {
- bool foe[3];
- bool operator==(const buysell &rhs) const;
- friend std::ostream& operator<<(std::ostream& os, const buysell& bs);
- };
- struct buysell_text {
- char txt[3];
- bool operator==(const buysell_text &rhs) const;
- friend std::ostream& operator<<(std::ostream& os, const buysell_text &bst);
- };
- #define MAX_WARPS 6
- typedef uint16_t sector_type;
- struct sector_warps {
- sector_type sector;
-
- sector_type warps[MAX_WARPS];
-
-
-
- sector_warps();
- void add(sector_type sector);
-
- friend std::ostream& operator<<(std::ostream& os, const sector_warps& warps);
- };
- constexpr buysell get_buysell(uint8_t type) {
- switch (type) {
- case 1:
- return {true, true, false};
- case 2:
- return {true, false, true};
- case 3:
- return {false, true, true};
- case 4:
- return {false, false, true};
- case 5:
- return {false, true, false};
- case 6:
- return {true, false, false};
- case 7:
- return {false, false, false};
- case 8:
- case 9:
- return {true, true, true};
- default:
- throw std::invalid_argument("invalid buysell type");
- }
- }
- constexpr buysell_text text_from_buysell(const buysell market) {
- buysell_text text{'?', '?', '?'};
- for (int x = 0; x < 3; ++x) {
- text.txt[x] = market.foe[x] ? 'B' : 'S';
- }
- return text;
- }
- constexpr buysell_text text_from_type(uint8_t type) {
- switch (type) {
- case 1:
- return buysell_text{'B', 'B', 'S'};
- case 2:
- return buysell_text{'B', 'S', 'B'};
- case 3:
- return buysell_text{'S', 'B', 'B'};
- case 4:
- return buysell_text{'S', 'S', 'B'};
- case 5:
- return buysell_text{'S', 'B', 'S'};
- case 6:
- return buysell_text{'B', 'S', 'S'};
- case 7:
- return buysell_text{'S', 'S', 'S'};
- case 8:
- case 9:
- return buysell_text{'B', 'B', 'B'};
- default:
- throw std::invalid_argument("invalid text_from_type type");
- }
- }
- constexpr uint8_t type_from_buysell(const buysell market) {
- if (market.foe[0]) {
- if (market.foe[1]) {
- if (market.foe[2]) {
- return 8;
- } else
- return 1;
- } else {
- if (market.foe[2]) {
- return 2;
- } else
- return 6;
- }
- } else {
- if (market.foe[1]) {
- if (market.foe[2]) {
- return 3;
- } else
- return 5;
- } else {
- if (market.foe[2]) {
- return 4;
- } else
- return 7;
- }
- }
- }
- struct port {
- uint16_t sector;
- uint8_t type;
- uint16_t amount[3];
- uint8_t percent[3];
- friend std::ostream& operator<<(std::ostream& os, const port &p);
- };
- struct port parse_portcim(const std::string line);
- class GameData {
- public:
- std::map<std::string, std::string> config;
-
-
- };
|