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

Method checkNeedRoom

source/ai/KeeperAI.cpp:546–601  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

544}
545
546bool KeeperAI::checkNeedRoom(RoomType roomType)
547{
548 // We should try to build one room of each except special rooms (like bridges)
549 switch(roomType)
550 {
551 case RoomType::dormitory:
552 {
553 // If we have no dormitory, we try to build 1. If we already have one, we try to build another
554 // if nothing else can be built
555 if(mPlayer.getSeat()->getNbRooms(roomType) <= 0)
556 return true;
557
558 // If too many dormitories, no need to build more
559 if(mPlayer.getSeat()->getNbRooms(roomType) > 1)
560 return false;
561
562 for(RoomType roomType: wantedBuildings)
563 {
564 if(roomType == RoomType::dormitory)
565 continue;
566
567 if(!checkNeedRoom(roomType))
568 continue;
569
570 if(!SkillManager::isRoomAvailable(roomType, mPlayer.getSeat()))
571 continue;
572
573 // Another room is needed
574 return false;
575 }
576
577 return true;
578 }
579 case RoomType::treasury:
580 {
581 int totalStorage = mPlayer.getSeat()->getGoldMax();
582 int totalGold = mPlayer.getSeat()->getGold();
583
584 if(((totalStorage - totalGold) < 200) && (totalGold < 20000))
585 return true;
586
587 return false;
588 }
589 case RoomType::bridgeWooden:
590 case RoomType::bridgeStone:
591 return false;
592
593 default:
594 {
595 if(mPlayer.getSeat()->getNbRooms(roomType) <= 0)
596 return true;
597
598 return false;
599 }
600 }
601}
602
603void KeeperAI::saveWoundedCreatures()

Callers

nothing calls this directly

Calls 4

getNbRoomsMethod · 0.80
getGoldMaxMethod · 0.80
getGoldMethod · 0.80
getSeatMethod · 0.45

Tested by

no test coverage detected