void CmdMove(CORE_DATA *cd) { USER_DATA *ud = UD(cd); // the game hasnt started if (ud->in_progress == false) { Reply("The game has not yet begun"); return; } // check for correct arg count if (cd->cmd_argc != 2) { ReplyFmt("Usage: !move Coord,Coord"); ReplyFmt("Example: !move e2,e4"); return; } // make sure the player is playing if (IsPlaying(ud, cd->cmd_name) == false) { Reply("You are not playing in this match"); return; } // replies to players in-game are via arena // check whos turn it is if (GetColor(ud, cd->cmd_name) != ud->to_move) { ArenaMessage("It is not your move"); return; } // parse argument char xstr[3]; char ystr[3]; DelimArgs(xstr, 3, cd->cmd_argv[1], 0, ',', false); DelimArgs(ystr, 3, cd->cmd_argv[1], 1, ',', false); int x1, y1, x2, y2; if (ParseCoords(xstr, &x1, &y1) == true && ParseCoords(ystr, &x2, &y2) == true) { char *err = TryMove(ud, ud->to_move, x1, y1, x2, y2); if (err == NULL && ud->in_progress == true) { // successful moves are announced in TryMove() ud->to_move = GetOppositeColor(ud->to_move); LvzToMove(ud->to_move, NULL); ArenaMessageFmt("%s (%s) to Move", GetPlayerName(ud, ud->to_move), GetColorText(ud->to_move)); } else if (ud->in_progress == true) { ArenaMessageFmt("Couldn't move: %s", err); } } else { ArenaMessageFmt("Invalid coordinates"); } }
void cmd_putfile(CORE_DATA *cd) { if (cd->cmd_argc != 2) { Reply("Usage: !putfile <filename>"); return; } if (queue_send_file(get_thread_data(), cd->cmd_argv[1], cd->cmd_name)) { ReplyFmt("Queued file upload: %s", cd->cmd_argv[1]); } else { ReplyFmt("Failed to queue file for upload: %s", cd->cmd_argv[1]); } }
void cmd_getfile(CORE_DATA *cd) { if (cd->cmd_argc != 2) { Reply("Usage: !getfile <filename>"); return; } THREAD_DATA *td = get_thread_data(); if (queue_get_file(td, cd->cmd_argv[1], cd->cmd_name)) { ReplyFmt("Queued file download: %s", cd->cmd_argv[1]); } else { ReplyFmt("Failed to queue file for download: %s", cd->cmd_argv[1]); } }
void CmdGameInfo(CORE_DATA *cd) { USER_DATA *ud = UD(cd); if (ud->in_progress == false) { Reply("There is no game going on"); return; } ReplyFmt("%s (White) vs. %s (Black) is In Progress", ud->white, ud->black); char time[32]; TicksToText(time, 32, GetTicksMs() - ud->start_tick); ReplyFmt("The match has been going on for %s", time); ReplyFmt("%s (White) to Move", ud->white); }
void cmd_go(CORE_DATA *cd) { if (cd->cmd_argc != 2) { Reply("Usage: !go <arena"); return; } ReplyFmt("Changing to arena: %s", cd->cmd_argv[1]); Go(cd->cmd_argv[1]); }
void CmdBlack(CORE_DATA *cd) { USER_DATA *ud = UD(cd); if (IsPlaying(ud, cd->cmd_name) == true) { Reply("You are already playing"); } else if (ud->black[0] != '\0') { ReplyFmt("%s is Black", ud->black); } else { strlcpy(ud->black, cd->cmd_name, 24); if (ud->white[0]) { StartGame(ud); } else { ArenaMessageFmt("%s is Black and awaits a challenger!", ud->black); } } }