Void Rune::Save( XMLNode * outNode ) const { Assert( m_iType != RUNE_TYPE_COUNT ); Assert( outNode != NULL ); Assert( StringFn->Cmp(outNode->GetTagName(), TEXT("Rune")) == 0 ); const GameParameters * pGameParams = GameplayFn->GetGameParameters(); GChar strBuffer[1024]; const GChar * strValue; strValue = pGameParams->RuneTypeToString( m_iType ); outNode->CreateAttribute( TEXT("Type"), strValue ); StringFn->FromUInt( strBuffer, m_iSlot ); outNode->CreateAttribute( TEXT("Slot"), strBuffer ); StringFn->FromUInt( strBuffer, m_iRank ); outNode->CreateAttribute( TEXT("Rank"), strBuffer ); StringFn->FromUInt( strBuffer, m_iLevel ); outNode->CreateAttribute( TEXT("Level"), strBuffer ); Assert( m_arrBonuses[RUNE_STAT_PRIMARY].iStat != MONSTER_STAT_COUNT ); for( UInt i = 0; i < RUNE_STAT_COUNT; ++i ) { if ( m_arrBonuses[i].iStat == MONSTER_STAT_COUNT ) continue; const GChar * strNameI = pGameParams->RuneStatisticToString( (RuneStatistic)i ); XMLNode * pStatBonusNode = XMLDocument::CreateNode( strNameI, true ); strValue = pGameParams->MonsterStatisticToString( m_arrBonuses[i].iStat ); pStatBonusNode->CreateAttribute( TEXT("Stat"), strValue ); StringFn->FromUInt( strBuffer, m_arrBonuses[i].bIsRatio ? 1 : 0 ); pStatBonusNode->CreateAttribute( TEXT("IsRatio"), strBuffer ); outNode->AppendChild( pStatBonusNode ); } }
Void PlayerTown::Save( XMLNode * outNode ) const { Assert( outNode != NULL ); Assert( StringFn->Cmp(outNode->GetTagName(), TEXT("PlayerTown")) == 0 ); const GameParameters * pGameParams = GameplayFn->GetGameParameters(); GChar strBuffer[1024]; // Currencies, scrolls & essences XMLNode * pCurrenciesNode = XMLDocument::CreateNode( TEXT("Currencies"), true ); XMLNode * pScrollsNode = XMLDocument::CreateNode( TEXT("Scrolls"), true ); XMLNode * pEssencesNode = XMLDocument::CreateNode( TEXT("Essences"), false ); for( UInt i = 0; i < CURRENCY_COUNT; ++i ) { const GChar * strNameI = pGameParams->CurrencyTypeToString( (CurrencyType)i ); StringFn->FromUInt( strBuffer, m_arrCurrencies[i] ); pCurrenciesNode->CreateAttribute( strNameI, strBuffer ); } for( UInt i = 0; i < SCROLL_TYPE_COUNT; ++i ) { const GChar * strNameI = pGameParams->ScrollTypeToString( (ScrollType)i ); StringFn->FromUInt( strBuffer, m_arrScrolls[i] ); pScrollsNode->CreateAttribute( strNameI, strBuffer ); } for( UInt i = 0; i < MONSTER_ELEMENT_COUNT; ++i ) { const GChar * strNameI = pGameParams->MonsterElementToString( (MonsterElement)i ); XMLNode * pElementNode = XMLDocument::CreateNode( strNameI, true ); for( UInt j = 0; j < ESSENCE_TYPE_COUNT; ++j ) { const GChar * strNameJ = pGameParams->EssenceTypeToString( (EssenceType)j ); StringFn->FromUInt( strBuffer, m_arrEssences[i][j] ); pElementNode->CreateAttribute( strNameJ, strBuffer ); } pEssencesNode->AppendChild( pElementNode ); } outNode->AppendChild( pCurrenciesNode ); outNode->AppendChild( pScrollsNode ); outNode->AppendChild( pEssencesNode ); // Monster collection & storage XMLNode * pMonsterCollectionNode = XMLDocument::CreateNode( TEXT("MonsterCollection"), false ); XMLNode * pMonsterStorageNode = XMLDocument::CreateNode( TEXT("MonsterStorage"), false ); StringFn->FromUInt( strBuffer, m_iMonsterCollectionLevel ); pMonsterCollectionNode->CreateAttribute( TEXT("Level"), strBuffer ); StringFn->FromUInt( strBuffer, m_iMonsterStorageLevel ); pMonsterStorageNode->CreateAttribute( TEXT("Level"), strBuffer ); UInt iMonsterCount = m_arrMonsterCollection.Count(); for( UInt i = 0; i < iMonsterCount; ++i ) { XMLNode * pMonsterInstanceNode = XMLDocument::CreateNode( TEXT("MonsterInstance"), false ); m_arrMonsterCollection[i].Save( pMonsterInstanceNode ); pMonsterCollectionNode->AppendChild( pMonsterInstanceNode ); } iMonsterCount = m_arrMonsterStorage.Count(); for( UInt i = 0; i < iMonsterCount; ++i ) { XMLNode * pMonsterInstanceNode = XMLDocument::CreateNode( TEXT("MonsterInstance"), false ); m_arrMonsterStorage[i].Save( pMonsterInstanceNode ); pMonsterStorageNode->AppendChild( pMonsterInstanceNode ); } outNode->AppendChild( pMonsterCollectionNode ); outNode->AppendChild( pMonsterStorageNode ); // Rune collection & storage XMLNode * pRuneCollectionNode = XMLDocument::CreateNode( TEXT("RuneCollection"), false ); XMLNode * pRuneStorageNode = XMLDocument::CreateNode( TEXT("RuneStorage"), false ); StringFn->FromUInt( strBuffer, m_iRuneCollectionLevel ); pRuneCollectionNode->CreateAttribute( TEXT("Level"), strBuffer ); StringFn->FromUInt( strBuffer, m_iRuneStorageLevel ); pRuneStorageNode->CreateAttribute( TEXT("Level"), strBuffer ); for( UInt i = 0; i < RUNE_TYPE_COUNT; ++i ) { UInt iRuneCount = m_arrRuneCollection[i].Count(); for( UInt j = 0; j < iRuneCount; ++j ) { XMLNode * pRuneNode = XMLDocument::CreateNode( TEXT("Rune"), false ); (m_arrRuneCollection[i])[j].Save( pRuneNode ); pRuneCollectionNode->AppendChild( pRuneNode ); } iRuneCount = m_arrRuneStorage[i].Count(); for( UInt j = 0; j < iRuneCount; ++j ) { XMLNode * pRuneNode = XMLDocument::CreateNode( TEXT("Rune"), false ); (m_arrRuneStorage[i])[j].Save( pRuneNode ); pRuneStorageNode->AppendChild( pRuneNode ); } } outNode->AppendChild( pRuneCollectionNode ); outNode->AppendChild( pRuneStorageNode ); // Mana & Crystal production XMLNode * pManaCrystalProductionNode = XMLDocument::CreateNode( TEXT("ManaCrystalProduction"), true ); StringFn->FromUInt( strBuffer, m_iManaProductionRateLevel ); pManaCrystalProductionNode->CreateAttribute( TEXT("ManaRateLevel"), strBuffer ); StringFn->FromUInt( strBuffer, m_iCrystalProductionRateLevel ); pManaCrystalProductionNode->CreateAttribute( TEXT("CrystalRateLevel"), strBuffer ); StringFn->FromUInt( strBuffer, m_iManaCapacityLevel ); pManaCrystalProductionNode->CreateAttribute( TEXT("ManaCapacityLevel"), strBuffer ); StringFn->FromUInt( strBuffer, m_iCrystalCapacityLevel ); pManaCrystalProductionNode->CreateAttribute( TEXT("CrystalCapacityLevel"), strBuffer ); StringFn->FromUInt( strBuffer, m_iManaBuffer ); pManaCrystalProductionNode->CreateAttribute( TEXT("ManaBuffer"), strBuffer ); StringFn->FromUInt( strBuffer, m_iCrystalBuffer ); pManaCrystalProductionNode->CreateAttribute( TEXT("CrystalBuffer"), strBuffer ); StringFn->FromUInt( strBuffer, m_hLastUpdateTime ); pManaCrystalProductionNode->CreateAttribute( TEXT("LastUpdateTime"), strBuffer ); outNode->AppendChild( pManaCrystalProductionNode ); // Shop // Wishes // Building operations XMLNode * pBuildingOperationsNode = XMLDocument::CreateNode( TEXT("BuildingOperations"), true ); pBuildingOperationsNode->CreateAttribute( TEXT("EssenceFusion"), m_bEssenceFusionUnlocked ? TEXT("1") : TEXT("0") ); pBuildingOperationsNode->CreateAttribute( TEXT("MonsterSummoning"), m_bMonsterSummoningUnlocked ? TEXT("1") : TEXT("0") ); pBuildingOperationsNode->CreateAttribute( TEXT("MonsterFusion"), m_bMonsterFusionUnlocked ? TEXT("1") : TEXT("0") ); pBuildingOperationsNode->CreateAttribute( TEXT("MonsterPowerUp"), m_bMonsterPowerUpUnlocked ? TEXT("1") : TEXT("0") ); pBuildingOperationsNode->CreateAttribute( TEXT("MonsterEvolution"), m_bMonsterEvolutionUnlocked ? TEXT("1") : TEXT("0") ); pBuildingOperationsNode->CreateAttribute( TEXT("MonsterAwakening"), m_bMonsterAwakeningUnlocked ? TEXT("1") : TEXT("0") ); pBuildingOperationsNode->CreateAttribute( TEXT("RunePowerUp"), m_bRunePowerUpUnlocked ? TEXT("1") : TEXT("0") ); pBuildingOperationsNode->CreateAttribute( TEXT("RuneEvolution"), m_bRuneEvolutionUnlocked ? TEXT("1") : TEXT("0") ); outNode->AppendChild( pBuildingOperationsNode ); // Arena XMLNode * pArenaNode = XMLDocument::CreateNode( TEXT("Arena"), true ); StringFn->FromUInt( strBuffer, m_iArenaScore ); pArenaNode->CreateAttribute( TEXT("Score"), strBuffer ); StringFn->FromUInt( strBuffer, m_iArenaRank ); pArenaNode->CreateAttribute( TEXT("Rank"), strBuffer ); for( UInt i = 0; i < BATTLE_TEAMSIZE_ARENA; ++i ) { GChar strNameI[16]; StringFn->Format( strNameI, TEXT("DefenseSlot_%d"), i ); StringFn->FromUInt( strBuffer, m_arrArenaDefense[i] ); pArenaNode->CreateAttribute( strNameI, strBuffer ); } outNode->AppendChild( pArenaNode ); // Guild ///////////////////////////////////// }