MCPcopy Create free account
hub / github.com/OpenDungeons/OpenDungeons / repairRooms

Method repairRooms

source/ai/KeeperAI.cpp:736–767  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

734}
735
736bool KeeperAI::repairRooms()
737{
738 if(mCooldownRepairRooms > 0)
739 {
740 --mCooldownRepairRooms;
741 return false;
742 }
743
744 mCooldownRepairRooms = Random::Int(20,60);
745
746 Seat* seat = mPlayer.getSeat();
747 for(Room* room : mGameMap.getRooms())
748 {
749 if(room->getSeat() != seat)
750 continue;
751
752 if(!room->canBeRepaired())
753 continue;
754
755 int goldRequired = room->getCostRepair();
756
757 if(!mGameMap.withdrawFromTreasuries(goldRequired, mPlayer.getSeat()))
758 return false;
759
760 room->repairRoom();
761 // We only repair one room at a time. Note that if we want to repair more than one room at a time, we should pay
762 // attention to not modify the room list (if room absorbed in RoomManager::buildRoom) while iterating it
763 break;
764 }
765
766 return false;
767}
768
769bool KeeperAI::handleTiredCreatures()
770{

Callers

nothing calls this directly

Calls 6

IntFunction · 0.85
canBeRepairedMethod · 0.80
getCostRepairMethod · 0.80
repairRoomMethod · 0.80
getSeatMethod · 0.45

Tested by

no test coverage detected