26 lines
627 B
C++
26 lines
627 B
C++
|
//
|
||
|
// Created by hamac on 18.12.2024.
|
||
|
//
|
||
|
|
||
|
#include <string>
|
||
|
#include <sstream>
|
||
|
#include <vector>
|
||
|
#include <unordered_map>
|
||
|
#include "ChessUtils.h"
|
||
|
|
||
|
std::vector<std::string> ChessUtils::split(const std::string &s, char delim) {
|
||
|
std::vector<std::string> elems;
|
||
|
std::stringstream ss(s);
|
||
|
std::string item;
|
||
|
while (std::getline(ss, item, delim)) {
|
||
|
elems.push_back(item);
|
||
|
}
|
||
|
return elems;
|
||
|
}
|
||
|
|
||
|
std::pair<int, int> ChessUtils::convertPosition(const std::string &pos) {
|
||
|
int y = pos[pos.size()-2] - 'a';
|
||
|
int x = ChessUtils::fileConvertion.find((pos[pos.size()-1] - '0')-1)->second;
|
||
|
return std::make_pair(x, y);
|
||
|
}
|