back to scratko.xyz
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md47
-rw-r--r--windows_client/client.c8
-rw-r--r--windows_client/client.h3
3 files changed, 38 insertions, 20 deletions
diff --git a/README.md b/README.md
index a7d1a5a..da73c73 100644
--- a/README.md
+++ b/README.md
@@ -4,14 +4,17 @@
## Description
-Network game. Client and server are written in pure C.
-For network communication the socket system with TCP/IP protocol is used. Due to this it is possible to use streaming through read and write system calls, and there is a guarantee that the data will arrive in strict order.
-The client and server are written in an event-driven programming model. Events are selected using the select system call, thus multiplexing I/O.
+Network game. Client and server are written in pure C.
+For network communication the socket system with TCP/IP protocol is used. Due to this it is possible to use streaming through read
+and write system calls, and there is a guarantee that the data will arrive in strict order.
+The client and server are written in an event-driven programming model. Events are selected using the select system call, thus
+multiplexing I/O.
GUI: console version.
Card suits are labeled as %, #, v, ^.
Card ranks: 2, 3, 4, 5, 6, 7, 8, 9, 9, 10, J, Q, K, A.
-There are several stages: attacking, defending, and tossing cards. Unlike classic Fool's game, here you can toss cards depending on the reaction of the players --- whoever has time to toss a card, that card goes on the table.
+There are several stages: attacking, defending, and tossing cards. Unlike classic Fool's game, here you can toss cards depending on
+the reaction of the players --- whoever has time to toss a card, that card goes on the table.
There are hints to help players.
@@ -19,8 +22,13 @@ There are hints to help players.
* When defending: those cards that can be used to beat back the attacking card on the table (higher rank, or with a trump suit).
* When tossing: those cards that have the same rank.
-It is possible to give up defense and accept attacking cards -- then press enter. It is also possible to discard the toss -- also press enter.
-The server analyzes whether the defender can fight back. If so, the server analyzes whether the defender can fight back. The defender is shown one card at a time (the others see all cards), which he must defeat. If the server decides that the defender does not have any cards that can be used to fight off the attacking cards, then the tossing phase is analyzed. If the other players (except the defender, of course) have cards with the same rank as on the table, then the player moves to the tossing phase, otherwise the player moves to a new attack phase.
+It is possible to give up defense and accept attacking cards -- then press enter. It is also possible to discard the toss -- also
+press enter.
+The server analyzes whether the defender can fight back. If so, the server analyzes whether the defender can fight back.
+The defender is shown one card at a time (the others see all cards), which he must defeat. If the server decides that the defender
+does not have any cards that can be used to fight off the attacking cards, then the tossing phase is analyzed.
+If the other players (except the defender, of course) have cards with the same rank as on the table, then the player moves to
+the tossing phase, otherwise the player moves to a new attack phase.
## Building
@@ -28,19 +36,30 @@ The server analyzes whether the defender can fight back. If so, the server analy
```
git clone https://git.scratko.xyz/durak
-cd client
-```
-
-To connect to the current game server (scratko.xyz), do the following:
- - open the client.c file with any text editor.
- - In line 14, change the ip from `127.0.0.1` to `109.107.161.30`
-
-```
+cd durak/linux_client
make
./client
```
+Note: for Android, you need to use a terminal like Termux. After installing it, you should to install packages:
+clang, make, git. Then follow the steps above.
+
### On Windows
You can download the built version for the Windows platform (it already contains the IP address for connecting to this server).
Windows version: <a href="https://scratko.xyz/games/durak.exe" target="_blank">Download</a>
+
+### Use for your server
+
+ * Build the server executable file.
+Run the file on the command line, specify a free port to be used by the server (from 1024 to 65535) as the second argument.
+Example: `./server 1025`
+ * Open the linux_client/client.c (or windows_client/client.c) file with any text editor.
+ * On line 14, change the ip from `109.107.161.30` to `%server ip-address%` (either `127.0.0.1` if you want to test on a local
+computer).
+ * On line 15 in the same file, correct the port to the one specified above.
+ * Build the client file and run it without arguments.
+
+---
+
+If you have any questions, please contact me: m@scratko.xyz \ No newline at end of file
diff --git a/windows_client/client.c b/windows_client/client.c
index 521dd0f..0388e34 100644
--- a/windows_client/client.c
+++ b/windows_client/client.c
@@ -211,14 +211,14 @@ static int fill_in_buffer(struct client *cl, int *data_size,
/* the data has not yet been entered up to the newline character */
if(!end_status && input_status) {
for(; (key = _getch()) != '\r'; ) {
- if(key == back && buffer_idx > 0) {
+ if(key == backspace && buffer_idx > 0) {
--buffer_idx;
cl->buffer[buffer_idx] = '\0';
- putchar(back);
+ putchar(backspace);
putchar(' ');
- putchar(back);
+ putchar(backspace);
continue;
- } else if(key == back)
+ } else if(key == backspace)
continue;
cl->buffer[buffer_idx] = key;
++buffer_idx;
diff --git a/windows_client/client.h b/windows_client/client.h
index f3b1ce8..060afcd 100644
--- a/windows_client/client.h
+++ b/windows_client/client.h
@@ -8,8 +8,7 @@ enum {
max_cot_arr_size = 18,
card_size = 4,
max_cq_arr_size = 5,
- backspace = 127,
- back = 8
+ backspace = 8
};
enum client_states {