[Cruce-commit] SF.net SVN: cruce:[38] C/trunk
Status: Beta
Brought to you by:
caiusb
|
From: <hor...@us...> - 2010-03-16 12:48:03
|
Revision: 38
http://cruce.svn.sourceforge.net/cruce/?rev=38&view=rev
Author: horiaradu
Date: 2010-03-16 12:47:56 +0000 (Tue, 16 Mar 2010)
Log Message:
-----------
Am bagat ultimele modificari facute de Lavinia, si mesajul START_ROUND care sa se trimita la inceputul unei runde.
Modified Paths:
--------------
C/trunk/client/client.c
C/trunk/protocol/protocol.h
Modified: C/trunk/client/client.c
===================================================================
--- C/trunk/client/client.c 2010-03-13 16:49:02 UTC (rev 37)
+++ C/trunk/client/client.c 2010-03-16 12:47:56 UTC (rev 38)
@@ -204,7 +204,7 @@
return 1;
}
-int hand() {
+int hands() {
char message[MSG_SIZE];
int endHand = 0;
@@ -273,7 +273,7 @@
printf("Ceva nu e bine, mai da o data!");
}
}
- else if (code == END_HAND) {
+ else if (code == END_ROUND) {
printf("%s\n", message);
endHand = 1;
}
@@ -281,6 +281,65 @@
return 1;
}
+void round() {
+ char opt = ' ', ok = 0;
+
+ while (!ok) {
+ if (!receiveCards()) {
+ printf("couldn't receive cards\n");
+ exit(1);
+ }
+
+ do {
+ showCards();
+ printf("Do you like your cards? y|n");
+ scanf("%c", opt);
+ if (opt == 'y')
+ ok = accept_cards();
+ else if (opt == 'n')
+ ok = reject_cards();
+ } while(opt != 'y' && opt != 'n');
+ }
+
+ bidding();
+
+ hands();
+}
+
+void score() {
+
+ char message[MSG_SIZE];
+
+ memset(message, 0, MSG_SIZE);
+ read(player.sfd, message, MSG_SIZE);
+ unpad(message);
+ int code = decode_message(message);
+
+ if (code == INFO_MSG)
+ printf("%s\n", message);
+}
+
+void game() {
+ char message[MSG_SIZE];
+ int code;
+
+ do {
+ memset(message, 0, MSG_SIZE);
+ read(player.sfd, message, MSG_SIZE);
+ unpad(message);
+ code = decode_message(message);
+
+ if (code == START_ROUND) {
+ round();
+ score(); // the score for the 2 teams
+ }
+ } while (code == START_ROUND);
+
+ printf("The game ended!");
+ printf("%s\n", message); // the score for the 2 teams
+}
+
+
/** adresa, port, nume **/
int main(int argc, char *argv[]) {
if (argc != 4) {
@@ -329,26 +388,7 @@
exit(1);
}
- char opt = ' ', ok = 0;
- while (!ok) {
- if (!receiveCards()) {
- printf("couldn't receive cards\n");
- exit(1);
- }
-
- do {
- showCards();
- printf("Do you like your cards? y|n");
- scanf("%c", opt);
- if (opt == 'y')
- ok = accept_cards();
- else if (opt == 'n')
- ok = reject_cards();
- } while(opt != 'y' && opt != 'n');
- }
-
- bidding();
- hand();
+ game();
//shutdown(player.sfd, SHUT_RDWR);
close(player.sfd);
Modified: C/trunk/protocol/protocol.h
===================================================================
--- C/trunk/protocol/protocol.h 2010-03-13 16:49:02 UTC (rev 37)
+++ C/trunk/protocol/protocol.h 2010-03-16 12:47:56 UTC (rev 38)
@@ -17,9 +17,10 @@
#define CARD_ANUNT 11
//propunere de extindere a protocolului:
-#define END_HAND 12
+#define END_ROUND 12
#define END_BID 13
#define CARD 14
+#define START_ROUND 15
#define DELIMITER " "
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|