Skip to content

Commit

Permalink
alpha-22032024.2123
Browse files Browse the repository at this point in the history
  • Loading branch information
GNUAn committed Mar 22, 2024
1 parent 0860659 commit 91d342d
Show file tree
Hide file tree
Showing 12 changed files with 899 additions and 93 deletions.
703 changes: 674 additions & 29 deletions LICENSE

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
.PHONY: all clean
all:
cc nettrap.c -o nettrap -std=c11 -Wall -Wextra -Werror
cc addr/sell.c -o sell -std=c11 -Wall -Wextra -Werror

cc nettrap.c -o nettrap -std=c11 -Wall -Wextra
clean:
rm nettrap sell
rm nettrap
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,20 @@
## Nettrap is a simple game about a man(the player) who was teleported to the net.

**NETTRAP IS IN ACTIVE DEVELOPMENT AND YOU MAY ENCOUNTER BUGS**

Nettrap, very interesting game
Copyright (C) 2024 AnatoliyL

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.

18 changes: 3 additions & 15 deletions addr/sell.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <stdio.h>
#include "../zio.h"
#include <string.h>
void sell(int, char **);
void sell(int money, char **inventory)
{
Expand All @@ -9,7 +9,8 @@ void sell(int money, char **inventory)
for (;;)
{
printf("Hello! What do you want to sell?\n");
sgets(buf, 1024);
fgets(buf, 1024, stdin);
buf[strlen(buf) - 1] = '\0';
if (strcmp(buf, "exit") == 0)
{
printf("Come back again!\nExiting sell.site...\n");
Expand All @@ -29,16 +30,3 @@ void sell(int money, char **inventory)
strcpy(inventory[indexsame], "\0");
}
}



int main(int argc, char **argv)
{
if (argc != 2147483647)
{
// Do nothing
}
int money = 50;
sell(money, argv);
return 0;
}
32 changes: 32 additions & 0 deletions addr/sell.c~
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include <stdio.h>
#include <string.h>
void sell(int, char **);
void sell(int money, char **inventory)
{
char* buf = {0};
int price;
int indexsame = -1;
for (;;)
{
printf("Hello! What do you want to sell?\n");
fgets(buf, 1024, stdin);
buf[strlen(buf) - 1] = '\0'
if (strcmp(buf, "exit") == 0)
{
printf("Come back again!\nExiting sell.site...\n");
break;
}
for (int i = 0; i < 64; i++)
{
if (strcmp(buf, inventory[i]) == 0)
indexsame = i;
if (indexsame == 0)
printf("You don't have %s\nTry to sell something else\n", buf);
}
printf("Ok, you want to sell %s, but at what price?\n", buf);
scanf("%d", &price);
money+=price;
printf("%s sold for %d$, now you have %d$", buf, price, price);
strcpy(inventory[indexsame], "\0");
}
}
29 changes: 25 additions & 4 deletions addr/shop.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,23 @@
#include <unistd.h>
#include <stdlib.h>

void shop(int);
void shop(int, char**);
void ask(void);

void shop(int money)
void shop(int money, char **inventory)
{
int empty = 0;
printf("Loading Gshop...\n");
sleep(5);
printf("Welcome to Gshop v0.0.1!\n");
printf("Welcome to gshop v0.0.1!\n");
char buf[128];
fgets(buf, 127, stdin);
buf[strlen(buf)-1] = '\0';
for (;;)
{
fgets(buf, 127, stdin);
buf[strlen(buf)-1] = '\0';
printf("Gshop 0.0.1 loading... User input: %s\n", buf);
printf("gshop 0.0.1 loading... User input: %s\n", buf);
if (strcmp(buf, "list") == 0)
{
printf("List of things that you can buy in this shop:\n\n");
Expand All @@ -30,11 +31,31 @@ void shop(int money)
{
ask();
money-=15;
for (int i = 0; i < 64; i++)
{
if (strcmp(inventory[i], "\0") == 0)
{
empty = i;
break;
}
}
strcpy(inventory[empty], "cbook");
printf("cbook added to tile %d\n", empty);
}
if (strcmp(buf, "2") == 0 && money >= 20)
{
ask();
money-=20;
for (int i = 0; i < 64; i++)
{
if (strcmp(inventory[i], "\0") == 0)
{
empty = i;
break;
}
}
strcpy(inventory[empty], "notebook");
printf("notebook added to tile %d\n", empty);
}
if (strcmp(buf, "3") == 0 && money >= 50)
{
Expand Down
91 changes: 91 additions & 0 deletions addr/shop.c~
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>

void shop(int, char**);
void ask(void);

void shop(int money, char **inventory)
{
int empty = 0;
printf("Loading Gshop...\n");
sleep(5);
printf("Welcome to gshop v0.0.1!\n");
char buf[128];
fgets(buf, 127, stdin);
buf[strlen(buf)-1] = '\0';
for (;;)
{
fgets(buf, 127, stdin);
buf[strlen(buf)-1] = '\0';
printf("gshop 0.0.1 loading... User input: %s\n", buf);
if (strcmp(buf, "list") == 0)
{
printf("List of things that you can buy in this shop:\n\n");
printf("1. C language learning book $15\t2. Notebook(not computer) $20\n");
printf("3. 500 coins $10\t4. FastConnect $10\t5. HyperfastConnect $30\n");
printf("Select one of these to buy it\n");
}
if (strcmp(buf, "1") == 0 && money >= 15)
{
ask();
money-=15;
for (int i = 0; i < 64; i++)
{
if (strcmp(inventory, "\0") == 0)
{
empty = i;
break;
}
}
strcpy(inventory[empty], "cbook");
printf("cbook added to tile %d\n", empty);
}
if (strcmp(buf, "2") == 0 && money >= 20)
{
ask();
money-=20;
for (int i = 0; i < 64; i++)
{
if (strcmp(inventory, "\0") == 0)
{
empty = i;
break;
}
}
strcpy(inventory[empty], "notebook");
printf("notebook added to tile %d\n", empty);
}
if (strcmp(buf, "3") == 0 && money >= 50)
{
ask();
money-=10;
printf("SCAM!\n");
}
if (strcmp(buf, "4") == 0 && money >= 10)
{
ask();
money-=10;
}
if (strcmp(buf, "5") == 0 && money >= 30)
{
ask();
money-=30;
}
if (money < 10)
{
printf("You don't have enough money!\nTry to get some more and go back here\n");
break;
}
if (strcmp(buf, "exit") == 0)
{
return;
}
}
}
void ask(void)
{
printf("Are you sure?\n");
getchar();
}
17 changes: 17 additions & 0 deletions addr/zio.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <stdio.h>
#include <string.h>
char *asgets(char *str);
char *sgets(char *str, int count);
char *sgets(char *str, int count)
{
fgets(str, count, stdin);
str[strlen(str)-1] = '\0';
return str;
}

char *asgets(char *str)
{
int count = sizeof(str);
sgets(str, count);
return str;
}
8 changes: 0 additions & 8 deletions credits.txt

This file was deleted.

14 changes: 0 additions & 14 deletions docs/index.html

This file was deleted.

6 changes: 6 additions & 0 deletions docs/whatisthisabout.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
What is this game about?
This game is about man who was serfing the net,
but then, he was sucked into the computer.
What do i need to do?
You need to buy and sell things, get reputation,
and then try to find the way out.
51 changes: 32 additions & 19 deletions nettrap.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
#include <string.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include "zio.h"
#include "addr/shop.c"
void bridge(int);
void bridge(int money)
#include "addr/sell.c"
void bridge(int, char**);
void bridge(int money, char **inventory)
{
printf("Area: Bridge\n");
char adr[512];
Expand All @@ -13,33 +16,43 @@ void bridge(int money)
if (strcmp(adr, "exit") == 0)
{
printf("Thanks for playing nettrap! Hope you like it!\n");
FILE *f = fopen("credits.txt", "r");
int c;
while ((c = fgetc(f)) != EOF)
putchar(c);
break;
}
if (strcmp(adr, "shop") == 0)
shop(money);
if (strcmp(adr, "list") == 0)
shop(money, inventory);
else if (strcmp(adr, "sell") == 0)
{
sell(money, inventory);
}
else if (strcmp(adr, "list") == 0)
printf("shop, exit, list\n");
if (strcmp(adr, "exit") == 0)
break;


printf("Last input:%s\n", adr);
}
}

int main()
int main(void)
{
FILE *f = fopen("startstory.txt", "r");
int c;
while ((c = fgetc(f)) != EOF)
printf("\t\tStory\n\
\n\n\
It was a typical day, you opened browser,\watched some\n\
videos, but then, everything dissapeared and you were sucked\n\
into computer. You opened your eyes and saw, that you're in the WWW\n\
");
sleep(7);
system("clear");
int money = 75;
char **inventory;
for (int i = 0; i < 64; i++)
{
putchar(c);
for (int j = 0; j < 64; j++)
inventory = '\0';
}
int money = 75;
bridge(money);
printf("\
nettrap Copyright (C) 2024 AnatoliyL\n\
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n\
This is free software, and you are welcome to redistribute it\n\
under certain conditions; type `show c' for details.\n");

bridge(money, inventory);
return 0;
}

0 comments on commit 91d342d

Please sign in to comment.