refactoring

This commit is contained in:
2024-05-28 17:03:07 +02:00
parent efcc81f339
commit bae11647e4
8 changed files with 96 additions and 49 deletions
+2
View File
@@ -0,0 +1,2 @@
extern int board_size;
extern bool ishost;
+55
View File
@@ -0,0 +1,55 @@
#include<iostream>
#include"global.hpp"
#include"input.hpp"
using std::cout;
using std::cin;
int board_size;
bool ishost;
bool repeat = true;
void ishost_check() {
char charishost;
while (repeat) {
cout << "will you be host or guest of this game?\n" << "(h/g): ";
cin >> charishost;
repeat = false;
switch(charishost) {
case 'h':
ishost = true;
break;
case 'g':
ishost = false;
break;
default:
repeat = true;
}
}
}
void board_size_check() {
repeat = true;
while (repeat) {
cout << "\nplease enter board size(for example: 3 for 3x3): ";
cin >> board_size;
if(cin.fail()) {
cout << "integer please\n";
cin.clear();
cin.ignore(256,'\n');
} else {
if(board_size > 0) {
repeat = false;
} else {
cout << "positive integer please\n";
}
}
}
}
+2
View File
@@ -0,0 +1,2 @@
void ishost_check();
void board_size_check();
+58
View File
@@ -0,0 +1,58 @@
#include<iostream>
#include"global.hpp"
#include"net.hpp"
#include"input.hpp"
using std::cout;
using std::cin;
int main() {
cout << R"( ___ __ _______ ___ ________ ________ _____ ______ _______ _________ ________
|\ \ |\ \|\ ___ \ |\ \ |\ ____\|\ __ \|\ _ \ _ \|\ ___ \ |\___ ___\\ __ \
\ \ \ \ \ \ \ __/|\ \ \ \ \ \___|\ \ \|\ \ \ \\\__\ \ \ \ __/| \|___ \ \_\ \ \|\ \
\ \ \ __\ \ \ \ \_|/_\ \ \ \ \ \ \ \ \\\ \ \ \\|__| \ \ \ \_|/__ \ \ \ \ \ \\\ \
\ \ \|\__\_\ \ \ \_|\ \ \ \____\ \ \____\ \ \\\ \ \ \ \ \ \ \ \_|\ \ \ \ \ \ \ \\\ \
\ \____________\ \_______\ \_______\ \_______\ \_______\ \__\ \ \__\ \_______\ \ \__\ \ \_______\
\|____________|\|_______|\|_______|\|_______|\|_______|\|__| \|__|\|_______| \|__| \|_______|
________ ___ ___ _______ ________ _________ ___ ___ _______ ________ _______ _________ ___ __ ________ ________ ___ __
|\ __ \|\ \ / /|\ ___ \ |\ __ \ |\___ ___\\ \|\ \|\ ___ \ |\ ___ \|\ ___ \|\___ ___\\ \ |\ \|\ __ \|\ __ \|\ \|\ \
\ \ \|\ \ \ \ / / | \ __/|\ \ \|\ \ \|___ \ \_\ \ \\\ \ \ __/| \ \ \\ \ \ \ __/\|___ \ \_\ \ \ \ \ \ \ \|\ \ \ \|\ \ \ \/ /|_
\ \ \\\ \ \ \/ / / \ \ \_|/_\ \ _ _\ \ \ \ \ \ __ \ \ \_|/__ \ \ \\ \ \ \ \_|/__ \ \ \ \ \ \ __\ \ \ \ \\\ \ \ _ _\ \ ___ \
\ \ \\\ \ \ / / \ \ \_|\ \ \ \\ \| \ \ \ \ \ \ \ \ \ \_|\ \ \ \ \\ \ \ \ \_|\ \ \ \ \ \ \ \|\__\_\ \ \ \\\ \ \ \\ \\ \ \\ \ \
\ \_______\ \__/ / \ \_______\ \__\\ _\ \ \__\ \ \__\ \__\ \_______\ \ \__\\ \__\ \_______\ \ \__\ \ \____________\ \_______\ \__\\ _\\ \__\\ \__\
\|_______|\|__|/ \|_______|\|__|\|__| \|__| \|__|\|__|\|_______| \|__| \|__|\|_______| \|__| \|____________|\|_______|\|__|\|__|\|__| \|__|
_________ ___ ________ _________ ________ ________ _________ ________ _______
|\___ ___\\ \|\ ____\ |\___ ___\\ __ \|\ ____\ |\___ ___\\ __ \|\ ___ \
\|___ \ \_\ \ \ \ \___| ___________\|___ \ \_\ \ \|\ \ \ \___| ___________\|___ \ \_\ \ \|\ \ \ __/|
\ \ \ \ \ \ \ \ |\____________\ \ \ \ \ \ __ \ \ \ |\____________\ \ \ \ \ \ \\\ \ \ \_|/__
\ \ \ \ \ \ \ \___\|____________| \ \ \ \ \ \ \ \ \ \___\|____________| \ \ \ \ \ \\\ \ \ \_|\ \
\ \__\ \ \__\ \_______\ \ \__\ \ \__\ \__\ \_______\ \ \__\ \ \_______\ \_______\
\|__| \|__|\|_______| \|__| \|__|\|__|\|_______| \|__| \|_______|\|_______|
)" << '\n';
int board_size;
ishost_check();
board_size_check();
{
int init_net_status = init_net();
if(init_net_status != 0){
cout << "failed to initialize network\n";
return 2;
}
}
char board[board_size*board_size];
return 0;
}
+9
View File
@@ -0,0 +1,9 @@
#include"net.hpp"
int init_net() {
return 0;
}
+1
View File
@@ -0,0 +1 @@
extern int init_net();