Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1ディレクトリ分の宝さがしゲーム #11

Draft
wants to merge 17 commits into
base: master
Choose a base branch
from
32 changes: 32 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
CFLAGS = -Wall

all: treasure

treasure: main.o base64.o command.o viewText.o fileSystem.o
gcc main.o base64.o command.o viewText.o fileSystem.o -lncursesw -ltinfo -o treasure

main.o: main.c fileSystem.h command.h

base64.o: base64.c base64.h

command.o: command.c fileSystem.h base64.h viewText.h command.h

viewText.o: viewText.c viewText.h

fileSystem.o: fileSystem.c fileSystem.h

.c.o:
gcc -c $< $(CFLAGS)

.SUFFIXES: .c .o

clean:
-rm *.o

distclean: clean
-rm treasure

dist: distclean
(tar zcvf treasure.tgz ./; mv ./treasure.tgz ../)

.PHONY: all clean distclean
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Treasure-hunt-Game
An treasure hunt game made in a school class

# 概要
実際にある(進行上必要なコマンドを除いて)Linuxコマンドを用いて宝探しを行うゲームを作る

# 作業
完了
- Ver0.0.0 コマンドラインの再現
---
進行中
- Ver1.0.0 1ディレクトリ分の宝探しゲーム
---
予定
- Ver1.1.0 ヒント機能、目的表示機能追加
- Ver2.0.0 二部屋目の実装

# 到達進度
~~コマンドラインの再現~~<br>
~~echo,cat,lsの実装~~<br>
~~base64の実装~~<br>
~~前のコマンドを矢印キーで呼び出す機能の実装~~<br>
~~catのグラフィカル化~~<br>
~~ディレクトリシステムの構造体化~~<br>
構造体化に伴う各種コマンドの最適化<br>
宝箱の実装<br>
curlを用いてヒントを表示する機能を作る<br>
目的表示機能の追加<br>
二部屋目の実装<br>
マップ風表示機能の追加<br>
鍵のかかった部屋の実装<br>
20 changes: 20 additions & 0 deletions aes.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "fileSystem.h"
#include "aes.h"

//boner

void DecodeAes(char* passwd,Item* root,Item* inFile,char* outName,char* out,char* path)
{
Item* node = (Item*)malloc(sizeof(Item));

printf("dec %s\n",inFile->name);
if (!strcmp(passwd,"boner"))
{
append(outName,0,inFile->parent,node);
SetContent(root,path,"tesst");
}
else strcpy(out,"bad decrypt");
}
1 change: 1 addition & 0 deletions aes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
void DecodeAes(char* ,Item* ,Item* ,char* ,char* ,char* );
94 changes: 94 additions & 0 deletions base64.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "base64.h"

int DecodeBase64_6(int c)
{
if (c >= 'A' && c <= 'Z') {
return c - 'A';
} else if (c >= 'a' && c <= 'z') {
return c - 'a' + 26;
} else if (c >= '0' && c <= '9') {
return c - '0' + 52;
} else if (c == '+') {
return 62;
} else if (c == '/') {
return 63;
} else if (c == '=') {
return 0;
} else {
fprintf(stderr, "Error: unknown data %d\n", c);
exit(1);
}
}

void DecodeBase64(char *dst, char *src)
{
unsigned int o[4];
char *p = dst;
size_t i;

for (i = 0; src[i]; i += 4) {
o[0] = DecodeBase64_6(src[i]);
o[1] = DecodeBase64_6(src[i + 1]);
o[2] = DecodeBase64_6(src[i + 2]);
o[3] = DecodeBase64_6(src[i + 3]);

*p++ = (o[0] << 2) | ((o[1] & 0x30) >> 4);
*p++ = ((o[1] & 0xf) << 4) | ((o[2] & 0x3c) >> 2);
*p++ = ((o[2] & 0x3) << 6) | (o[3] & 0x3f);
}

*p = '\0';
}

void EncodeBase64(char *dst, char *src)
{
size_t i;
unsigned int o[4];
unsigned int x;
const char table[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
size_t len = strlen(src);
size_t mod = len % 3;
size_t mod_len = len - mod;
char *p = dst;

for (i = 0; i < mod_len; i += 3) {
x = ((unsigned int) src[i] << 16)
+ ((unsigned int) src[i + 1] << 8)
+ (unsigned int) src[i + 2];
o[0] = (x >> 18) & 0x3f;
o[1] = (x >> 12) & 0x3f;
o[2] = (x >> 6) & 0x3f;
o[3] = x & 0x3f;
*p++ = table[o[0]];
*p++ = table[o[1]];
*p++ = table[o[2]];
*p++ = table[o[3]];
}

/* do nothing if mod == 0. */
if (mod == 1) {
x = (unsigned int) src[i] << 16;
o[0] = (x >> 18) & 0x3f;
o[1] = (x >> 12) & 0x3f;
*p++ = table[o[0]];
*p++ = table[o[1]];
*p++ = '=';
*p++ = '=';
} else if (mod == 2) {
x = ((unsigned int) src[i] << 16) + ((unsigned int) src[i + 1] << 8);
o[0] = (x >> 18) & 0x3f;
o[1] = (x >> 12) & 0x3f;
o[2] = (x >> 6) & 0x3f;
*p++ = table[o[0]];
*p++ = table[o[1]];
*p++ = table[o[2]];
*p++ = '=';
}

*p = '\0';
}

3 changes: 3 additions & 0 deletions base64.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

void DecodeBase64(char* ,char* );
void EncodeBase64(char* ,char* );
Loading