1 | /*****************************************************/ |
---|
2 | /* this file is part of the tiTan / tiTanNIT Project */ |
---|
3 | /* and allowed only for use with this. */ |
---|
4 | /* */ |
---|
5 | /* copyright by NIT */ |
---|
6 | /*****************************************************/ |
---|
7 | |
---|
8 | #ifndef WINS3_H |
---|
9 | #define WINS3_H |
---|
10 | |
---|
11 | void wins3new(struct skin* wins3) |
---|
12 | { |
---|
13 | struct skin* node = wins3; |
---|
14 | |
---|
15 | while(node != NULL) |
---|
16 | { |
---|
17 | if(ostrcmp(node->text, "O") == 0 || ostrcmp(node->text, "X") == 0) |
---|
18 | changetext(node, NULL); |
---|
19 | |
---|
20 | node = node->next; |
---|
21 | } |
---|
22 | } |
---|
23 | |
---|
24 | void wins3changetitle(struct skin* wins3, int player) |
---|
25 | { |
---|
26 | char* title = "3 WINS - Player "; |
---|
27 | char* tmpstr = NULL, *tmpnr = NULL; |
---|
28 | |
---|
29 | tmpnr = oitoa(player); |
---|
30 | tmpstr = ostrcat(_(title), tmpnr, 0, 0); |
---|
31 | |
---|
32 | changetitle(wins3, tmpstr); |
---|
33 | |
---|
34 | free(tmpstr); tmpstr = NULL; |
---|
35 | free(tmpnr); tmpnr = NULL; |
---|
36 | } |
---|
37 | |
---|
38 | void screenwins3() |
---|
39 | { |
---|
40 | int rcret = 0, player = 1; |
---|
41 | struct skin* wins3 = getscreen("wins3"); |
---|
42 | struct skin* grid = getscreennode(wins3, "grid"); |
---|
43 | |
---|
44 | wins3new(wins3); |
---|
45 | wins3changetitle(wins3, player); |
---|
46 | |
---|
47 | drawscreen(wins3, 0, 0); |
---|
48 | addscreenrc(wins3, grid); |
---|
49 | |
---|
50 | while(1) |
---|
51 | { |
---|
52 | rcret = waitrc(wins3, 0, 0); |
---|
53 | |
---|
54 | if(rcret == getrcconfigint("rcexit", NULL)) break; |
---|
55 | if(rcret == getrcconfigint("rcok", NULL)) |
---|
56 | { |
---|
57 | if(grid->select != NULL && grid->select->text == NULL) |
---|
58 | { |
---|
59 | if(player == 1) |
---|
60 | { |
---|
61 | changetext(grid->select, "X"); |
---|
62 | player = 2; |
---|
63 | } |
---|
64 | else |
---|
65 | { |
---|
66 | changetext(grid->select, "O"); |
---|
67 | player = 1; |
---|
68 | } |
---|
69 | wins3changetitle(wins3, player); |
---|
70 | drawscreen(wins3, 0, 0); |
---|
71 | } |
---|
72 | continue; |
---|
73 | } |
---|
74 | if(rcret == getrcconfigint("rcred", NULL)) |
---|
75 | { |
---|
76 | wins3new(grid); |
---|
77 | player = 1; |
---|
78 | wins3changetitle(wins3, player); |
---|
79 | drawscreen(wins3, 0, 0); |
---|
80 | } |
---|
81 | } |
---|
82 | |
---|
83 | delownerrc(wins3); |
---|
84 | clearscreen(wins3); |
---|
85 | } |
---|
86 | |
---|
87 | #endif |
---|