#include "xrisk.h" #include "cardex.h" #include "risklibex.h" #include "xrisklibex.h" /* Show the text in do or die button */ int show_do_or_die(player) playerp player; { if (FlagSet(player,DO_OR_DIE)) write_button(player->xcon,MENU_DO_DIE,RISK_CURSOR,"#027_Do or Die"); else write_button(player->xcon,MENU_DO_DIE,RISK_CURSOR,"#045_Single Attacks"); return(0); } /* Show number of attacking forces */ int show_att_force(player) playerp player; { if (player->attr.attack_armies == 1) write_button (player->xcon,MENU_ATT_FORCE,RISK_CURSOR,"#020_Attack with 1 army"); if (player->attr.attack_armies == 2) write_button (player->xcon,MENU_ATT_FORCE,RISK_CURSOR,"#021_Attack with 2 armies"); if (player->attr.attack_armies == 3) write_button (player->xcon,MENU_ATT_FORCE,RISK_CURSOR,"#022_Attack with 3 armies"); return(0); } /* Show text in player-write-window */ int show_write_line(player) playerp player; { if (*player->pstat->string[1]) write_button(player->xcon,MENU_WRITE,RISK_WRITE,player->pstat->string[1]); else write_button(player->xcon,MENU_WRITE,RISK_WRITE,"#070_Message to all"); return(0); } /* Show text in mission-button */ int show_mission(player) playerp player; { write_button(player->xcon,MENU_MISSION,RISK_CURSOR,"#068_Mission"); return(0); } /* Write your mission */ int write_misson(player) playerp player; { if (player->mission) write_msg(player,player->mission->sentence); else write_msg(player,mappet("#076_Stay alive")); return(0); } /* Clear the field where the mission is written */ int clear_mission(player) playerp player; { write_msg(player,""); return(0); } /* Refresh all windows */ int refresh(player) playerp player; { update_colors(player); update_cardwin(player); update_infowin(player,0,O_ALL); update_mapwin(player); return(0); } /* Show text in refresh-button */ int show_refresh(player) playerp player; { write_button(player->xcon,MENU_REFRESH,RISK_CURSOR,"#069_Refresh"); return(0); } /* Show text in exit and suecide - button */ int show_exit_text(player) playerp player; { if (player->state->state != END_GAME) write_button (player->xcon,MENU_EXIT,RISK_DIE,"#033_Suicide"); else write_button (player->xcon,MENU_EXIT,RISK_DIE,"#030_END GAME"); return(0); } /* Does he want to kill himself or dismiss the windows */ int which_suicide(player) playerp player; { if (player->state->state == END_GAME) return(2); if (player->pstat->exit_press != time(0)) { write_msg(player,"#071_Double-click to take your life"); player->pstat->exit_press = time(0); return(0); } parse_killed(player); write_msg(player,"#057_You killed yourself in dishonor"); write_msg_all_arg("#005_%s killed theirself in dishonor", player->name,LAST_ARG); return(1); } /* Switch between do or die and single attacks */ int do_or_die_sw(player) playerp player; { SwitchFlag(player,DO_OR_DIE); show_do_or_die(player); return(0); } /* Lesser attacking force */ int weaker_attack(player) playerp player; { if (player->attr.attack_armies == 1) return(0); player->attr.attack_armies--; show_att_force(player); return(0); } /* Stronger attacking force */ int stronger_attack(player) playerp player; { if (player->attr.attack_armies == 3) return(0); player->attr.attack_armies++; show_att_force(player); return(0); } /* Get the messing which the player wants to give */ int get_menu_string(player) playerp player; { XEvent *pev; int strmin=1,length; KeySym tegn; XComposeStatus compose; char *string,*string1; char buffer[10]; xconp xinfo; pev = GetEventp(player); xinfo = player->xcon; string = player->pstat->string[1]; length = strlen(string); XLookupString(&(pev->xkey),buffer,10,&tegn,&compose); if ( ((tegn==XK_Return)||(tegn==XK_Linefeed)) && (length>=strmin)) { show_write_line(player); write_msg_all_arg("%s: %s",player->name,string,LAST_ARG); *string=0; return(1); } if ((tegn>=XK_space)&&(tegn<=XK_asciitilde)) if(length!=MAXLEN_MISC) string[length++]=buffer[0]; if ((tegn==XK_Delete)||(tegn==XK_BackSpace)) if (length) length--; string[length] = 0; if (length > 23) string1 = &string[length-23]; else string1 = string; if (length) write_button(xinfo,MENU_WRITE,RISK_WRITE,string1); else show_write_line(player); return(0); }