cleanup, license
This commit is contained in:
parent
daa9fee4c4
commit
ef93a77a37
|
@ -0,0 +1,29 @@
|
||||||
|
BSD 3-Clause License
|
||||||
|
|
||||||
|
Copyright (c) 2022, entity known as stacksmith
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
3. Neither the name of the copyright holder nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived from
|
||||||
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||||
|
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@ -3,7 +3,7 @@
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
//https://gist.github.com/ibaned/41481b2fdddbb61a4291
|
|
||||||
#include "eleven.h"
|
#include "eleven.h"
|
||||||
|
|
||||||
const char* tochar(int val){
|
const char* tochar(int val){
|
||||||
|
@ -61,14 +61,14 @@ int read_move(void){
|
||||||
static struct termios backup;
|
static struct termios backup;
|
||||||
static struct termios current;
|
static struct termios current;
|
||||||
|
|
||||||
void take_stdin(void){
|
void term_start(void){
|
||||||
tcgetattr(STDIN_FILENO, &backup);
|
tcgetattr(STDIN_FILENO, &backup);
|
||||||
current = backup;
|
current = backup;
|
||||||
current.c_lflag &= (~ICANON & ~ECHO);
|
current.c_lflag &= (~ICANON & ~ECHO);
|
||||||
tcsetattr(STDIN_FILENO, TCSANOW, ¤t);
|
tcsetattr(STDIN_FILENO, TCSANOW, ¤t);
|
||||||
}
|
}
|
||||||
|
|
||||||
void give_stdin(void){
|
void term_end(void){
|
||||||
tcsetattr(STDIN_FILENO, TCSANOW, &backup);
|
tcsetattr(STDIN_FILENO, TCSANOW, &backup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ int main(){
|
||||||
srand(time(0));
|
srand(time(0));
|
||||||
init(tiles);
|
init(tiles);
|
||||||
print(tiles);
|
print(tiles);
|
||||||
take_stdin();
|
term_init();
|
||||||
while ((c = read_move()) != EOF) {
|
while ((c = read_move()) != EOF) {
|
||||||
if(move(tiles, c)){
|
if(move(tiles, c)){
|
||||||
moves++;
|
moves++;
|
||||||
|
@ -93,7 +93,7 @@ int main(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf("%d moves\n",moves);
|
printf("%d moves\n",moves);
|
||||||
give_stdin();
|
term_end();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue