@@ -1448,7 +1448,75 @@ def AnyKongCanBuy(self, location, buy_empty=True):
14481448 return AnyKongCanBuy (self .spoiler , location , self , buy_empty )
14491449
14501450 def CanAccessKRool (self ):
1451- """Make sure that each required key has been turned in."""
1451+ """Make sure that each required key has been turned in, or if ship spawn method is win condition-based, check if win condition items are obtained."""
1452+ # If using win condition-based ship spawning, check if win condition item requirements are met
1453+ if self .settings .win_condition_spawns_ship :
1454+ condition = self .settings .win_condition_item
1455+ if condition == WinConditionComplex .krem_kapture :
1456+ for subject in self .spoiler .valid_photo_items :
1457+ if subject in (
1458+ Items .PhotoKasplatDK ,
1459+ Items .PhotoKasplatDiddy ,
1460+ Items .PhotoKasplatLanky ,
1461+ Items .PhotoKasplatTiny ,
1462+ Items .PhotoKasplatChunky ,
1463+ ):
1464+ continue
1465+ if self .Photos .get (subject , 0 ) == 0 :
1466+ return False
1467+ return self .camera
1468+ elif condition == WinConditionComplex .get_key8 :
1469+ return self .HelmKey
1470+ elif condition == WinConditionComplex .dk_rap_items :
1471+ dk_rap_items = [
1472+ self .donkey ,
1473+ self .diddy ,
1474+ self .lanky ,
1475+ self .tiny ,
1476+ self .chunky ,
1477+ self .coconut ,
1478+ self .peanut ,
1479+ self .grape ,
1480+ self .pineapple ,
1481+ self .guitar ,
1482+ self .trombone ,
1483+ self .strongKong ,
1484+ self .jetpack ,
1485+ self .handstand ,
1486+ self .balloon ,
1487+ self .mini ,
1488+ self .twirl ,
1489+ self .barrels ,
1490+ self .oranges ,
1491+ self .climbing ,
1492+ self .crankyAccess ,
1493+ ]
1494+ return all (dk_rap_items )
1495+ elif condition == WinConditionComplex .kill_the_rabbit :
1496+ return Events .KilledRabbit in self .Events
1497+ elif condition == WinConditionComplex .req_bonuses :
1498+ return self .bonuses_beaten >= self .settings .win_condition_count
1499+ elif condition == WinConditionComplex .req_bosses :
1500+ return self .bosses_beaten >= self .settings .win_condition_count
1501+ else :
1502+ # Item-based win conditions
1503+ win_con_table = {
1504+ WinConditionComplex .req_bean : BarrierItems .Bean ,
1505+ WinConditionComplex .req_bp : BarrierItems .Blueprint ,
1506+ WinConditionComplex .req_companycoins : BarrierItems .CompanyCoin ,
1507+ WinConditionComplex .req_crown : BarrierItems .Crown ,
1508+ WinConditionComplex .req_fairy : BarrierItems .Fairy ,
1509+ WinConditionComplex .req_key : BarrierItems .Key ,
1510+ WinConditionComplex .req_gb : BarrierItems .GoldenBanana ,
1511+ WinConditionComplex .req_medal : BarrierItems .Medal ,
1512+ WinConditionComplex .req_pearl : BarrierItems .Pearl ,
1513+ WinConditionComplex .req_rainbowcoin : BarrierItems .RainbowCoin ,
1514+ }
1515+ if condition in win_con_table :
1516+ return self .ItemCheck (win_con_table [condition ], self .settings .win_condition_count )
1517+ return True
1518+
1519+ # Otherwise use key-based access
14521520 required_base_keys = [
14531521 Events .JapesKeyTurnedIn ,
14541522 Events .AztecKeyTurnedIn ,
@@ -1662,10 +1730,14 @@ def IsLevelEnterable(self, level):
16621730
16631731 def WinConditionMet (self ):
16641732 """Check if the current game state has met the win condition."""
1733+ condition = self .settings .win_condition_item
1734+ # When using win condition-based ship spawning, always require K. Rool defeat in addition to win condition items
1735+ krool_complete = not self .settings .win_condition_spawns_ship or Events .KRoolDefeated in self .Events
1736+
16651737 # Special Win Cons
1666- if self . settings . win_condition_item == WinConditionComplex .beat_krool :
1738+ if condition == WinConditionComplex .beat_krool :
16671739 return Events .KRoolDefeated in self .Events
1668- elif self . settings . win_condition_item == WinConditionComplex .krem_kapture :
1740+ elif condition == WinConditionComplex .krem_kapture :
16691741 for subject in self .spoiler .valid_photo_items :
16701742 if subject in (
16711743 Items .PhotoKasplatDK ,
@@ -1676,11 +1748,17 @@ def WinConditionMet(self):
16761748 ):
16771749 continue
16781750 if self .Photos .get (subject , 0 ) == 0 :
1751+ # print(f"Could not reach {subject.name}")
16791752 return False
1680- return self .camera
1681- elif self .settings .win_condition_item == WinConditionComplex .get_key8 :
1682- return self .HelmKey
1683- elif self .settings .win_condition_item == WinConditionComplex .dk_rap_items :
1753+ result = self .camera
1754+ return result and krool_complete
1755+ elif condition == WinConditionComplex .get_key8 :
1756+ result = self .HelmKey
1757+ return result and krool_complete
1758+ elif condition == WinConditionComplex .get_keys_3_and_8 :
1759+ result = self .FactoryKey and self .HelmKey
1760+ return result and krool_complete
1761+ elif condition == WinConditionComplex .dk_rap_items :
16841762 dk_rap_items = [
16851763 self .donkey ,
16861764 self .diddy ,
@@ -1711,16 +1789,20 @@ def WinConditionMet(self):
17111789 for k in dk_rap_items :
17121790 if not k :
17131791 return False
1714- return True
1715- elif self .settings .win_condition_item == WinConditionComplex .krools_challenge :
1792+ result = True
1793+ return result and krool_complete
1794+ elif condition == WinConditionComplex .krools_challenge :
17161795 # Krool's Challenge: Beat K. Rool + collect all Keys, Blueprints, Bosses, and Bonus Barrels
17171796 return Events .KRoolDefeated in self .Events and self .ItemCheck (BarrierItems .Key , 8 ) and self .ItemCheck (BarrierItems .Blueprint , 40 ) and self .bosses_beaten >= 7 and self .bonuses_beaten >= 43
1718- elif self .settings .win_condition_item == WinConditionComplex .kill_the_rabbit :
1719- return Events .KilledRabbit in self .Events
1720- elif self .settings .win_condition_item == WinConditionComplex .req_bosses :
1721- return self .bosses_beaten >= self .settings .win_condition_count
1722- elif self .settings .win_condition_item == WinConditionComplex .req_bonuses :
1723- return self .bonuses_beaten >= self .settings .win_condition_count
1797+ elif condition == WinConditionComplex .kill_the_rabbit :
1798+ result = Events .KilledRabbit in self .Events
1799+ return result and krool_complete
1800+ elif condition == WinConditionComplex .req_bonuses :
1801+ result = self .bonuses_beaten >= self .settings .win_condition_count
1802+ return result and krool_complete
1803+ elif condition == WinConditionComplex .req_bosses :
1804+ result = self .bosses_beaten >= self .settings .win_condition_count
1805+ return result and krool_complete
17241806 # Get X amount of Y item win cons
17251807 win_con_table = {
17261808 WinConditionComplex .req_bean : BarrierItems .Bean ,
@@ -1734,9 +1816,10 @@ def WinConditionMet(self):
17341816 WinConditionComplex .req_pearl : BarrierItems .Pearl ,
17351817 WinConditionComplex .req_rainbowcoin : BarrierItems .RainbowCoin ,
17361818 }
1737- if self . settings . win_condition_item not in win_con_table :
1819+ if condition not in win_con_table :
17381820 raise Exception (f"Invalid Win Condition { self .settings .win_condition_item .name } " )
1739- return self .ItemCheck (win_con_table [self .settings .win_condition_item ], self .settings .win_condition_count )
1821+ result = self .ItemCheck (win_con_table [condition ], self .settings .win_condition_count )
1822+ return result and krool_complete
17401823
17411824 def CanGetRarewareCoin (self ):
17421825 """Check if you meet the logical requirements to obtain the Rareware Coin."""
0 commit comments