/*========================================================================= gameslot.h Author: PKG Created: Project: Spongebob Purpose: Copyright (c) 2001 Climax Development Ltd ===========================================================================*/ #ifndef __GAME_GAMESLOT_H__ #define __GAME_GAMESLOT_H__ /*---------------------------------------------------------------------- Includes -------- */ #ifndef __SHOP_SHOP_H__ #include "shop\shop.h" #endif // Just for ASSERT().. #ifndef __SYSTEM_DBG_H__ #include "system\dbg.h" #endif /* Std Lib ------- */ /*---------------------------------------------------------------------- Tyepdefs && Defines ------------------- */ /*---------------------------------------------------------------------- Structure defintions -------------------- */ class CGameSlotManager { public: enum { INITIAL_LIVES=5, INITIAL_CONTINUES=3, NUM_GAME_SLOTS=4, NUM_CHAPTERS=5, NUM_LEVELS_WITH_SPATULAS=4, NUM_LEVELS_PER_CHAPTER_WITH_QUEST_ITEMS=4, NUM_BONUS_LEVELS_PER_CHAPTER=1, }; enum { LEVELCOMPETESTATE_NOT_OPEN, // Level is not available to play LEVELCOMPETESTATE_OPEN, // Level is available to play LEVELCOMPETESTATE_COMPLETED, // Level has been completed }; typedef struct { unsigned char m_isInUse; signed char m_lives; signed char m_continues; unsigned char m_hasSeenOpeningFMA; unsigned char m_spatulaCollectedCounts[NUM_CHAPTERS*NUM_LEVELS_WITH_SPATULAS]; unsigned char m_kelpTokenCollectedFlags[NUM_CHAPTERS][16]; // Enuf space for 128 tokens per level unsigned char m_kelpTokensHeld; unsigned char m_partyItemsHeld[CShopScene::NUM_SHOP_ITEM_IDS]; unsigned char m_levelCompletionState[NUM_CHAPTERS*(NUM_LEVELS_PER_CHAPTER_WITH_QUEST_ITEMS+NUM_BONUS_LEVELS_PER_CHAPTER)]; // Spat functions.. int getSpatulaCollectedCount(unsigned int _chapter,unsigned int _level) { ASSERT(_chapter<=NUM_CHAPTERS); ASSERT(_level<=NUM_LEVELS_WITH_SPATULAS); return m_spatulaCollectedCounts[(_chapter*NUM_LEVELS_WITH_SPATULAS)+_level]; } void setSpatulaCollectedCount(unsigned int _chapter,unsigned int _level,unsigned char _count,unsigned char _totalCount) { ASSERT(_chapter<=NUM_CHAPTERS); ASSERT(_level<=NUM_LEVELS_WITH_SPATULAS); m_spatulaCollectedCounts[(_chapter*NUM_LEVELS_WITH_SPATULAS)+_level]=_count; // Does this open up a bonus level? int percentRequired,percentAchieved; percentRequired=(_chapter*10)+60; // 60% on chapter 1 ... to ... 100% on chapter 5 percentAchieved=(_count*100)/_totalCount; if(percentAchieved>=percentRequired) { levelIsNowOpen(_chapter,4); } } // Kelp Token functions.. int getKelpTokenCollectedCount(unsigned int _chapter,unsigned int _level) { ASSERT(_chapter<=NUM_CHAPTERS); ASSERT(_level==NUM_LEVELS_WITH_SPATULAS); int i,j,count; count=0; for(i=0;i<8;i++) { unsigned char flags=m_kelpTokenCollectedFlags[_chapter][i]; for(j=0;j<8;j++) { if(flags&1)count++; flags>>=1; } } return count; } void collectKelpToken(unsigned int _chapter,unsigned int _level,unsigned int _token) { ASSERT(_chapter<=NUM_CHAPTERS); ASSERT(_level==NUM_LEVELS_WITH_SPATULAS); ASSERT(_token<=128); m_kelpTokenCollectedFlags[_chapter][_token>>3]|=1<<(_token&7); m_kelpTokensHeld++; } int isKelpTokenUncollected(unsigned int _chapter,unsigned int _level,unsigned int _token) { ASSERT(_chapter<=NUM_CHAPTERS); ASSERT(_level==NUM_LEVELS_WITH_SPATULAS); ASSERT(_token<=128); return (m_kelpTokenCollectedFlags[_chapter][_token>>3]>>(_token&7))&1?false:true; } // Shop int getNumberOfKelpTokensHeld() { return m_kelpTokensHeld; } void useKelpTokens(int _count) { ASSERT(((int)m_kelpTokensHeld-_count)>=0); m_kelpTokensHeld-=_count; } int isPartyItemHeld(int _itemNumber) { return m_partyItemsHeld[_itemNumber]; } void buyPartyItem(int _itemNumber) { ASSERT(!m_partyItemsHeld[_itemNumber]); m_partyItemsHeld[_itemNumber]=true; } // Levels int isLevelOpen(unsigned int _chapter,unsigned int _level) { int index; index=(_chapter*(NUM_LEVELS_PER_CHAPTER_WITH_QUEST_ITEMS+NUM_BONUS_LEVELS_PER_CHAPTER))+_level; return m_levelCompletionState[index]!=(int)LEVELCOMPETESTATE_NOT_OPEN; } int hasQustItemBeenCollected(unsigned int _chapter,unsigned int _level) { int index; index=(_chapter*(NUM_LEVELS_PER_CHAPTER_WITH_QUEST_ITEMS+NUM_BONUS_LEVELS_PER_CHAPTER))+_level; return m_levelCompletionState[index]==(int)LEVELCOMPETESTATE_COMPLETED; } void levelIsNowOpen(unsigned int _chapter,unsigned int _level) { int index; index=(_chapter*(NUM_LEVELS_PER_CHAPTER_WITH_QUEST_ITEMS+NUM_BONUS_LEVELS_PER_CHAPTER))+_level; if(m_levelCompletionState[index]==LEVELCOMPETESTATE_NOT_OPEN) { m_levelCompletionState[index]=LEVELCOMPETESTATE_OPEN; } } void levelHasBeenCompleted(unsigned int _chapter,unsigned int _level) { int index; index=(_chapter*(NUM_LEVELS_PER_CHAPTER_WITH_QUEST_ITEMS+NUM_BONUS_LEVELS_PER_CHAPTER))+_level; m_levelCompletionState[index]=LEVELCOMPETESTATE_COMPLETED; } void getHighestLevelOpen(int *_chapter,int *_level) { int chapter,level; for(chapter=0;chapter