-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
899 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters