bool WifesGlobalState::OnMessage(MinersWife *wife, const Telegram &msg) { switch (msg.Msg) { case Msg_HiHoneyImHome: { cout << "\nMessage handled by " << GetNameOfEntity(wife->ID()) << " at time: " << time(NULL); cout << "\n" << GetNameOfEntity(wife->ID()) << ": Hi honey. Let me make you some of mah fine country stew"; wife->GetFSM()->ChangeState(CookStew::Instance()); } return true; } return false; }
void EnterMineAndDigForNugget::Enter(Miner * miner) { if(miner->Location() != location_type::goldmine) { std::cout << "\n" << GetNameOfEntity(miner->ID()) << ": " << "Walkin' to the gold mine"; miner->ChangeLocation(location_type::goldmine); } }
void CookStew::Enter(MinersWife *wife) { if(!wife->Cooking()) { cout << "\n" << GetNameOfEntity(wife->ID()) << ": Putting the stew in the oven"; Dispatch->DispatchMessage(1.5, //time delay wife->ID(), //sender ID wife->ID(), //receiver ID Msg_StewReady, //msg NO_ADDITIONAL_INFO); wife->SetCooking(true); } }
void EnterMineAndDigForNugget::Execute(Miner * miner) { miner->AddToGoldCarried(1); miner->IncreaseFatigue(); std::cout << "\n" << GetNameOfEntity(miner->ID()) << ": " << "Pickin' up a nugget"; // if enough gold mined go and put in bank if(miner->PocketsFull()) miner->ChangeState(VisitBankAndDepositGold::Instance()); if(miner->Thirsty()) miner->ChangeState(QuenchThirst::Instance()); }
bool CookStew::OnMessage(MinersWife *wife, const Telegram &msg) { switch (msg.Msg) { case Msg_StewReady: { cout << "\nMessage received by " << GetNameOfEntity(wife->ID()) << " at time: " << time(NULL); Dispatch->DispatchMessage(SEND_MSG_IMMEDIATELY, wife->ID(), ent_Miner_Bob, Msg_StewReady, NO_ADDITIONAL_INFO); wife->SetCooking(false); wife->GetFSM()->ChangeState(DoHouseWork::Instance()); } return true; } return false; }
void EnterMineAndDigForNugget::Exit(Miner * miner) { std::cout << "\n" << GetNameOfEntity(miner->ID()) << ": " << "Ah'm Leavin' the gold mine with mah pockets full o' sweet gold"; }
void CookStew::Exit(MinersWife *wife) { cout << "\n" << GetNameOfEntity(wife->ID()) << ": Puttin' the stew on the table"; }
void CookStew::Execute(MinersWife *wife) { cout << "\n" << GetNameOfEntity(wife->ID()) << ": Fussin' over food"; }