// Implement the command interface void ARec::ExecCommand(const string & cmdname) { char buf[100]; if (cmdname == "start") StartCmd(); else if (cmdname == "stop") StopCmd(); else if (cmdname == "setmode") SetModeCmd(); else if (cmdname == "usegrp") UseGrpCmd(); else if (cmdname == "setnbest") { if(nBest==0) { CreateHeap(&ansHeap,"Lattice heap",MSTAK,1,0.0,4000,4000); CreateHeap(&altHeap,"Lattice heap",MSTAK,1,0.0,4000,4000); } int nb; if (!GetIntArg(nb, 1, 100000)) HPostMessage(HThreadSelf(),"Setnbest, n-best num expected\n"); nBest=nb; } else { sprintf(buf,"Unknown command %s\n", cmdname.c_str()); HPostMessage(HThreadSelf(),buf); } }
void UpkeepPhase::FinishUpkeep(CommitSession& session, const Player& player) { const Team& team = GetGame().GetTeam(player); session.DoAndPushRecord(RecordPtr(new IncomeRecord(team.GetColour()))); if (team.GetGraveyard().IsEmpty()) FinishGraveyard(session, player); else StartCmd(CmdPtr(new GraveyardCmd(team.GetColour(), GetGame())), session); }
void PerformIO ( struct AHIRequest *ioreq, struct AHIBase *AHIBase ) { struct AHIDevUnit *iounit; iounit = (struct AHIDevUnit *) ioreq->ahir_Std.io_Unit; ioreq->ahir_Std.io_Error = 0; // Just to make sure TermIO won't free a bad address ioreq->ahir_Extras = NULL; switch(ioreq->ahir_Std.io_Command) { case NSCMD_DEVICEQUERY: Devicequery(ioreq, AHIBase); break; case CMD_RESET: ResetCmd(ioreq, AHIBase); break; case CMD_READ: ReadCmd(ioreq, AHIBase); break; case CMD_WRITE: if(iounit->StopCnt) { AddTail((struct List *) &iounit->RequestQueue,(struct Node *) ioreq); } else { WriteCmd(ioreq, AHIBase); } break; case CMD_STOP: StopCmd(ioreq, AHIBase); break; case CMD_START: StartCmd(ioreq, AHIBase); break; case CMD_FLUSH: FlushCmd(ioreq, AHIBase); break; default: ioreq->ahir_Std.io_Error = IOERR_NOCMD; TermIO(ioreq, AHIBase); break; } }
void UpkeepPhase::Init(CommitSession& session) { auto& game = session.GetGame(); std::set<Colour> influenceableHexes; // Team -> hex IDs. for (auto& pair : game.GetMap().GetHexes()) { auto& hex = pair.second; // "If you have at least one Ship in a hex that has no population, remove the previous controller’s Influence Disc." if (hex->IsOwned() && !hex->HasPopulation() && hex->HasForeignShip(hex->GetColour())) session.DoAndPushRecord(RecordPtr(new InfluenceRecord(hex->GetColour(), &hex->GetPos(), nullptr))); // If at the end of the Combat Phase your Ship is in a hex without an Influence Disc, you may place a disc there." Colour c = AutoInfluenceCmd::GetAutoInfluenceColour(*hex); if (c != Colour::None) influenceableHexes.insert(c); } for (auto& c : influenceableHexes) StartCmd(CmdPtr(new AutoInfluenceCmd(c, game)), session); // TODO: Stop user undoing. }