1 #include "xrisk.h"
2 #include "cardex.h"
3 #include "risklibex.h"
4 #include "xrisklibex.h"
5
6 /* Show the text in do or die button */
show_do_or_die(player)7 int show_do_or_die(player)
8 playerp player;
9 {
10 if (FlagSet(player,DO_OR_DIE))
11 write_button(player->xcon,MENU_DO_DIE,RISK_CURSOR,"#027_Do or Die");
12 else
13 write_button(player->xcon,MENU_DO_DIE,RISK_CURSOR,"#045_Single Attacks");
14 return(0);
15 }
16
17 /* Show number of attacking forces */
show_att_force(player)18 int show_att_force(player)
19 playerp player;
20 {
21 if (player->attr.attack_armies == 1) write_button
22 (player->xcon,MENU_ATT_FORCE,RISK_CURSOR,"#020_Attack with 1 army");
23 if (player->attr.attack_armies == 2) write_button
24 (player->xcon,MENU_ATT_FORCE,RISK_CURSOR,"#021_Attack with 2 armies");
25 if (player->attr.attack_armies == 3) write_button
26 (player->xcon,MENU_ATT_FORCE,RISK_CURSOR,"#022_Attack with 3 armies");
27 return(0);
28 }
29
30 /* Show text in player-write-window */
show_write_line(player)31 int show_write_line(player)
32 playerp player;
33 {
34 if (*player->pstat->string[1])
35 write_button(player->xcon,MENU_WRITE,RISK_WRITE,player->pstat->string[1]);
36 else
37 write_button(player->xcon,MENU_WRITE,RISK_WRITE,"#070_Message to all");
38 return(0);
39 }
40
41 /* Show text in mission-button */
show_mission(player)42 int show_mission(player)
43 playerp player;
44 {
45 write_button(player->xcon,MENU_MISSION,RISK_CURSOR,"#068_Mission");
46 return(0);
47 }
48
49 /* Write your mission */
write_misson(player)50 int write_misson(player)
51 playerp player;
52 {
53 if (player->mission) write_msg(player,player->mission->sentence);
54 else write_msg(player,mappet("#076_Stay alive"));
55 return(0);
56 }
57
58 /* Clear the field where the mission is written */
clear_mission(player)59 int clear_mission(player)
60 playerp player;
61 {
62 write_msg(player,"");
63 return(0);
64 }
65
66 /* Refresh all windows */
refresh(player)67 int refresh(player)
68 playerp player;
69 {
70 update_colors(player);
71 update_cardwin(player);
72 update_infowin(player,0,O_ALL);
73 update_mapwin(player);
74
75 return(0);
76 }
77
78 /* Show text in refresh-button */
show_refresh(player)79 int show_refresh(player)
80 playerp player;
81 {
82 write_button(player->xcon,MENU_REFRESH,RISK_CURSOR,"#069_Refresh");
83 return(0);
84 }
85
86 /* Show text in exit and suecide - button */
show_exit_text(player)87 int show_exit_text(player)
88 playerp player;
89 {
90 if (player->state->state != END_GAME) write_button
91 (player->xcon,MENU_EXIT,RISK_DIE,"#033_Suicide");
92 else write_button
93 (player->xcon,MENU_EXIT,RISK_DIE,"#030_END GAME");
94 return(0);
95 }
96
97 /* Does he want to kill himself or dismiss the windows */
which_suicide(player)98 int which_suicide(player)
99 playerp player;
100 {
101 if (player->state->state == END_GAME) return(2);
102
103 if (player->pstat->exit_press != time(0))
104 {
105 write_msg(player,"#071_Double-click to take your life");
106 player->pstat->exit_press = time(0);
107 return(0);
108 }
109
110 parse_killed(player);
111 write_msg(player,"#057_You killed yourself in dishonor");
112 write_msg_all_arg("#005_%s killed theirself in dishonor",
113 player->name,LAST_ARG);
114 return(1);
115 }
116
117 /* Switch between do or die and single attacks */
do_or_die_sw(player)118 int do_or_die_sw(player)
119 playerp player;
120 {
121 SwitchFlag(player,DO_OR_DIE);
122 show_do_or_die(player);
123 return(0);
124 }
125
126 /* Lesser attacking force */
weaker_attack(player)127 int weaker_attack(player)
128 playerp player;
129 {
130 if (player->attr.attack_armies == 1) return(0);
131 player->attr.attack_armies--;
132 show_att_force(player);
133 return(0);
134 }
135
136 /* Stronger attacking force */
stronger_attack(player)137 int stronger_attack(player)
138 playerp player;
139 {
140 if (player->attr.attack_armies == 3) return(0);
141 player->attr.attack_armies++;
142 show_att_force(player);
143 return(0);
144 }
145
146 /* Get the messing which the player wants to give */
get_menu_string(player)147 int get_menu_string(player)
148 playerp player;
149 {
150 XEvent *pev;
151 int strmin=1,length;
152 KeySym tegn;
153 XComposeStatus compose;
154 char *string,*string1;
155 char buffer[10];
156 xconp xinfo;
157
158 pev = GetEventp(player);
159 xinfo = player->xcon;
160 string = player->pstat->string[1];
161 length = strlen(string);
162
163 XLookupString(&(pev->xkey),buffer,10,&tegn,&compose);
164 if ( ((tegn==XK_Return)||(tegn==XK_Linefeed))
165 && (length>=strmin))
166 {
167 show_write_line(player);
168 write_msg_all_arg("%s: %s",player->name,string,LAST_ARG);
169 *string=0;
170 return(1);
171 }
172
173 if ((tegn>=XK_space)&&(tegn<=XK_asciitilde))
174 if(length!=MAXLEN_MISC) string[length++]=buffer[0];
175
176 if ((tegn==XK_Delete)||(tegn==XK_BackSpace))
177 if (length) length--;
178
179 string[length] = 0;
180
181 if (length > 23) string1 = &string[length-23];
182 else string1 = string;
183
184 if (length) write_button(xinfo,MENU_WRITE,RISK_WRITE,string1);
185 else show_write_line(player);
186 return(0);
187 }
188